diff --git a/app/assets/javascripts/desktop/journal_pages.js.erb b/app/assets/javascripts/desktop/journal_pages.js.erb new file mode 100644 index 00000000..e69de29b diff --git a/app/assets/javascripts/orbitdesktop.js b/app/assets/javascripts/orbitdesktop.js index 321292a2..2de7da1b 100755 --- a/app/assets/javascripts/orbitdesktop.js +++ b/app/assets/javascripts/orbitdesktop.js @@ -586,7 +586,7 @@ var orbitDesktop = function(dom){ $(this).val(sectionnames[i]); }) bindHandlers(); - }) + }) } diff --git a/app/controllers/desktop/journal_pages_controller.rb b/app/controllers/desktop/journal_pages_controller.rb new file mode 100644 index 00000000..4db1bbdf --- /dev/null +++ b/app/controllers/desktop/journal_pages_controller.rb @@ -0,0 +1,54 @@ +class Desktop::JournalPagesController < ApplicationController + def index + @writing_journal = WritingJournal.where(create_user_id: current_user.id) + @level_types = JournalLevelType.all + + respond_to do |format| + format.html { render :layout => false} + end + end + + def new + @writing_journal = WritingJournal.new + @level_types = JournalLevelType.all + @author_types = JournalAuthorType.all + @paper_types= JournalPaperType.all + + respond_to do |format| + format.html { render :layout => false} + end + end + + def edit + end + + def create + if params[:commit].eql?"Save" + if not params[:writing_journal][:publication_date].nil? + params[:writing_journal][:publication_date] = \ + Date.new *(params[:writing_journal][:publication_date].split("/").map{|s| s.to_i}) + end + + params[:writing_journal][:create_user_id] = current_user.id + + @writing_journal = WritingJournal.new(params[:writing_journal]) + if @writing_journal.save + respond_to do |format| + format.html { redirect_to desktop_journal_pages_url, :layout => false, notice: 'User was successfully created.'} + # format.json { render json: @writing_journal, status: :created, location: @writing_journal} + # format.js + end + else + end + end + end + + def show + end + + def update + if params[:commit].eql?"Edit" + params[:writing_journal][:update_user_id] = current_user.id + end + end +end diff --git a/app/controllers/desktop_publications_controller.rb b/app/controllers/desktop_publications_controller.rb index c55f348e..1eb6b244 100644 --- a/app/controllers/desktop_publications_controller.rb +++ b/app/controllers/desktop_publications_controller.rb @@ -4,21 +4,29 @@ class DesktopPublicationsController< ApplicationController def journal_p render "desktop/journal_p", :layout => false end +# +# def journal_p_list +# render "desktop/journal_pages/list", :layout => false +# end - def journal_p_list - render "desktop/journal_pages/list", :layout => false - end - - def journal_p_add - @writing_journal = WritingJournal.new - @level_types = JournalLevelType.all - +# def journal_p_add +# @writing_journal = WritingJournal.new +# @level_types = JournalLevelType.all +# # respond_to do |format| -# format.html # new.html.erb -# format.xml { render :xml => @writing_journal } +# format.html { render "desktop/journal_pages/add", :layout => false} # end - render "desktop/journal_pages/add", :layout => false - end +# end +# +# def journal_p_create +# @writing_journal = WritingJournal.all.first +# @level_types = JournalLevelType.all +# respond_to do |format| +# format.html { render "desktop/journal_pages/list", :layout => false} +# #format.js +# end +# +# end def books render "desktop/books", :layout => false @@ -75,8 +83,6 @@ class DesktopPublicationsController< ApplicationController def getjournals publications = WritingJournal.where(create_user_id: current_user.id) - p current_user.id -p "=======" sort_publications= Hash.new data = Array.new diff --git a/app/views/desktop/journal_p.html.erb b/app/views/desktop/journal_p.html.erb index 07452f20..868136c4 100644 --- a/app/views/desktop/journal_p.html.erb +++ b/app/views/desktop/journal_p.html.erb @@ -1,33 +1,33 @@
Find me in app/views/desktop/journal_pages/edit.html.erb
diff --git a/app/views/desktop/journal_pages/index.html.erb b/app/views/desktop/journal_pages/index.html.erb new file mode 100644 index 00000000..4a351773 --- /dev/null +++ b/app/views/desktop/journal_pages/index.html.erb @@ -0,0 +1,88 @@ + +Find me in app/views/desktop/journal_pages/show.html.erb
diff --git a/config/routes.rb b/config/routes.rb index ff2be742..84bb967e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,7 +2,7 @@ Orbit::Application.routes.draw do devise_for :users mount Resque::Server, :at => "/admin/resque" - + # routes for sinatra app match '/site/set_registered', :to => CentralServerExchangeApp match '/site/public_key', :to => CentralServerExchangeApp @@ -28,7 +28,7 @@ Orbit::Application.routes.draw do match 'new_interface' => "object_auths_new_interface#setting" ,:as => :ob_auth,:via => :get match 'new_interface' => "object_auths_new_interface#update_setting" ,:as => :ob_auth,:via => :post match 'new_interface' => "object_auths_new_interface#user_list" ,:as => :ob_auth_show,:via => :put - + collection do match 'new/:type/:obj_id',:action => 'new',:via => "get",:as => :init end @@ -43,11 +43,11 @@ Orbit::Application.routes.draw do match 'ad_banners/:id/rename' => 'ad_banners#rename',:as => :rename_ad_banner,:via => :post resources :ad_banners do - collection do - match 'new_ad_image' => 'ad_images#new',:as => :new_ad_image,:via => :get - match 'new_ad_image' => 'ad_images#create',:as => :create_ad_image,:via => :post - end - resources :ad_images ,:except => [:show,:index] + collection do + match 'new_ad_image' => 'ad_images#new',:as => :new_ad_image,:via => :get + match 'new_ad_image' => 'ad_images#create',:as => :create_ad_image,:via => :post + end + resources :ad_images ,:except => [:show,:index] end resources :dashboards resources :designs do @@ -87,7 +87,7 @@ Orbit::Application.routes.draw do match 'remove/:type/:target_id' ,:action=> 'remove',:via => "delete",:as =>:remove end end - + member do match 'assign_manager' ,:action=> 'assign_manager',:via => "post",:as =>:assign_manager match 'assign_sub_manager' ,:action=> 'assign_sub_manager',:via => "post",:as =>:assign_sub_manager @@ -136,78 +136,47 @@ Orbit::Application.routes.draw do end # end admin - + namespace :panel do resources :users end resources :desktop_widgets do collection do - get 'upload' - get 'delete' - post 'upload' + get 'upload' + get 'delete' + post 'upload' end end -namespace :desktop do - - match "/"=>"desktop#index" + namespace :desktop do - # Sinatra Routes start + match "/" => "desktop#index" - # match '/desktop/desktop', :to => Desktopapp::DesktopApp - # match '/desktop/app_manager', :to => Desktopapp::DesktopApp - # match '/desktop/sections', :to => Desktopapp::DesktopApp - # match '/desktop/settings', :to => Desktopapp::DesktopApp - # match '/desktop/get_desktop_settings/', :to => Desktopapp::DesktopApp - # match '/desktop/save_desktop_settings/', :to => Desktopapp::DesktopApp - # match '/desktop/getgroups/', :to => Desktopapp::DesktopApp - # match '/desktop/getsectionlist/', :to => Desktopapp::DesktopApp - # match '/desktop/settingthemes/', :to => Desktopapp::DesktopApp - # match '/desktop/settingsections/', :to => Desktopapp::DesktopApp - # match '/desktop/getapplist/', :to => Desktopapp::DesktopApp - # match '/desktop/newpositions/', :to => Desktopapp::DesktopApp - # match '/desktop/settingconnection/', :to => Desktopapp::DesktopApp + match '/desktop'=>'desktop#desktop' + match '/app_manager'=>'desktop#app_manager' + match '/sections'=>'desktop#sections' + match '/settings'=>'desktop#settings' + match '/get_desktop_settings/'=>'desktop#get_desktop_settings' + match '/save_desktop_settings/'=>'desktop#save_desktop_settings' + match '/getgroups/'=>'desktop#getgroups' + match '/getsectionlist/'=>'desktop#getsectionlist' + match '/themes/'=>'desktop#themes' + match '/sections/'=>'desktop#sections' + match '/getapplist/'=>'desktop#getapplist' + match '/newpositions/'=>'desktop#newpositions' + match '/connections/'=>'desktop#connections' + match '/widget_layout' => 'desktop#widget_layout' - # match '/desktop/journal_p/', :to => Desktopapp::DesktopAppPublications - # match '/desktop/journal_p_list/', :to => Desktopapp::DesktopAppPublications - # match '/desktop/journal_p_add/', :to => Desktopapp::DesktopAppPublications - # match '/desktop_publications/getjournals', :to => Desktopapp::DesktopAppPublications + match '/temp_func/'=>'desktop#temp_func' + resources :journal_pages + end - # match '/desktop/twitter/', :to => Desktopapp::Otheraccounts - # match '/desktop/forgmail/', :to => Desktopapp::Otheraccounts - # match '/desktop/getaccounts', :to => Desktopapp::Otheraccounts - # match '/desktop/save_account_info/', :to => Desktopapp::Otheraccounts - - # match '/desktop_appstore/appstore', :to => Desktopapp::DesktopAppAppstore - # match '/desktop_appstore/widgets', :to => Desktopapp::DesktopAppAppstore - # match '/desktop_appstore/getuserwidgets', :to => Desktopapp::DesktopAppAppstore - # match '/desktop_appstore/widgets_settings', :to => Desktopapp::DesktopAppAppstore - - # Sinatra Routes end - - match '/desktop'=>'desktop#desktop' - match '/app_manager'=>'desktop#app_manager' - match '/sections'=>'desktop#sections' - match '/settings'=>'desktop#settings' - match '/get_desktop_settings/'=>'desktop#get_desktop_settings' - match '/save_desktop_settings/'=>'desktop#save_desktop_settings' - match '/getgroups/'=>'desktop#getgroups' - match '/getsectionlist/'=>'desktop#getsectionlist' - match '/themes/'=>'desktop#themes' - match '/sections/'=>'desktop#sections' - match '/getapplist/'=>'desktop#getapplist' - match '/newpositions/'=>'desktop#newpositions' - match '/connections/'=>'desktop#connections' - match '/widget_layout' => 'desktop#widget_layout' - - match '/temp_func/'=>'desktop#temp_func' -end - -# namespace :desktop_publications do - match 'desktop_publications/journal_p'=>'desktop_publications#journal_p' - match 'desktop_publications/journal_p_list'=>'desktop_publications#journal_p_list' - match 'desktop_publications/journal_p_add'=>'desktop_publications#journal_p_add' + # namespace :desktop_publications do + match 'desktop_publications/journal_p'=>'desktop_publications#journal_p' + # match 'desktop_publications/journal_p_list'=>'desktop_publications#journal_p_list' + # match 'desktop_publications/journal_p_add'=>'desktop_publications#journal_p_add' + # match 'desktop_publications/journal_p_create'=>'desktop_publications#journal_p_create' , :via => :post match 'desktop_publications/books' => 'desktop_publications#books' match 'desktop_publications/books_list'=>'desktop_publications#books_list' match 'desktop_publications/books_add'=>'desktop_publications#books_add' @@ -216,9 +185,9 @@ end match 'desktop_publications/seminar_p_list/'=>'desktop_publications#seminar_p_list' match 'desktop_publications/seminar_p_add/'=>'desktop_publications#seminar_p_add' match 'desktop_publications/getjournals' => 'desktop_publications#getjournals' -# end + # end -# namespace :desktop_research do + # namespace :desktop_research do match 'desktop_research/research_d' => 'desktop_research#research_d' match 'desktop_research/research_d_list/' => 'desktop_research#research_d_list' match 'desktop_research/research_d_add' => 'desktop_research#research_d_add' @@ -226,7 +195,7 @@ end match 'desktop_research/research_p' => 'desktop_research#research_p' match 'desktop_research/research_p_list/' => 'desktop_research#research_p_list' match 'desktop_research/research_p_add' => 'desktop_research#research_p_add' -# end + # end match '/twitter/'=>'otheraccounts#twitter' match '/forgmail/'=>'otheraccounts#gmail' @@ -243,36 +212,36 @@ end match '/desktop_orbit/eventajaxload'=> 'desktop_orbit#eventajaxload' match '/desktop_orbit/gettimelinespan' => 'desktop_orbit#gettimelinespan' - - #match '/desktop_orbit/eventajaxload' => 'desktop_publications#create_journal' + + #match '/desktop_orbit/eventajaxload' => 'desktop_publications#create_journal' #match '/desktop_orbit/eventajaxload' => 'desktop_publications#delete_journal' # match '/desktop_orbit/eventajaxload' => 'desktop_publications#update_journal' - - + + match '/panel/:app_name/front_end/:app_action/:id(/:controller_action)' => 'pages#show_from_link', :constraints => lambda { |request| !request.query_string.include?("inner=true") } - + match '/panel/:app_name/front_end/:app_action' => 'pages#index_from_link', :constraints => lambda { |request| !request.query_string.include?("inner=true") } match '/share/:model/:id' => 'application#render_share' - + # routes for gridfs files match "/gridfs/*path" => "gridfs#serve" # match "/images/*path" => "gridfs#serve_images" # match "/admin/pages/images/*path" => "gridfs#serve_images" - + # routes for pages to generate match '*page_name' => 'pages#show', :as => :page, :constraints => lambda{|request| !request.path.starts_with?("/panel") } - + root :to => 'pages#index' - + end diff --git a/vendor/built_in_modules/personal_journal/app/models/journal_author_type.rb b/vendor/built_in_modules/personal_journal/app/models/journal_author_type.rb index 8fe9f963..6715468e 100644 --- a/vendor/built_in_modules/personal_journal/app/models/journal_author_type.rb +++ b/vendor/built_in_modules/personal_journal/app/models/journal_author_type.rb @@ -1,9 +1,5 @@ -# encoding: utf-8 - class JournalAuthorType < WritingJournalCategory - field :title, localize: true has_and_belongs_to_many :writing_journals - -end \ No newline at end of file +end diff --git a/vendor/built_in_modules/personal_journal/app/models/journal_level_type.rb b/vendor/built_in_modules/personal_journal/app/models/journal_level_type.rb index 98ef6017..d7639d18 100644 --- a/vendor/built_in_modules/personal_journal/app/models/journal_level_type.rb +++ b/vendor/built_in_modules/personal_journal/app/models/journal_level_type.rb @@ -1,9 +1,5 @@ -# encoding: utf-8 - class JournalLevelType < WritingJournalCategory - field :title, localize: true has_and_belongs_to_many :writing_journals - -end \ No newline at end of file +end diff --git a/vendor/built_in_modules/personal_journal/app/models/journal_paper_type.rb b/vendor/built_in_modules/personal_journal/app/models/journal_paper_type.rb index 5758c8d5..7db2ca1f 100644 --- a/vendor/built_in_modules/personal_journal/app/models/journal_paper_type.rb +++ b/vendor/built_in_modules/personal_journal/app/models/journal_paper_type.rb @@ -1,7 +1,3 @@ -# encoding: utf-8 - class JournalPaperType < WritingJournalCategory - field :title - -end \ No newline at end of file +end diff --git a/vendor/built_in_modules/personal_journal/app/models/personal_journal_tag.rb b/vendor/built_in_modules/personal_journal/app/models/personal_journal_tag.rb index c88207dc..eb85e89f 100644 --- a/vendor/built_in_modules/personal_journal/app/models/personal_journal_tag.rb +++ b/vendor/built_in_modules/personal_journal/app/models/personal_journal_tag.rb @@ -1,9 +1,7 @@ class PersonalJournalTag < Tag - has_and_belongs_to_many :writing_journals - - def get_visible_links(sort = :title) - self.writing_journals.where(:is_hidden => false).desc(:is_top, sort) - end -end \ No newline at end of file + def get_visible_links(sort = :title) + self.writing_journals.where(:is_hidden => false).desc(:is_top, sort) + end +end diff --git a/vendor/built_in_modules/personal_journal/app/models/writing_journal.rb b/vendor/built_in_modules/personal_journal/app/models/writing_journal.rb index 2f0eafe4..0c5cda31 100644 --- a/vendor/built_in_modules/personal_journal/app/models/writing_journal.rb +++ b/vendor/built_in_modules/personal_journal/app/models/writing_journal.rb @@ -1,26 +1,20 @@ -# encoding: utf-8 - class WritingJournal include Mongoid::Document include Mongoid::Timestamps include Mongoid::MultiParameterAttributes - - # scope :available_for_lang, ->(locale){ where("available_for_#{locale}".to_sym => true) } - - LANGUAGE_TYPES = [ "English", "Chinese" ] + LANGUAGE_TYPES = [ "English", "Chinese" ] field :paper_title, localize: true field :journal_title, localize: true field :authors, localize: true - + has_and_belongs_to_many :tags, :class_name => "PersonalJournalTag" - has_and_belongs_to_many :journal_author_types has_and_belongs_to_many :journal_level_types - + belongs_to :journal_paper_type - + field :year field :language field :isbn @@ -36,54 +30,36 @@ class WritingJournal field :note field :create_user_id, :type => BSON::ObjectId field :update_user_id, :type => BSON::ObjectId - - # field :is_top, :type => Boolean, :default => false - # field :is_hot, :type => Boolean, :default => false - # field :is_hidden, :type => Boolean, :default => false - + has_many :writing_journal_files, :autosave => true, :dependent => :destroy - + accepts_nested_attributes_for :writing_journal_files, :allow_destroy => true - - # before_save :update_avliable_language, :clean_checkboxs - - validates :paper_title, :at_least_one => true - - before_validation :add_http - after_save :save_writing_journal_files - + before_validation :add_http + validates :paper_title, :at_least_one => true validates :url, :format => /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix, :unless => Proc.new{self.url.blank?} def self.search( category_id = nil ) - - if category_id.to_s.size > 0 - - find(:all, :conditions => {writing_journal_category_id: category_id}).desc( :is_top, :title ) - - else - - find(:all).desc( :is_top, :title) - - end - + if category_id.to_s.size > 0 + find(:all, :conditions => {writing_journal_category_id: category_id}).desc( :is_top, :title ) + else + find(:all).desc( :is_top, :title) + end end def self.widget_datas - - where( :is_hidden => false ).desc(:is_top, :created_at) - + where( :is_hidden => false ).desc(:is_top, :created_at) end def is_top? self.is_top - end + end def sorted_tags tags.order_by(I18n.locale, :asc) end - + def update_avliable_language VALID_LOCALES.each do |locale| if (title_translations[locale].blank? rescue true) @@ -93,22 +69,21 @@ class WritingJournal end end end - + def save_writing_journal_files - self.writing_journal_files.each do |t| - if t.should_destroy - t.destroy - end + self.writing_journal_files.each do |t| + if t.should_destroy + t.destroy + end end end - + def create_link - - title = ["\"#{self.paper_title}\""] - title << self.journal_title - title.join(', ') - title << ( !self.journal_level_types.blank? ? "(#{self.journal_level_types.collect{|x| x.title}.join(', ')})" : nil) - title.join(', ') + title = ["\"#{self.paper_title}\""] + title << self.journal_title + title.join(', ') + title << ( !self.journal_level_types.blank? ? "(#{self.journal_level_types.collect{|x| x.title}.join(', ')})" : nil) + title.join(', ') end protected @@ -124,5 +99,4 @@ class WritingJournal self.journal_author_type_ids.delete('') self.journal_level_type_ids.delete('') end - -end \ No newline at end of file +end diff --git a/vendor/built_in_modules/personal_journal/app/models/writing_journal_category.rb b/vendor/built_in_modules/personal_journal/app/models/writing_journal_category.rb index fa4f967b..e0ba2a4d 100644 --- a/vendor/built_in_modules/personal_journal/app/models/writing_journal_category.rb +++ b/vendor/built_in_modules/personal_journal/app/models/writing_journal_category.rb @@ -1,30 +1,26 @@ -# encoding: utf-8 - class WritingJournalCategory include Mongoid::Document include Mongoid::Timestamps include OrbitCoreLib::ObjectAuthable include OrbitCoreLib::ObjectDisable - # include Mongoid::MultiParameterAttributes + AfterObjectAuthUrl = '/panel/personal_journal/back_end/writing_journal_categorys' APP_NAME = 'writing_journal' # ObjectAuthTitlesOptions = %W{edit} ObjectAuthTitlesOptions = %W{submit_new fact_check} field :key - has_many :writing_journals - + def pp_object title end - + def self.from_id(id) WritingJournalCategory.find(id) rescue nil end def self.is_localized?(field_name) - self.fields[field_name.to_s].localized? + self.fields[field_name.to_s].localized? end - -end \ No newline at end of file +end diff --git a/vendor/built_in_modules/personal_journal/app/models/writing_journal_file.rb b/vendor/built_in_modules/personal_journal/app/models/writing_journal_file.rb index 39d159fc..22416a0a 100644 --- a/vendor/built_in_modules/personal_journal/app/models/writing_journal_file.rb +++ b/vendor/built_in_modules/personal_journal/app/models/writing_journal_file.rb @@ -6,9 +6,9 @@ class WritingJournalFile mount_uploader :file, AssetUploader # field :description, localize: true - field :should_destroy, :type => Boolean + field :should_destroy, :type => Boolean field :title, localize: true - + belongs_to :writing_journal end