diff --git a/.gitignore b/.gitignore index df0dc67c5..412920612 100644 --- a/.gitignore +++ b/.gitignore @@ -10,8 +10,7 @@ uploads/**/* *.swp -public/javascripts -public/stylesheets +public/assets config/application.rb .rvmrc diff --git a/Gemfile b/Gemfile index d33409841..abf87c594 100644 --- a/Gemfile +++ b/Gemfile @@ -1,55 +1,62 @@ -source 'http://rubygems.org' -gem 'rails', '>=3.1.0', '<3.2.0' - -gem "brakeman" - -gem 'bson_ext' -gem 'carrierwave' -gem 'carrierwave-mongoid', :require => 'carrierwave/mongoid' -gem 'devise', '1.5.3' -gem 'exception_notification' # Send error trace -gem 'execjs' -gem 'jquery-rails' - -gem 'kaminari' - -gem 'mini_magick' -gem 'mongoid' -gem "mongo_session_store-rails3" -gem 'nokogiri' -gem 'radius' -gem 'rake' -gem 'ruby-debug19' -gem 'rubyzip' -gem 'sinatra' -#gem 'sinatra-contrib' -gem 'sprockets' -gem 'tinymce-rails' -gem 'therubyracer' if RUBY_PLATFORM.downcase.include?("linux") -gem 'mongoid-encryptor', :require => 'mongoid/encryptor' -#gem 'contacts' - -# Gems used only for assets and not required -# in production environments by default. -group :assets do - gem 'sass-rails' - gem 'coffee-rails' - gem 'uglifier' -end - - -group :test, :development do - #gem 'spork' - gem 'database_cleaner' #Strategies for cleaning databases. Can be used to ensure a clean state for testing. - gem "rspec", "~> 2.0" - gem "rspec-rails", "~> 2.0" - gem "factory_girl_rails" - gem "shoulda-matchers" - gem "simplecov" - gem "delorean" - gem "watchr" - #gem "spork" - # gem "capybara" - # gem 'yard' - # gem "bluecloth" -end +source 'http://rubygems.org' +gem 'rails', '>=3.1.0', '<3.2.0' + +gem "brakeman" + +gem 'bson_ext' +gem 'carrierwave' +gem 'carrierwave-mongoid', :require => 'carrierwave/mongoid' +gem 'devise', '1.5.3' +gem 'exception_notification' # Send error trace +gem 'execjs' +gem 'jquery-rails' +gem 'jquery-ui-rails' + +gem 'kaminari', :git => 'git://github.com/amatsuda/kaminari.git' + +gem 'mini_magick' +gem 'mongoid' +gem 'mongoid-tree', :require => 'mongoid/tree' +gem "mongo_session_store-rails3" +gem 'nokogiri' +gem 'radius' +gem 'rake' +gem 'resque' # background jobs +gem 'resque-scheduler' # job scheduling +gem 'resque-restriction' +gem 'ruby-debug19' +gem 'rubyzip' +gem 'sinatra' +#gem 'sinatra-contrib' +gem 'sprockets' +gem 'tinymce-rails' +gem 'therubyracer' if RUBY_PLATFORM.downcase.include?("linux") +gem 'mongoid-encryptor', :require => 'mongoid/encryptor' +#gem 'contacts' + +gem "impressionist", :require => "impressionist", :path => "vendor/impressionist" + +# Gems used only for assets and not required +# in production environments by default. +group :assets do + gem 'sass-rails' + gem 'coffee-rails' + gem 'uglifier' +end + + +group :test, :development do + gem 'spork' + gem 'database_cleaner' #Strategies for cleaning databases. Can be used to ensure a clean state for testing. + gem "rspec", "~> 2.0" + gem "rspec-rails", "~> 2.0" + gem "factory_girl_rails" + gem "shoulda-matchers" + gem "simplecov" + gem "delorean" + gem "watchr" + gem "spork" + # gem "capybara" + # gem 'yard' + # gem "bluecloth" +end diff --git a/Gemfile.lock b/Gemfile.lock index 5d5b90ff9..65c9dbe8f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,267 +1,301 @@ -GEM - remote: http://rubygems.org/ - specs: - actionmailer (3.1.4) - actionpack (= 3.1.4) - mail (~> 2.3.0) - actionpack (3.1.4) - activemodel (= 3.1.4) - activesupport (= 3.1.4) - builder (~> 3.0.0) - erubis (~> 2.7.0) - i18n (~> 0.6) - rack (~> 1.3.6) - rack-cache (~> 1.1) - rack-mount (~> 0.8.2) - rack-test (~> 0.6.1) - sprockets (~> 2.0.3) - activemodel (3.1.4) - activesupport (= 3.1.4) - builder (~> 3.0.0) - i18n (~> 0.6) - activerecord (3.1.4) - activemodel (= 3.1.4) - activesupport (= 3.1.4) - arel (~> 2.2.3) - tzinfo (~> 0.3.29) - activeresource (3.1.4) - activemodel (= 3.1.4) - activesupport (= 3.1.4) - activesupport (3.1.4) - multi_json (~> 1.0) - archive-tar-minitar (0.5.2) - arel (2.2.3) - bcrypt-ruby (3.0.1) - bcrypt-ruby (3.0.1-x86-mingw32) - brakeman (1.5.1) - activesupport - erubis (~> 2.6) - haml (~> 3.0) - i18n - ruby2ruby (~> 1.2) - ruport (~> 1.6) - sass (~> 3.0) - bson (1.6.1) - bson_ext (1.6.1) - bson (~> 1.6.1) - builder (3.0.0) - carrierwave (0.5.8) - activesupport (~> 3.0) - carrierwave-mongoid (0.1.3) - carrierwave (>= 0.5.6) - mongoid (~> 2.1) - chronic (0.6.7) - coffee-rails (3.1.1) - coffee-script (>= 2.2.0) - railties (~> 3.1.0) - coffee-script (2.2.0) - coffee-script-source - execjs - coffee-script-source (1.2.0) - color (1.4.1) - columnize (0.3.6) - database_cleaner (0.7.1) - delorean (1.2.0) - chronic - devise (1.5.3) - bcrypt-ruby (~> 3.0) - orm_adapter (~> 0.0.3) - warden (~> 1.1) - diff-lcs (1.1.3) - encrypted_strings (0.3.3) - erubis (2.7.0) - exception_notification (2.5.2) - actionmailer (>= 3.0.4) - execjs (1.3.0) - multi_json (~> 1.0) - factory_girl (2.6.3) - activesupport (>= 2.3.9) - factory_girl_rails (1.7.0) - factory_girl (~> 2.6.0) - railties (>= 3.0.0) - fastercsv (1.5.4) - haml (3.1.4) - hike (1.2.1) - hoe (2.16.1) - rake (~> 0.8) - i18n (0.6.0) - jquery-rails (1.0.19) - railties (~> 3.0) - thor (~> 0.14) - json (1.6.5) - kaminari (0.13.0) - actionpack (>= 3.0.0) - activesupport (>= 3.0.0) - railties (>= 3.0.0) - libv8 (3.3.10.4) - linecache19 (0.5.12) - ruby_core_source (>= 0.1.4) - mail (2.3.3) - i18n (>= 0.4.0) - mime-types (~> 1.16) - treetop (~> 1.4.8) - mime-types (1.17.2) - mini_magick (3.4) - subexec (~> 0.2.1) - mongo (1.6.1) - bson (~> 1.6.1) - mongo_session_store-rails3 (3.0.5) - actionpack (>= 3.0) - mongo - mongoid (2.4.6) - activemodel (~> 3.1) - mongo (~> 1.3) - tzinfo (~> 0.3.22) - mongoid-encryptor (0.0.5) - activesupport (~> 3.0) - encrypted_strings (~> 0.3.3) - mongoid (~> 2) - multi_json (1.1.0) - nokogiri (1.5.2) - nokogiri (1.5.2-x86-mingw32) - orm_adapter (0.0.6) - pdf-writer (1.1.8) - color (>= 1.4.0) - transaction-simple (~> 1.3) - polyglot (0.3.3) - rack (1.3.6) - rack-cache (1.2) - rack (>= 0.4) - rack-mount (0.8.3) - rack (>= 1.0.0) - rack-protection (1.2.0) - rack - rack-ssl (1.3.2) - rack - rack-test (0.6.1) - rack (>= 1.0) - radius (0.7.3) - rails (3.1.4) - actionmailer (= 3.1.4) - actionpack (= 3.1.4) - activerecord (= 3.1.4) - activeresource (= 3.1.4) - activesupport (= 3.1.4) - bundler (~> 1.0) - railties (= 3.1.4) - railties (3.1.4) - actionpack (= 3.1.4) - activesupport (= 3.1.4) - rack-ssl (~> 1.3.2) - rake (>= 0.8.7) - rdoc (~> 3.4) - thor (~> 0.14.6) - rake (0.9.2.2) - rdoc (3.12) - json (~> 1.4) - rspec (2.8.0) - rspec-core (~> 2.8.0) - rspec-expectations (~> 2.8.0) - rspec-mocks (~> 2.8.0) - rspec-core (2.8.0) - rspec-expectations (2.8.0) - diff-lcs (~> 1.1.2) - rspec-mocks (2.8.0) - rspec-rails (2.8.1) - actionpack (>= 3.0) - activesupport (>= 3.0) - railties (>= 3.0) - rspec (~> 2.8.0) - ruby-debug-base19 (0.11.25) - columnize (>= 0.3.1) - linecache19 (>= 0.5.11) - ruby_core_source (>= 0.1.4) - ruby-debug19 (0.11.6) - columnize (>= 0.3.1) - linecache19 (>= 0.5.11) - ruby-debug-base19 (>= 0.11.19) - ruby2ruby (1.3.1) - ruby_parser (~> 2.0) - sexp_processor (~> 3.0) - ruby_core_source (0.1.5) - archive-tar-minitar (>= 0.5.2) - ruby_parser (2.3.1) - sexp_processor (~> 3.0) - rubyzip (0.9.6.1) - ruport (1.6.3) - fastercsv - pdf-writer (= 1.1.8) - sass (3.1.15) - sass-rails (3.1.5) - actionpack (~> 3.1.0) - railties (~> 3.1.0) - sass (~> 3.1.10) - tilt (~> 1.3.2) - sexp_processor (3.1.0) - shoulda-matchers (1.0.0) - simplecov (0.6.1) - multi_json (~> 1.0) - simplecov-html (~> 0.5.3) - simplecov-html (0.5.3) - sinatra (1.3.2) - rack (~> 1.3, >= 1.3.6) - rack-protection (~> 1.2) - tilt (~> 1.3, >= 1.3.3) - sprockets (2.0.3) - hike (~> 1.2) - rack (~> 1.0) - tilt (~> 1.1, != 1.3.0) - subexec (0.2.1) - therubyracer (0.10.1) - libv8 (~> 3.3.10) - thor (0.14.6) - tilt (1.3.3) - tinymce-rails (3.4.8) - railties (>= 3.1) - transaction-simple (1.4.0) - hoe (>= 1.1.7) - treetop (1.4.10) - polyglot - polyglot (>= 0.3.1) - tzinfo (0.3.32) - uglifier (1.2.3) - execjs (>= 0.3.0) - multi_json (>= 1.0.2) - warden (1.1.1) - rack (>= 1.0) - watchr (0.7) - -PLATFORMS - ruby - x86-mingw32 - -DEPENDENCIES - brakeman - bson_ext - carrierwave - carrierwave-mongoid - coffee-rails - database_cleaner - delorean - devise (= 1.5.3) - exception_notification - execjs - factory_girl_rails - jquery-rails - kaminari - mini_magick - mongo_session_store-rails3 - mongoid - mongoid-encryptor - nokogiri - radius - rails (>= 3.1.0, < 3.2.0) - rake - rspec (~> 2.0) - rspec-rails (~> 2.0) - ruby-debug19 - rubyzip - sass-rails - shoulda-matchers - simplecov - sinatra - sprockets - therubyracer - tinymce-rails - uglifier - watchr +GEM + remote: http://rubygems.org/ + specs: + actionmailer (3.1.4) + actionpack (= 3.1.4) + mail (~> 2.3.0) + actionpack (3.1.4) + activemodel (= 3.1.4) + activesupport (= 3.1.4) + builder (~> 3.0.0) + erubis (~> 2.7.0) + i18n (~> 0.6) + rack (~> 1.3.6) + rack-cache (~> 1.1) + rack-mount (~> 0.8.2) + rack-test (~> 0.6.1) + sprockets (~> 2.0.3) + activemodel (3.1.4) + activesupport (= 3.1.4) + builder (~> 3.0.0) + i18n (~> 0.6) + activerecord (3.1.4) + activemodel (= 3.1.4) + activesupport (= 3.1.4) + arel (~> 2.2.3) + tzinfo (~> 0.3.29) + activeresource (3.1.4) + activemodel (= 3.1.4) + activesupport (= 3.1.4) + activesupport (3.1.4) + multi_json (~> 1.0) + archive-tar-minitar (0.5.2) + arel (2.2.3) + bcrypt-ruby (3.0.1) + bcrypt-ruby (3.0.1-x86-mingw32) + brakeman (1.5.1) + activesupport + erubis (~> 2.6) + haml (~> 3.0) + i18n + ruby2ruby (~> 1.2) + ruport (~> 1.6) + sass (~> 3.0) + bson (1.6.1) + bson_ext (1.6.1) + bson (~> 1.6.1) + builder (3.0.0) + carrierwave (0.5.8) + activesupport (~> 3.0) + carrierwave-mongoid (0.1.3) + carrierwave (>= 0.5.6) + mongoid (~> 2.1) + chronic (0.6.7) + coffee-rails (3.1.1) + coffee-script (>= 2.2.0) + railties (~> 3.1.0) + coffee-script (2.2.0) + coffee-script-source + execjs + coffee-script-source (1.2.0) + color (1.4.1) + columnize (0.3.6) + database_cleaner (0.7.1) + delorean (1.2.0) + chronic + devise (1.5.3) + bcrypt-ruby (~> 3.0) + orm_adapter (~> 0.0.3) + warden (~> 1.1) + diff-lcs (1.1.3) + encrypted_strings (0.3.3) + erubis (2.7.0) + exception_notification (2.5.2) + actionmailer (>= 3.0.4) + execjs (1.3.0) + multi_json (~> 1.0) + factory_girl (2.6.3) + activesupport (>= 2.3.9) + factory_girl_rails (1.7.0) + factory_girl (~> 2.6.0) + railties (>= 3.0.0) + fastercsv (1.5.4) + haml (3.1.4) + hike (1.2.1) + hoe (2.16.1) + rake (~> 0.8) + httpclient (2.2.5) + i18n (0.6.0) + jquery-rails (1.0.19) + railties (~> 3.0) + thor (~> 0.14) + jquery-ui-rails (0.4.0) + jquery-rails + railties (>= 3.1.0) + json (1.6.5) + linecache19 (0.5.12) + ruby_core_source (>= 0.1.4) + mail (2.3.3) + i18n (>= 0.4.0) + mime-types (~> 1.16) + treetop (~> 1.4.8) + mime-types (1.17.2) + mini_magick (3.4) + subexec (~> 0.2.1) + mongo (1.6.1) + bson (~> 1.6.1) + mongo_session_store-rails3 (3.0.5) + actionpack (>= 3.0) + mongo + mongoid (2.4.6) + activemodel (~> 3.1) + mongo (~> 1.3) + tzinfo (~> 0.3.22) + mongoid-encryptor (0.0.5) + activesupport (~> 3.0) + encrypted_strings (~> 0.3.3) + mongoid (~> 2) + mongoid-tree (0.7.0) + mongoid (~> 2.0) + multi_json (1.1.0) + nokogiri (1.5.2) + nokogiri (1.5.2-x86-mingw32) + orm_adapter (0.0.6) + pdf-writer (1.1.8) + color (>= 1.4.0) + transaction-simple (~> 1.3) + polyglot (0.3.3) + rack (1.3.6) + rack-cache (1.2) + rack (>= 0.4) + rack-mount (0.8.3) + rack (>= 1.0.0) + rack-protection (1.2.0) + rack + rack-ssl (1.3.2) + rack + rack-test (0.6.1) + rack (>= 1.0) + radius (0.7.3) + rails (3.1.4) + actionmailer (= 3.1.4) + actionpack (= 3.1.4) + activerecord (= 3.1.4) + activeresource (= 3.1.4) + activesupport (= 3.1.4) + bundler (~> 1.0) + railties (= 3.1.4) + railties (3.1.4) + actionpack (= 3.1.4) + activesupport (= 3.1.4) + rack-ssl (~> 1.3.2) + rake (>= 0.8.7) + rdoc (~> 3.4) + thor (~> 0.14.6) + rake (0.9.2.2) + rdoc (3.12) + json (~> 1.4) + redis (2.2.2) + redis-namespace (1.0.3) + redis (< 3.0.0) + resque (1.20.0) + multi_json (~> 1.0) + redis-namespace (~> 1.0.2) + sinatra (>= 0.9.2) + vegas (~> 0.1.2) + resque-restriction (0.3.0) + resque (>= 1.7.0) + resque-scheduler (1.9.9) + redis (>= 2.0.1) + resque (>= 1.8.0) + rufus-scheduler + rspec (2.8.0) + rspec-core (~> 2.8.0) + rspec-expectations (~> 2.8.0) + rspec-mocks (~> 2.8.0) + rspec-core (2.8.0) + rspec-expectations (2.8.0) + diff-lcs (~> 1.1.2) + rspec-mocks (2.8.0) + rspec-rails (2.8.1) + actionpack (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec (~> 2.8.0) + ruby-debug-base19 (0.11.25) + columnize (>= 0.3.1) + linecache19 (>= 0.5.11) + ruby_core_source (>= 0.1.4) + ruby-debug19 (0.11.6) + columnize (>= 0.3.1) + linecache19 (>= 0.5.11) + ruby-debug-base19 (>= 0.11.19) + ruby2ruby (1.3.1) + ruby_parser (~> 2.0) + sexp_processor (~> 3.0) + ruby_core_source (0.1.5) + archive-tar-minitar (>= 0.5.2) + ruby_parser (2.3.1) + sexp_processor (~> 3.0) + rubyzip (0.9.6.1) + rufus-scheduler (2.0.16) + tzinfo (>= 0.3.23) + ruport (1.6.3) + fastercsv + pdf-writer (= 1.1.8) + sass (3.1.15) + sass-rails (3.1.5) + actionpack (~> 3.1.0) + railties (~> 3.1.0) + sass (~> 3.1.10) + tilt (~> 1.3.2) + sexp_processor (3.1.0) + shoulda-matchers (1.0.0) + simplecov (0.6.1) + multi_json (~> 1.0) + simplecov-html (~> 0.5.3) + simplecov-html (0.5.3) + sinatra (1.3.2) + rack (~> 1.3, >= 1.3.6) + rack-protection (~> 1.2) + tilt (~> 1.3, >= 1.3.3) + spork (0.9.0) + spork (0.9.0-x86-mingw32) + win32-process + sprockets (2.0.3) + hike (~> 1.2) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + subexec (0.2.1) + thor (0.14.6) + tilt (1.3.3) + tinymce-rails (3.4.8) + railties (>= 3.1) + transaction-simple (1.4.0) + hoe (>= 1.1.7) + treetop (1.4.10) + polyglot + polyglot (>= 0.3.1) + tzinfo (0.3.32) + uglifier (1.2.3) + execjs (>= 0.3.0) + multi_json (>= 1.0.2) + vegas (0.1.11) + rack (>= 1.0.0) + warden (1.1.1) + rack (>= 1.0) + watchr (0.7) + win32-api (1.4.8-x86-mingw32) + win32-process (0.6.5) + windows-pr (>= 1.1.2) + windows-api (0.4.1) + win32-api (>= 1.4.5) + windows-pr (1.2.1) + win32-api (>= 1.4.5) + windows-api (>= 0.3.0) + +PLATFORMS + ruby + x86-mingw32 + +DEPENDENCIES + brakeman + bson_ext + carrierwave + carrierwave-mongoid + coffee-rails + database_cleaner + delorean + devise (= 1.5.3) + exception_notification + execjs + factory_girl_rails + impressionist! + jquery-rails + jquery-ui-rails + kaminari! + mini_magick + mongo_session_store-rails3 + mongoid + mongoid-encryptor + mongoid-tree + nokogiri + radius + rails (>= 3.1.0, < 3.2.0) + rake + resque + resque-restriction + resque-scheduler + rspec (~> 2.0) + rspec-rails (~> 2.0) + ruby-debug19 + rubyzip + sass-rails + shoulda-matchers + simplecov + sinatra + spork + sprockets + tinymce-rails + uglifier + watchr diff --git a/Rakefile b/Rakefile index 9a495de7b..e0dc9c5b8 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,9 @@ +# /usr/bin/ruby -Ku # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require File.expand_path('../config/application', __FILE__) +require 'resque/tasks' require 'rake/dsl_definition' require 'rake' diff --git a/app/assets/fonts/widget.css b/app/assets/fonts/widget.css deleted file mode 100644 index fe83b22d4..000000000 --- a/app/assets/fonts/widget.css +++ /dev/null @@ -1,79 +0,0 @@ -.widget-size-300 { - width:298px; -} -.widget-box { - background-color: #FFF; - overflow: hidden; - min-width: 300px; - border: 1px solid #DDD; - border-radius: 5px; - -moz-border-radius: 5px; - -webkit-border-radius: 5px; - margin: 0 0 5px 5px; - position:relative; -} -.widget-box .widget-title { - background: #999; - color: #FFF; - padding-left: 5px; - border-radius: 5px 5px 0 0; - -moz-border-radius: 5px 5px 0 0; - -webkit-border-radius: 5px 5px 0 0; -} -.widget-box .widget-content { - padding: 10px; -} -.widget-box .form-horizontal .control-group > label { - width: 50px; -} -.widget-box .form-horizontal .controls { - margin-left: 60px; -} -.widget-action { - position:absolute; - right:1px; - top:6px; -} -.action { - float: left; - display:inline-block; - margin-right: 5px; - opacity: 0.8; - filter: alpha(opacity=80); -} -.action:hover { - opacity: 1; - filter: alpha(opacity=100); - cursor: pointer; -} -.select-role { - display:none; - padding: 10px 0 0; -} -.file-upload { - position:relative; -} -.file-upload .file-name { - display: inline-block; - margin: 0 0 5px 5px; - white-space: nowrap; - width: 140px; -} -.file-upload .upload { - margin:0; - padding:0; - position:absolute; - top:0; - left:0; - opacity:.0; - filter: alpha(opacity=100); -} -.file-upload .upload:focus { - position:absolute; -} -.upload-picture { - margin-right: 5px; -} -#widget-link table { - margin-bottom:0 -} \ No newline at end of file diff --git a/app/assets/images/-sign-in-logo.png b/app/assets/images/-sign-in-logo.png new file mode 100644 index 000000000..53756c7c3 Binary files /dev/null and b/app/assets/images/-sign-in-logo.png differ diff --git a/app/assets/images/Thumbs.db b/app/assets/images/Thumbs.db new file mode 100644 index 000000000..20b6d49ed Binary files /dev/null and b/app/assets/images/Thumbs.db differ diff --git a/app/assets/images/ajax-loader.gif b/app/assets/images/ajax-loader.gif new file mode 100644 index 000000000..5f117fd81 Binary files /dev/null and b/app/assets/images/ajax-loader.gif differ diff --git a/app/assets/images/check.png b/app/assets/images/check.png index e415c89b5..0972e33a4 100644 Binary files a/app/assets/images/check.png and b/app/assets/images/check.png differ diff --git a/app/assets/images/editicon.png b/app/assets/images/editicon.png new file mode 100644 index 000000000..cef3e6000 Binary files /dev/null and b/app/assets/images/editicon.png differ diff --git a/app/assets/images/icons_pack.png b/app/assets/images/icons_pack.png index 396693032..16ac98720 100644 Binary files a/app/assets/images/icons_pack.png and b/app/assets/images/icons_pack.png differ diff --git a/app/assets/images/icons_pack_white.png b/app/assets/images/icons_pack_white.png index 70fe3d851..e73607023 100644 Binary files a/app/assets/images/icons_pack_white.png and b/app/assets/images/icons_pack_white.png differ diff --git a/app/assets/images/ncculogo.ico b/app/assets/images/ncculogo.ico new file mode 100644 index 000000000..3aa5e1c67 Binary files /dev/null and b/app/assets/images/ncculogo.ico differ diff --git a/app/assets/images/orbit-bar.png b/app/assets/images/orbit-bar.png index 160b9d781..4b2a55852 100644 Binary files a/app/assets/images/orbit-bar.png and b/app/assets/images/orbit-bar.png differ diff --git a/app/assets/images/sign-in-logo.png b/app/assets/images/sign-in-logo.png index 53756c7c3..a3148babd 100644 Binary files a/app/assets/images/sign-in-logo.png and b/app/assets/images/sign-in-logo.png differ diff --git a/app/assets/javascripts/ajax_form.js b/app/assets/javascripts/ajax_form.js index c026e518e..d9b5abfec 100644 --- a/app/assets/javascripts/ajax_form.js +++ b/app/assets/javascripts/ajax_form.js @@ -1,4 +1,4 @@ -$('#submit_button').live('click', function(){ +$(document).on('click', '#ajax_form_submit', function(){ $('#ajaxForm').ajaxSubmit({ beforeSubmit: function(a,f,o) { o.dataType = 'script'; diff --git a/app/assets/javascripts/bulletin_form.js.erb b/app/assets/javascripts/bulletin_form.js.erb index abb908b4e..cf2dfd69c 100644 --- a/app/assets/javascripts/bulletin_form.js.erb +++ b/app/assets/javascripts/bulletin_form.js.erb @@ -6,23 +6,14 @@ $('.bulletin_files_block a.delete').live('click', function(){ $(this).parents('.list_item').remove(); }); -$('.action a.remove_existing_record').live('click', function(){ +$(document).on('click', '.action a.remove_existing_record', function(){ $(this).next('.should_destroy').attr('value', 1); - //$("#bulletin_" + $(this).prev().attr('value')).hide(); - $("tr#bulletin_" + $(this).prev().attr('value')).hide(); + $("tr #" + $(this).prev().attr('value')).hide(); }); -$('.quick_edit_cancel').live('click', function(){ +$(document).on('click', '.quick_edit_cancel', function(){ tr = $(this).attr('rel'); $('#' + tr).hide(); $("tr#bulletin_file_" + $(this).prev().attr('value')).hide(); $("tr#bulletin_link_" + $(this).prev().attr('value')).hide(); -}); - -$(document).on('click', '.list-remove', function(){ - $('#delete_bulletins').submit(); -}); - -$(document).on('click', '#check_all_bulletins', function(){ - $('.checkbox_in_list').attr("checked", this.checked); }); \ No newline at end of file diff --git a/app/assets/javascripts/desktop.js b/app/assets/javascripts/desktop.js index 281a0b3d4..7bfcb0b58 100644 --- a/app/assets/javascripts/desktop.js +++ b/app/assets/javascripts/desktop.js @@ -7,7 +7,7 @@ //= require jquery //= require jquery_ujs //= require jquery-ui -//= require jquery.tinyscrollbar.min +//= require jquery.tinyscrollbar //= require jquery.miniColors.min //= require bootstrap //= require orbitdesktopAPI diff --git a/app/assets/javascripts/event.js b/app/assets/javascripts/event.js index afe558d85..7db3e47c1 100644 --- a/app/assets/javascripts/event.js +++ b/app/assets/javascripts/event.js @@ -66,7 +66,7 @@ $(document).ready(function(){ function getEvent(selet){ $.ajax({ type: "GET", - url: "/static/Other.xml", + url: "/static/nccu_calendar.xml", dataType: "xml", timeout: 1000, error: function(xml){ diff --git a/app/assets/javascripts/inc/ajax_setting.js b/app/assets/javascripts/inc/ajax_setting.js new file mode 100644 index 000000000..c23a73bfd --- /dev/null +++ b/app/assets/javascripts/inc/ajax_setting.js @@ -0,0 +1,7 @@ +jQuery(document).ajaxStart(function(){ + $('').appendTo('body'); +}); + +jQuery(document).ajaxComplete(function(){ + $("#sys_modal").hide().remove(); +}); diff --git a/app/assets/javascripts/inc/jquery.imagesloaded.js b/app/assets/javascripts/inc/jquery.imagesloaded.js new file mode 100644 index 000000000..5b35bb9c4 --- /dev/null +++ b/app/assets/javascripts/inc/jquery.imagesloaded.js @@ -0,0 +1,137 @@ +/*! + * jQuery imagesLoaded plugin v2.0.1 + * http://github.com/desandro/imagesloaded + * + * MIT License. by Paul Irish et al. + */ + +/*jshint curly: true, eqeqeq: true, noempty: true, strict: true, undef: true, browser: true */ +/*global jQuery: false */ + +;(function($, undefined) { +'use strict'; + +// blank image data-uri bypasses webkit log warning (thx doug jones) +var BLANK = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=='; + +$.fn.imagesLoaded = function( callback ) { + var $this = this, + deferred = $.isFunction($.Deferred) ? $.Deferred() : 0, + hasNotify = $.isFunction(deferred.notify), + $images = $this.find('img').add( $this.filter('img') ), + loaded = [], + proper = [], + broken = []; + + function doneLoading() { + var $proper = $(proper), + $broken = $(broken); + + if ( deferred ) { + if ( broken.length ) { + deferred.reject( $images, $proper, $broken ); + } else { + deferred.resolve( $images ); + } + } + + if ( $.isFunction( callback ) ) { + callback.call( $this, $images, $proper, $broken ); + } + } + + function imgLoaded( img, isBroken ) { + // don't proceed if BLANK image, or image is already loaded + if ( img.src === BLANK || $.inArray( img, loaded ) !== -1 ) { + return; + } + + // store element in loaded images array + loaded.push( img ); + + // keep track of broken and properly loaded images + if ( isBroken ) { + broken.push( img ); + } else { + proper.push( img ); + } + + // cache image and its state for future calls + $.data( img, 'imagesLoaded', { isBroken: isBroken, src: img.src } ); + + // trigger deferred progress method if present + if ( hasNotify ) { + deferred.notifyWith( $(img), [ isBroken, $images, $(proper), $(broken) ] ); + } + + // call doneLoading and clean listeners if all images are loaded + if ( $images.length === loaded.length ){ + setTimeout( doneLoading ); + $images.unbind( '.imagesLoaded' ); + } + } + + // if no images, trigger immediately + if ( !$images.length ) { + doneLoading(); + } else { + $images.bind( 'load.imagesLoaded error.imagesLoaded', function( event ){ + // trigger imgLoaded + imgLoaded( event.target, event.type === 'error' ); + }).each( function( i, el ) { + var src = el.src; + + // find out if this image has been already checked for status + // if it was, and src has not changed, call imgLoaded on it + var cached = $.data( el, 'imagesLoaded' ); + if ( cached && cached.src === src ) { + imgLoaded( el, cached.isBroken ); + return; + } + + // if complete is true and browser supports natural sizes, try + // to check for image status manually + if ( el.complete && el.naturalWidth !== undefined ) { + imgLoaded( el, el.naturalWidth === 0 || el.naturalHeight === 0 ); + return; + } + + // cached images don't fire load sometimes, so we reset src, but only when + // dealing with IE, or image is complete (loaded) and failed manual check + // webkit hack from http://groups.google.com/group/jquery-dev/browse_thread/thread/eee6ab7b2da50e1f + if ( el.readyState || el.complete ) { + el.src = BLANK; + el.src = src; + } + }); + } + + return deferred ? deferred.promise( $this ) : $this; +}; + +})(jQuery); + +$(document).ready(function() { + $('.upload-picture').find('img').imagesLoaded(function(){ + var picH = $('.upload-picture').width()/$('.upload-picture').find('img').width()*$('.upload-picture').find('img').height(); + var imgMarginTop = ($('.upload-picture').height()-picH)/2; + var d = $('.upload-picture').height(); + if(imgMarginTop>0){ + imgMarginTop = 0; + d = picH; + $('.upload-picture').css({height:d}) + } + $('.upload-picture').find('img').css({marginTop:imgMarginTop}) + $('.upload-picture').each(function (i){ + $(this).mouseenter(function(){ + var h= picH; + $(this).stop().animate({height:h}, 500); + $(this).find('img').stop().animate({marginTop:0}, 500); + }); + $(this).mouseleave(function(){ + $(this).stop().animate({height:d}, 500); + $(this).find('img').stop().animate({marginTop:imgMarginTop}, 500); + }); + }); + }); +}); \ No newline at end of file diff --git a/app/assets/javascripts/inc/modal-preview.js b/app/assets/javascripts/inc/modal-preview.js new file mode 100644 index 000000000..959f04b2c --- /dev/null +++ b/app/assets/javascripts/inc/modal-preview.js @@ -0,0 +1,20 @@ +//Preview need a link in form as Ex and a corresponding PUT action in controller +//Ex preview trigger: +// <%= link_to "NewPreview", realtime_preview_admin_ad_banner_path(ad_banner_tab) , :class=>'preview_trigger'%> + +$(document).ready(function() { + $("a.preview_trigger").click(function(){ + $("#main-wrap").after(""); + $.ajax({ + type: 'PUT', + url:$(this).attr("href"), + data:$(this).parents("form").serialize(), + success: function (msg) { + $("#"+start_modal_with_id).modal('show'); }, + error: function(){ + alert("ERROR"); + } + }); + return false; + }); +}); \ No newline at end of file diff --git a/app/assets/javascripts/inc/permission-checkbox.js b/app/assets/javascripts/inc/permission-checkbox.js index fc91b8579..23716f682 100644 --- a/app/assets/javascripts/inc/permission-checkbox.js +++ b/app/assets/javascripts/inc/permission-checkbox.js @@ -1,4 +1,7 @@ $(document).ready(function() { + permissionCheckbox(); +}); +function permissionCheckbox(){ $('.check[checked="checked"]').parents(".checkbox").addClass("checked") $(".checkbox").click(function(){ if($(this).children(".check").attr("checked")){ @@ -16,4 +19,4 @@ $(document).ready(function() { placement: 'bottom', delay: { show: 100, hide: 300 }, }); -}); \ No newline at end of file +}; \ No newline at end of file diff --git a/app/assets/javascripts/inc/search.js b/app/assets/javascripts/inc/search.js index 979b5621d..50f3835fb 100644 --- a/app/assets/javascripts/inc/search.js +++ b/app/assets/javascripts/inc/search.js @@ -8,24 +8,29 @@ $.extend($.expr[':'], { return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0; } }); +var interval,sval; $(document).ready(function(){ - $("#user_filter").keyup(function(){ - if($(this).val()){ - var totalfoundbyname = $("div#users_checkbox_ary label.member-name:containsi("+$(this).val()+")").length - if(totalfoundbyname!=0){ - $("div#users_checkbox_ary label.member-name:not(:containsi("+$(this).val()+"))").parent().parent().slideUp(); - //$("div#users_checkbox_ary label.member-name:not(:containsi("+$(this).val()+"))").parent().popover('hide'); - $("div#users_checkbox_ary label.member-name:containsi("+$(this).val()+")").parent().parent().slideDown(); - $("div#users_checkbox_ary label.member-name:containsi("+$(this).val()+")").parent().popover('toggle'); - }else if(totalfoundbyname==0){ - $("div#users_checkbox_ary div.for_unit:not(:containsi("+$(this).val()+"))").parent().slideUp(); - //$("div#users_checkbox_ary div.for_unit:not(:containsi("+$(this).val()+"))").popover('hide'); - $("div#users_checkbox_ary div.for_unit:containsi("+$(this).val()+")").parent().slideDown(); - $("div#users_checkbox_ary div.for_unit:containsi("+$(this).val()+")").popover('toggle'); - } - }else{ - $(".checkbox").popover('hide'); - $("div.checkblock").slideDown(); + $("#user_filter").keyup(function(e){ + if((e.which>96 && e.which<123) || (e.which>64 && e.which<92) || (e.which == 32) || (e.which == 8)){ + sval = $(this).val(); + $(".checkbox").popover("hide"); + $("div.checkblock").hide(); + clearInterval(interval); + interval = setInterval(waitForSearch,1000); } }) -}) \ No newline at end of file +}) +var waitForSearch = function(){ + if(sval){ + var totalfoundbyname = $("div#users_checkbox_ary label.member-name:containsi("+sval+")").length + if(totalfoundbyname!=0){ + $("div#users_checkbox_ary label.member-name:containsi("+sval+")").parent().parent().show(); + }else if(totalfoundbyname==0){ + $("div#users_checkbox_ary div.for_unit:containsi("+sval+")").parent().show(); + } + }else{ + $(".checkbox").popover('hide'); + $("div.checkblock").show(); + } + clearInterval(interval); +} \ No newline at end of file diff --git a/app/assets/javascripts/jquery.tinyscrollbar.js b/app/assets/javascripts/jquery.tinyscrollbar.js new file mode 100644 index 000000000..e9aeffdea --- /dev/null +++ b/app/assets/javascripts/jquery.tinyscrollbar.js @@ -0,0 +1,211 @@ +/* + * Tiny Scrollbar 1.8 + * http://www.baijs.nl/tinyscrollbar/ + * + * Copyright 2012, Maarten Baijs + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://www.opensource.org/licenses/mit-license.php + * http://www.opensource.org/licenses/gpl-2.0.php + * + * Date: 26 / 07 / 2012 + * Depends on library: jQuery + * + */ +( function( $ ) +{ + $.tiny = $.tiny || { }; + + $.tiny.scrollbar = { + options: { + axis : 'y' // vertical or horizontal scrollbar? ( x || y ). + , wheel : 40 // how many pixels must the mouswheel scroll at a time. + , scroll : true // enable or disable the mousewheel. + , lockscroll : true // return scrollwheel to browser if there is no more content. + , size : 'auto' // set the size of the scrollbar to auto or a fixed number. + , sizethumb : 'auto' // set the size of the thumb to auto or a fixed number. + , onMove : function(){} + } + }; + + $.fn.tinyscrollbar = function( params ) + { + var options = $.extend( {}, $.tiny.scrollbar.options, params ); + + this.each( function() + { + $( this ).data('tsb', new Scrollbar( $( this ), options ) ); + }); + + return this; + }; + + $.fn.tinyscrollbar_update = function(sScroll) + { + return $( this ).data( 'tsb' ).update( sScroll ); + }; + + function Scrollbar( root, options ) + { + var oSelf = this + , oWrapper = root + , oViewport = { obj: $( '.viewport', root ) } + , oContent = { obj: $( '.overview', root ) } + , oScrollbar = { obj: $( '.scrollbar', root ) } + , oTrack = { obj: $( '.track', oScrollbar.obj ) } + , oThumb = { obj: $( '.thumb', oScrollbar.obj ) } + , sAxis = options.axis === 'x' + , sDirection = sAxis ? 'left' : 'top' + , sSize = sAxis ? 'Width' : 'Height' + , iScroll = 0 + , iPosition = { start: 0, now: 0 } + , iMouse = {} + , touchEvents = ( 'ontouchstart' in document.documentElement ) ? true : false + ; + + function initialize() + { + oSelf.update(); + setEvents(); + + return oSelf; + } + + this.update = function( sScroll ) + { + oViewport[ options.axis ] = oViewport.obj[0][ 'offset'+ sSize ]; + oContent[ options.axis ] = oContent.obj[0][ 'scroll'+ sSize ]; + oContent.ratio = oViewport[ options.axis ] / oContent[ options.axis ]; + + oScrollbar.obj.toggleClass( 'disable', oContent.ratio >= 1 ); + + oTrack[ options.axis ] = options.size === 'auto' ? oViewport[ options.axis ] : options.size; + oThumb[ options.axis ] = Math.min( oTrack[ options.axis ], Math.max( 0, ( options.sizethumb === 'auto' ? ( oTrack[ options.axis ] * oContent.ratio ) : options.sizethumb ) ) ); + + oScrollbar.ratio = options.sizethumb === 'auto' ? ( oContent[ options.axis ] / oTrack[ options.axis ] ) : ( oContent[ options.axis ] - oViewport[ options.axis ] ) / ( oTrack[ options.axis ] - oThumb[ options.axis ] ); + + iScroll = ( sScroll === 'relative' && oContent.ratio <= 1 ) ? Math.min( ( oContent[ options.axis ] - oViewport[ options.axis ] ), Math.max( 0, iScroll )) : 0; + iScroll = ( sScroll === 'bottom' && oContent.ratio <= 1 ) ? ( oContent[ options.axis ] - oViewport[ options.axis ] ) : isNaN( parseInt( sScroll, 10 ) ) ? iScroll : parseInt( sScroll, 10 ); + + setSize(); + }; + + function setSize() + { + var sCssSize = sSize.toLowerCase(); + + oThumb.obj.css( sDirection, iScroll / oScrollbar.ratio ); + oContent.obj.css( sDirection, -iScroll ); + iMouse.start = oThumb.obj.offset()[ sDirection ]; + + oScrollbar.obj.css( sCssSize, oTrack[ options.axis ] ); + oTrack.obj.css( sCssSize, oTrack[ options.axis ] ); + oThumb.obj.css( sCssSize, oThumb[ options.axis ] ); + } + + function setEvents() + { + if( ! touchEvents ) + { + oThumb.obj.bind( 'mousedown', start ); + oTrack.obj.bind( 'mouseup', drag ); + } + else + { + oViewport.obj[0].ontouchstart = function( event ) + { + if( 1 === event.touches.length ) + { + start( event.touches[ 0 ] ); + event.stopPropagation(); + } + }; + } + + if( options.scroll && window.addEventListener ) + { + oWrapper[0].addEventListener( 'DOMMouseScroll', wheel, false ); + oWrapper[0].addEventListener( 'mousewheel', wheel, false ); + } + else if( options.scroll ) + { + oWrapper[0].onmousewheel = wheel; + } + } + + function start( event ) + { + var oThumbDir = parseInt( oThumb.obj.css( sDirection ), 10 ); + iMouse.start = sAxis ? event.pageX : event.pageY; + iPosition.start = oThumbDir == 'auto' ? 0 : oThumbDir; + + if( ! touchEvents ) + { + $( document ).bind( 'mousemove', drag ); + $( document ).bind( 'mouseup', end ); + oThumb.obj.bind( 'mouseup', end ); + } + else + { + document.ontouchmove = function( event ) + { + event.preventDefault(); + drag( event.touches[ 0 ] ); + }; + document.ontouchend = end; + } + } + + function wheel( event ) + { + if( oContent.ratio < 1 ) + { + var oEvent = event || window.event + , iDelta = oEvent.wheelDelta ? oEvent.wheelDelta / 120 : -oEvent.detail / 3 + ; + + iScroll -= iDelta * options.wheel; + iScroll = Math.min( ( oContent[ options.axis ] - oViewport[ options.axis ] ), Math.max( 0, iScroll )); + + oThumb.obj.css( sDirection, iScroll / oScrollbar.ratio ); + oContent.obj.css( sDirection, -iScroll ); + + if( options.lockscroll || ( iScroll !== ( oContent[ options.axis ] - oViewport[ options.axis ] ) && iScroll !== 0 ) ) + { + oEvent = $.event.fix( oEvent ); + oEvent.preventDefault(); + } + } + options.onMove.call(this,iScroll); + } + + function drag( event ) + { + if( oContent.ratio < 1 ) + { + if( ! touchEvents ) + { + iPosition.now = Math.min( ( oTrack[ options.axis ] - oThumb[ options.axis ] ), Math.max( 0, ( iPosition.start + ( ( sAxis ? event.pageX : event.pageY ) - iMouse.start)))); + } + else + { + iPosition.now = Math.min( ( oTrack[ options.axis ] - oThumb[ options.axis ] ), Math.max( 0, ( iPosition.start + ( iMouse.start - ( sAxis ? event.pageX : event.pageY ) )))); + } + + iScroll = iPosition.now * oScrollbar.ratio; + oContent.obj.css( sDirection, -iScroll ); + oThumb.obj.css( sDirection, iPosition.now ); + } + } + + function end() + { + $( document ).unbind( 'mousemove', drag ); + $( document ).unbind( 'mouseup', end ); + oThumb.obj.unbind( 'mouseup', end ); + document.ontouchmove = document.ontouchend = null; + } + + return initialize(); + } + +}(jQuery)); \ No newline at end of file diff --git a/app/assets/javascripts/jquery.tinyscrollbar.min.js b/app/assets/javascripts/jquery.tinyscrollbar.min.js index 98786a770..e385ff8ed 100644 --- a/app/assets/javascripts/jquery.tinyscrollbar.min.js +++ b/app/assets/javascripts/jquery.tinyscrollbar.min.js @@ -1 +1,118 @@ -(function(a){function b(b,c){function w(a){if(!(g.ratio>=1)){o.now=Math.min(i[c.axis]-j[c.axis],Math.max(0,o.start+((k?a.pageX:a.pageY)-p.start)));n=o.now*h.ratio;g.obj.css(l,-n);j.obj.css(l,o.now)}return false}function v(b){a(document).unbind("mousemove",w);a(document).unbind("mouseup",v);j.obj.unbind("mouseup",v);document.ontouchmove=j.obj[0].ontouchend=document.ontouchend=null;return false}function u(b){if(!(g.ratio>=1)){var b=b||window.event;var d=b.wheelDelta?b.wheelDelta/120:-b.detail/3;n-=d*c.wheel;n=Math.min(g[c.axis]-f[c.axis],Math.max(0,n));j.obj.css(l,n/h.ratio);g.obj.css(l,-n);b=a.event.fix(b);b.preventDefault()}}function t(b){p.start=k?b.pageX:b.pageY;var c=parseInt(j.obj.css(l));o.start=c=="auto"?0:c;a(document).bind("mousemove",w);document.ontouchmove=function(b){a(document).unbind("mousemove");w(b.touches[0])};a(document).bind("mouseup",v);j.obj.bind("mouseup",v);j.obj[0].ontouchend=document.ontouchend=function(b){a(document).unbind("mouseup");j.obj.unbind("mouseup");v(b.touches[0])};return false}function s(){j.obj.bind("mousedown",t);j.obj[0].ontouchstart=function(a){a.preventDefault();j.obj.unbind("mousedown");t(a.touches[0]);return false};i.obj.bind("mouseup",w);if(c.scroll&&this.addEventListener){e[0].addEventListener("DOMMouseScroll",u,false);e[0].addEventListener("mousewheel",u,false)}else if(c.scroll){e[0].onmousewheel=u}}function r(){j.obj.css(l,n/h.ratio);g.obj.css(l,-n);p["start"]=j.obj.offset()[l];var a=m.toLowerCase();h.obj.css(a,i[c.axis]);i.obj.css(a,i[c.axis]);j.obj.css(a,j[c.axis])}function q(){d.update();s();return d}var d=this;var e=b;var f={obj:a(".viewport",b)};var g={obj:a(".overview",b)};var h={obj:a(".scrollbar",b)};var i={obj:a(".track",h.obj)};var j={obj:a(".thumb",h.obj)};var k=c.axis=="x",l=k?"left":"top",m=k?"Width":"Height";var n,o={start:0,now:0},p={};this.update=function(a){f[c.axis]=f.obj[0]["offset"+m];g[c.axis]=g.obj[0]["scroll"+m];g.ratio=f[c.axis]/g[c.axis];h.obj.toggleClass("disable",g.ratio>=1);i[c.axis]=c.size=="auto"?f[c.axis]:c.size;j[c.axis]=Math.min(i[c.axis],Math.max(0,c.sizethumb=="auto"?i[c.axis]*g.ratio:c.sizethumb));h.ratio=c.sizethumb=="auto"?g[c.axis]/i[c.axis]:(g[c.axis]-f[c.axis])/(i[c.axis]-j[c.axis]);n=a=="relative"&&g.ratio<=1?Math.min(g[c.axis]-f[c.axis],Math.max(0,n)):0;n=a=="bottom"&&g.ratio<=1?g[c.axis]-f[c.axis]:isNaN(parseInt(a))?n:parseInt(a);r()};return q()}a.tiny=a.tiny||{};a.tiny.scrollbar={options:{axis:"y",wheel:40,scroll:true,size:"auto",sizethumb:"auto"}};a.fn.tinyscrollbar=function(c){var c=a.extend({},a.tiny.scrollbar.options,c);this.each(function(){a(this).data("tsb",new b(a(this),c))});return this};a.fn.tinyscrollbar_update=function(b){return a(this).data("tsb").update(b)};})(jQuery) \ No newline at end of file +(function(a){ + function b(b,c){ + function w(a){ + if(!(g.ratio>=1)){ + o.now=Math.min(i[c.axis]-j[c.axis],Math.max(0,o.start+((k?a.pageX:a.pageY)-p.start))); + n=o.now*h.ratio;g.obj.css(l,-n); + j.obj.css(l,o.now) + } + return false + } + function v(b){ + a(document).unbind("mousemove",w); + a(document).unbind("mouseup",v); + j.obj.unbind("mouseup",v); + document.ontouchmove=j.obj[0].ontouchend=document.ontouchend=null; + return false + } + function u(b){ + if(!(g.ratio>=1)){ + var b=b||window.event; + var d=b.wheelDelta?b.wheelDelta/120:-b.detail/3; + n-=d*c.wheel; + n=Math.min(g[c.axis]-f[c.axis],Math.max(0,n)); + j.obj.css(l,n/h.ratio); + g.obj.css(l,-n); + b=a.event.fix(b); + b.preventDefault() + } + } + function t(b){ + p.start=k?b.pageX:b.pageY; + var c=parseInt(j.obj.css(l)); + o.start=c=="auto"?0:c; + a(document).bind("mousemove",w); + document.ontouchmove=function(b){ + a(document).unbind("mousemove"); + w(b.touches[0]) + }; + a(document).bind("mouseup",v); + j.obj.bind("mouseup",v); + j.obj[0].ontouchend=document.ontouchend=function(b){ + a(document).unbind("mouseup"); + j.obj.unbind("mouseup"); + v(b.touches[0]) + }; + return false + } + function s(){ + j.obj.bind("mousedown",t); + j.obj[0].ontouchstart=function(a){ + a.preventDefault(); + j.obj.unbind("mousedown"); + t(a.touches[0]); + return false + }; + i.obj.bind("mouseup",w); + if(c.scroll&&this.addEventListener){ + e[0].addEventListener("DOMMouseScroll",u,false); + e[0].addEventListener("mousewheel",u,false) + }else if(c.scroll){ + e[0].onmousewheel=u + } + } + function r(){ + j.obj.css(l,n/h.ratio); + g.obj.css(l,-n); + p["start"]=j.obj.offset()[l]; + var a=m.toLowerCase(); + h.obj.css(a,i[c.axis]); + i.obj.css(a,i[c.axis]); + j.obj.css(a,j[c.axis]) + } + function q(){ + d.update(); + s(); + return d + } + var d=this; + var e=b; + var f={obj:a(".viewport",b)}; + var g={obj:a(".overview",b)}; + var h={obj:a(".scrollbar",b)}; + var i={obj:a(".track",h.obj)}; + var j={obj:a(".thumb",h.obj)}; + var k=c.axis=="x", + l=k?"left":"top", + m=k?"Width":"Height"; + var n, + o={start:0,now:0}, + p={}; + this.update=function(a){ + f[c.axis]=f.obj[0]["offset"+m]; + g[c.axis]=g.obj[0]["scroll"+m]; + g.ratio=f[c.axis]/g[c.axis]; + h.obj.toggleClass("disable",g.ratio>=1); + i[c.axis]=c.size=="auto"?f[c.axis]:c.size; + j[c.axis]=Math.min(i[c.axis],Math.max(0,c.sizethumb=="auto"?i[c.axis]*g.ratio:c.sizethumb)); + h.ratio=c.sizethumb=="auto"?g[c.axis]/i[c.axis]:(g[c.axis]-f[c.axis])/(i[c.axis]-j[c.axis]); + n=a=="relative"&&g.ratio<=1?Math.min(g[c.axis]-f[c.axis],Math.max(0,n)):0; + n=a=="bottom"&&g.ratio<=1?g[c.axis]-f[c.axis]:isNaN(parseInt(a))?n:parseInt(a); + r() + }; + return q() + } + a.tiny=a.tiny||{}; + a.tiny.scrollbar={options:{axis:"y",wheel:40,scroll:true,size:"auto",sizethumb:"auto"}}; + a.fn.tinyscrollbar=function(c){ + var c=a.extend({},a.tiny.scrollbar.options,c); + this.each(function(){ + a(this).data("tsb",new b(a(this),c)) + }); + return this + }; + a.fn.tinyscrollbar_update=function(b){ + return a(this).data("tsb").update(b) + }; +}) +(jQuery) \ No newline at end of file diff --git a/app/assets/javascripts/lib/contenteditable.js.erb b/app/assets/javascripts/lib/contenteditable.js.erb new file mode 100644 index 000000000..40c19dd35 --- /dev/null +++ b/app/assets/javascripts/lib/contenteditable.js.erb @@ -0,0 +1,56 @@ +<%#= encoding: utf-8 %> +$(function() { + var content_holder, content; + var selector = 'a[contenteditable="true"]'; + // prevent clicks inside editable area to fire + // a click event on the body + // and therefor saving our content before we even edit it + +$(".nav-tabs").find(".icons-pencil").click(function(){ + $(this).css({ + "display" : "none" + }) + $(this).next().attr("contenteditable",true).addClass("edit"); + // $(selector).click(function(e) { + // e.stopPropagation(); + // }); + + // initialize the "save" function + $(selector).focus(function(e) { + content_holder = $(this); + content = content_holder.html(); + // one click outside the editable area saves the content + $(selector).keypress( function(e) { + // but not if the content didn't change + //alert('out!!'); + if(e.keyCode == 13){ + $(".nav-tabs>li>a").removeClass("edit"); + $(this).prev(".icons-pencil").css({ + "display" : "block" + }) + e.preventDefault(); + // if ($(e.target).is(selector) || content == content_holder.html()) { + // return; + // } + + $.ajax({ + url: content_holder.data('edit-url'), + type: 'POST', + dataType: 'json', + data: { body: content_holder.html() }, + success: function(json) { + $(selector).attr("contenteditable",false) + alert("<%= I18n.t('admin.contenteditable.update_done') %>"); + //content_holder.effect('highlight', {'color': '#0f0'}, 3000); + }, + error: function() { + alert("<%= I18n.t('admin.contenteditable.update_failed') %>"); + //content_holder.effect('highlight', {'color': '#f00'}, 3000); + content_holder.html(content); + } + }); + } + }); + }); +}); +}); \ No newline at end of file diff --git a/app/assets/javascripts/lib/jquery.ui.nestedSortable.js b/app/assets/javascripts/lib/jquery.ui.nestedSortable.js new file mode 100755 index 000000000..aad83af5f --- /dev/null +++ b/app/assets/javascripts/lib/jquery.ui.nestedSortable.js @@ -0,0 +1,391 @@ +/* + * jQuery UI Nested Sortable + * v 1.3.4 / 28 apr 2011 + * http://mjsarfatti.com/sandbox/nestedSortable + * + * Depends: + * jquery.ui.sortable.js 1.8+ + * + * License CC BY-SA 3.0 + * Copyright 2010-2011, Manuele J Sarfatti + */ + +(function($) { + + $.widget("ui.nestedSortable", $.extend({}, $.ui.sortable.prototype, { + + options: { + tabSize: 20, + disableNesting: 'ui-nestedSortable-no-nesting', + errorClass: 'ui-nestedSortable-error', + listType: 'ol', + maxLevels: 0, + revertOnError: 1 + }, + + _create: function() { + this.element.data('sortable', this.element.data('nestedSortable')); + return $.ui.sortable.prototype._create.apply(this, arguments); + }, + + destroy: function() { + this.element + .removeData("nestedSortable") + .unbind(".nestedSortable"); + return $.ui.sortable.prototype.destroy.apply(this, arguments); + }, + + _mouseDrag: function(event) { + + //Compute the helpers position + this.position = this._generatePosition(event); + this.positionAbs = this._convertPositionTo("absolute"); + + if (!this.lastPositionAbs) { + this.lastPositionAbs = this.positionAbs; + } + + //Do scrolling + if(this.options.scroll) { + var o = this.options, scrolled = false; + if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') { + + if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) + this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed; + else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) + this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed; + + if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) + this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed; + else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) + this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed; + + } else { + + if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) + scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed); + else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) + scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed); + + if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) + scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed); + else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) + scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed); + + } + + if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) + $.ui.ddmanager.prepareOffsets(this, event); + } + + //Regenerate the absolute position used for position checks + this.positionAbs = this._convertPositionTo("absolute"); + + //Set the helper position + if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px'; + if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px'; + + //Rearrange + for (var i = this.items.length - 1; i >= 0; i--) { + + //Cache variables and intersection, continue if no intersection + var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item); + if (!intersection) continue; + + if(itemElement != this.currentItem[0] //cannot intersect with itself + && this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before + && !$.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked + && (this.options.type == 'semi-dynamic' ? !$.contains(this.element[0], itemElement) : true) + //&& itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container + ) { + + $(itemElement).mouseenter(); + + this.direction = intersection == 1 ? "down" : "up"; + + if (this.options.tolerance == "pointer" || this._intersectsWithSides(item)) { + $(itemElement).mouseleave(); + this._rearrange(event, item); + } else { + break; + } + + // Clear emtpy ul's/ol's + this._clearEmpty(itemElement); + + this._trigger("change", event, this._uiHash()); + break; + } + } + + var parentItem = (this.placeholder[0].parentNode.parentNode + && $(this.placeholder[0].parentNode.parentNode).closest('.ui-sortable').length) + ? $(this.placeholder[0].parentNode.parentNode) + : null, + level = this._getLevel(this.placeholder), + childLevels = this._getChildLevels(this.helper), + previousItem = this.placeholder[0].previousSibling ? $(this.placeholder[0].previousSibling) : null; + + if (previousItem != null) { + while (previousItem[0].nodeName.toLowerCase() != 'li' || previousItem[0] == this.currentItem[0]) { + if (previousItem[0].previousSibling) { + previousItem = $(previousItem[0].previousSibling); + } else { + previousItem = null; + break; + } + } + } + + newList = document.createElement(o.listType); + + this.beyondMaxLevels = 0; + + // If the item is moved to the left, send it to its parent level + if (parentItem != null && this.positionAbs.left < parentItem.offset().left) { + parentItem.after(this.placeholder[0]); + this._clearEmpty(parentItem[0]); + this._trigger("change", event, this._uiHash()); + } + // If the item is below another one and is moved to the right, make it a children of it + else if (previousItem != null && this.positionAbs.left > previousItem.offset().left + o.tabSize) { + this._isAllowed(previousItem, level+childLevels+1); + if (!previousItem.children(o.listType).length) { + previousItem[0].appendChild(newList); + } + previousItem.children(o.listType)[0].appendChild(this.placeholder[0]); + this._trigger("change", event, this._uiHash()); + } + else { + this._isAllowed(parentItem, level+childLevels); + } + + //Post events to containers + this._contactContainers(event); + + //Interconnect with droppables + if($.ui.ddmanager) $.ui.ddmanager.drag(this, event); + + //Call callbacks + this._trigger('sort', event, this._uiHash()); + + this.lastPositionAbs = this.positionAbs; + return false; + + }, + + _mouseStop: function(event, noPropagation) { + + // If the item is in a position not allowed, send it back + if (this.beyondMaxLevels) { + + this.placeholder.removeClass(this.options.errorClass); + + if (this.options.revertOnError) { + if (this.domPosition.prev) { + $(this.domPosition.prev).after(this.placeholder); + } else { + $(this.domPosition.parent).prepend(this.placeholder); + } + this._trigger("revert", event, this._uiHash()); + } else { + var parent = this.placeholder.parent().closest(this.options.items); + + for (var i = this.beyondMaxLevels - 1; i > 0; i--) { + parent = parent.parent().closest(this.options.items); + } + + parent.after(this.placeholder); + this._trigger("change", event, this._uiHash()); + } + + } + + // Clean last empty ul/ol + for (var i = this.items.length - 1; i >= 0; i--) { + var item = this.items[i].item[0]; + this._clearEmpty(item); + } + + $.ui.sortable.prototype._mouseStop.apply(this, arguments); + + }, + + serialize: function(o) { + + var items = this._getItemsAsjQuery(o && o.connected), + str = []; o = o || {}; + + $(items).each(function() { + var res = ($(o.item || this).attr(o.attribute || 'id') || '') + .match(o.expression || (/(.+)[-=_](.+)/)), + pid = ($(o.item || this).parent(o.listType) + .parent('li') + .attr(o.attribute || 'id') || '') + .match(o.expression || (/(.+)[-=_](.+)/)); + + if (res) { + str.push(((o.key || res[1]) + '[' + (o.key && o.expression ? res[1] : res[2]) + ']') + + '=' + + (pid ? (o.key && o.expression ? pid[1] : pid[2]) : 'root')); + } + }); + + if(!str.length && o.key) { + str.push(o.key + '='); + } + + return str.join('&'); + + }, + + toHierarchy: function(o) { + + o = o || {}; + var sDepth = o.startDepthCount || 0, + ret = []; + + $(this.element).children('li').each(function () { + var level = _recursiveItems($(this)); + ret.push(level); + }); + + return ret; + + function _recursiveItems(li) { + var id = ($(li).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/)); + if (id) { + var item = {"id" : id[2]}; + if ($(li).children(o.listType).children('li').length > 0) { + item.children = []; + $(li).children(o.listType).children('li').each(function() { + var level = _recursiveItems($(this)); + item.children.push(level); + }); + } + return item; + } + } + }, + + toArray: function(o) { + + o = o || {}; + var sDepth = o.startDepthCount || 0, + ret = [], + left = 2; + + ret.push({ + "item_id": 'root', + "parent_id": 'none', + "depth": sDepth, + "left": '1', + "right": ($('li', this.element).length + 1) * 2 + }); + + $(this.element).children('li').each(function () { + left = _recursiveArray(this, sDepth + 1, left); + }); + + ret = ret.sort(function(a,b){ return (a.left - b.left); }); + + return ret; + + function _recursiveArray(item, depth, left) { + + var right = left + 1, + id, + pid; + + if ($(item).children(o.listType).children('li').length > 0) { + depth ++; + $(item).children(o.listType).children('li').each(function () { + right = _recursiveArray($(this), depth, right); + }); + depth --; + } + + id = ($(item).attr(o.attribute || 'id')).match(o.expression || (/(.+)[-=_](.+)/)); + + if (depth === sDepth + 1) { + pid = 'root'; + } else { + var parentItem = ($(item).parent(o.listType) + .parent('li') + .attr(o.attribute || 'id')) + .match(o.expression || (/(.+)[-=_](.+)/)); + pid = parentItem[2]; + } + + if (id) { + ret.push({"item_id": id[2], "parent_id": pid, "depth": depth, "left": left, "right": right}); + } + + left = right + 1; + return left; + } + + }, + + _clearEmpty: function(item) { + + var emptyList = $(item).children(this.options.listType); + if (emptyList.length && !emptyList.children().length) { + emptyList.remove(); + } + + }, + + _getLevel: function(item) { + + var level = 1; + + if (this.options.listType) { + var list = item.closest(this.options.listType); + while (!list.is('.ui-sortable')) { + level++; + list = list.parent().closest(this.options.listType); + } + } + + return level; + }, + + _getChildLevels: function(parent, depth) { + var self = this, + o = this.options, + result = 0; + depth = depth || 0; + + $(parent).children(o.listType).children(o.items).each(function (index, child) { + result = Math.max(self._getChildLevels(child, depth + 1), result); + }); + + return depth ? result + 1 : result; + }, + + _isAllowed: function(parentItem, levels) { + var o = this.options; + // Are we trying to nest under a no-nest or are we nesting too deep? + if (parentItem == null || !(parentItem.hasClass(o.disableNesting))) { + if (o.maxLevels < levels && o.maxLevels != 0) { + this.placeholder.addClass(o.errorClass); + this.beyondMaxLevels = levels - o.maxLevels; + } else { + this.placeholder.removeClass(o.errorClass); + this.beyondMaxLevels = 0; + } + } else { + this.placeholder.addClass(o.errorClass); + if (o.maxLevels < levels && o.maxLevels != 0) { + this.beyondMaxLevels = levels - o.maxLevels; + } else { + this.beyondMaxLevels = 1; + } + } + } + + })); + + $.ui.nestedSortable.prototype.options = $.extend({}, $.ui.sortable.prototype.options, $.ui.nestedSortable.prototype.options); +})(jQuery); \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/assets/javascripts/module_widget.js b/app/assets/javascripts/module.js.erb similarity index 93% rename from vendor/built_in_modules/announcement/app/assets/javascripts/module_widget.js rename to app/assets/javascripts/module.js.erb index 9c429aacd..fc19b8e61 100644 --- a/vendor/built_in_modules/announcement/app/assets/javascripts/module_widget.js +++ b/app/assets/javascripts/module.js.erb @@ -6,4 +6,3 @@ // //= require jquery //= require jquery_ujs -//= require announcement_link \ No newline at end of file diff --git a/app/assets/javascripts/new_admin.js b/app/assets/javascripts/new_admin.js index 45bfcbbc1..949753a9f 100644 --- a/app/assets/javascripts/new_admin.js +++ b/app/assets/javascripts/new_admin.js @@ -6,6 +6,7 @@ // //= require jquery //= require jquery_ujs +//= require jquery.form //= require bootstrap //= require jquery.isotope.min //= require jquery.tinyscrollbar.min @@ -13,4 +14,7 @@ //= require tinymce-jquery //= require tinymce_orbit //= require orbit-bar-search -//= require side_bar_history \ No newline at end of file +//= require side_bar_history +//= require rss +//= require ajax_form +//= require inc/ajax_setting diff --git a/app/assets/javascripts/news_bulletin_form.js b/app/assets/javascripts/news_bulletin_form.js new file mode 100644 index 000000000..6f0f9ac56 --- /dev/null +++ b/app/assets/javascripts/news_bulletin_form.js @@ -0,0 +1,19 @@ +$('.news_bulletin_links_block a.delete').live('click', function(){ + $(this).parents('.list_item').remove(); +}); + +$('.news_bulletin_files_block a.delete').live('click', function(){ + $(this).parents('.list_item').remove(); +}); + +$(document).on('click', '.action a.remove_existing_record', function(){ + $(this).next('.should_destroy').attr('value', 1); + $("tr #" + $(this).prev().attr('value')).hide(); +}); + +$(document).on('click', '.quick_edit_cancel', function(){ + tr = $(this).attr('rel'); + $('#' + tr).hide(); + $("tr#news_bulletin_file_" + $(this).prev().attr('value')).hide(); + $("tr#news_bulletin_link_" + $(this).prev().attr('value')).hide(); +}); \ No newline at end of file diff --git a/app/assets/javascripts/orbit-1.0.js b/app/assets/javascripts/orbit-1.0.js index 5f69b297e..b1ac99937 100644 --- a/app/assets/javascripts/orbit-1.0.js +++ b/app/assets/javascripts/orbit-1.0.js @@ -14,9 +14,9 @@ $(document).ready(function(){ placement: "left" }); + $(document).on('click', '.privacy', function() { - console.log($(this).val()); switch ($(this).val()) { case 'true': $(this).parents('.controls').children('.select-role').slideUp(300); @@ -47,14 +47,19 @@ $(document).ready(function(){ /*tinyscrollbar&windows-Size*/ resize(); - var $mainWrapMarginLeft = parseInt($('#main-wrap').css("margin-left"))-2; - $('#main-sidebar').css("height", viewportheight-30); - $('#main-sidebar .viewport').css("height", viewportheight-30); - $('.post-title').css("width", viewportwidth-495); + var $mainWrapMarginLeft = parseInt($('#main-wrap').css("margin-left"))-2, + $subWiget = $('#sub-wiget').width()+18; + $orbitBar = $('#orbit-bar').height(), + $mainSidebar = $('#main-sidebar').width()+5, + $formActionPadding = parseInt($('.form-fixed').css("padding-left"))+parseInt($('.form-fixed').css("padding-right")); + $('#main-sidebar').css("height", viewportheight-$orbitBar); + $('#main-sidebar .viewport').css("height", viewportheight-$orbitBar); + $('#post-body').css("width", viewportwidth-$mainWrapMarginLeft-$subWiget); + $('.post-title').css("width", viewportwidth-$mainWrapMarginLeft-$subWiget-16); $('#main-wrap .subnav').css("width", viewportwidth-$mainWrapMarginLeft); - $('#main-sidebar').tinyscrollbar(); + $('.form-fixed').css("width", viewportwidth-$mainWrapMarginLeft-$formActionPadding); + $('#main-sidebar').tinyscrollbar({size:(viewportheight-$orbitBar-4)}); $('.detal-list').tinyscrollbar(); - $('#main-sidebar').tinyscrollbar({size:(viewportheight-34)}); mainTablePosition(); /*isotope*/ @@ -68,12 +73,18 @@ $(document).ready(function(){ }); $(window).resize(function(){ resize(); - var $mainWrapMarginLeft = parseInt($('#main-wrap').css("margin-left"))-2; - $('#main-sidebar').css("height", viewportheight-30); - $('#main-sidebar .viewport').css("height", viewportheight-30); - $('.post-title').css("width", viewportwidth-495); - $('#main-wrap .subnav').css("width", viewportwidth-$mainWrapMarginLeft) - $('#main-sidebar').tinyscrollbar({size:(viewportheight-34)}); + var $mainWrapMarginLeft = parseInt($('#main-wrap').css("margin-left"))-2, + $subWiget = $('#sub-wiget').width()+18; + $orbitBar = $('#orbit-bar').height(), + $mainSidebar = $('#main-sidebar').width()+5, + $formActionPadding = parseInt($('.form-fixed').css("padding-left"))+parseInt($('.form-fixed').css("padding-right")); + $('#main-sidebar').css("height", viewportheight-$orbitBar); + $('#main-sidebar .viewport').css("height", viewportheight-$orbitBar); + $('#post-body').css("width", viewportwidth-$mainWrapMarginLeft-$subWiget); + $('.post-title').css("width", viewportwidth-$mainWrapMarginLeft-$subWiget-16); + $('#main-wrap .subnav').css("width", viewportwidth-$mainWrapMarginLeft); + $('.form-fixed').css("width", viewportwidth-$mainWrapMarginLeft-$formActionPadding); + $('#main-sidebar').tinyscrollbar({size:(viewportheight-$orbitBar-4)}); mainTablePosition(); }); /*main-table position*/ @@ -101,5 +112,4 @@ $(window).scroll(function () { $(".table-label").css({left:$winLeft*-1} ); //$(".table-label").css({left:$mainWrapMarginLeft+($winLeft*-1)} ); //$("#main-wrap > .subnav").css({width:$subnavWidth+($winLeft)} ); - //console.log($mainWrapMarginLeft+($winLeft*-1)+5); }); diff --git a/app/assets/javascripts/orbit-bar-search.js b/app/assets/javascripts/orbit-bar-search.js index 26f44d843..7ef1dd055 100644 --- a/app/assets/javascripts/orbit-bar-search.js +++ b/app/assets/javascripts/orbit-bar-search.js @@ -1,3 +1,9 @@ + +$(document).ready(function(){ + $('.search').tooltip({ + placement: "bottom" + }); +}); $(document).on('click', '.orbit-bar-search', function (){ if ($(this).parents('.search').hasClass('visible')){ $(this).parents('.search').stop().animate({ diff --git a/app/assets/javascripts/orbitTimeline.js b/app/assets/javascripts/orbitTimeline.js index 5eecb48c4..fd4121394 100644 --- a/app/assets/javascripts/orbitTimeline.js +++ b/app/assets/javascripts/orbitTimeline.js @@ -6,57 +6,79 @@ var orbitTimeline = function(dom){ this.dom = $("#"+dom); this.timelineHtml = $("
"); //this.marker = t.timelineHtml.find("#timline_marker"); - this.scale = t.timelineHtml.find("#timeline_scale"); + this.scale = ""; //this.container = t.timelineHtml.find("#t_container"); this.events = new Array; this.monthList = ["","January","February","March","April","May","June","July","August","September","October","November","December"]; + this.dt = new Date(); + this.fromdate = [t.dt.getFullYear(),t.dt.getMonth()+1]; + this.ajaxload = true; this.initialize = function(){ t.dom.html(t.timelineHtml); $("div.scrollbar").hide(); t.constructTimeScale(function(timelineScale){ - console.log(timelineScale); $("#timeline_scale").html(timelineScale); - var totalyearwidth =timelineScale.find(".year").length * 100; + var totalyearwidth =timelineScale.find(".year").length * 200; var totalul = 0; + $(".t_scale").css({"min-width":$(".tinycanvas .viewport").width()+200 + "px"}) for(eve in t.events){ t.makeBubble(t.events[eve]); totalul = $("#scale_wrapper ul").length $(".t_scale").width((totalul*350) + totalyearwidth); } - $('.tinycanvas').tinyscrollbar({ axis: 'x'}); + $('.tinycanvas').tinyscrollbar({ + axis: 'x', + onMove: function(x){ + var limit = $("#timeline_scale").width() - $(".tinycanvas .scrollbar").width(); + if(t.ajaxload){ + if((limit - x) < 10){ + t.eventAjaxLoad(function(){ + var totalul = 0; + for(eve in t.events){ + t.makeBubble(t.events[eve]); + totalul = $("#scale_wrapper ul").length + $(".t_scale").width((totalul*350) + totalyearwidth); + } + $('.tinycanvas').tinyscrollbar_update(x); + }); + } + } + } + }); }); } this.constructTimeScale = function(callbackFn){ - var mon ="",year=""; + var mon ="",year="",formname; var scale = $("
"); - $.getJSON("desktop_orbit/getevents",{"event":"papers"},function(journals){ - $.each(journals,function(x,journal){ - $.each(journal.papers,function(i,paper){ - var dt = new Date(paper.created_at); - var cur_mon = paper.created_at.substr(5,2); - var cur_year = dt.getFullYear(); - var cdt = paper.created_at.substr(0,7).replace("-",""); - var formname = (cur_mon.charAt(0) == "0"?cur_mon.charAt(1) : cur_mon) - var bubbleData = {"fulldate" : t.monthList[parseInt(formname)] +", " + dt.getDate() + ", " + cur_year,"title":paper.title,"jtitle":journal.title,"coauthors":paper.coauthors,"abstract":paper.abstract,"timestamp":cdt} - t.events.push(bubbleData); - if(cur_year != year){ - year = cur_year; - scale.append($("
"+(year+1)+"
")); - } - if(cur_mon != mon){ - mon = cur_mon; - console.log(parseInt(cur_mon)); - scale.append($("
"+t.monthList[parseInt(formname)]+"
")) - } + $.getJSON("desktop_orbit/eventajaxload",{"event":"papers","from":t.fromdate},function(papersArray){ + $.each(papersArray,function(i,pa){ + $.each(pa.papers,function(i,paper){ + var dt = new Date(paper.created_at); + var cur_mon = paper.created_at.substr(5,2); + var cur_year = dt.getFullYear(); + var cdt = paper.created_at.substr(0,7).replace("-",""); + formname = (cur_mon.charAt(0) == "0"?cur_mon.charAt(1) : cur_mon) + var bubbleData = {"fulldate" : t.monthList[parseInt(formname)] +", " + dt.getDate() + ", " + cur_year,"title":paper.title,"jtitle":"Harry","coauthors":paper.coauthors,"abstract":paper.abstract,"timestamp":cdt} + t.events.push(bubbleData); + if(cur_year != year){ + year = cur_year; + scale.append($("
"+(year+1)+"
")); + } + if(cur_mon != mon){ + mon = cur_mon; + var yr = scale.find("div[data-content="+year+"]"); + yr.append($("
"+t.monthList[parseInt(formname)]+"
")) + } + }); }); + scale.append($("
"+year+"
")); + t.fromdate = [year,formname-1]; + if(typeof callbackFn == "function"){ + callbackFn.call(this,scale); + } }) - scale.append($("
"+year+"
")); - if(typeof callbackFn == "function"){ - callbackFn.call(this,scale); - } - }); } this.makeBubble = function(bubbleData){ var totalul = $("#scale_wrapper").find("div[data-content="+bubbleData.timestamp+"] ul").length; @@ -87,4 +109,45 @@ var orbitTimeline = function(dom){ }); })//.mouseout(function(){t.oapi.toolPopup("destroy");}) } + this.eventAjaxLoad = function(callbackFn){ + t.events = []; + var mon ="",year="",formname; + var scale = $("#scale_wrapper"); + + t.ajaxload = false; + $.getJSON("desktop_orbit/eventajaxload",{"from":t.fromdate},function(papersArray){ + $.each(papersArray,function(i,pa){ + $.each(pa.papers,function(i,paper){ + var dt = new Date(paper.created_at); + var cur_mon = paper.created_at.substr(5,2); + var cur_year = dt.getFullYear(); + var cdt = paper.created_at.substr(0,7).replace("-",""); + formname = (cur_mon.charAt(0) == "0"?cur_mon.charAt(1) : cur_mon) + var bubbleData = {"fulldate" : t.monthList[parseInt(formname)] +", " + dt.getDate() + ", " + cur_year,"title":paper.title,"jtitle":"Harry","coauthors":paper.coauthors,"abstract":paper.abstract,"timestamp":cdt} + t.events.push(bubbleData); + if(cur_year != year){ + year = cur_year; + if(scale.find("div[data-content="+year+"]").length == 0){ + scale.append($("
"+(year+1)+"
")); + } + } + if(cur_mon != mon){ + mon = cur_mon; + var yr = scale.find("div[data-content="+year+"]"); + yr.append($("
"+t.monthList[parseInt(formname)]+"
")) + } + }); + }); + if(papersArray.length != 0){ + if(scale.find("div[data-content="+(year-1)+"]").length == 0) + scale.append($("
"+year+"
")); + t.ajaxload = true; + t.fromdate = [year,formname-1]; + } + if(typeof callbackFn == "function"){ + callbackFn.call(this,scale); + } + }) + + } } \ No newline at end of file diff --git a/app/assets/javascripts/orbit_bar.js b/app/assets/javascripts/orbit_bar.js index 06c3113dc..e9b1b4ea2 100644 --- a/app/assets/javascripts/orbit_bar.js +++ b/app/assets/javascripts/orbit_bar.js @@ -4,4 +4,4 @@ $(document).ready(function() { $('body').prepend($(this).html()); $(this).remove(); }); -}); \ No newline at end of file +}); diff --git a/app/assets/javascripts/page_edit.js b/app/assets/javascripts/page_edit.js.erb similarity index 52% rename from app/assets/javascripts/page_edit.js rename to app/assets/javascripts/page_edit.js.erb index 31a7d600d..d7aaccd0a 100644 --- a/app/assets/javascripts/page_edit.js +++ b/app/assets/javascripts/page_edit.js.erb @@ -24,7 +24,36 @@ $("#module_app_list select").live('change', function() { $.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_widgets'); }); +$("#tag_list select").live('change', function() { + $.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_r_tag_options'); +}); + $('.part_kind').live('click', function() { $('.part_kind_partial').hide(); $('#part_' + $(this).attr('value')).show(); }); + +$(document).ready(function(){ + bindTreeDragHandle(); +}); + +var bindTreeDragHandle = function(){ + $('ol.sortable').nestedSortable({ + disableNesting: 'no-nest', + forcePlaceholderSize: true, + handle: 'i', + helper: 'clone', + items: 'li', + maxLevels: 3, + opacity: .5, + placeholder: 'placeholder', + revert: 250, + tabSize: 25, + tolerance: 'pointer', + toleranceElement: '> div', + + stop: function(event, ui) { + $.post("<%= Rails.application.routes.url_helpers.admin_update_position_path %>", { id: ui.item.attr('id'), parent_id: ui.item.parent().closest('li').attr('id'), position: ui.item.index() } ); + } + }); +} \ No newline at end of file diff --git a/app/assets/javascripts/side_bar_history.js b/app/assets/javascripts/side_bar_history.js index 4b5da1d4c..f23fd6cc9 100644 --- a/app/assets/javascripts/side_bar_history.js +++ b/app/assets/javascripts/side_bar_history.js @@ -1,28 +1,19 @@ var history_edited = false; -// $('#back_sidebar a, #back_main a.nav').live('click', -// function () { -// $.getScript(this.href); -// history.pushState(null, document.title, this.href); -// history_edited = true; -// return false; -// } -// ); +$('#back_main a.reload').live('click', + function () { + $.getScript(this.href); + history.replaceState(null, document.title, this.href); + history_edited = true; + return false; + } +); -// $('#back_main a.reload').live('click', -// function () { -// $.getScript(this.href); -// history.replaceState(null, document.title, this.href); -// history_edited = true; -// return false; -// } -// ); - -// $('.form').live('submit', function () { -// $.post(this.action, $(this).serialize(), null, 'script'); -// history_edited = true; -// return false; -// }); +$('#back_main form').live('submit', function () { + $.post(this.action, $(this).serialize(), null, 'script'); + history_edited = true; + return false; +}); $(document).on('click', '.js_history', function () { diff --git a/app/assets/javascripts/site_editor.js b/app/assets/javascripts/site_editor.js index 98405564c..5d77e701e 100644 --- a/app/assets/javascripts/site_editor.js +++ b/app/assets/javascripts/site_editor.js @@ -5,6 +5,17 @@ // the compiled file. // //= require jquery +//= require jquery.ui.draggable +//= require jquery.ui.droppable +//= require jquery.ui.sortable //= require jquery_ujs +//= require bootstrap +//= require jquery.isotope.min +//= require jquery.tinyscrollbar.min +//= require orbit-1.0 +//= require orbit-bar-search +//= require side_bar_history //= require page_edit -//= require side_bar_history \ No newline at end of file +//= require tinymce-jquery +//= require tinymce_orbit +//= require lib/jquery.ui.nestedSortable.js \ No newline at end of file diff --git a/app/assets/javascripts/sort_header.js b/app/assets/javascripts/sort_header.js new file mode 100644 index 000000000..25a163449 --- /dev/null +++ b/app/assets/javascripts/sort_header.js @@ -0,0 +1,7 @@ +$(document).on('click', '.list-remove', function(){ + $('#delete_all').submit(); +}); + +$(document).on('click', '#check_all', function(){ + $('.checkbox_in_list').attr("checked", this.checked); +}); \ No newline at end of file diff --git a/app/assets/javascripts/tinymce_orbit.js b/app/assets/javascripts/tinymce_orbit.js deleted file mode 100644 index 604929148..000000000 --- a/app/assets/javascripts/tinymce_orbit.js +++ /dev/null @@ -1,25 +0,0 @@ -$(function() { - $('.tinymce_textarea').tinymce({ - theme: 'advanced', - plugins : "autolink,lists,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template", - - // Theme options - theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,fontselect,fontsizeselect", - theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,bullist,numlist,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,forecolor,backcolor", - theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,fullscreen", - theme_advanced_toolbar_location : "top", - theme_advanced_toolbar_align : "left", - theme_advanced_statusbar_location : "bottom", - theme_advanced_resizing : true, - - // Skin options - skin : "o2k7", - skin_variant : "silver", - - // Drop lists for link/image/media/template dialogs - template_external_list_url : "js/template_list.js", - external_link_list_url : "js/link_list.js", - external_image_list_url : "js/image_list.js", - media_external_list_url : "js/media_list.js" - }); -}); \ No newline at end of file diff --git a/app/assets/javascripts/tinymce_orbit.js.erb b/app/assets/javascripts/tinymce_orbit.js.erb new file mode 100644 index 000000000..f12bfa3df --- /dev/null +++ b/app/assets/javascripts/tinymce_orbit.js.erb @@ -0,0 +1,90 @@ +function load_tinymce() { + $('.tinymce_textarea').tinymce({ + + // General options + theme: 'advanced', + file_browser_callback : 'myFileBrowser', + plugins : "autolink,lists,pagebreak,style,layer,table,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave", + + // Theme options + theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,fontselect,fontsizeselect", + theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,bullist,numlist,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,forecolor,backcolor", + theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,fullscreen", + theme_advanced_toolbar_location : "top", + theme_advanced_toolbar_align : "left", + theme_advanced_statusbar_location : "bottom", + theme_advanced_resizing : true, + + // Skin options + skin : "o2k7", + skin_variant : "silver", + + // Drop lists for link/image/media/template dialogs + template_external_list_url : "js/template_list.js", + // external_link_list_url : "js/link_list.js", + // external_image_list_url : "js/image_list.js", + // media_external_list_url : "js/media_list.js" + + // Style formats + style_formats : [ + {title : 'Bold text', inline : 'b'}, + {title : 'Red text', inline : 'span', styles : {color : '#ff0000'}}, + {title : 'Red header', block : 'h1', styles : {color : '#ff0000'}}, + {title : 'Example 1', inline : 'span', classes : 'example1'}, + {title : 'Example 2', inline : 'span', classes : 'example2'}, + {title : 'Table styles'}, + {title : 'Table row 1', selector : 'tr', classes : 'tablerow1'} + ], + + // Replace values for the template plugin + template_replace_values : { + username : "Some User", + staffid : "991234" + } + }); +} +function myFileBrowser(field_name, url, type, win) { + var cmsURL = window.location.toString(); + cmsURL = cmsURL.split("/"); + cmsURL = "<%= Rails.application.routes.url_helpers.file_upload_admin_assets_path %>"; + console.log(cmsURL); + // script URL - use an absolute path! + if (cmsURL.indexOf("?") < 0) { + //add the type as the only query parameter + cmsURL = cmsURL + "?type=" + type; + } + else { + //add the type as an additional query parameter + // (PHP session ID is now included if there is one at all) + cmsURL = cmsURL + "&type=" + type; + } + + tinyMCE.activeEditor.windowManager.open({ + file : cmsURL, + title : 'File Browser', + width : 530, // Your dimensions may differ - toy around with them! + height : 350, + resizable : "no", + inline : "no", // This parameter only has an effect if you use the inlinepopups plugin! + close_previous : "no" + }, { + window : win, + input : field_name, + alt : "alt", + title : "title" + }); + return false; + } + function ajaxSave() { + var ed = tinyMCE.get('content'); + // Do you ajax call here, window.setTimeout fakes ajax call + ed.setProgressState(1); // Show progress + window.setTimeout(function() { + ed.setProgressState(0); // Hide progress + alert(ed.getContent()); + }, 3000); + } + +$(document).ready(function() { + load_tinymce(); +}); diff --git a/app/assets/stylesheets/admin/ad_banner_preview.css.erb b/app/assets/stylesheets/admin/ad_banner_preview.css.erb new file mode 100644 index 000000000..f46be689f --- /dev/null +++ b/app/assets/stylesheets/admin/ad_banner_preview.css.erb @@ -0,0 +1,4 @@ +.banner-preview { + width: auto; + left: 35%; +} \ No newline at end of file diff --git a/app/assets/stylesheets/banner_nav.css b/app/assets/stylesheets/banner_nav.css new file mode 100644 index 000000000..ed613576e --- /dev/null +++ b/app/assets/stylesheets/banner_nav.css @@ -0,0 +1,34 @@ +#banner_nav { + position: absolute; + z-index: 10; + bottom: 0; + margin-right: 5px; + right: 0; +} +#banner_nav>li { + float: left; + display: inline-block; + *display: inline; + +} +#banner_nav>li>a { + width: 10px; + height: 10px; + border-radius: 5px; + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + background-color: #FFFFFF; + opacity: .5; + filter: alpha(opacity = 50); + margin: 0 4px 10px; + text-indent: -9999px; + box-shadow: 0 0 5px rgba(0,0,0,.7); +} +#banner_nav>li>a:hover { + opacity: 1; + filter: alpha(opacity = 100); +} +#banner_nav>li.activeSlide>a { + opacity: 1; + filter: alpha(opacity = 100); +} diff --git a/app/assets/stylesheets/bootstrap-orbit.css b/app/assets/stylesheets/bootstrap-orbit.css index 34425d500..2ce9bc9cb 100644 --- a/app/assets/stylesheets/bootstrap-orbit.css +++ b/app/assets/stylesheets/bootstrap-orbit.css @@ -1,3 +1,5 @@ +/*bootstrap-orbit*/ + h1, h2, h3, h4, h5, h6 { font-weight:normal ; } @@ -110,6 +112,18 @@ table .span1-3 { .qe-block .form-horizontal .form-actions { text-align:right; } +.form-actions form { + margin-bottom: 0; +} +.form-actions form input { + margin-bottom: 0; +} .modal.fade { top: -50%; +} +.form-search button { + margin-bottom: 0; +} +.modal form { + margin-bottom: 0; } \ No newline at end of file diff --git a/app/assets/stylesheets/bootstrap.css.erb b/app/assets/stylesheets/bootstrap.css.erb index ee2ae5a48..62a0afe8e 100644 --- a/app/assets/stylesheets/bootstrap.css.erb +++ b/app/assets/stylesheets/bootstrap.css.erb @@ -1,3 +1,4 @@ +/*bootstrap*/ /*! * Bootstrap v2.0.0 * @@ -65,6 +66,7 @@ textarea { margin: 0; font-size: 100%; vertical-align: middle; + margin-bottom: 10px; } button, input { *overflow: visible; @@ -538,7 +540,7 @@ select, width: 210px; height: 18px; padding: 4px; - margin-bottom: 9px; + /*margin-bottom: 9px;*/ font-size: 13px; line-height: 18px; color: #555555; @@ -2664,18 +2666,23 @@ button.btn.small, input[type="submit"].btn.small { display: inline; } -.pagination .page{ +/*.pagination .page{ float: left; padding: 0 14px; line-height: 34px; text-decoration: none; border: 1px solid #ddd; border-left-width: 0; -} +}*/ .pagination a { float: left; + padding: 0 14px; + line-height: 34px; + text-decoration: none; + border: 1px solid #DDD; + border-left-width: 0; } -.pagination .next{ +/*.pagination .next{ float: left; padding: 0 14px; line-height: 34px; @@ -2690,12 +2697,15 @@ button.btn.small, input[type="submit"].btn.small { text-decoration: none; border: 1px solid #ddd; border-left-width: 0; -} +}*/ .pagination .current{ border-left-width: 1px; } +.pagination a { + background-color: #FFFFFF; +} .pagination a:hover, .pagination .active a { - background-color: #f5f5f5; + background-color: #e8e8e8; } .pagination .active a { color: #999999; diff --git a/app/assets/stylesheets/inc/permission-checkbox.css b/app/assets/stylesheets/inc/permission-checkbox.css.erb similarity index 84% rename from app/assets/stylesheets/inc/permission-checkbox.css rename to app/assets/stylesheets/inc/permission-checkbox.css.erb index 0adf72259..a5a50a178 100644 --- a/app/assets/stylesheets/inc/permission-checkbox.css +++ b/app/assets/stylesheets/inc/permission-checkbox.css.erb @@ -1,3 +1,5 @@ +/*permission-checkbox*/ + .checkblock { display: inline-block; float: left; @@ -8,37 +10,40 @@ } .checkbox{ padding: 5px; - margin: 5px 5px 10px; + margin: 10px; display: inline-block; color:#777777; text-shadow: 0 1px 0px rgba(255,255,255,.4); - border-radius: 3px; - -moz-border-radius: 3px; - -webkit-border-radius: 3px; height: 30px; position: relative; cursor: pointer; + border-style: solid; + border-width: 0px 1px 1px 0; + border-color: #dfdfdf; background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #ededed), color-stop(1, #dfdfdf) ); background:-moz-linear-gradient( center top, #ededed 5%, #dfdfdf 100% ); filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ededed', endColorstr='#dfdfdf'); -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); + border-radius: 3px; + -moz-border-radius: 3px; + -webkit-border-radius: 3px; } .checkbox .check-icon { display: none; position: absolute; - width: 26px; - height: 26px; - background: url('img/check.png') no-repeat left top; + width: 32px; + height: 32px; + background: url(<%= asset_path 'check.png' %>) no-repeat left top; right: -10px; - top: -5px; + top: 15px; } .checkbox .member-name { cursor: pointer; font-family: helvetica; font-size: 12px; - line-height: 30px; + line-height: 15px; padding: 0 10px 0 40px; color: #333333; display: inline-block; @@ -74,4 +79,7 @@ img.member-img { } .popover-content p { font-size: 12px; +} +.preview_trigger { + margin: 5px 10px 0 0; } \ No newline at end of file diff --git a/app/assets/stylesheets/isotope.css b/app/assets/stylesheets/isotope.css index 1d659c5ef..3e7bf739c 100644 --- a/app/assets/stylesheets/isotope.css +++ b/app/assets/stylesheets/isotope.css @@ -1,16 +1,11 @@ +/*isotope*/ + #isotope { margin-top: 2px; - background-color:#f4f4f4; } .isotope-item { z-index: 2; } - -.isotope-hidden.isotope-item { - pointer-events: none; - z-index: 1; -} - /**** Isotope CSS3 transitions ****/ .isotope, @@ -46,28 +41,27 @@ transition-duration: 0s; } .w-a { - width: 388px; + width: 398px; } .w-b { - width: 802px; + width: 812px; } .h-a { height: 315px; } .h-b { - height: 699px; + height: 703px; } .item { margin: 5px 0 15px 15px; } .item h3 { - margin: 5px 0; + margin: 20px 0 5px; } .item h3 [class^="icons-"] { - margin: 3px 5px 0 3px; + margin: 1px 5px 0 3px; } .item .detail { - padding: 5px; border: 1px solid rgba(0, 0, 0, 0.1); background-color: #FFFFFF; border-radius: 5px; @@ -75,12 +69,11 @@ -moz-border-radius: 5px; box-shadow: 0 3px 3px rgba(0, 0, 0, 0.1); -webkit-box-shadow: 0 3px 3px rgba(0, 0, 0, 0.1); - -moz-box-shadow: 0 3px 3px rgba(0, 0, 0, 0.1); } .item .detail .totle { font-size: 50px; - padding:10px 5px 20px 0; - margin: 0px; + padding:10px 5px 30px 0; + margin: 0; text-align: right; border-bottom:1px solid #d9d9d9; } @@ -90,20 +83,60 @@ color: #333; padding-left: 5px; text-align:left; + margin-bottom: -7px; +} +.item .detail .table { + margin-bottom: 0; } .item .detail .table th, .item .detail .table td { border-top: none; border-bottom: 1px solid #DDDDDD; } +.item .detail .table tr th { + background-color: #F2F2F2; + border-bottom: 1px solid #AAAAAA; +} .item .detail .table tr td:first-child { color: #666;; } -.item .detail .table tr td:last-child { +.item .detail .table tr td:last-child, .item .detail .table tr th:last-child { text-align:right; + padding-right: 15px; } .item .h-a .my_scroll .viewport { - height: 248px; + height: 210px; } .item .h-b .my_scroll .viewport { - height: 632px; + height: 594px; +} +.item .isotope-hidden.isotope-item { + pointer-events: none; + z-index: 1; +} +.item .my_scroll { + position: relative; +} +.item .my_scroll .scrollbar { + right: 3px; + top: 0; + position: absolute; + z-index: 10; +} +.item .my_scroll .track { + background-color: transparent; +} +.detail.noStatistics { + overflow: hidden; +} +.detail.noStatistics.h-a { + height: 315px; +} +.detail.noStatistics.h-a .my_scroll .viewport { + height: 280px; +} +.detail.noStatistics.h-b { + height: 704px; +} +.detail.noStatistics.h-b .my_scroll .viewport { + height: 670px; } \ No newline at end of file diff --git a/app/assets/stylesheets/list.css b/app/assets/stylesheets/list.css index 11f17a558..4d7c11b1f 100644 --- a/app/assets/stylesheets/list.css +++ b/app/assets/stylesheets/list.css @@ -1,151 +1,203 @@ -.list-remove { - position: relative; - top: 2px; - left: 2px; -} -.table th.select { - border-bottom:2px solid #0088CC; -} -.main-list { - margin-bottom: 0; -} -.main-wrap>.main-list thead th { - background-color: transparent; - border-right: medium none; -} -.main-list thead th:last-child { - border-right: none; -} -.main-list .span1 { - min-width: 32px; -} -.main-list .span7 { - min-width: 300px; -} -.main-list .nav-pills > li > a { - border-radius: 5px 5px 5px 5px; - margin: 2px; - padding:5px -} -.main-list tbody .quick-edit { - position:relative; - height:20px; -} -.main-list tbody .quick-edit .nav { - /*left: -55px;*/ - position: absolute; - /*top: -3px;*/ - width: 350px; - left: -8px; -} -.main-list td { - background-color: #FFFFFF; - border-bottom: 1px solid #DDDDDD; - border-top: medium none; -} -.main-list .nav { - margin-top: 0; - margin-bottom: 3px; -} -.main-list tr.with_action:hover .hide { - display:block !important; -} -.main-list .label-group { - position: relative; - height: 40px; -} -.main-list .label-td { - background-color: rgba(255, 255, 255, 1); - height: 40px; - overflow: hidden; - position: absolute; - width: 100%; - left: 0; - z-index: 1; -} -.main-list .label-td:hover { - height: auto; - text-align: center; - padding: 5px 5px 8px; - left: -6px; - top: -6px; - border: 1px solid rgba(0, 0, 0, 0.2); - box-shadow: 0px 5px 10px rgba(0,0,0,0.2); - -moz-box-shadow: 0px 5px 10px rgba(0,0,0,0.2); - -webkit-box-shadow: 0px 5px 10px rgba(0,0,0,0.2); - border-radius: 3px; - -webkit-border-radius: 3px; - -moz-border-radius: 3px; - z-index: 5; -} -.table-label { - background-color: #F2F2F2; - position: relative; -} -.table-label .main-list thead th { - background-color: #F2F2F2; - border-right: 1px solid #DDDDDD; - border-top: 1px solid #DDDDDD !important; -} -.route-group .route { - padding: 0; -} -.route-group .route .breadcrumb { - border-width: 0!important; -} -.qe-block td { - height:auto; - padding: 0; -} -.qe-block .table td, .qe-block .table th { - padding: 8px; -} -.qe-block .form-horizontal { - margin-bottom: 0; -} -.qe-block .form-actions { - margin-bottom: 0; -} -legend { - font-size: 15px; - line-height: 30px; - margin-bottom: 15px; - padding-bottom: 5px; -} -.upload-picture { - margin-left: 20px; -} -.subnav { - -moz-border-radius: 0; - -webkit-border-radius: 0; - border-radius: 0; - border-left: none; - border-right: none; - position: fixed; - top: 30px; - z-index: 50; -} -.subnav .nav > li:first-child > a, .subnav .nav > li:first-child > a:hover { - -moz-border-radius: 0; - -webkit-border-radius: 0; - border-radius: 0; -} -.dropdown-menu.tags { - max-width: none; -} -.dropdown-menu.tags .tags-cloud { - width: 300px; - padding:10px; -} -.dropdown-menu.tags .tags-cloud .active { - background-color: #0088CC; - color: #FFFFFF; -} -.dropdown-menu.tags .tags-cloud a { - display: inline-block; - margin-bottom: 3px; -} -.dropdown-menu.tags li:last-child a { - display: block; - text-align:center; +/*list*/ + +.table th.select { + border-bottom:2px solid #0088CC; +} +.main-list { + margin-bottom: 0; +} +.main-wrap>.main-list thead th { + background-color: transparent; + border-right: medium none; +} +.main-list thead th:last-child { + border-right: none; +} +.main-list .span1 { + min-width: 32px; +} +.main-list .span7 { + min-width: 300px; +} +.main-list .nav-pills > li > a { + border-radius: 5px 5px 5px 5px; + margin: 2px; + padding:5px; +} +.main-list tbody .quick-edit { + position:relative; + height:20px; +} +.main-list tbody .quick-edit .nav { + /*left: -55px;*/ + position: absolute; + /*top: -3px;*/ + width: 350px; + left: -8px; +} +.main-list tr:first-child td { + border-top: 1px solid #DDDDDD; +} +.main-list td { + background-color: #FFFFFF; + border-bottom: 1px solid #DDDDDD; + border-top: medium none; +} +.main-list .nav { + margin-top: 0; + margin-bottom: 3px; +} +.main-list tr.with_action:hover .hide { + display:block !important; +} +.main-list .label-group { + position: relative; + height: 40px; +} +.main-list .label-group .label { + margin-bottom: 1px; + display: inline-block; + padding: 0 3px; +} +.main-list .label-td { + background-color: rgba(255, 255, 255, 1); + height: 40px; + overflow: hidden; + position: absolute; + width: 100%; + left: 0; + z-index: 1; +} +.main-list .label-td:hover { + height: auto; + padding: 5px 5px 8px; + left: -40px; + top: -6px; + border: 1px solid rgba(0, 0, 0, 0.2); + box-shadow: 0px 5px 10px rgba(0,0,0,0.2); + -moz-box-shadow: 0px 5px 10px rgba(0,0,0,0.2); + -webkit-box-shadow: 0px 5px 10px rgba(0,0,0,0.2); + border-radius: 3px; + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + z-index: 5; + width: 200px; +} +.qe-edit-div .table-condensed { + background-color: #F2F2F2; +} +.table-label { + background-color: #F2F2F2; + position: relative; +} +.table-label .main-list thead th { + background-color: #F2F2F2; + border-right: 1px solid #DDDDDD; + border-top: 1px solid #DDDDDD !important; +} +.route-group .route { + padding: 0; +} +.route-group .route .breadcrumb { + border-width: 0!important; +} +.qe-block td { + height:auto; + padding: 0; + /*background-color: #dedede;*/ +} +.qe-block legend { + padding-left: 8px; + margin-bottom: 0; + padding-bottom: 0; +} +.qe-block .control-group { + margin-bottom: 0; +} +.qe-block .controls, .qe-block .control-label { + margin-top: 10px; + margin-bottom: 10px; +} +.qe-block .table td, .qe-block .table th { + padding: 8px; +} +.qe-block .form-horizontal { + margin-bottom: 0; +} +.qe-block .form-actions { + margin-bottom: 0; +} +legend { + font-size: 15px; + line-height: 30px; + margin-bottom: 15px; + padding-bottom: 5px; +} +.subnav { + -moz-border-radius: 0; + -webkit-border-radius: 0; + border-radius: 0; + border-left: none; + border-right: none; + position: fixed; + top: 30px; + z-index: 50; +} +.subnav .nav > li:first-child > a, .subnav .nav > li:first-child > a:hover { + -moz-border-radius: 0; + -webkit-border-radius: 0; + border-radius: 0; +} +.dropdown-menu.tags { + max-width: none; +} +.dropdown-menu.tags .tags-cloud { + width: 300px; + padding:10px; +} +.dropdown-menu.tags .tags-cloud .active { + background-color: #0088CC; + color: #FFFFFF; +} +.dropdown-menu.tags .tags-cloud a { + display: inline-block; + margin-bottom: 3px; +} +.dropdown-menu.tags li:last-child a { + display: block; + text-align:center; +} +.sort-header th { + padding: 0 8px; + vertical-align: inherit; + position: relative; +} +.sort-header th a { + display: block; + padding: 10px 0; + white-space: nowrap; +} +.sort-header th a:hover { + text-decoration: none; +} +.list-remove { + position: absolute; + top: 0; + padding-top: 9px !important; + left: 25px; +} +.form-fixed { + position: fixed; + margin: 0; + padding: 10px; + bottom: 0; + z-index: 2; +} +.form-fixed .btn { + margin-top: 4px; +} +.paginationFixed { +} +.paginationFixed .pagination { + margin-top: 0 !important; } \ No newline at end of file diff --git a/app/assets/stylesheets/message.css b/app/assets/stylesheets/message.css index ad67f31a7..7206bd727 100644 --- a/app/assets/stylesheets/message.css +++ b/app/assets/stylesheets/message.css @@ -1,5 +1,7 @@ +/*message*/ + .error{ - color:red; + color: #B94A48; } .notice, .message{ diff --git a/app/assets/stylesheets/new_admin.css.erb b/app/assets/stylesheets/new_admin.css.erb index d81761bcf..995421010 100644 --- a/app/assets/stylesheets/new_admin.css.erb +++ b/app/assets/stylesheets/new_admin.css.erb @@ -6,10 +6,10 @@ *= require_self *= require message *= require bootstrap + *= require style *= require bootstrap-orbit *= require list - *= require widget - *= require style + *= require widgets *= require scroll_style *= require isotope -*/ \ No newline at end of file +*/ diff --git a/app/assets/stylesheets/orbitTimeline.css b/app/assets/stylesheets/orbitTimeline.css index feb007a69..2718b69db 100644 --- a/app/assets/stylesheets/orbitTimeline.css +++ b/app/assets/stylesheets/orbitTimeline.css @@ -1,5 +1,4 @@ .t_scale{ - min-width:2000px; height:516px; bottom:0; } diff --git a/app/assets/stylesheets/reset.css.erb b/app/assets/stylesheets/reset.css.erb index 5c0a9cd57..f0a027a30 100644 --- a/app/assets/stylesheets/reset.css.erb +++ b/app/assets/stylesheets/reset.css.erb @@ -1,3 +1,6 @@ +/*reset*/ + + html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video { -webkit-text-size-adjust:none; } diff --git a/app/assets/stylesheets/scroll_style.css b/app/assets/stylesheets/scroll_style.css index 2f79f62bf..849fbc13e 100644 --- a/app/assets/stylesheets/scroll_style.css +++ b/app/assets/stylesheets/scroll_style.css @@ -1,3 +1,5 @@ +/*scroll_style*/ + @charset "UTF-8"; /* CSS Document */ .my_scroll { diff --git a/app/assets/stylesheets/sidebar.css.erb b/app/assets/stylesheets/sidebar.css.erb index f5a5d572e..1a77e0e7b 100644 --- a/app/assets/stylesheets/sidebar.css.erb +++ b/app/assets/stylesheets/sidebar.css.erb @@ -1,15 +1,36 @@ +/*sidebar*/ -#back_sidebar { - background: url(<%= asset_path "75.png" %>) repeat scroll left top transparent; - box-shadow: 3px 0 4px #472A12; - border-right: 1px solid #121212; - height: 100%; - left: 0; - position: fixed; - top: 0; - width: 220px; +.nav-list { + padding: 0px 0px 100px 5px; } - +.nav-list li { + position: relative; +} +.nav-list ol { + margin-left: 20px; +} +.nav-list ol li { + padding: 5px 0; + list-style: none; +} +.nav-list ol li a { + font-size: 13px; + padding: 3px 0px; + display: block; +} +.nav-list>li>ol { + margin-left: 0; +} +.nav-list>li>.with_action { + padding-left: 0; +} +.nav-list>li>.with_action>.quick-edit { + margin: 0 0 0 3px !important; +} +.nav-list>li>.with_action>i { + display: none; +} +/* #back_sidebar h1 { background: url(<%= asset_path "h1_bg.png" %>) repeat-x scroll left top transparent; border-bottom: 1px solid #1B1B1B; @@ -91,4 +112,80 @@ } #sidebar .translations_setup { margin-top: 42px; +} + + +#main-sidebar{ + left:0; +} +#main-sidebar .list{ +} +#main-sidebar li{ + position:relative; +} +#main-sidebar li a{ + border-bottom: 1px solid #CCCCCC; + display: block; + padding: 10px 0 10px 10px; +} +#main-sidebar ul ul li a{ + padding: 10px 0 10px 20px; +}*/ +.with_action:hover .hide { + display: block; +} +#main-sidebar .quick-edit { + background: none repeat scroll 0 0 #FFFFFF; + border: 1px solid #DDDDDD; + border-radius: 5px 5px 5px 5px; + margin: 0 0 0 20px; + padding: 0; + z-index:1; + position: absolute; + left: -3px; + width: 70px; +} +#main-sidebar .quick-edit a { + display: block; + line-height: 22px; + border-bottom: medium none; + font-size:12px; + margin: 0; + padding: 3px 5px; +} +#main-sidebar .quick-edit a:first-child { + border-radius: 5px 5px 0px 0px; +} +#main-sidebar .quick-edit a:last-child { + border-radius: 0px 0px 5px 5px; +} +#main-sidebar .quick-edit a:hover { + background-color: #DDDDDD; +} +ol.nav>li>.icons-moves { + display: none; +} +.sortable i { + position: absolute; + left: 0px; + top: 6px; + margin-right: 0; + opacity: 0.3; + filter: alpha(opacity=30); +} +.sortable i:hover { + cursor:move; + opacity: 0.7; + filter: alpha(opacity=70); +} +.with_action { + padding-left: 20px; +} +.placeholder { + background-color: rgba(0,136,204,.6); + border-radius: 3px; +} +.ui-nestedSortable-error { + background: rgba(255,206,206,.6); + color: #8a1f11; } \ No newline at end of file diff --git a/app/assets/stylesheets/site_assets.css.erb b/app/assets/stylesheets/site_assets.css.erb index cd5e882d5..41c14933b 100644 --- a/app/assets/stylesheets/site_assets.css.erb +++ b/app/assets/stylesheets/site_assets.css.erb @@ -1,3 +1,5 @@ +/*site_assets*/ + .assets_setup{ padding:42px 0 0 0; } \ No newline at end of file diff --git a/app/assets/stylesheets/site_designs.css.erb b/app/assets/stylesheets/site_designs.css.erb index cf8442d0c..805468cc4 100644 --- a/app/assets/stylesheets/site_designs.css.erb +++ b/app/assets/stylesheets/site_designs.css.erb @@ -1,3 +1,5 @@ +/*site_designs*/ + .designs_setup{ padding:42px 0 0 0; } diff --git a/app/assets/stylesheets/site_editor.css.erb b/app/assets/stylesheets/site_editor.css.erb index 1e16ea3f4..e36d0b7bb 100644 --- a/app/assets/stylesheets/site_editor.css.erb +++ b/app/assets/stylesheets/site_editor.css.erb @@ -5,6 +5,10 @@ *= require reset *= require_self *= require message + *= require bootstrap + *= require style + *= require bootstrap-orbit + *= require scroll_style *= require site_items *= require sidebar */ \ No newline at end of file diff --git a/app/assets/stylesheets/site_items.css.erb b/app/assets/stylesheets/site_items.css.erb index 4e23bd4c3..6fcef6bdf 100644 --- a/app/assets/stylesheets/site_items.css.erb +++ b/app/assets/stylesheets/site_items.css.erb @@ -1,10 +1,12 @@ +/*site_items*/ + html, body{ height: 100%; margin: 0; padding: 0; } html{ - background: url(<%= asset_path "body.jpg" %>) no-repeat fixed 0 0 transparent; + background-size: cover; } @@ -172,8 +174,6 @@ body{ .main { background: none repeat scroll 0 0 #FFFFFF; height: 100%; - margin-left: 220px; - padding: 0 40px; position: relative; } .main_list { diff --git a/app/assets/stylesheets/style.css.erb b/app/assets/stylesheets/style.css.erb index 0440dcde9..4f28c2d9d 100644 --- a/app/assets/stylesheets/style.css.erb +++ b/app/assets/stylesheets/style.css.erb @@ -1,3 +1,5 @@ +/*style*/ + @import url(http://fonts.googleapis.com/css?family=Cuprum); @font-face{ font-family: 'WebSymbolsRegular'; @@ -9,7 +11,7 @@ } .login-logo { text-indent: -9999px; - background: url(<%= asset_path 'sign-in-logo.png' %>) no-repeat center 40px; + background: url(<%= asset_path 'sign-in-logo.png' %>) no-repeat center 80px; padding-top: 40px; height: 160px; } @@ -60,8 +62,8 @@ margin-right: -20px; } #orbit-bar .search-query { - padding: 4px 9px; - height: 12px; + padding: 7px 9px 5px; + height: 10px; margin-top: 3px; border: 1px solid #333333; font-size: 11px; @@ -117,7 +119,8 @@ background-position: -10px -10px; } #orbit-bar .nav > li > a.orbit-bar-desktop { - background-position: -106px -9px; + background-position: -73px -42px; + width: 48px; } #orbit-bar .nav > li > a.orbit-bar-member { background-position: -4px -37px; @@ -241,7 +244,7 @@ padding-right: 4px; border-right: 1px solid rgba(0,0,0,.2); position:fixed; - top: 32px; + top: 31px; z-index: 88; } #main-sidebar .nav { @@ -262,6 +265,10 @@ box-shadow: 0px 2px 1px rgba(0,0,0,0.1); -moz-box-shadow: 0px 2px 1px rgba(0,0,0,0.1); -webkit-box-shadow: 0px 2px 1px rgba(0,0,0,0.1); + display: none; +} +#main-sidebar .nav > li.active > .nav { + display: block; } #main-sidebar .nav > li > .nav > li > a { margin-left: 0; @@ -280,17 +287,18 @@ background-color: #FFF; margin-left:160px; padding-top: 32px; - padding-bottom: 18px; + /*padding-bottom: 18px;*/ position: relative; - min-height: 100%; + padding-bottom: 45px; + /*min-height: 100%;*/ } -#main-wrap > .form-actions { +/*#main-wrap > .form-actions { background-color: #FFF; text-align: center; padding: 17px 20px 0; margin: 0; border-top: none; -} +}*/ #main-wrap .subnav { height: auto; min-height: 36px; @@ -318,6 +326,9 @@ font-size: 12px; color: #999; } +.form-actions .btn { + margin-bottom: 0; +} #sub-wiget { clear: right; float: right; @@ -336,7 +347,7 @@ text-align: right; padding-left: 10px; padding-right: 10px; - margin-bottom: 0; + margin-bottom: -50px; clear: both; } #poststuff form { @@ -368,7 +379,7 @@ #post-body .editor { } #post-body-content { - margin-right: 320px; + /*margin-right: 320px;*/ padding: 8px 0 8px 6px; } .filter .accordion-heading > a:hover { @@ -434,6 +445,26 @@ .filters .in { /*border-bottom: 1px solid rgba(0,0,0,0.07)*/ } +#tags { +} +#tags .tag { + line-height: 32px; + padding: 0 10px; + background-color: #FFFFFF; + border-bottom: 1px solid #DDDDDD; + border-top: medium none; +} +#tags .tag form, #tags .tag form input { + margin:0; +} +#tags .tagitem { + display: inline-block; + float: left; +} +#tags .action { + display: inline-block; + float: right; +} .sign-in { width: 360px; margin: 0 auto 70px; @@ -540,12 +571,56 @@ padding: 5px; } .popover-content { - border-radius: 3px; + -webkit-border-radius: 0 0 3px 3px; + -moz-border-radius: 0 0 3px 3px; + border-radius: 0 0 3px 3px; padding: 5px; } .popover-title { display: none; } + +/*show link and file*/ +.linkAndFile { + clear: both; +} +.linkAndFile>div { + margin-top: 20px; +} +.linkAndFile [class^="icons-"] { + float: left; + margin-top: 10px; +} +.linkAndFile .showLink, .linkAndFile .showFile { + background-color: #ededed; + padding: 5px; + border-radius: 5px; + margin-left: 25px; +} +.linkAndFile .showLink a, .linkAndFile .showFile a { + display: inline-block; + margin: 5px 10px; +} +.linkAndFile>div>a:last-child { + margin-right: 5px +} +.news_paragraph p { + line-height: 20px; +} +.nav-tabs>li>.edit, .nav-tabs>li>.edit:hover { + background-color: #333; + color: #FFF; + padding-right: 12px; +} +.nav-tabs li .icons-pencil { + float: right; + margin-top: 8px; +} +.nav-tabs li a { + padding-right: 32px; +} + + /*icons*/ .the-icons i:after { content: attr(class); @@ -582,6 +657,76 @@ .text-green { color: #39b54a !important; } +.adbanner-setup { + margin-right: 10px; + margin-bottom: 30px !important; +} +.adbanner-list { + border-top: 1px solid #AAA; + margin-right: 10px; + padding-top: 10px; + position: relative; +} +.adbanner-list ul { + margin: 0px; +} +.adbanner-list ul li { + list-style: none; + margin-left: 0; + margin-right: 20px; +} +.adbanner-action { + margin-bottom: 20px; +} +.textarea-height-s { + resize: none; + max-height: 150px; +} +.textarea-height-m { + resize: none; + max-height: 250px; +} +.textarea-height-l { + resize: none; + max-height: 350px; +} +.textarea-height-xl { + resize: none; + max-height: 500px; +} +#banner [id^="slideshow-"] { + z-index: 2 !important; +} + +#back_main .editable { + position: relative; +} +#back_main .editable:after { + content: ''; + clear: both; + display: block; + visibility: hidden; + height: 0; +} + +#back_main .edit_link a { + position: absolute; + z-index: 10; + width: 100%; + height: 100%; + top: 0; + left: 0; + text-indent: -9999px; + background: url(<%= asset_path 'editicon.png' %>) no-repeat center center rgba(255,255,255,.8); + -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 1); + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 1); + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 1); +} + +#category_id, #module_app_id { + width: auto; +} + [class^="icons-"] { display: inline-block; width: 16px; @@ -664,15 +809,99 @@ .icons-unlock { background-position: -192px -32px; } +.icons-thumbtack { + background-position: -224px -32px; +} +.icons-pin { + background-position: -257px -32px; +} +.icons-shield { + background-position: -288px -32px; +} +.icons-key { + background-position: -320px -32px; +} +.icons-fire { + background-position: -352px -32px; +} +.icons-bulls-eye { + background-position: -384px -32px; +} +.icons-flash { + background-position: -416px -32px; +} .icons-time { background-position: -448px -32px; } +.icons-halo { + background-position: -480px -32px; +} +.icons-hourglass { + background-position: -513px -32px; +} +.icons-alarm-clock { + background-position: -545px -32px; +} +.icons-paper { + background-position: -577px -32px; +} .icons-banner { background-position: -608px -32px; } /*3*/ +.icons-phone { + background-position: 0px -64px; +} +.icons-mobile { + background-position: -32px -64px; +} +.icons-mail { + background-position: -64px -64px; +} +.icons-mail-open { + background-position: -96px -64px; +} +.icons-mail-read { + background-position: -128px -64px; +} .icons-content { - background-position: -160px -66px; + background-position: -160px -64px; +} +.icons-content-out { + background-position: -192px -64px; +} +.icons-content-in { + background-position: -224px -64px; +} +.icons-projector { + background-position: -256px -64px; +} +.icons-tape { + background-position: -288px -64px; +} +.icons-chat-a { + background-position: -320px -64px; +} +.icons-chat-b { + background-position: -352px -64px; +} +.icons-chat-c { + background-position: -384px -64px; +} +.icons-comment { + background-position: -416px -64px; +} +.icons-rss { + background-position: -448px -64px; +} +.icons-ship { + background-position: -480px -64px; +} +.icons-send { + background-position: -512px -64px; +} +.icons-bell { + background-position: -544px -64px; } .icons-announcement { background-position: -576px -64px; @@ -733,20 +962,110 @@ .icons-page-copy { background-position: -64px -128px; } -.icons- { - background-position: -0px -128px; +.icons-folder { + background-position: -96px -128px; +} +.icons-folder-open { + background-position: -128px -128px; +} +.icons-folder-lock { + background-position: -160px -128px; +} +.icons-folder-plus { + background-position: -192px -128px; +} +.icons-folder-minus { + background-position: -224px -128px; +} +.icons-page-plus { + background-position: -256px -128px; +} +.icons-page-minus { + background-position: -288px -128px; +} +.icons-page-edit { + background-position: -320px -128px; +} +.icons-page-download { + background-position: -352px -128px; } /*6*/ +.icons-house-w { + background-position: 0px -160px; +} +.icons-house-b { + background-position: -32px -160px; +} +.icons-signs { + background-position: -64px -160px; +} .icons-globe { background-position: -96px -160px; } +.icons-map { + background-position: -128px -160px; +} +.icons-markers { + background-position: -160px -160px; +} +.icons-barrier { + background-position: -192px -160px; +} +.icons-assist { + background-position: -224px -160px; +} +.icons-cones { + background-position: -256px -160px; +} +.icons-group { + background-position: -288px -160px; +} +.icons-cuble { + background-position: -320px -160px; +} .icons-structure { background-position: -352px -160px; } +.icons-layer { + background-position: -384px -160px; +} /*7*/ +.icons-shopcar-a { + background-position: 0px -192px; +} +.icons-shopcar-b { + background-position: -34px -192px; +} .icons-purchase { background-position: -64px -192px; } +.icons-shopcart { + background-position: -96px -192px; +} +.icons-van { + background-position: -128px -192px; +} +.icons-form { + background-position: -160px -192px; +} +.icons-gift { + background-position: -192px -192px; +} +.icons-credit-card { + background-position: -224px -192px; +} +.icons-cash { + background-position: -256px -192px; +} +.icons-assets { + background-position: -288px -192px; +} +.icons-computer { + background-position: -320px -192px; +} +.icons-library { + background-position: -352px -192px; +} /*8*/ .icons-dashboard { background-position: 0 -224px; @@ -776,21 +1095,90 @@ background-position: -256px -224px; } /*9*/ +.icons-book-cover { + background-position: 0px -256px; +} +.icons-book-make { + background-position: -32px -256px; +} +.icons-binder { + background-position: -64px -256px; +} +.icons-album { + background-position: -96px -256px; +} +.icons-camera { + background-position: -128px -256px; +} +.icons-video-camera { + background-position: -160px -256px; +} +.icons-pillar { + background-position: -192px -256px; +} +.icons-chart { + background-position: -224px -256px; +} .icons-picture { background-position: -256px -256px; } +.icons-pictures { + background-position: -288px -256px; +} +.icons-brief { + background-position: -320px -256px; +} +.icons-film { + background-position: -352px -256px; +} .icons-asset { background-position: -384px -256px; } -.icons-asset-upload { - background-position: -448px -256px; -} .icons-asset-download { background-position: -416px -256px; } +.icons-asset-upload { + background-position: -448px -256px; +} +.icons-music { + background-position: -480px -256px; +} +.icons-book-open-w { + background-position: -512px -256px; +} +.icons-book-open-b { + background-position: -544px -256px; +} +.icons-clapper-board { + background-position: -576px -256px; +} /*10*/ -.icons- { - background-position: -0px -288px; +.icons-date { + background-position: 0px -288px; +} +.icons-screen { + background-position: -32px -288px; +} +.icons-iphone { + background-position: -64px -288px; +} +.icons-ipad { + background-position: -96px -288px; +} +.icons-ipod { + background-position: -128px -288px; +} +.icons-battery-low { + background-position: -160px -288px; +} +.icons-battery-mid { + background-position: -192px -288px; +} +.icons-battery-full { + background-position: -224px -288px; +} +.icons-battery-charge { + background-position: -256px -288px; } /*11*/ .icons-pie { @@ -818,14 +1206,50 @@ background-position: -224px -320px; } /*12*/ +.icons-heart-w { + background-position: 0px -352px; +} +.icons-heart-b { + background-position: -32px -352px; +} +.icons-like { + background-position: -64px -352px; +} +.icons-hate { + background-position: -96px -352px; +} +.icons-medal { + background-position: -128px -352px; +} +.icons-warning { + background-position: -160px -352px; +} +.icons-check { + background-position: -192px -352px; +} +.icons-check-box-solid { + background-position: -224px -352px; +} +.icons-check-box-dot { + background-position: -256px -352px; +} .icons-check-2 { background-position: -288px -352px; } +.icons-check-circle-solid { + background-position: -320px -352px; +} +.icons-check-circle-dot { + background-position: -352px -352px; +} +.icons-check-circle-b { + background-position: -384px -352px; +} .icons-star-thin { background-position: -416px -352px; } -.icons- { - background-position: -0px -352px; +.icons-star { + background-position: -448px -352px; } /*13*/ .icons- { @@ -861,12 +1285,63 @@ .icons-plus { background-position: -288px -576px; } +/*20*/ .icons-power { background-position: -0px -608px; } -/*20*/ -.icons- { - background-position: -0px -608px; +.icons-output { + background-position: -32px -608px; +} +.icons-col-resize { + background-position: -64px -608px; +} +.icons-move { + background-position: -96px -608px; +} +.icons-size-out { + background-position: -128px -608px; +} +.icons-size-in { + background-position: -160px -608px; +} +.icons-slash { + background-position: -192px -608px; +} +.icons-level { + background-position: -224px -608px; +} +.icons-share { + background-position: -256px -608px; +} +.icons-share2 { + background-position: -288px -608px; +} +.icons-re { + background-position: -320px -608px; +} +.icons-insert { + background-position: -352px -608px; +} +.icons-insert2 { + background-position: -384px -608px; +} +.icons-download { + background-position: -416px -608px; +} +.icons-tag-rignt { + background-position: -448px -608px; +} +.icons-tag-top { + background-position: -480px -608px; +} +.icons-tag-bottom { + background-position: -512px -608px; +} +.icons-tag-left { + background-position: -544px -608px; +} +.icons-moves { + background-position: -576px -608px; } /*21*/ .icons- { diff --git a/app/assets/stylesheets/widget.css b/app/assets/stylesheets/widgets.css similarity index 90% rename from app/assets/stylesheets/widget.css rename to app/assets/stylesheets/widgets.css index f1c4d615c..86088fee1 100644 --- a/app/assets/stylesheets/widget.css +++ b/app/assets/stylesheets/widgets.css @@ -1,3 +1,6 @@ +/*Widget*/ + + .widget-size-300 { width:298px; } @@ -58,7 +61,7 @@ cursor: pointer; } .select-role { - display:none; + display:none; padding: 10px 0; } .file-upload { @@ -81,7 +84,7 @@ border-radius: 0 3px 3px 0; text-align: left; margin: 0; - width: 182px; + width: 193px; } .file-upload .upload { margin:0; @@ -92,12 +95,24 @@ opacity:.0; font-size: 60px; left: -595px/9; - filter: alpha(opacity: 0); + filter: alpha(opacity= 0); outline: none; } .file-upload .upload:focus { position:absolute; } +.file-upload .input-medium { + border-radius: 3px 3px 3px 3px !important; + width: 267px; + position: relative; + z-index: 5; + display: block; + clear: both; +} +.file-upload .control-label { + margin-top: 0; + margin-bottom: 5px; +} .upload-picture { margin-bottom: 5px; text-align: center; @@ -117,12 +132,6 @@ margin : 0px 0 5px; padding: 5px 10px; } -.file-upload .input-medium { - border-radius: 3px 3px 3px 3px !important; - width: 267px; - position: relative; - z-index: 5; -} #widget-link table { margin-bottom:0 } diff --git a/app/controllers/admin/ad_banners_controller.rb b/app/controllers/admin/ad_banners_controller.rb index 95ce7e7c3..f43c19e52 100644 --- a/app/controllers/admin/ad_banners_controller.rb +++ b/app/controllers/admin/ad_banners_controller.rb @@ -1,8 +1,14 @@ -class Admin::AdBannersController < ApplicationController +class Admin::AdBannersController < OrbitBackendController layout "new_admin" before_filter :authenticate_user! - before_filter :is_admin? + before_filter :for_app_manager,:except => [:index,:show,:update,:realtime_preview] + before_filter :for_app_sub_manager + def rename + @ad_banner = AdBanner.find(params[:id]) + @ad_banner.title = params[:body] + render :json => {:success =>@ad_banner.save!} + end def destroy @ad_banner = AdBanner.find(params[:id]) @ad_banner.destroy @@ -22,9 +28,14 @@ class Admin::AdBannersController < ApplicationController def create @ad_banner = AdBanner.new(params[:ad_banner]) - @ad_banner.save - redirect_to admin_ad_banners_url - + if @ad_banner.save + @active = @ad_banner + respond_to do |format| + format.js {render 'new_created_node'} + end + else + render 'create_error_msg' + end end def edit @@ -39,13 +50,14 @@ class Admin::AdBannersController < ApplicationController redirect_to admin_ad_banners_url end - def destroy_ad_image - + def realtime_preview + @ad_banner = AdBanner.find( params[:id] ).preview_clone + @ad_banner.update_attributes(params[:ad_banner])#.update_attributes(params[:ad_images]) end def index @ad_banners = AdBanner.all - @active = @ad_banners.first + @active = @ad_banners.first end end \ No newline at end of file diff --git a/app/controllers/admin/ad_images_controller.rb b/app/controllers/admin/ad_images_controller.rb index 3fb681dab..e3cef303a 100644 --- a/app/controllers/admin/ad_images_controller.rb +++ b/app/controllers/admin/ad_images_controller.rb @@ -1,8 +1,8 @@ -class Admin::AdImagesController < ApplicationController +class Admin::AdImagesController < OrbitBackendController layout 'new_admin' before_filter :authenticate_user! - before_filter :is_admin? - + before_filter :for_app_sub_manager + def edit @ad_banner = AdBanner.find params[:ad_banner_id] @ad_image = @ad_banner.ad_images.find params[:id] @@ -18,7 +18,10 @@ class Admin::AdImagesController < ApplicationController end def new - @ad_image =AdImage.new + ad_banner = AdBanner.find params[:ad_banner_id] + @ad_image =ad_banner.ad_images.build + @ad_image.post_date = Date.today + @ad_image.unpost_date = Date.today + 30 #render :action => 'new',:url=> {:ad_banner_id => params.has_key?(:ad_banner_id)? params[:ad_banner_id],nil} end diff --git a/app/controllers/admin/asset_categories_controller.rb b/app/controllers/admin/asset_categories_controller.rb new file mode 100644 index 000000000..9ce6bb482 --- /dev/null +++ b/app/controllers/admin/asset_categories_controller.rb @@ -0,0 +1,64 @@ +class Admin::AssetCategoriesController < OrbitBackendController + + def index + @asset_categories = AssetCategory.all + @asset_category = AssetCategory.new + @url = admin_asset_categories_path + + end + + def show + @asset_category = AssetCategory.find(params[:id]) + end + + def new + @asset_category = AssetCategory.new + end + + def edit + @asset_category = AssetCategory.find(params[:id]) + @url = admin_asset_categories_path(@asset_category) + end + + def create + @asset_category = AssetCategory.new(params[:asset_category]) + + respond_to do |format| + if @asset_category.save + format.html { redirect_to(admin_asset_categories_url, :notice => t('announcement.create_asset_category_success')) } + format.js + else + format.html { render :action => "new" } + format.js { render action: "new" } + end + end + end + + def update + @asset_category = AssetCategory.find(params[:id]) + + @url = admin_asset_categories_path(@asset_category) + + respond_to do |format| + if @asset_category.update_attributes(params[:asset_category]) + # format.html { redirect_to(panel_announcement_back_end_asset_category_url(@asset_category), :notice => t('asset_category.update_asset_category_success')) } + # format.html { redirect_to(panel_announcement_back_end_asset_categories_url, :notice => t('asset_category.update_asset_category_success')) } + # format.xml { head :ok } + format.js + else + format.html { render :action => "edit" } + format.js { render :action => "edit" } + end + end + end + + def destroy + @asset_category = AssetCategory.find(params[:id]) + @asset_category.destroy + + respond_to do |format| + format.html { redirect_to(admin_asset_categories_url) } + format.js + end + end +end diff --git a/app/controllers/admin/asset_tags_controller.rb b/app/controllers/admin/asset_tags_controller.rb new file mode 100644 index 000000000..ea3fc41ed --- /dev/null +++ b/app/controllers/admin/asset_tags_controller.rb @@ -0,0 +1,8 @@ +class Admin::AssetTagsController < Admin::TagsController + + def initialize + super + @app_title = 'asset' + end + +end \ No newline at end of file diff --git a/app/controllers/admin/assets_controller.rb b/app/controllers/admin/assets_controller.rb index 1591cf39a..58f4a746d 100644 --- a/app/controllers/admin/assets_controller.rb +++ b/app/controllers/admin/assets_controller.rb @@ -1,11 +1,7 @@ -class Admin::AssetsController < ApplicationController - - layout "admin" - before_filter :authenticate_user! - before_filter :is_admin? +class Admin::AssetsController < OrbitBackendController def index - @assets = Asset.all.entries + @assets = (params[:sort] || @filter) ? get_sorted_and_filtered("asset") : Asset.all.page(params[:page]).per(10) end def show @@ -14,6 +10,8 @@ class Admin::AssetsController < ApplicationController def new @asset = Asset.new + @asset_categories = AssetCategory.all + @tags = AssetTag.all respond_to do |format| format.html {} format.js { render 'js/show_pop_up', :locals => {:partial => 'admin/assets/new'} } @@ -22,6 +20,8 @@ class Admin::AssetsController < ApplicationController def edit @asset = Asset.find(params[:id]) + @asset_categories = AssetCategory.all + @tags = AssetTag.all respond_to do |format| format.html {} format.js { render 'js/show_pop_up', :locals => {:partial => 'admin/assets/edit'} } @@ -30,15 +30,29 @@ class Admin::AssetsController < ApplicationController def create @asset = Asset.new(params[:asset]) - if @asset.save + @asset.filename = @asset.title[I18n.locale] rescue nil + if @asset.filename && @asset.save respond_to do |format| - format.html { redirect_to admin_assets_url } - format.js { render 'js/remove_pop_up_and_reload_content', :locals => {:function => 'append', :id => 'asset_tbody', :value => @asset, :values => nil, :partial => 'admin/assets/asset', :locals => nil} } + format.js { + if params[:uploader] + render 'create' + else + render 'js/remove_pop_up_and_reload_content', :locals => {:function => 'replaceWith', :id => "asset_#{@asset.id}", :value => @asset, :values => nil, :partial => 'admin/assets/asset', :locals => nil} + end + } end else + flash[:error] = t(:create_fail) + @asset_categories = AssetCategory.all + @tags = AssetTag.all respond_to do |format| - format.html { render :action => :new } - format.js { render 'js/reload_pop_up', :locals => {:value => @asset, :values => nil, :partial => 'admin/assets/new', :locals => {:is_html => false}} } + format.js { + if params[:uploader] + render 'file_upload' + else + render 'js/reload_pop_up', :locals => {:value => @asset, :values => nil, :partial => 'admin/assets/new', :locals => {:is_html => false}} + end + } end end end @@ -51,6 +65,9 @@ class Admin::AssetsController < ApplicationController format.js { render 'js/remove_pop_up_and_reload_content', :locals => {:function => 'replaceWith', :id => "asset_#{@asset.id}", :value => @asset, :values => nil, :partial => 'admin/assets/asset', :locals => nil} } end else + flash[:error] = t(:update_fail) + @asset_categories = AssetCategory.all + @tags = AssetTag.all respond_to do |format| format.html { render :action => :edit } format.js { render 'js/reload_pop_up', :locals => {:value => @asset, :values => nil, :partial => 'admin/assets/edit', :locals => {:is_html => false}} } @@ -66,5 +83,24 @@ class Admin::AssetsController < ApplicationController format.js { render 'js/remove_element', :locals => {:id => "asset_#{@asset.id}"} } end end + + def delete + if params[:to_delete] + asset = Asset.any_in(:_id => params[:to_delete]).delete_all + end + redirect_to assets_url(:filter => params[:filter], :direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]) + end + + def file_upload + @asset = Asset.new + @asset_categories = AssetCategory.all + @tags = AssetTag.all + render :layout => false + end + + def file_select + @assets = Asset.all + render :layout => false + end end diff --git a/app/controllers/admin/dashboards_controller.rb b/app/controllers/admin/dashboards_controller.rb index 7b7613611..991f19af5 100644 --- a/app/controllers/admin/dashboards_controller.rb +++ b/app/controllers/admin/dashboards_controller.rb @@ -2,9 +2,52 @@ class Admin::DashboardsController < ApplicationController layout "new_admin" before_filter :authenticate_user! - before_filter :is_admin? +# before_filter :is_admin? def index + @module_app_contents, @module_app_contents_total = get_module_app_count('bulletin', 'news_bulletin', 'page_context', 'web_link') + @recent_updated = get_recently_updated('bulletin', 'news_bulletin', 'page_context', 'web_link') + @most_visited = get_most_visited('bulletin', 'news_bulletin', 'page_context') + end + + protected + + def get_module_app_count(*args) + a = {} + total = 0 + args.each do |module_app| + module_app_class = module_app.classify.constantize + count = module_app_class.count + a.merge!(module_app => count) + total += count + end + [a.sort {|a,b| b[1]<=>a[1]}, total] + end + + def get_recently_updated(*args) + a = {} + args.each do |module_app| + module_app_class = module_app.classify.constantize + objects = module_app_class.order_by(:updated_at, :desc).limit(10) + objects.each do |object| + a.merge!(object => object.updated_at) unless (object.archived rescue nil) + end + end + sorted_objects = a.sort {|a,b| b[1]<=>a[1]} + sorted_objects[0..9] + end + + def get_most_visited(*args) + a = {} + args.each do |module_app| + module_app_class = module_app.classify.constantize + objects = module_app_class.order_by(:view_count, :desc).limit(10) + objects.each do |object| + a.merge!(object => object.view_count) if object.view_count > 0 && (!object.archived rescue true) + end + end + sorted_objects = a.sort {|a,b| b[1]<=>a[1]} + sorted_objects[0..9] end end diff --git a/app/controllers/admin/designs_controller.rb b/app/controllers/admin/designs_controller.rb index 519b36a59..84f2b770a 100644 --- a/app/controllers/admin/designs_controller.rb +++ b/app/controllers/admin/designs_controller.rb @@ -1,11 +1,12 @@ -class Admin::DesignsController < ApplicationController +class Admin::DesignsController < OrbitBackendController require "net/http" require "uri" require 'zip/zip' layout "new_admin" before_filter :authenticate_user! - before_filter :is_admin? + before_filter :is_admin? + before_filter :for_admin_only def upload_package if !params[:design].nil? @@ -24,7 +25,7 @@ class Admin::DesignsController < ApplicationController end def index - @designs = Design.all.entries + @designs = params[:sort] ? get_sorted_and_filtered("designs") : Design.all end def new @@ -83,6 +84,13 @@ class Admin::DesignsController < ApplicationController render :action => 'new' end end + + def delete + if params[:to_delete] + designs = Design.any_in(:_id => params[:to_delete]).delete_all + end + redirect_to admin_designs_url(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]) + end protected diff --git a/app/controllers/admin/infos_controller.rb b/app/controllers/admin/infos_controller.rb index bc86b662e..21306c6e5 100644 --- a/app/controllers/admin/infos_controller.rb +++ b/app/controllers/admin/infos_controller.rb @@ -21,7 +21,6 @@ class Admin::InfosController < ApplicationController def edit @attribute = Info.find(params[:id]) - @i18n_variable = @attribute.i18n_variable render :template => 'admin/attributes/edit' end diff --git a/app/controllers/admin/items_controller.rb b/app/controllers/admin/items_controller.rb index 33bc0fd20..1ea406405 100644 --- a/app/controllers/admin/items_controller.rb +++ b/app/controllers/admin/items_controller.rb @@ -15,6 +15,12 @@ class Admin::ItemsController < ApplicationController @item = get_homepage end end + + def update_position + item = Item.find(params[:id]) + item.shift_to(params[:parent_id], params[:position]) + render :nothing => true + end protected diff --git a/app/controllers/admin/links_controller.rb b/app/controllers/admin/links_controller.rb index 533ff8293..c233c18f8 100644 --- a/app/controllers/admin/links_controller.rb +++ b/app/controllers/admin/links_controller.rb @@ -65,9 +65,11 @@ class Admin::LinksController < ApplicationController end def delete + @item = Link.find(params[:id]) + @item.destroy respond_to do |format| format.html {} - format.js { destroy } + format.js { @item = @item.parent } end end diff --git a/app/controllers/admin/module_apps_controller.rb b/app/controllers/admin/module_apps_controller.rb index 13075a422..1393bf324 100644 --- a/app/controllers/admin/module_apps_controller.rb +++ b/app/controllers/admin/module_apps_controller.rb @@ -2,7 +2,7 @@ class Admin::ModuleAppsController < ApplicationController before_filter :user_has_manager_privilege?, :only => [ :assign_manager, :remove_manager ] before_filter :user_has_sub_manager_privilege?, :only => [ :assign_sub_manager, :remove_sub_manager ] - layout "admin" + layout "new_admin" def index @module_apps = ModuleApp.all.entries @@ -11,12 +11,26 @@ class Admin::ModuleAppsController < ApplicationController def reload_frontend_pages @module_app = ModuleApp.find(params[:id]) - @categories = @module_app.key.eql?('announcement') ? BulletinCategory.all : nil + case @module_app.key + when 'announcement' + @categories = BulletinCategory.all + @tags = AnnouncementTag.all + when 'news' + @categories = NewsBulletinCategory.all + @tags = NewsTag.all + when 'web_resource' + @categories = WebLinkCategory.all + @tags = WebResourceTag.all + end respond_to do |format| format.js {} end end + def module_auth_proc + @module_app = ModuleApp.find(params[:id]) + end + def edit @module_app = ModuleApp.find(params[:id]) end diff --git a/app/controllers/admin/module_apps_new_interface_controller.rb b/app/controllers/admin/module_apps_new_interface_controller.rb new file mode 100644 index 000000000..d9989fab1 --- /dev/null +++ b/app/controllers/admin/module_apps_new_interface_controller.rb @@ -0,0 +1,67 @@ +class Admin::ModuleAppsNewInterfaceController < OrbitBackendController + before_filter :authenticate_user! + before_filter :is_admin? + include AdminHelper + + layout "new_admin" + + def setting + @sys_users = User.all(conditions: {admin: false}).includes(:avatar) + @module_app = ModuleApp.find(params[:module_app_id]) + @options_from_collection_for_select_bulletin_categorys = [@module_app].collect{|ma| [ma.title,ma.id] } + # if params.has_key? :category + # @bulletin_category = BulletinCategory.find params[:category][:id] + # else + # @bulletin_category = @bulletin_categorys.first + # end + @users_array = @module_app.managing_users rescue [] + + respond_to do |format| + format.html + format.js + end + end + + def update_setting + module_app = update_setting_by_params + if module_app.save! + flash[:notice] = t("admin.object_auth.update_done") + else + flash[:notice] = t("admin.object_auth.update_failed") + end + end + + def user_list + @module_app = ModuleApp.find params[:module_app][:id] + end + + protected + def update_setting_by_params + user_sat = [] + ma = ModuleApp.find params[:module_app][:id] + user_sat = User.find params[:users].keys if params.has_key? :users + users_to_new = user_sat - ma.managing_users + users_to_remove = ma.managing_users - user_sat + + users_to_new.each do |new_user| + ma.assign_manager(new_user,current_user) + end + + users_to_remove.each do |remove_user| + ma.remove_manager(remove_user) + end + ma + end + + def get_categorys(id = nil) + @bulletin_categorys = [] + if(is_manager? || is_admin?) + @bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.excludes('disabled' => true)) + elsif is_sub_manager? + @bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit_new') + end + end + + + +end \ No newline at end of file diff --git a/app/controllers/admin/object_auths_controller.rb b/app/controllers/admin/object_auths_controller.rb index e8779dc4c..ab343360d 100644 --- a/app/controllers/admin/object_auths_controller.rb +++ b/app/controllers/admin/object_auths_controller.rb @@ -1,6 +1,6 @@ class Admin::ObjectAuthsController < ApplicationController include OrbitCoreLib::PermissionUnility - layout "admin" + layout "new_admin" before_filter :force_order # before_filter :is_admin? ,:only => :index diff --git a/app/controllers/admin/object_auths_new_interface_controller.rb b/app/controllers/admin/object_auths_new_interface_controller.rb new file mode 100644 index 000000000..42e82b479 --- /dev/null +++ b/app/controllers/admin/object_auths_new_interface_controller.rb @@ -0,0 +1,69 @@ +class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController + include OrbitCoreLib::PermissionUnility + before_filter :force_order + + + def setting + @sys_users = User.all(conditions: {admin: false}).includes(:avatar) + @ob_auth = ObjectAuth.find params[:object_auth_id] + @options_from_collection_for_select_ob_auth = [@ob_auth].collect{|oa| [oa.auth_obj.pp_object,oa.id] } + @users_array = @ob_auth.privilege_users rescue [] + + respond_to do |format| + format.html + format.js + end + end + + def update_setting + ob_auth = update_setting_by_params + if ob_auth.save! + flash[:notice] = t("admin.object_auth.update_done") + else + flash[:notice] = t("admin.object_auth.update_failed") + end + end + + def user_list + @ob_auth = ObjectAuth.find params[:ob_auth][:id] + end + + protected + def update_setting_by_params + user_sat = [] + oa = ObjectAuth.find params[:ob_auth][:id] + user_sat += User.find params[:users].keys if params.has_key? :users + users_to_new = user_sat - oa.auth_users + users_to_remove = oa.auth_users - user_sat + + users_to_new.each do |new_user| + oa.add_user_to_privilege_list(new_user) + end + + users_to_remove.each do |remove_user| + oa.remove_user_from_privilege_list(remove_user) + end + oa + end + + # def get_categorys(id = nil) + # @bulletin_categorys = [] + # if(is_manager? || is_admin?) + # @bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.excludes('disabled' => true)) + # elsif is_sub_manager? + # @bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit_new') + # end + # end + + def force_order + authenticate_user! + check_if_user_can_do_object_auth + end + + def check_if_user_can_do_object_auth + unless check_permission(:manager) + render :nothing => true, :status => 403 + end + end + +end \ No newline at end of file diff --git a/app/controllers/admin/page_parts_controller.rb b/app/controllers/admin/page_parts_controller.rb index bb759403b..9ef2aa1b2 100644 --- a/app/controllers/admin/page_parts_controller.rb +++ b/app/controllers/admin/page_parts_controller.rb @@ -22,15 +22,20 @@ class Admin::PagePartsController < ApplicationController def edit @part = PagePart.find(params[:id]) - @module_apps = ModuleApp.all(:conditions => {:enable_frontend => true}) + @module_apps = ModuleApp.excludes(widgets: nil).where(enable_frontend: true).order_by(:title, :asc) @module_app = @part.module_app ? @part.module_app : @module_apps[0] @r_tag = @part.public_r_tag.blank? ? LIST[:public_r_tags][0] : @part.public_r_tag - @tag_objects = @r_tag.classify.constantize.all + @tag_objects = @r_tag.classify.constantize.all rescue nil case @module_app.key - when 'bulletin' + when 'announcement' @categories = BulletinCategory.all + @tags = AnnouncementTag.all + when 'news' + @categories = NewsBulletinCategory.all + @tags = NewsTag.all when 'web_resource' @categories = WebLinkCategory.all + @tags = WebResourceTag.all end end @@ -41,8 +46,8 @@ class Admin::PagePartsController < ApplicationController def update @part = PagePart.find(params[:id]) if @part.update_attributes(params[:page_part]) + set_children_sub_menu(@part) if @part.public_r_tag && @part.public_r_tag.eql?('sub_menu') flash.now[:notice] = t('admin.update_success_content') - @part.save respond_to do |format| format.html { redirect_to admin_page_url( @part.page ) @@ -67,12 +72,34 @@ class Admin::PagePartsController < ApplicationController case @module_app.key when 'announcement' @categories = BulletinCategory.all + @tags = AnnouncementTag.all + when 'news' + @categories = NewsBulletinCategory.all + @tags = NewsTag.all when 'web_resource' @categories = WebLinkCategory.all + @tags = WebResourceTag.all end respond_to do |format| format.js {} end end + + def reload_r_tag_options + @r_tag = (ModuleApp.find(params[:id]) rescue nil) || params[:id] + @tag_objects = @r_tag.classify.constantize.all rescue nil + respond_to do |format| + format.js {} + end + end + + protected + + def set_children_sub_menu(part) + part.page.children.each do |child| + child_part = child.page_parts.detect{ |x| x.name.eql?(part.name) } rescue nil + child_part.update_attributes(:kind => part.kind, :public_r_tag => part.public_r_tag, :public_r_tag_object_id => part.public_r_tag_object_id) rescue nil + end + end end diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/admin/pages_controller.rb index 411297ce9..5fc6cb77e 100644 --- a/app/controllers/admin/pages_controller.rb +++ b/app/controllers/admin/pages_controller.rb @@ -20,24 +20,38 @@ class Admin::PagesController < ApplicationController def new @item = Page.new @item.parent = Item.find(params[:parent_id]) rescue nil - @apps = ModuleApp.all + @apps = ModuleApp.excludes(app_pages: nil).entries @designs = Design.all.entries @design = Design.first end def edit @item = Page.find(params[:id]) - @apps = ModuleApp.all + @apps = ModuleApp.excludes(app_pages: nil).entries @designs = Design.all.entries @design = @item.design ? @item.design : @designs.first @app_frontend_urls = @item.module_app.app_pages if @item.module_app - @categories = BulletinCategory.all if @item.module_app && @item.module_app.key.eql?('announcement') + if @item.module_app + case @item.module_app.key + when 'announcement' + @categories = BulletinCategory.all + @tags = AnnouncementTag.all + when 'news' + @categories = NewsBulletinCategory.all + @tags = NewsTag.all + when 'web_resource' + @categories = WebLinkCategory.all + @tags = WebResourceTag.all + end + else + @categories = nil + end end def create @item = Page.new(params[:page]) - if @item.module_app.key == 'page_content' + if @item.module_app && @item.module_app.key == 'page_content' @item.page_contexts.build(:create_user_id => current_user.id, :update_user_id => current_user.id ) end @@ -85,14 +99,16 @@ class Admin::PagesController < ApplicationController format.html { redirect_to admin_items_url( :parent_id => @item.parent_id ) } - format.js {} + format.js { redirect_to admin_items_url } end end def delete + @item = Page.find(params[:id]) + @item.destroy respond_to do |format| format.html {} - format.js { destroy } + format.js { @item = @item.parent } end end diff --git a/app/controllers/admin/roles_controller.rb b/app/controllers/admin/roles_controller.rb index 65c86f362..d02224a5f 100644 --- a/app/controllers/admin/roles_controller.rb +++ b/app/controllers/admin/roles_controller.rb @@ -21,7 +21,6 @@ class Admin::RolesController < ApplicationController def edit @attribute = Role.find(params[:id]) - @i18n_variable = @attribute.i18n_variable render :template => 'admin/attributes/edit' end diff --git a/app/controllers/admin/sites_controller.rb b/app/controllers/admin/sites_controller.rb index 9475e7084..1a19aebd9 100644 --- a/app/controllers/admin/sites_controller.rb +++ b/app/controllers/admin/sites_controller.rb @@ -1,16 +1,48 @@ class Admin::SitesController < ApplicationController - layout "admin" + layout "new_admin" before_filter :authenticate_user! before_filter :is_admin? + before_filter :get_site - def index - @site = Site.first - redirect_to :action => :new unless @site + # def index + # @site = Site.first + # # redirect_to :action => :new unless @site + # end + + # def new + # @site = Site.new + # end + + def update + @site.update_attributes(params[:site]) + redirect_to :back end - - def new - @site = Site.new + + def site_info + + end + + def system_info + + end + + def language + + end + + def mail_setting + + end + + def ui_theme + + end + + private + + def get_site + @site ||= Site.first end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index fb82774ef..5fd9de5c9 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -8,6 +8,10 @@ class ApplicationController < ActionController::Base helper :all before_filter :set_locale, :set_site + def set_current_user + User.current = current_user + end + def front_end_available(module_app_title='') app_controller = ModuleApp.first(conditions: {:key => module_app_title} ) unless app_controller.enable_frontend? @@ -39,15 +43,65 @@ class ApplicationController < ActionController::Base @parent_item = Item.first(:conditions => { :id => BSON::ObjectId(params[:parent_id]) }) rescue nil end + def auth_failed_in_backend + #redirect_to admin_dashboards_url + redirect_to root_path + end + # Check if the current_user is admin def is_admin? - redirect_to root_url unless current_user.admin? + current_user.admin? ? true : auth_failed_in_backend + end + + def is_manager? + @module_app.managing_users.include?(current_user) || is_admin? + end + + def for_admin_only + if is_admin? + true + else + flash[:error] = t("admin.access.denied.not_admin") + auth_failed_in_backend + end + end + + def for_app_manager + if is_manager? + true + else + flash[:error] = t("admin.access.denied.app.not_manager") + auth_failed_in_backend + end + end + + def for_app_sub_manager + if (@module_app.sub_managing_users.include?(current_user) || is_manager?) + true + else + flash[:error] = t("admin.access.denied.app.not_sub_manager") + auth_failed_in_backend + end + end + + def for_app_user + if (@module_app.app_auth.auth_users.include?(current_user) || for_app_sub_manager ) + true + else + flash[:error] = t("admin.access.denied.app.not_authed_user") + auth_failed_in_backend + end + end + + def check_object_premission(obj,title) + flash[:error] = t("admin.access.denied.object") + auth_failed_in_backend unless (obj.get_object_auth_by_title(title).auth_users.include?(current_user) || is_manager? || is_admin? ) end # Render the page - def render_page(id = nil) + def render_page if @item - render :text => process_page(@item, id), :layout => 'page_layout' + render :text => parse_page_noko(@item), :layout => 'page_layout' else render :text => '404 Not Found' end @@ -78,8 +132,8 @@ class ApplicationController < ActionController::Base # set site if exist or create site @site = Site.first || Site.create({:valid_locales => [], :in_use_locales => []}) session[:site] = @site.id - @site_in_use_locales = @site.in_use_locales - @site_valid_locales = @site.valid_locales + @site_in_use_locales = site_locales_default_head(@site.in_use_locales) + @site_valid_locales = site_locales_default_head(@site.valid_locales) end def set_current_item @@ -103,7 +157,7 @@ class ApplicationController < ActionController::Base end def get_homepage - Item.first(:conditions => {:parent_id => nil}) + Page.root end def layout_by_resource @@ -114,4 +168,14 @@ class ApplicationController < ActionController::Base end end + def site_locales_default_head(locales) + if locales[0].eql? I18n.locale.to_s + locales + else + a = Array.new(locales) + shift_out = a.delete(I18n.locale.to_s) + [shift_out] + a + end + end + end diff --git a/app/controllers/desktop_orbit_controller.rb b/app/controllers/desktop_orbit_controller.rb index 0aaf3a6a5..29761bfb2 100644 --- a/app/controllers/desktop_orbit_controller.rb +++ b/app/controllers/desktop_orbit_controller.rb @@ -7,12 +7,43 @@ class DesktopOrbitController< ApplicationController def getevents @event = params["event"] @data = Array.new + @fromdate = params["from"] case @event when "papers" - @journals = current_user.journals - @journals.each do |journal| - @data << {"title"=> journal.title,"papers"=> journal.papers} + @data = current_user.papers.where(:created_at.gt => Date.new(Integer(@fromdate[0]),Integer(@fromdate[1])-1),:created_at.lt => Date.new(Integer(@fromdate[0]),Integer(@fromdate[1])+1)).desc(:created_at) + end + render :json=>@data.to_json + end + + def eventajaxload + @limit = 15 + @fromdate = params["from"] + @fromdate[0] = Integer(@fromdate[0]) + @fromdate[1] = Integer(@fromdate[1]) + @totalpapers = 0 + @lastpaper = current_user.papers.all.desc(:created_at).last + @date = Date.new(Integer(@lastpaper.created_at.strftime("%Y")),Integer(@lastpaper.created_at.strftime("%m"))) + @data = Array.new + while @totalpapers < @limit + if Date.new(@date.year,@date.month-1) > Date.new(@fromdate[0],@fromdate[1]) + break end + if(@fromdate[1] == 12) + @papers = current_user.papers.where(:created_at.gt => Date.new(@fromdate[0],@fromdate[1]),:created_at.lt => Date.new(@fromdate[0]+1,1)).desc(:created_at) + else + @papers = current_user.papers.where(:created_at.gt => Date.new(@fromdate[0],@fromdate[1]),:created_at.lt => Date.new(@fromdate[0],@fromdate[1]+1)).desc(:created_at) + end + if(@papers.length > 0) + @data << {"papers" => @papers} + end + @totalpapers = @totalpapers + @papers.length + + @fromdate[1] = @fromdate[1]-1 + if(@fromdate[1] == 0) + @fromdate[1] = 12 + @fromdate[0] = @fromdate[0] - 1 + end + end render :json=>@data.to_json end diff --git a/app/controllers/desktop_publications_controller.rb b/app/controllers/desktop_publications_controller.rb index 7e3b3feb1..f09520a2d 100644 --- a/app/controllers/desktop_publications_controller.rb +++ b/app/controllers/desktop_publications_controller.rb @@ -1,50 +1,61 @@ -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_add - render "desktop/journal_pages/add", :layout => false - end - - def books - render "desktop/books", :layout => false - end - - def books_list - render "desktop/books/list", :layout => false - end - - def books_add - render "desktop/books/add", :layout => false - end - - def create_journal - Journal.create(user_id: current_user.id, title: "Google") - b = Array.new - b << {"success"=>"true"} - render :json=>b.to_json - end - - def getjournals - @journals = current_user.journals - data = Array.new - @journals.each do |journal| - @papers = journal.papers.all - data << {"title" => journal.title, "papers" => @papers} - end - render :json=>data.to_json - end - - def delete_journal - @journals = Journal.find("") - @journals.delete - b = Array.new - b << {"success"=>"true"} - render :json=>b.to_json - end -end +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_add + render "desktop/journal_pages/add", :layout => false + end + + def books + render "desktop/books", :layout => false + end + + def books_list + render "desktop/books/list", :layout => false + end + + def books_add + render "desktop/books/add", :layout => false + end + + def create_journal + Journal.create(user_id: current_user.id, title: "Ice Cream Sandwich") + b = Array.new + b << {"success"=>"true"} + render :json=>b.to_json + end + + def getjournals + @journals = current_user.journals + data = Array.new + @journals.each do |journal| + @papers = journal.papers.all + data << {"title" => journal.title, "papers" => @papers} + end + render :json=>data.to_json + end + + def delete_journal + @journals = Journal.find("") + @journals.delete + b = Array.new + b << {"success"=>"true"} + render :json=>b.to_json + end + + def update_journal + @journal = Journal.find("4ff2d6ebbd98eb02b9000017") + @papers = @journal.papers + @papers.each do |paper| + paper.update_attributes(:user_id => current_user.id) + end + b = Array.new + b << {"success"=>"true"} + render :json=>b.to_json + end +end diff --git a/app/controllers/orbit_backend_controller.rb b/app/controllers/orbit_backend_controller.rb index fe37db82f..28f99fa20 100644 --- a/app/controllers/orbit_backend_controller.rb +++ b/app/controllers/orbit_backend_controller.rb @@ -1,6 +1,8 @@ class OrbitBackendController< ApplicationController before_filter :force_order,:except => [:public] before_filter :setup_vars + before_filter :set_current_user + # before_filter {|c| c.front_end_available(@app_title)} # before_filter :check_user_can_use include OrbitCoreLib::PermissionUnility @@ -10,9 +12,11 @@ class OrbitBackendController< ApplicationController def setup_vars @app_title = request.fullpath.split('/')[2] + @app_title = request.fullpath.split('/')[1] if(@app_title == "back_end") + @app_title.gsub!(/[?].*/,'') @module_app = ModuleApp.first(conditions: {:key => @app_title} ) end - + private def force_order @@ -22,8 +26,164 @@ class OrbitBackendController< ApplicationController def check_user_can_use unless check_permission - redirect_to polymorphic_path(['panel',@app_title,'back_end','public']) + #redirect_to polymorphic_path(['panel',@app_title,'back_end','public']) + redirect_to root_url end end + + def get_sorted_and_filtered(object_class, query=nil) + objects = get_objects(object_class, query) + object_class = object_class.classify.constantize + if !params[:sort].blank? + options = params[:sort_options] + options = [options] if !options.class.eql?(Array) + options.each do |option| + if object_class.fields.include?(option) + case object_class.fields[option].type.to_s + when 'BigDecimal', 'Boolean', 'Date', 'DateTime', 'Float', 'Integer', 'String', 'Symbol', 'Time' + (objects = objects.order_by(option, params[:direction])) rescue nil + when 'Object' + objects = get_objects_from_referenced_objects(object_class.fields[option].options[:class_name].constantize, objects, option) + end + elsif object_class.relations.include?(option) + case object_class.relations[option].macro + when :references_one + a = Array.new + objects.each { |object| a << [get_string_value_from_object(object), object] } + sorted = params[:direction].eql?('asc') ? a.sort : a.sort.reverse! + objects = sorted.collect {|x| x[1] } + when :references_many, :references_and_referenced_in_many + objects = get_objects_from_self(object_class, objects, option) + when :referenced_in + objects = get_objects_from_referenced_objects(object_class.relations[option].class_name.constantize, objects, "#{option}_id") + end + end + end + end + if @filter + @filter.each do |key, value| + case key + when 'status' + a = Array.new + objects.each do |object| + value.each do |v| + a << object if object[v] + end + end + objects = a.uniq + when 'categories' + a = Array.new + objects.each do |object| + a << object if (value.include?(object.send("#{object.class.to_s.underscore}_category").id.to_s) rescue nil) + end + objects = a.uniq + when 'tags' + a = Array.new + objects.each do |object| + object.tags.each do |tag| + a << object if value.include?(tag.id.to_s) + end + end + objects = a.uniq + end if value.size > 0 + end + end + Kaminari.paginate_array(filter_authorized_objects(objects)).page(params[:page]).per(10) + end + + def get_string_value_from_object(object) + s = object[I18n.locale] rescue nil + s = object.i18n_variable unless s rescue nil + s = object.name unless s rescue nil + s = object.title unless s rescue nil + if s + case s.class.to_s + when "String" + s.downcase rescue '' + when "I18nVariable" + s[I18n.locale].downcase rescue '' + else + nil + end + end + end + + def get_objects_from_referenced_objects(object_class, objects, option) + referer_ids = objects.distinct(option) + referenced_objects = object_class.find(referer_ids) rescue nil + if referenced_objects + a = Array.new + referenced_objects.each { |referer| a << [get_string_value_from_object(referer), referer.id] } + sorted = params[:direction].eql?('asc') ? a.sort : a.sort.reverse! + sorted_objects = sorted.collect {|x| objects.where(option => x[1]).entries } + sorted_objects.flatten! + sorted_objects.uniq! + get_with_nil(objects, option, sorted_objects) + else + objects + end + end + + def get_objects_from_self(object_class, objects, option) + referenced_class = object_class.relations[option].class_name.constantize + referenced_objects = referenced_class.all rescue nil + if referenced_objects + reverse_relation = nil + referenced_class.relations.each { |relation| reverse_relation = relation[1].name.to_s if relation[1].class_name.eql?(object_class.to_s) } + a = Array.new + referenced_objects.each { |referenced_object| a << [get_string_value_from_object(referenced_object), referenced_object] } + a.compact! + sorted = params[:direction].eql?('asc') ? a.sort : a.sort.reverse! + sorted_objects = Array.new + sorted.each {|x| sorted_objects << x[1].send(reverse_relation) } + sorted_objects.flatten! + sorted_objects.uniq! + get_with_nil(objects, option, sorted_objects) + else + objects + end + end + + def get_with_nil(objects, option, sorted_objects) + tmp = Array.new + objects.each { |object| tmp << [get_string_value_from_object(object), object] if (object.send(option).blank? || (object.send(option).size == 0 rescue nil)) } + sorted = params[:direction].eql?('asc') ? tmp.sort : tmp.sort.reverse! + sorted_tmp = sorted.collect {|a| a[1] } + a = params[:direction].eql?('asc') ? (sorted_tmp + sorted_objects) : (sorted_objects + sorted_tmp) + a.flatten + end + + + def get_viewable(object_class) + objects = get_objects(object_class).order_by(:created_at, :desc) + Kaminari.paginate_array(objects).page(params[:page]).per(10) + end + + def get_objects(object_class, query=nil) + object_class = object_class.classify.constantize + if query + objects = object_class.all.where(query) + else + objects = object_class.all + end + objects + end + + def filter_authorized_objects(objects) + if(!is_admin? || !is_manager?) + objects.delete_if{ |object| + if object.is_pending == true + if check_permission(:manager) + object.create_user_id != current_user.id + else + !object.send("#{object.class.to_s.underscore}_category").authed_users('fact_check').include?(current_user) rescue false + end + else + false + end + } + end + objects + end end \ No newline at end of file diff --git a/app/controllers/orbit_frontend_component_controller.rb b/app/controllers/orbit_frontend_component_controller.rb index 185dbce67..09621e5f4 100644 --- a/app/controllers/orbit_frontend_component_controller.rb +++ b/app/controllers/orbit_frontend_component_controller.rb @@ -1,7 +1,7 @@ class OrbitFrontendComponentController< ApplicationController before_filter :setup_vars before_filter {|c| c.front_end_available(@app_title)} - layout :false + layout "module_widget" def setup_vars @app_title = request.fullpath.split('/')[2] diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 4860ea2e8..8758563e8 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -7,6 +7,7 @@ class PagesController < ApplicationController def index @item = Page.find_by_name('home') if @item + impressionist(@item) render_page else render :text => 'You need a home page' @@ -14,33 +15,38 @@ class PagesController < ApplicationController end def show - #begin - @item = Item.first(:conditions => {:full_name => params[:page_name]}) - if @item && @item.is_published - case @item._type - when 'Page' - render_page(params[:id]) - when 'Link' - redirect_to "http://#{@item[:url]}" - end - else - render :file => "#{Rails.root}/public/404.html", :status => :not_found - end + #begin + @item = Item.first(:conditions => {:path => params[:page_name]}) + if @item && @item.is_published && (@item.enabled_for.nil? ? true : @item.enabled_for.include?(I18n.locale.to_s)) + impressionist(@item) + case @item._type + when 'Page' + render_page + when 'Link' + redirect_to @item[:url] + end + else + render :file => "#{Rails.root}/public/404.html", :status => :not_found + end #rescue # render :file => "#{Rails.root}/public/404.html", :status => :not_found #end end def index_from_link - if params[:page] - redirect_to "/#{@item.full_name}?page=#{params[:page]}" - else - redirect_to "/#{@item.full_name}" - end + url = "/#{@item.path}" + options = '' + options << "?page_main=#{params[:page_main]}" unless params[:page_main].blank? + options << "#{options.blank? ? '?' : '&'}category_id=#{params[:category_id]}" unless params[:category_id].blank? + options << "#{options.blank? ? '?' : '&'}tag_id=#{params[:tag_id]}" unless params[:tag_id].blank? + redirect_to url + options end def show_from_link - redirect_to "/#{@item.full_name}?id=#{params[:id]}" + url = "/#{@item.path}?id=#{params[:id]}" + options = '' + options << "&preview=#{params[:preview]}" unless params[:preview].blank? + redirect_to url + options end def load_orbit_bar @@ -51,11 +57,7 @@ class PagesController < ApplicationController def get_item module_app = ModuleApp.first(:conditions => {:key => params[:app_name]}) - if params[:category_id] - @item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id]}) - else - @item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action]}) - end + @item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action]}) end end diff --git a/app/helpers/admin/ad_banner_helper.rb b/app/helpers/admin/ad_banner_helper.rb index eff12427c..ecba9b3b4 100644 --- a/app/helpers/admin/ad_banner_helper.rb +++ b/app/helpers/admin/ad_banner_helper.rb @@ -11,6 +11,21 @@ module Admin::AdBannerHelper printable_ad_images.shuffle! end - + def sub_manager?(ad_banner) + ad_banner.authed_users(:edit).include?(current_user) + end + + def show_ad_banner_permission_link(ad_banner) + type = 'edit' + oa = ad_banner.get_object_auth_by_title(type) + if oa.nil? + ad_banner.object_auths.new(title: type ).save + oa = ad_banner.get_object_auth_by_title(type) + end +# link_to t('announcement.bulletin.cate_auth'), edit_admin_object_auth_path(oa) + link_to t('admin.ad.cate_auth'),admin_object_auth_ob_auth_path(oa),:class => "btn btn-warning" + end + + end \ No newline at end of file diff --git a/app/helpers/admin/ad_images_helper.rb b/app/helpers/admin/ad_images_helper.rb index 1f2422fc0..b09bd2633 100644 --- a/app/helpers/admin/ad_images_helper.rb +++ b/app/helpers/admin/ad_images_helper.rb @@ -1,7 +1,3 @@ module Admin::AdImagesHelper - def active_when_default_locale_eq locale - locale.to_sym == I18n.default_locale ? 'active': '' - end - end diff --git a/app/helpers/admin/asset_helper.rb b/app/helpers/admin/asset_helper.rb new file mode 100644 index 000000000..818a23401 --- /dev/null +++ b/app/helpers/admin/asset_helper.rb @@ -0,0 +1,11 @@ +module Admin::AssetHelper + + def show_all_fields(asset, field) + a = [] + @site_valid_locales.each do |locale| + a << asset.send(field)[locale] rescue nil + end + a.join(' - ') + end + +end \ No newline at end of file diff --git a/app/helpers/admin/dashboard_helper.rb b/app/helpers/admin/dashboard_helper.rb new file mode 100644 index 000000000..dfe5763fb --- /dev/null +++ b/app/helpers/admin/dashboard_helper.rb @@ -0,0 +1,29 @@ +module Admin::DashboardHelper + + def get_link(title) + case title + when 'bulletin' + panel_announcement_front_end_bulletins_path + when 'news_bulletin' + panel_news_front_end_news_bulletins_path + when'page_context' + panel_page_content_front_end_page_contexts_path + when'web_link' + panel_web_resource_front_end_web_links_path + end + end + + def get_link_to_object(object) + case object._type.underscore + when 'bulletin' + panel_announcement_front_end_bulletin_path(object) + when 'news_bulletin' + panel_news_front_end_news_bulletin_path(object) + when'page_context' + "/#{object.page.path}" + when'web_link' + panel_web_resource_front_end_web_link_path(object) + end + end + +end \ No newline at end of file diff --git a/app/helpers/admin/item_helper.rb b/app/helpers/admin/item_helper.rb index d7a3455b7..78e911b92 100644 --- a/app/helpers/admin/item_helper.rb +++ b/app/helpers/admin/item_helper.rb @@ -8,31 +8,38 @@ module Admin::ItemHelper dest = admin_page_path(node) when 'Link' dest = admin_link_path(node) + no_nested = 'no-nest' end - ret << "" end ret.html_safe end def render_children(parent) - if children = parent.children + children = parent.children + if !parent.children.entries.blank? ret = '' - ret << "" + ret << '' ret + else + '' end end -end \ No newline at end of file +end diff --git a/app/helpers/admin/module_app_helper.rb b/app/helpers/admin/module_app_helper.rb index 0a636e9cd..3ac82364f 100644 --- a/app/helpers/admin/module_app_helper.rb +++ b/app/helpers/admin/module_app_helper.rb @@ -14,6 +14,7 @@ module Admin::ModuleAppHelper end def get_auth_by(manager_obj) - "-AuthBy: " +( manager_obj.rule_creator==current_user ? t('me') : manager_obj.rule_creator.name) + showing_name = manager_obj.rule_creator==current_user ? t('me') : manager_obj.rule_creator.name + t("admin.user_role.auth.auth_by",:user_display_name => showing_name) end end diff --git a/app/helpers/admin/page_content_helper.rb b/app/helpers/admin/page_content_helper.rb new file mode 100644 index 000000000..9f2b22e0a --- /dev/null +++ b/app/helpers/admin/page_content_helper.rb @@ -0,0 +1,18 @@ +module Admin::PageContentHelper +include ActionView::Helpers::UrlHelper + + + def show_page_context_edit_auth_link(page_context) + type = 'Edit' +# debugger +# a=1 + oa = page_context.get_object_auth_by_title(type) + if oa.nil? + page_context.object_auths.new(title: type ).save rescue + oa = page_context.get_object_auth_by_title(type) + end +# link_to t('announcement.bulletin.cate_auth'), edit_admin_object_auth_path(oa) + link_to t('admin.page_context.ob_auth.edit'),admin_object_auth_ob_auth_path(oa) + end + +end \ No newline at end of file diff --git a/app/helpers/admin/web_link_helper.rb b/app/helpers/admin/web_link_helper.rb new file mode 100644 index 000000000..813bc48c5 --- /dev/null +++ b/app/helpers/admin/web_link_helper.rb @@ -0,0 +1,11 @@ +module Admin::WebLinkHelper + def show_web_link_permission_link(web_link) + type = 'edit' + oa = web_link.get_object_auth_by_title(type) + if oa.nil? + web_link.object_auths.new(title: type ).save + oa = web_link.get_object_auth_by_title(type) + end + link_to t('admin.web_link.cate_auth'),admin_object_auth_ob_auth_path(oa) + end +end \ No newline at end of file diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e45fa4d67..0ed5a1bd6 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,13 +1,7 @@ module ApplicationHelper FLASH_NOTICE_KEYS = [:error, :notice, :warning] - - def site_valid_locales_default_head - index = @site_valid_locales.rindex I18n.default_locale.to_s - shift_out = @site_valid_locales.shift(index) - @site_valid_locales += shift_out - end - + def colorize_in_use_locale(locale) @site_in_use_locales.include?(locale)? 'green' : 'red' end @@ -74,78 +68,99 @@ module ApplicationHelper end end + def active_for_ob_auths_object(object_class,field = :object_auth_id) + unless active_for_action("object_auths_new_interface","setting").nil? + ob_auth = ObjectAuth.find params[field] + ob_auth.obj_authable_type == object_class.to_s ? 'active' : nil + end + end + + def active_for_ob_auth(ob_auth_title,field = :object_auth_id) + unless active_for_action("module_apps_new_interface","setting").nil? + oa_auth = ObjectAuth.find params[field] + oa_auth.title == ob_auth_title ? 'active' : nil + end + end + + def active_for_app_auth(app_title ='', opt={:controller_name => 'module_apps_new_interface',:action_name=>'setting',:field => :module_app_id}) + unless active_for_action(opt[:controller_name],opt[:action_name]).nil? + app = ModuleApp.find params[opt[:field]] + app.title == app_title ? 'active' : nil + else + nil + end + end + def active_for_controllers(*controller_names) - controller_names.include?(controller.controller_name) ? 'active' : nil + (controller_names.include?(controller.controller_name) || controller_names.include?(request.fullpath)) ? 'active' : nil end def visible_for_controllers(*controller_names) - controller_names.include?(controller.controller_name) ? '' : 'hide' + (controller_names.include?(controller.controller_name) || controller_names.include?(request.fullpath)) ? '' : 'hide' end def active_for_action(controller_name, action_name) ((controller.controller_name.eql?(controller_name) || request.fullpath.eql?(controller_name)) && controller.action_name.eql?(action_name)) ? 'active' : nil end - - def sortable(column) - direction = (column == params[:sort] && params[:direction] == "asc") ? "desc" : "asc" - {:sort => column, :direction => direction} - end - - def is_sort_active?(name) - res = '' - res << ' select' if params[:sort].eql?(name) - res << ' active' if params[:sort].eql?(name) && params[:direction].eql?('asc') - res - end - - def is_sort?(name) - ' web-symbol' if params[:sort].eql?(name) - end - - def is_filter_active?(type, id) - ' active' if (@filter[type].include?(id.to_s) rescue nil) - end - - def process_page(page, id) - parse_page_noko(page, id) - end - + def page_metas(page) + tmp_meta = {} metas = '' - @site.page_metas.each do |meta| + @site.site_metas.each do |meta| name, content = meta.get_name_content - metas << "\n" + tmp_meta.merge!(name => content) end rescue nil - return metas + page.page_metas.each do |meta| + name, content = meta.get_name_content + tmp_meta.merge!(name => content) + end rescue nil + tmp_meta.each_pair{|name, content| + metas << "\n" + } if !tmp_meta.blank? + metas end def page_title(page) - "#{page.title ? page.title[I18n.locale] : page.i18n_variable[I18n.locale]}\n" + res = "" + page_title = page.title ? page.title[I18n.locale] : page.i18n_variable[I18n.locale] + if page.root? && @site.title + res << @site.title[I18n.locale] + elsif @site.title && @site.title_always_on + res << @site.title[I18n.locale] + ' - ' + page_title + else + res << page_title + end + res << "\n" end - def page_stylesheets(page) + def page_stylesheets(page, edit=nil) stylesheets = '' - stylesheets << "\n" - stylesheets << "\n" - stylesheets << "\n" + unless edit + stylesheets << "\n" + stylesheets << "\n" + stylesheets << "\n" + end stylesheets << "\n" if page.design.reset_css + stylesheets << "\n" stylesheets << "\n" if page.design.default_css theme = page.design.themes.detect{ |d| d.id == page.theme_id } stylesheets << "\n" if theme stylesheets end - def page_javascripts(page) + def page_javascripts(page, edit=nil) javascripts = '' - javascripts << "\n" + unless edit + javascripts << "\n" + javascripts << "\n" + javascripts << "\n" + javascripts << "\n" + javascripts << "\n" + javascripts << "\n" + javascripts << "\n" + end javascripts << "\n" javascripts << "\n" - javascripts << "\n" - javascripts << "\n" - javascripts << "\n" - javascripts << "\n" - javascripts << "\n" - javascripts << "\n" javascripts << "\n" page.design.javascripts.each do |js| # javascripts << "" @@ -153,4 +168,48 @@ module ApplicationHelper javascripts end + def active_when_current_locale_eq(locale) + locale.to_sym == I18n.locale ? 'active in': '' + end + + def at_least_module_manager + is_manager? || is_admin? + end + + def dislpay_view_count(object) + "#{t(:view_count)}: #{object.view_count}" + end + + def display_visitors(options={}) + Impression.where(options).and(:referrer.ne => nil).distinct(:session_hash).count + end + + def display_visitors_today + display_visitors(created_at: {'$gte' => Date.today.beginning_of_day, '$lte' => Date.today.end_of_day}) + end + + def display_visitors_this_week + display_visitors(created_at: {'$gte' => Date.today.beginning_of_week, '$lte' => Date.today.end_of_week}) + end + + def display_visitors_this_month + display_visitors(created_at: {'$gte' => Date.today.beginning_of_month, '$lte' => Date.today.end_of_month}) + end + + def display_visitors_this_year + display_visitors(created_at: {'$gte' => Date.today.beginning_of_year, '$lte' => Date.today.end_of_year}) + end + + def at_least_module_manager + is_manager? || is_admin? + end + + def display_date_time(object) + object.strftime("%Y-%m-%d %H:%M") + end + + def display_date(object) + object.strftime("%Y-%m-%d") + end + end diff --git a/app/helpers/orbit_backend_helper.rb b/app/helpers/orbit_backend_helper.rb new file mode 100644 index 000000000..5d47e414a --- /dev/null +++ b/app/helpers/orbit_backend_helper.rb @@ -0,0 +1,45 @@ +module OrbitBackendHelper + + def sortable(column) + direction = (column == params[:sort] && params[:direction] == "asc") ? "desc" : "asc" + {:sort => column, :direction => direction} + end + + def is_sort_active?(name) + res = '' + res << ' select' if params[:sort].eql?(name) + res << ' active' if params[:sort].eql?(name) && params[:direction].eql?('asc') + res + end + + def is_sort?(name) + ' web-symbol' if params[:sort].eql?(name) + end + + def is_filter_active?(type, id) + ' active' if (@filter[type].include?(id.to_s) rescue nil) + end + + def render_sort_bar(delete_all, *titles) + content_tag :table, :class => "table main-list" do + content_tag :thead do + content_tag :tr, :class => "sort-header" do + concat (content_tag :th, :class => "span1 strong" do + concat check_box_tag :check_all + concat link_to content_tag(:i, nil, :class => "icon-trash"), '#', :class => "list-remove" + end) if (delete_all && (is_admin? || (is_manager? rescue nil))) + titles.each do |title| + concat render_title(title[0], title[1], title[2], title[3]) + end + end + end + end + end + + def render_title(title, fields, span, translation) + content_tag :th, :class => "sort #{span} #{is_sort_active?(title)}" do + link_to (t(translation) + content_tag(:b, nil, :class => is_sort?(title))).html_safe, url_for({:filter => @filter}.merge(sortable(title).merge(:sort_options => fields))), :class => 'js_history' + end + end + +end \ No newline at end of file diff --git a/app/jobs/fetch_time.rb b/app/jobs/fetch_time.rb new file mode 100644 index 000000000..5fce3036c --- /dev/null +++ b/app/jobs/fetch_time.rb @@ -0,0 +1,15 @@ +# require 'open-uri' +# require 'nokogiri' +class FetchTime < Resque::Plugins::RestrictionJob + restrict :per_300 => 10 + + @queue = :low + + def self.perform() +# sleep 10 + doc = Nokogiri::HTML(open('http://www.timeanddate.com/worldclock/city.html?n=241')) + CronMail.time_check(doc.at('#ct').children.first.text).deliver + puts "Mail Sent" + true + end +end diff --git a/app/jobs/nccu_calendar.rb b/app/jobs/nccu_calendar.rb new file mode 100644 index 000000000..1848c6918 --- /dev/null +++ b/app/jobs/nccu_calendar.rb @@ -0,0 +1,12 @@ +class NccuCalendar + require 'open-uri' + @queue = :high + + def self.perform() + File.open(File.join(Rails.root, 'public/static', 'nccu_calendar.rss'),'w') do |file| + file << open('http://events.nccu.edu.tw/Feed').read + CronMail.time_check("NCCU Calendar synced").deliver + end + puts "NccuCalendar Synced" + end +end diff --git a/app/jobs/restart_server.rb b/app/jobs/restart_server.rb new file mode 100644 index 000000000..53167fea1 --- /dev/null +++ b/app/jobs/restart_server.rb @@ -0,0 +1,8 @@ +class RestartServer + @queue = :high + + def self.perform() + CronMail.time_check("Going to restarting Orbit").deliver + %x[touch #{Rails.root}/tmp/restart] + end +end diff --git a/app/jobs/sync_db.rb b/app/jobs/sync_db.rb new file mode 100644 index 000000000..4f47b8d07 --- /dev/null +++ b/app/jobs/sync_db.rb @@ -0,0 +1,16 @@ +class SyncDb + + @queue = :high + + def self.perform() + self.start_sync + end + + def self.start_sync + task = 'mid_site:sync' + args = [] + %x[rake #{task} --trace >> #{Rails.root}/log/rake.log] + User.all.each{|ur| ur.create_dept_cache} + puts "SyncDb Synced" + end +end diff --git a/app/mailer/cron_mail.rb b/app/mailer/cron_mail.rb new file mode 100644 index 000000000..bda1d0636 --- /dev/null +++ b/app/mailer/cron_mail.rb @@ -0,0 +1,33 @@ +class CronMail < ActionMailer::Base + default :from => "orbit_test@rulingcom.com" + + def get_settings + # @@smtp_settings = { + # :address => "smtp.gmail.com", + # :port => '587', + # :domain => "smtp.gmail.com", + # :authentication => "plain", + # :user_name => "redmine@rulingcom.com", + # :password => "rulingredmine", + # :tls => true, + # :enable_starttls_auto => true + # } + @@smtp_settings = { + :address => @site['mail_settings']['address'], + :port => @site['mail_settings']['port'], + :domain => @site['mail_settings']['domain'], + :authentication => @site['mail_settings']['authentication'], + :user_name => @site['mail_settings']['user_name'], + :password => @site['mail_settings']['password'], + :tls => @site['mail_settings']['tls'], + :enable_starttls_auto => @site['mail_settings']['enable_starttls_auto'] + } + end + + + def time_check(msg) + get_settings + #attachments["rails.png"] = File.read("#{Rails.root}/public/images/rails.png") + mail(:to => "Chris ", :subject => msg) + end +end \ No newline at end of file diff --git a/app/models/ad_banner.rb b/app/models/ad_banner.rb index 3e09280fa..18c6d4481 100644 --- a/app/models/ad_banner.rb +++ b/app/models/ad_banner.rb @@ -2,18 +2,42 @@ class AdBanner include Mongoid::Document include Mongoid::Timestamps include Mongoid::MultiParameterAttributes - + include OrbitCoreLib::ObjectAuthable + field :title - field :transition_sec,type: Integer + field :transition_msec,type: Integer field :ad_fx #TODO Design should explain + field :best_size,:default => '' before_save :save_or_destroy validates_uniqueness_of :title + validates :title , :length => { :minimum => 2 } has_many :ad_images , dependent: :delete FX_TYPES = ["blindX","blindY","blindZ","cover","curtainX","curtainY","fade","fadeZoom","growX","growY","scrollUp","scrollDown","scrollLeft","scrollRight","scrollHorz","scrollVert","shuffle","slideX","slideY","toss","turnUp","turnDown","turnLeft","turnRight","uncover","wipe","zoom"] - +attr_writer :transition_sec + AfterObjectAuthUrl = '/panel/page_content/back_end/page_contexts' + APP_NAME = 'ad_banners' + ObjectAuthTitlesOptions = %W{edit} + + def pp_object + title + end + + def transition_sec + self.transition_msec/1000 rescue nil + end + + def transition_sec=(sec) + self.transition_msec = sec.to_i*1000 + end + + def preview_clone + preview_banner = self.clone + preview_banner.ad_images = self.ad_images + preview_banner + end # def new_ad_images(*attrs) # debugger # a=1 diff --git a/app/models/ad_image.rb b/app/models/ad_image.rb index 3eb635112..9d7fe55b7 100644 --- a/app/models/ad_image.rb +++ b/app/models/ad_image.rb @@ -24,16 +24,15 @@ class AdImage # validates_numericality_of :weight, greater_than_or_equal_to: 1,less_than_or_equal_to: 10 # validates_format_of :out_link, with: /(http:\/\/.*|)/ ,:message => 'Need a valid URL' - # validates_presence_of :post_date,:message => 'Need a valid post date' attr_reader :parse_post_date,:parse_unpost_date def parse_post_date=(att) - self.post_date = (Date.parse att rescue nil) + self.post_date = (Date.parse att.gsub(/\s+/, "") rescue nil) end def parse_unpost_date=(att) - self.unpost_date = (Date.parse att rescue nil) + self.unpost_date = (Date.parse att.gsub(/\s+/, "") rescue nil) end def display? diff --git a/app/models/asset.rb b/app/models/asset.rb index c44e8be14..e20fcb9e7 100644 --- a/app/models/asset.rb +++ b/app/models/asset.rb @@ -3,11 +3,43 @@ class Asset include Mongoid::Document include Mongoid::Timestamps - mount_uploader :data, AssetUploader + mount_uploader :data, FileAssetUploader field :filename field :description + + has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy + has_one :description, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy - validates_presence_of :filename, :data + validates_presence_of :title, :data, :description + + belongs_to :asset_category + belongs_to :assetable, polymorphic: true + has_and_belongs_to_many :tags, :class_name => "AssetTag" + + before_save :set_key + + def title + @title ||= I18nVariable.first(:conditions => {:key => 'title', :language_value_id => self.id, :language_value_type => self.class}) rescue nil + end + + def description + @description ||= I18nVariable.first(:conditions => {:key => 'description', :language_value_id => self.id, :language_value_type => self.class}) rescue nil + end + + def sorted_tags + tags.order_by(I18n.locale, :asc) + end + + protected + + def set_key + if title && title.new_record? + title.key = 'title' + end + if description && description.new_record? + description.key = 'description' + end + end end diff --git a/app/models/meta.rb b/app/models/asset_category.rb similarity index 54% rename from app/models/meta.rb rename to app/models/asset_category.rb index dbeac167f..89bceaf7b 100644 --- a/app/models/meta.rb +++ b/app/models/asset_category.rb @@ -1,15 +1,16 @@ -class Meta - +class AssetCategory include Mongoid::Document include Mongoid::Timestamps - + field :key - field :value, :default => nil - + field :display + has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy - - def get_name_content - [self.key, self.value ? self.value : self.i18n_variable[I18n.locale]] + + has_many :assets + + def self.from_id(id) + AssetCategory.find(id) rescue nil end -end +end \ No newline at end of file diff --git a/app/models/asset_tag.rb b/app/models/asset_tag.rb new file mode 100644 index 000000000..344a8e2e1 --- /dev/null +++ b/app/models/asset_tag.rb @@ -0,0 +1,5 @@ +class AssetTag < Tag + + has_and_belongs_to_many :assets + +end \ No newline at end of file diff --git a/app/models/design/design.rb b/app/models/design/design.rb index 2a25dd110..58f95bd48 100644 --- a/app/models/design/design.rb +++ b/app/models/design/design.rb @@ -3,10 +3,10 @@ class Design include Mongoid::Timestamps include ParserLayout - field :title - field :author - field :intro - field :version + field :title, :type => String + field :author, :type => String + field :intro, :type => String + field :version, :type => String has_many :pages diff --git a/app/models/item.rb b/app/models/item.rb index 44c6762d6..8dd5c0b45 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -2,56 +2,65 @@ class Item include Mongoid::Document include Mongoid::Timestamps + include Mongoid::Tree + include Mongoid::Tree::Ordering - field :name, :index => true - field :full_name, :index => true - field :position, :type => Integer - field :is_published, :type => Boolean, :default => false, :index => true + field :name + field :path + field :is_published, :type => Boolean, :default => false + field :enabled_for, :type => Array, :default => nil + field :menu_enabled_for, :type => Array, :default => nil + + has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy validates_format_of :name, :with => /^[0-9a-zA-Z\-_]+$/ validates :name, :exclusion => { :in => LIST[:forbidden_item_names] } validates_uniqueness_of :name, :scope => :parent_id - validates_presence_of :name, :full_name, :position + validates_presence_of :name + validates_associated :parent, :children - belongs_to :parent, :class_name => "Item" - has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy - has_many :children, :class_name => "Item", :as => 'parent' + before_destroy :destroy_children + after_rearrange :rebuild_path - before_validation :setup_default_value def self.find_by_name(item_name) Item.first(:conditions => { :name => item_name, :is_published => true }) end - - # Get an array of ancestors - def ancestors - node, nodes = self, [] - nodes << node = node.parent while !node.parent.blank? rescue nil - nodes.reverse - end - - # Build the url from the array of ancestors - def url - urls = ancestors.map{ |a| a.name } << self.name - urls.join("/") + + def visible_children + objects = self.children + a = [] + if objects + objects.each do |object| + a << object if object.menu_enabled_for.nil? ? true : object.menu_enabled_for.include?(I18n.locale.to_s) + end + end + a end + + def shift_to(new_parent, position) + unless self.parent_id.to_s.eql?(new_parent) && self.position.eql?(position.to_i) + new_parent = Item.find(new_parent) + current_position_sibling = find_by_parent_and_position(new_parent, position.to_i) + if current_position_sibling + current_position_sibling.at_bottom? ? move_below(current_position_sibling) : move_above(current_position_sibling) + elsif self.parent != new_parent + self.parent = new_parent + save! + end + end + end protected - def setup_default_value - # Set the position value within the parent scope - if self.position.blank? - max_page = Item.where(:parent_id => self.parent_id).count - self.position = (max_page)? max_page + 1 : 1 - end - - # Build the full_name from the ancestors array - full_node = self.ancestors.map{ |a| a.name }.push( self.name ) - # Remove root node if not root - full_node.shift if full_node.size >= 2 - self.full_name = full_node.join("/") + def rebuild_path + self.path = (self.ancestors_and_self - [Item.root]).collect{|x| x.name unless x.root?}.join('/') end - + + def find_by_parent_and_position(parent, position) + parent.children.detect{|child| child.position == position} + end + # Enable the validation for parent_id def validates_presence_of_parent_id? true diff --git a/app/models/journal.rb b/app/models/journal.rb index 88497f612..b1a652841 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -11,7 +11,7 @@ class Journal before_create :initialize_paper def initialize_paper - for i in 0..5 + for i in 0..11 self.papers.build end end diff --git a/app/models/link.rb b/app/models/link.rb index 4301ead4b..ccd79c89c 100644 --- a/app/models/link.rb +++ b/app/models/link.rb @@ -2,10 +2,20 @@ class Link < Item field :url - validates_presence_of :url + validates :url, :presence => true, :format => /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix + + before_validation :add_http def link ApplicationController.helpers.link_to(self.name, self.url) end + + protected + + def add_http + unless self.url[/^http:\/\//] || self.url[/^https:\/\//] + self.url = 'http://' + self.url + end + end end diff --git a/app/models/meta/meta.rb b/app/models/meta/meta.rb index 411a4f0c5..cd713d83f 100644 --- a/app/models/meta/meta.rb +++ b/app/models/meta/meta.rb @@ -7,5 +7,13 @@ class Meta field :value, :default => nil has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy + + def get_name_content + [self.key, get_content] + end + + def get_content + self.value ? self.value : self.i18n_variable[I18n.locale] + end end diff --git a/app/models/object_auth.rb b/app/models/object_auth.rb index ae3fd7015..d5cc48de5 100644 --- a/app/models/object_auth.rb +++ b/app/models/object_auth.rb @@ -2,6 +2,7 @@ class ObjectAuth < PrototypeAuth include OrbitCoreLib::ObjectTokenUnility validates_uniqueness_of :title ,:scope => [:obj_authable_type,:obj_authable_id] #{ |c| } belongs_to :obj_authable, polymorphic: true + after_save :check_user_has_app_auth # > - Something.find_with_auth(query) # > - or Something.find(query).auth def auth_obj @@ -9,4 +10,15 @@ class ObjectAuth < PrototypeAuth class_obj.find self.obj_authable_id end + def check_user_has_app_auth + sub_managing_users = auth_obj.app_auth.sub_managing_users rescue [] + app_auth = auth_obj.app_auth + self.auth_users.each do |auth_user| + if !sub_managing_users.include? auth_user && !auth_user.admin? + app_auth.assign_sub_manager(auth_user,User.current) + app_auth.save! + end + end + end + end \ No newline at end of file diff --git a/app/models/page.rb b/app/models/page.rb index d98f3a4ef..970df4cfe 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -1,8 +1,14 @@ class Page < Item + include Impressionist::Impressionable + + is_impressionable :counter_cache => { :column_name => :view_count } field :content field :app_frontend_url field :theme_id, :type => BSON::ObjectId, :default => nil + field :category + field :tag + field :view_count, :type => Integer, :default => 0 belongs_to :design belongs_to :module_app @@ -15,10 +21,6 @@ class Page < Item before_save :create_parts, :set_key # embeds_many :custom_images, :class_name => 'Image', as: :design_image - - def is_home? - self.parent ? false : true - end def title @title ||= I18nVariable.first(:conditions => {:key => 'title', :language_value_id => self.id, :language_value_type => self.class}) rescue nil @@ -28,8 +30,20 @@ class Page < Item def create_parts page_design = self.design + parent = self.parent + menu_part = parent.page_parts.detect{|page_part| page_part.kind.eql?('public_r_tag') && page_part.public_r_tag.eql?('sub_menu') && page_part.public_r_tag_object_id.eql?(parent.id.to_s)} if parent page_design.layout.layout_parts.each do |layout_part| - self.page_parts.new(:name => layout_part.name) unless self.page_parts.detect{|page_part| page_part.name.eql?(layout_part.name)} + current_part = self.page_parts.detect{|page_part| page_part.name.eql?(layout_part.name)} + current_part = self.page_parts.build(:name => layout_part.name) unless current_part + if menu_part && current_part.name.eql?(menu_part.name) + if current_part.new_record? + current_part.kind = menu_part.kind + current_part.public_r_tag = menu_part.public_r_tag + current_part.public_r_tag_object_id = menu_part.public_r_tag_object_id + else + current_part.update_attributes(:kind => menu_part.kind, :public_r_tag => menu_part.public_r_tag, :public_r_tag_object_id => menu_part.public_r_tag_object_id) + end + end end end diff --git a/app/models/page_part.rb b/app/models/page_part.rb index 9fe91e861..52eafdf31 100644 --- a/app/models/page_part.rb +++ b/app/models/page_part.rb @@ -7,12 +7,31 @@ class PagePart field :content field :kind field :public_r_tag - field :public_r_tag_object_id, :type => BSON::ObjectId, :default => nil + field :public_r_tag_object_id, :default => nil + field :public_r_tag_option, :default => nil field :widget_path - has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy + has_one :i18n_variable, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy + has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy belongs_to :page belongs_to :module_app + before_save :set_key + + def i18n_variable + @i18n_variable ||= I18nVariable.first(:conditions => {:key => 'i18n_variable', :language_value_id => self.id, :language_value_type => self.class}) rescue nil + end + + def title + @title ||= I18nVariable.first(:conditions => {:key => 'title', :language_value_id => self.id, :language_value_type => self.class}) rescue nil + end + + protected + + def set_key + title.key = 'title' if title && (title.key.blank? rescue true) + i18n_variable.key = 'i18n_variable' if i18n_variable && (i18n_variable.key.blank? rescue true) + end + end \ No newline at end of file diff --git a/app/models/paper.rb b/app/models/paper.rb index b085aaa71..a92dde1f9 100644 --- a/app/models/paper.rb +++ b/app/models/paper.rb @@ -7,9 +7,9 @@ class Paper field :abstract, default: "The concept of microstructure engineering has gained increasingly attention with the goal to quantitatively link the operational parameters of an industrial process to the properties of its product. The key component of this concept is to accurately model the microstructure evolution along the processing path. Modelling of recrystallization in Cuinterconnects will be presented as an example of a conventional process model. Further, the potential of developing next generation process models will be discussed by using models across different length and time scale. The multi-scale modelling approach will be illustrated with a case study for phase transformation in Fe-Mn alloys." field :level, default: "SCI" field :coauthors, default: "Allen, Shelly, Eric, Manson, Chris, Clara, Anna, Albee, Vincent, Devin, Chunchi, Ika, Jaoshua, Ray, Matt, Lin, Spen" - field :created_at, type: Date, default: ->{12.months.ago} - + field :created_at, type: Date belongs_to :journal + end \ No newline at end of file diff --git a/app/models/site.rb b/app/models/site.rb index 8f367c0a2..55d6bfaf7 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -1,5 +1,7 @@ class Site + METAS = ['description', 'keywords'] + include Mongoid::Document include Mongoid::Timestamps @@ -9,12 +11,20 @@ class Site field :roaming_id field :private_key, :type => Binary field :public_key, :type => Binary + field :title_always_on, :type => Boolean, :default => false + + field :mail_settings, :type => Hash field :school field :department + has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy + has_one :footer, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy + has_one :sub_menu, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy has_many :site_metas, :autosave => true, :dependent => :destroy + before_save :set_key + def generate_keys private_key = OpenSSL::PKey::RSA.generate(2048) self.public_key = private_key.public_key.to_s @@ -26,9 +36,43 @@ class Site end def up_to_date? - p res = %x(git remote show origin) res = res.split('rails_3_1').pop.gsub('(', '').gsub(')','').strip rescue nil res.eql?('local out of date') ? false : true end + + def title + @title ||= I18nVariable.first(:conditions => {:key => 'title', :language_value_id => self.id, :language_value_type => self.class}) rescue nil + end + + def footer + @footer ||= I18nVariable.first(:conditions => {:key => 'footer', :language_value_id => self.id, :language_value_type => self.class}) rescue nil + end + + def sub_menu + @sub_menu ||= I18nVariable.first(:conditions => {:key => 'sub_menu', :language_value_id => self.id, :language_value_type => self.class}) rescue nil + end + + METAS.each do |meta| + define_method meta do + fetch_meta = self.site_metas.where(key: meta).limit(1) + fetch_meta.blank? ? nil : fetch_meta[0].i18n_variable + end + define_method "#{meta}=" do |values| + if a = self.send(meta) + a.update_attributes(values) + else + a = self.site_metas.build(key: meta) + a.build_i18n_variable(values) + end + end + end + + protected + + def set_key + title.key = 'title' if title && (title.key.blank? rescue true) + footer.key = 'footer' if footer && (footer.key.blank? rescue true) + sub_menu.key = 'sub_menu' if sub_menu && (sub_menu.key.blank? rescue true) + end end diff --git a/app/models/tag.rb b/app/models/tag.rb index f77f24c17..f621de6a5 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -3,6 +3,8 @@ class Tag include Mongoid::Document include Mongoid::Timestamps + field :key + belongs_to :module_app end diff --git a/app/models/user/user.rb b/app/models/user/user.rb index c33d64fc2..0f808a06f 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -2,7 +2,7 @@ class User include Mongoid::Document include Mongoid::Timestamps - + devise :database_authenticatable, :recoverable, :rememberable, :trackable, :registerable mount_uploader :avatar, AvatarUploader @@ -10,6 +10,10 @@ class User field :admin, :type => Boolean, :default => true field :active_role + # field :cache_dept + # has_one :cache_dept, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy + field :cache_dept,type: Hash + has_many :attribute_values, :autosave => true, :dependent => :destroy has_many :app_auths,as: :privilege_apps,:inverse_of => :privilege_lists has_many :blocked_apps, :inverse_of => :blocked_users, :class_name => "AppAuth" @@ -19,10 +23,35 @@ class User has_one :desktop, :autosave => true, :dependent => :destroy has_many :other_accounts, :autosave => true, :dependent => :destroy has_many :journals, :autosave => true, :dependent => :destroy - + has_many :papers, :autosave => true, :dependent => :destroy + belongs_to :role has_and_belongs_to_many :sub_roles accepts_nested_attributes_for :attribute_values, :allow_destroy => true + + def create_dept_cache + dept_hash = {} + + VALID_LOCALES.each do |loc| + locale = loc.to_sym + # debugger + # if(self.cache_dept.nil?) + # self.build_cache_dept key: "dept_cache_user_#{self.id}" + # end + dept_hash[locale] = sub_roles.collect{|sr| sr.i18n_variable[locale]}.join(',') + # self.cache_dept[locale] = sub_roles.collect{|sr| sr.i18n_variable[locale]}.join(',') + end + self.cache_dept = dept_hash + self.save! + end + + def self.current + Thread.current[:user] + end + + def self.current=(user) + Thread.current[:user] = user + end before_create :initialize_desktop diff --git a/app/uploaders/asset_uploader.rb b/app/uploaders/asset_uploader.rb index 1e07bca6a..7b5749c93 100644 --- a/app/uploaders/asset_uploader.rb +++ b/app/uploaders/asset_uploader.rb @@ -49,7 +49,7 @@ class AssetUploader < CarrierWave::Uploader::Base # Override the filename of the uploaded files: # def filename - # "something.jpg" if original_filename + # model.filename # end end diff --git a/app/uploaders/file_asset_uploader.rb b/app/uploaders/file_asset_uploader.rb new file mode 100644 index 000000000..1f60f00bc --- /dev/null +++ b/app/uploaders/file_asset_uploader.rb @@ -0,0 +1,55 @@ +# encoding: utf-8 + +class FileAssetUploader < CarrierWave::Uploader::Base + require 'mime/types' + + process :set_content_type + + def set_content_type(*args) + content_type = file.content_type == ('binary/octet-stream' || 'application/octet-stream') || file.content_type.blank? ? MIME::Types.type_for(original_filename).first.to_s : file.content_type + self.file.instance_variable_set(:@content_type, content_type) + end + + # Include RMagick or ImageScience support: + # include CarrierWave::RMagick + # include CarrierWave::ImageScience + + # Choose what kind of storage to use for this uploader: + # storage :file + # storage :s3 + + # Override the directory where uploaded files will be stored. + # This is a sensible default for uploaders that are meant to be mounted: + def store_dir + "assets/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" + end + + # Provide a default URL as a default if there hasn't been a file uploaded: + # def default_url + # "/images/fallback/" + [version_name, "default.png"].compact.join('_') + # end + + # Process files as they are uploaded: + # process :scale => [200, 300] + # + # def scale(width, height) + # # do something + # end + + # Create different versions of your uploaded files: + # version :thumb do + # process :scale => [50, 50] + # end + + # Add a white list of extensions which are allowed to be uploaded. + # For images you might use something like this: + # def extension_white_list + # %w(jpg jpeg gif png) + # end + + # Override the filename of the uploaded files: + # def filename + # model.filename.force_encoding("UTF-8") + # end + +end diff --git a/app/views/admin/ad_banners/_ad_banner_tab.html.erb b/app/views/admin/ad_banners/_ad_banner_tab.html.erb index d9b1b9025..d65a17e0a 100644 --- a/app/views/admin/ad_banners/_ad_banner_tab.html.erb +++ b/app/views/admin/ad_banners/_ad_banner_tab.html.erb @@ -1,19 +1,39 @@ - -
" id=<%= ad_banner_tab.title %>> -

尺寸:

- +
" id=<%= ad_banner_tab.title.dehumanize %>> +<% if at_least_module_manager || sub_manager?(ad_banner_tab)%> <%= form_for ad_banner_tab,:url=> admin_ad_banner_path(ad_banner_tab),:method => :put,:class=>"input-medium" do |f| -%> - <%= f.label :ad_fx, t('admin.ad.ab_fx') %> - <%= f.select :ad_fx ,AdBanner::FX_TYPES %> - <%= f.label :transition_sec, t('admin.ad.transition_sec') %> - <%= f.text_field :transition_sec,:placeholder=>"3秒請輸入3000",:class=> "span3" %> <%= t("admin.ad.trans_unit_sec") %> - <%= f.submit %> - <%= f.submit 'Cancel',:type=>'reset' %> -
- <%= render :partial => "ad_image_update", :collection => ad_banner_tab.ad_images,:as => :ad_image,:locals=>{:ad_banner => ad_banner_tab} %> - <%#= render :partial => 'new_add_banner_file', :object => ad_banner_tab.ad_images.build, :locals => { :field_name => "new_ad_images[]", :f => f, :classes => "r_destroy" } %> - <%= link_to 'Add AdImage',new_admin_ad_banner_ad_image_path(ad_banner_tab) %> -
+
+ + <%= f.label :ad_fx, t('admin.ad.ab_fx') %> + <%= f.select :ad_fx ,AdBanner::FX_TYPES %> + <%= f.label :transition_sec, t('admin.ad.transition_sec') %> + <%= f.text_field :transition_sec,:placeholder=>t('admin.ad.sec_place_holder'),:class=> "span3" %> <%= t("admin.ad.trans_unit_sec") %> + <%if at_least_module_manager%> + <%= f.label :best_size, t('admin.ad.best_size') %> + <%= f.text_field :best_size %> Ex: 500px x 300px + <% end -%> +
+ <%= f.submit t("admin.ad.update_banner"), :class => 'btn' %> + <%= f.submit t("cancel"),:type=>'reset', :class => 'btn' %> +
<% end -%> - <%= render :partial => 'preview_block',:locals=> {:ad_banner =>ad_banner_tab} %> +<% end -%> +

<%= t("admin.ad.picture_list")%>

+
+ <%if (at_least_module_manager || ad_banner_tab.cur_user_is_sub_manager_of(:edit) )%> + <%= content_tag :div ,:class=>'adbanner-action' do%> + <%= link_to t("admin.ad.new_image"),new_admin_ad_banner_ad_image_path(ad_banner_tab) ,:class => "btn btn-primary"%> + <%= link_to t("modal.preview"), admin_realtime_preview_ad_banner_path(ad_banner_tab.id) , :class=>'preview_trigger btn btn-success'%> + <% end -%> + <% end -%> +
    + <%= render :partial => "ad_image_update", :collection => ad_banner_tab.ad_images,:as => :ad_image,:locals=>{:ad_banner => ad_banner_tab} %> +
+ <% if at_least_module_manager %> + <%= show_ad_banner_permission_link ad_banner_tab%> + <%= link_to t('admin.ad.delete_banner'),admin_ad_banner_path(ad_banner_tab),:class => 'btn',:method => :delete,:confirm => t('sure?') %> + <% end -%> + + <%#= render :partial => 'new_add_banner_file', :object => ad_banner_tab.ad_images.build, :locals => { :field_name => "new_ad_images[]", :f => f, :classes => "r_destroy" } %> +
+ <%#= render :partial => 'preview_block',:locals=> {:ad_banner =>ad_banner_tab} %>
diff --git a/app/views/admin/ad_banners/_ad_image_update.html.erb b/app/views/admin/ad_banners/_ad_image_update.html.erb index b2dfdc73d..0b4277a05 100644 --- a/app/views/admin/ad_banners/_ad_image_update.html.erb +++ b/app/views/admin/ad_banners/_ad_image_update.html.erb @@ -1,12 +1,13 @@ -
  • - <%= image_tag ad_image.file rescue nil %> +
  • + <%= image_tag ad_image.file rescue nil%>

    - <%= ad_image.display? ? '[Showing]' : '[NotShawing]' %> + <%= ad_image.display? ? "[#{t('admin.ad.showing')}]" : "[#{t('admin.ad.not_showing')}]" %> <%= "#{ad_image.post_date ||'NeedReset' }~#{ad_image.unpost_date || 'NeedReset'}" %>

    -

    - <%= link_to 'Edit',edit_admin_ad_banner_ad_image_path(ad_banner,ad_image),:class => 'btn btn-primary' %> - <%= link_to 'Del',admin_ad_banner_ad_image_path(ad_banner,ad_image),:class => 'btn',:method => :delete,:confirm => t('sure?') %> -

    -
  • - + <%if at_least_module_manager || sub_manager?(ad_image.ad_banner) %> +

    + <%= link_to t('edit'),edit_admin_ad_banner_ad_image_path(ad_banner,ad_image),:class => 'btn btn-primary' %> + <%= link_to t('delete'),admin_ad_banner_ad_image_path(ad_banner,ad_image),:class => 'btn',:method => :delete,:confirm => t('sure?') %> +

    + <% end -%> + \ No newline at end of file diff --git a/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb b/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb index 8e8de1d9a..68e0a9c60 100644 --- a/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb +++ b/app/views/admin/ad_banners/_modal_ad_banner_form.html.erb @@ -1,10 +1,10 @@ - - - +
    + <% end %> - diff --git a/app/views/admin/ad_banners/_modal_preview.html.erb b/app/views/admin/ad_banners/_modal_preview.html.erb new file mode 100644 index 000000000..ffc841074 --- /dev/null +++ b/app/views/admin/ad_banners/_modal_preview.html.erb @@ -0,0 +1,36 @@ +<% if ad_banner -%> + + + + + +<% end -%> diff --git a/app/views/admin/ad_banners/_preview_block.html.erb b/app/views/admin/ad_banners/_preview_block.html.erb index 4e8432b60..47646f6f1 100644 --- a/app/views/admin/ad_banners/_preview_block.html.erb +++ b/app/views/admin/ad_banners/_preview_block.html.erb @@ -1,7 +1,7 @@ <% if ad_banner -%> <%= link_to 'Preview',"#slideshow-#{ad_banner.title.dehumanize}",:class=>"btn btn-primary btn-large",:data=>{:toggle=>'modal'} %> -
    <%= yield %>
    diff --git a/app/views/layouts/page_layout.html.erb b/app/views/layouts/page_layout.html.erb index 8fb884b07..0a7240ef3 100644 --- a/app/views/layouts/page_layout.html.erb +++ b/app/views/layouts/page_layout.html.erb @@ -3,8 +3,8 @@ <%= page_title(@item).html_safe %> + "> <%= page_metas(@item).html_safe %> - <%= @metas %> diff --git a/app/views/layouts/site_editor.html.erb b/app/views/layouts/site_editor.html.erb index efcc54ca2..1f66aeccd 100644 --- a/app/views/layouts/site_editor.html.erb +++ b/app/views/layouts/site_editor.html.erb @@ -1,38 +1,36 @@ - - - - - <%= @title || APP_CONFIG['orbit'] %> - - - <%= stylesheet_link_tag "site_editor" %> - <%= javascript_include_tag "site_editor" %> - <%= yield :page_specific_css %> - <%= yield :page_specific_javascript %> - <%= csrf_meta_tag %> - - - - -
    -
    <%= yield :sidebar %>
    -
    - <%= yield %> -
    -
    <%= yield :tertiary %>
    - -
    - - - + + + + + <%= @title || APP_CONFIG['orbit'] %> + + + <%= stylesheet_link_tag "site_editor" %> + <%= javascript_include_tag "site_editor" %> + <%= csrf_meta_tag %> + + + <%= render 'layouts/orbit_bar' %> + +
    +
    + <%= yield %> +
    +
    + + diff --git a/app/views/shared/_privilege_user.html.erb b/app/views/shared/_privilege_user.html.erb new file mode 100644 index 000000000..9d49be356 --- /dev/null +++ b/app/views/shared/_privilege_user.html.erb @@ -0,0 +1,16 @@ +
    + + <%= content_tag :div,:data=>{'original-title'=>t('announcement.bulletin.approval_setting_window_title'),:content => user.cache_dept[I18n.locale.to_s]},:class=>"checkbox clear" do %> +
    +
    +
    + <% if user.avatar? %> + <%= image_tag(user.avatar.thumb.url,:class => "member-img") %> + <% else %> + <%= image_tag "person.png",:class => "member-img" %> + <% end %> +
    + <%= label_tag "lab-user-#{user.id}", (user.name rescue ''),:class=>"member-name",:id=>nil -%> + <%= check_box_tag "[users][#{user.id}]", 'true',chosen_users.include?(user),:class => "check" -%> + <%end %> +
    diff --git a/config/application.rb b/config/application.rb index b77655c7d..00dad7e82 100644 --- a/config/application.rb +++ b/config/application.rb @@ -63,6 +63,8 @@ module Orbit # Enable the asset pipeline config.assets.enabled = true + #config.time_zone = 'Taipei' + ENV['TZ'] = 'Asia/Taipei' end end Orbit_Apps = [] diff --git a/config/environments/development.rb b/config/environments/development.rb index 1dbff0320..2dac58e9a 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -24,6 +24,9 @@ Orbit::Application.configure do config.action_dispatch.best_standards_support = :builtin + config.assets.debug = true + + # config.middleware.use ExceptionNotifier, # :email_prefix => "[R4_error]", # :sender_address => %{"notifier" }, @@ -39,6 +42,6 @@ Orbit::Application.configure do # :authentication => "plain", # :user_name => "redmine@rulingcom.com", # :password => "rulingredmine" } - + end diff --git a/config/initializers/impression.rb b/config/initializers/impression.rb new file mode 100644 index 000000000..4b57f34a0 --- /dev/null +++ b/config/initializers/impression.rb @@ -0,0 +1,6 @@ +# Use this hook to configure impressionist parameters +Impressionist.setup do |config| + # Define ORM. Could be :active_record (default) and :mongo_mapper + # config.orm = :active_record + config.orm = :mongoid +end diff --git a/config/initializers/resque.rb b/config/initializers/resque.rb new file mode 100644 index 000000000..62de3fa45 --- /dev/null +++ b/config/initializers/resque.rb @@ -0,0 +1,20 @@ +require 'resque_scheduler' +# require 'resque_scheduler/server' +# require 'yaml' + +Resque.redis = 'localhost:6379' +#Resque.redis.namespace = "resque:SchedulerExample" + +# If you want to be able to dynamically change the schedule, +# uncomment this line. A dynamic schedule can be updated via the +# Resque::Scheduler.set_schedule (and remove_schedule) methods. +# When dynamic is set to true, the scheduler process looks for +# schedule changes and applies them on the fly. +# Note: This feature is only available in >=2.0.0. +#Resque::Scheduler.dynamic = true + +Dir["#{Rails.root}/app/jobs/*.rb"].each { |file| require file } + +# The schedule doesn't need to be stored in a YAML, it just needs to +# be a hash. YAML is usually the easiest. +Resque.schedule = YAML.load_file(Rails.root.join('config', 'resque_schedule.yml')) diff --git a/config/list.yml b/config/list.yml index 9b3a1a961..ef95ba314 100644 --- a/config/list.yml +++ b/config/list.yml @@ -9,6 +9,7 @@ markups: public_r_tags: - ad_banner + - sub_menu page_part_kinds: - text diff --git a/config/locales/en.yml b/config/locales/en.yml index da72a4eb9..cb638475d 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -9,7 +9,9 @@ en: account_settings: Account settings add: Add back: Back + browse: Browse cancel: Cancel + create_fail: Creation failed create: Create delete: Delete desktop: Desktop @@ -28,6 +30,9 @@ en: logout: Logout no_: "No" nothing: Nothing + nccu: NCCU + nccu_c: + nccu_ldap_uid: NCCU LDAP Account or_lower: or password: Password register: Register @@ -37,17 +42,74 @@ en: submit: Submit sure?: Are you sure? update: Update + update_failed: Update failed + view: View + view_count: View count yes_: "Yes" - + + all_content: All Content + all_file: All File + all_member: All Member + content: Content + data: Data + file: File + file_type: File Type + hits: Hits + item: Item + member: Member + module: Module + most_visited_page: Most Visited Page + quantity: Quantity + recent_update: Recent Update + referral_in_links: Referral in Links + role: Role + site_info: Site Info + site_name: Site Name + statistics: Statistics + title: Title + total_visitors: Total Visitors + traffic: Traffic + + visitors_today: Today's visitors + visitors_this_week: This week's visitors + visitors_this_month: This month's visitors + visitors_this_year: This year's visitors + admin: + access: + denied: + app: + not_sub_manager: Access Denied for you are not SubManager for this app + not_manager: Access Denied for you are not SubManager for this app + not_authed_user: Access Denied for you are not User for this app + not_admin: Access Denied for you are not Admin + object: "Access Denied for you don't have permission for this object" action: Action ad_banner: AD Banner + ad: + sec_place_holder: Enter 3 if 3 sec + ab_fx: FX + all_banners: AdBanner list + banner_best_size: Banner Best Size + best_size: Best size + new_banner: New banner + new_image: New image + showing: Showing + not_showing: NotShowing + picture_list: Picture List + title: Title + transition_sec: Transition time + trans_unit_sec: sec + update_banner: Update Banner + widget_info_for_ad_image_size: "Best size with: %{best_size}" add: Add add_item: Add item add_language: Add language add_drop_down_item: +Add Menu Item admin: Admin action: Action + all_articles: List + always_display_title: Always displayed in the title bar announcement: Announcement asset: Asset assets: @@ -60,6 +122,7 @@ en: calendar: Calendar cant_delete_self: You can not delete yourself. cant_revoke_self_admin: You can not revoke your admin role yourself. + category: Category choose_file: Choose a file... class: Class content: Content @@ -75,7 +138,7 @@ en: dashboard: Dashboard delete_language: Delete language description: Description - design: Design + design: Template disable_language: Disable language editing_home: Editing homepage editing_layout: Editing layout @@ -86,8 +149,10 @@ en: editing_role: Editing user role email: Email enable_language: Enable language + enabled_for: Enabled for file_name: Filename file_size: File size + file_upload: File upload format: Format home: Home id: ID @@ -96,10 +161,12 @@ en: is_published: Is published item: Item key: Key + keywords: Keywords language: Language layout: Layout layout_name: Layout name links: Links + link: Links list_assets: Assets list list_designs: Designs list list_items: Items list @@ -108,7 +175,18 @@ en: list_users: Users list list_infos: User information list list_roles: User roles list + mail_address: Address + mail_port: Port + mail_domain: Domain + mail_authentication: Authentication + mail_user_name: User Name + mail_password: Password + mail_tls: TLS + mail_enable_starttls_auto: Enable Start TLS Auto member: Member + menu_enabled_for: Menu enabled for + module: + authorization: Module Authorization move_down: Move down move_up: Move up multilingual: Multilingual @@ -117,6 +195,8 @@ en: no_layout: You don't have a layout name: Name nccu: NCCU Custom + nccu_c: + nccu_ldap_uid: NCCU LDAP Account new_asset: New asset new_component: New component new_design: New design @@ -128,10 +208,23 @@ en: new_user: New user new_info: New user information new_role: New user role + news: News non_multilingual: Non multilingual + object_auth: + list_title_of_users: %{auth_title} Auth List + update_done: Update done,reulst showing in list + update_failed: Update failed options: Options orig_upload_file: Original filename page: Page + page_context: + edit: Edit + ob_auth: + edit: Category authorization + page_part_kinds: + text: Text Area + public_r_tag: System Widget + module_widget: Plug-in Module Widget position: Position published?: Published? purchase: Purchase @@ -142,9 +235,14 @@ en: setup_translations: Translations setup setup_designs: Designs setup site: Site - site_setting: Site Setting + site_description: Site description + site_footer: Site footer + site_settings: Site Setting + site_sub_menu: Site sub-menu + site_title: Site title super_pages: Super pages structure: Structure + tags: Tags title: Title translation: Translation type: Type @@ -161,8 +259,33 @@ en: upload_design: Upload design url: URL user: User + user_role: + auth: + all_member: All Member + manager: Manager + sub_mamanger: SubManager + by_role: By Role + by_sub_role: By SubRole + block_list: Block List + privilege_list: Privilege List + add_manager: Add Manager + add_sub_manager: Add SubManager + add_to_block_list: Add to block List + add_to_privilege_list: Add to privilege List + auth_by: -AuthBy %{user_display_name} info: User information panel: User panel role: User role - + + dashboard: + bulletin: Announcement + news_bulletin: News + page_context: Page + web_link: Link + panel: + + modal: + close: Close + preview: Preview + diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 491d80e8d..ea0264b79 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -6,13 +6,15 @@ zh_tw: account_settings: 帳號設定 add: 新增 back: 回上一步 + browse: 選擇檔案 cancel: 取消 - create: 創建 + create: 新增 + create_fail: 創建失敗 delete: 刪除 desktop: 桌面 disable: 禁用 dots: … - downloaded: 已經下載 + downloaded: 已下載 download: 下載 edit: 編輯 email: 電子郵件 @@ -34,25 +36,76 @@ zh_tw: submit: 送出 sure?: 您肯定嗎? update: 更新 + update_failed: 更新失敗 + view: 檢視 + view_count: 查看次數 yes_: "Yes" - + + all_content: 全部內容有 + all_file: 全部檔案有 + all_member: 成員總數 + content: 內容 + data: 數據 + file: 檔案 + file_type: 檔案類型 + hits: 點擊率 + item: 項目 + member: 會員 + module: 模組 + most_visited_page: 熱門頁面 + quantity: 數量 + recent_update: 近期更新 + referral_in_links: 外部推薦連結 + role: 角色 + site_info: 網站資訊 + site_name: 網站名稱 + statistics: 統計 + title: 標題 + total_visitors: 造訪次數 + traffic: 流量 + + visitors_today: 今日造訪 + visitors_this_week: 本星期造訪 + visitors_this_month: 本月造訪 + visitors_this_year: 今年造訪 + admin: + access: + denied: + app: + not_sub_manager: 拒絕存取因你不是此應用程式次管理員 + not_manager: 拒絕存取因你不是此應用程式管理員 + not_authed_user: 拒絕存取因你不是此應用程式授權使用者 + not_admin: 拒絕存取因你不是此應用程式次管理員 + object: 拒絕存取因你不是網站管理者 action: 操作 ad_banner: 廣告輪播 ad: + sec_place_holder: 3秒請輸入3 ab_fx: 轉場特效 all_banners: 輪播清單 + banner_best_size: Banner 尺寸 + best_size: 最佳尺寸 + cate_auth: 分類授權 + delete_banner: 刪除整組輪播 new_banner: 新增輪播 new_image: 新增橫幅 + showing: 顯示中 + not_showing: 沒有顯示 + picture_list: 圖片列表 title: 標題 transition_sec: 轉場單位時間 trans_unit_sec: 秒 + update_banner: 更新輪播 + widget_info_for_ad_image_size: "此區塊圖片尺寸請使用 %{best_size}" add: 新增 add_item: 新增項目 add_language: 新增語言 add_drop_down_item: +增加Orbit選單 - admin: 管理 - announcement: 公告系統 + admin: 網站管理者 + all_articles: 列表 + always_display_title: 永遠顯示於標題列 + announcement: 公告管理 asset: 資產 assets: file: 檔案 @@ -63,27 +116,31 @@ zh_tw: author: 作者 calendar: 行事曆 cant_delete_self: 您不可以刪除自己。 - cant_revoke_self_admin: 您不可以撤銷自己的管理作用。 + cant_revoke_self_admin: 您不可以撤銷自己的管理身份。 + category: 類別 choose_file: 請選擇一個文件... class: 階級 content: 內容 - create_error_link: 創建連接時出錯。 - create_error_page: 創建頁面時出錯。 - create_success_home: 首頁已成功創建。 - create_success_layout: 樣板已成功創建。 - create_success_link: 連結已成功創建。 - create_success_page: 頁面已成功創建。 - create_success_home: 首頁已成功創建。 - create_success_layout: 佈局已成功創建。 - create_success_link: 連結已成功創建。 - create_success_page: 頁面已成功創建。 - create_success_snippet: 片段已成功創建。 - create_success_user: 用戶已成功創建。。 + contenteditable: + update_done: 更新完成 + update_failed: 更新失敗 + create_error_link: 新增連接時出錯。 + create_error_page: 新增頁面時出錯。 + create_success_home: 首頁已成功新增。 + create_success_layout: 樣板已成功新增。 + create_success_link: 連結已成功新增。 + create_success_page: 頁面已成功新增。 + create_success_home: 首頁已成功新增。 + create_success_layout: 佈局已成功新增。 + create_success_link: 連結已成功新增。 + create_success_page: 頁面已成功新增。 + create_success_snippet: 片段已成功新增。 + create_success_user: 用戶已成功新增。。 dashboard: 儀表板 data: 資料數據 delete_language: 刪除語言 description: 描述 - design: 網站版型 + design: 版型管理 disable_language: 禁用語言 editing_home: 編輯首頁 editing_layout: 編輯樣板 @@ -91,11 +148,13 @@ zh_tw: editing_page: 編輯頁面 editing_snippet: 編輯片段 editing_info: 編輯用戶資料 - editing_role: 編輯用戶角色 + editing_role: 編輯用戶身份 email: Email enable_language: 啟用語言 + enabled_for: 啟用 file_name: 檔名 file_size: 檔案大小 + file_upload: 文件上載 format: 格式 home: 首頁 id: ID @@ -104,9 +163,11 @@ zh_tw: is_published: 被出版 item: 網站架構 key: 關鍵 + keywords: 關鍵字 language: 語言 layout: 佈局 layout_name: 佈局名字 + link: 連結管理 links: 網路資源 list_assets: 資產列表 list_designs: 設計列表 @@ -115,8 +176,19 @@ zh_tw: list_snippets: 斷片列表 list_users: 使用列表 list_infos: 用戶資料列表 - list_roles: 用戶角色列表 + list_roles: 用戶身份列表 + mail_address: 郵件地址 + mail_port: 傳輸埠 + mail_domain: 網域名稱 + mail_authentication: 認證 + mail_user_name: 帳號 + mail_password: 密碼 + mail_tls: TLS + mail_enable_starttls_auto: Enable Start TLS Auto member: 會員 + menu_enabled_for: 選單啟用 + module: + authorization: 模組授權 move_down: 往下移 move_up: 往上移 multilingual: 多種語言 @@ -135,16 +207,34 @@ zh_tw: new_snippet: 新增片段 new_user: 新增使用 new_info: 新增用戶資料 - new_role: 新增用戶角色 - non_multilingual: 非多種語言 + new_role: 新增用戶身份 + news: 新聞 + non_multilingual: + object_auth: + list_title_of_users: 授權清單-%{auth_title} + update_done: 更新完成,結果顯示於清單 + update_failed: 更新失敗 options: 選項 orig_upload_file: 原上傳檔名 - page: Page + page: 頁面管理 + page_context: + edit: 編輯 + ob_auth: + edit: 分類授權 + page_part_kinds: + text: 文字區塊 + public_r_tag: 系統模塊 + module_widget: 外掛模塊 position: 位置 published?: 發布? purchase: 購買 - role: 角色 - roles: 角色 + role: 身份 + roles: 身份 + site_description: 網站描述 + site_footer: 網站頁尾 + site_settings: 基本設定 + site_sub_menu: 網站次選單 + site_title: 網站標題 setup_member: 成員設置 setup_translations: 語系設定 setup_designs: 版型設定 @@ -152,6 +242,7 @@ zh_tw: site_setting: 網站設定 super_pages: 可編頁面 structure: 網站結構 + tags: 標籤 title: 標題 translation: 翻譯 type: 類型 @@ -168,10 +259,30 @@ zh_tw: upload_design: 上傳設計 url: URL user: 用戶 + user_role: + auth: + all_member: 所有會員 + manager: 管理員 + sub_manager: 次管理員 + by_role: 根據身份 + by_sub_role: 根據次身份 + block_list: 封鎖名單 + add_manager: 增加到管理員 + add_sub_manager: 增加到次管理員 + add_to_block_list: 封鎖名單 + add_to_privilege_list: 特許名單 + auth_by: -由%{user_display_name}授權 + user: 使用會員 info: 用戶資料 panel: 用戶面板 - role: 用戶角色 + role: 用戶身份 + dashboard: + bulletin: 公告 + news_bulletin: 新聞 + page_context: 頁面 + web_link: 鏈接 + panel: @@ -386,3 +497,6 @@ zh_tw: create: "新增%{model}" update: "更新%{model}" submit: "儲存%{model}" + modal: + close: "關閉" + preview: "預覽" \ No newline at end of file diff --git a/config/mongoid.yml b/config/mongoid.yml index 0270b13ce..f333e2e65 100644 --- a/config/mongoid.yml +++ b/config/mongoid.yml @@ -22,4 +22,4 @@ production: # password: <%= ENV['MONGOID_PASSWORD'] %> # database: <%= ENV['MONGOID_DATABASE'] %> <<: *defaults - database: prototype_r4_development \ No newline at end of file + database: prototype_r4_development diff --git a/config/resque.god b/config/resque.god new file mode 100644 index 000000000..6c4e4bded --- /dev/null +++ b/config/resque.god @@ -0,0 +1,55 @@ +rails_env = 'development' #ENV['RAILS_ENV'] || "production" +rails_root = ENV['RAILS_ROOT'] || "/Users/kaito/Documents/MyWorkspeace/orbit/orbit" +num_workers = rails_env == 'production' ? 5 : 2 + +num_workers.times do |num| + God.watch do |w| + w.dir = "#{rails_root}" + w.name = "resque-#{num}" + w.group = 'resque' + w.interval = 30.seconds + p "/usr/bin/rake -f #{rails_root}/Rakefile resque:work QUEUE=* RAILS_ENV=#{rails_env}" +# w.env = {"QUEUE"=>"critical,high,low", "RAILS_ENV"=>rails_env} + w.start = "rake -f #{rails_root}/Rakefile resque:work QUEUE=* RAILS_ENV=#{rails_env}" + + w.uid = 'kaito' + w.gid = 'staff' + + # restart if memory gets too high + w.transition(:up, :restart) do |on| + on.condition(:memory_usage) do |c| + c.above = 350.megabytes + c.times = 2 + end + end + + # determine the state on startup + w.transition(:init, { true => :up, false => :start }) do |on| + on.condition(:process_running) do |c| + c.running = true + end + end + + # determine when process has finished starting + w.transition([:start, :restart], :up) do |on| + on.condition(:process_running) do |c| + c.running = true + c.interval = 5.seconds + end + + # failsafe + on.condition(:tries) do |c| + c.times = 5 + c.transition = :start + c.interval = 5.seconds + end + end + + # start if process is not running + w.transition(:up, :start) do |on| + on.condition(:process_running) do |c| + c.running = false + end + end + end +end \ No newline at end of file diff --git a/config/resque_schedule.yml b/config/resque_schedule.yml new file mode 100644 index 000000000..601941013 --- /dev/null +++ b/config/resque_schedule.yml @@ -0,0 +1,23 @@ +# do_mail_matt: +# every: 10s +# class: FetchTime +# args: +# description: Runs the perform method in FetchTime + +nccu_daily_ldap_sync: + cron: * * [0,12] * * * + class: SyncDb + args: + description: Sync NCCU middle site with Orbit for LDAP data + +nccu_daily_restart: + cron: * * */3 * * * + class: RestartServer + args: + description: Restart NCCU site + +nccu_claender_sync: + cron: * * [0,12] * * * + class: NccuCalendar + args: + description: Sync NCCU calendar RSS Feeds \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index bd73aea6d..648fe9b18 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,5 @@ Orbit::Application.routes.draw do - + mount Resque::Server, :at => "/admin/resque" devise_for :users # routes for sinatra app @@ -12,9 +12,22 @@ Orbit::Application.routes.draw do # routes for admin namespace :admin do - resources :assets + mount Resque::Server.new, :at => "/resque" + resources :assets do + collection do + get 'file_upload' + post 'delete' + end + end + resources :asset_categories + resources :asset_tags resources :app_auths resources :object_auths do + match 'new_interface/:ob_type/:title/new' => "object_auths_new_interface#new" ,:as => :init_ob_auth,:via => :get + 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 @@ -24,7 +37,10 @@ Orbit::Application.routes.draw do end end - + + match 'ad_banners/:id/preview' => 'ad_banners#realtime_preview',:as => :realtime_preview_ad_banner,:via => :put + 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 @@ -36,6 +52,7 @@ Orbit::Application.routes.draw do resources :designs do collection do get 'upload_package' + post 'delete' post 'upload_package' end member do @@ -46,6 +63,7 @@ Orbit::Application.routes.draw do get 'add_attribute_field' end resources :items + match 'update_position' => 'items#update_position' resources :links do member do get 'delete' @@ -58,6 +76,9 @@ Orbit::Application.routes.draw do end end resources :module_apps do + match 'manager_auth_proc' => "module_apps_new_interface#setting" ,:as => :manager_auth_proc,:via => :get + match 'manager_auth_proc' => "module_apps_new_interface#update_setting" ,:as => :manager_auth_proc,:via => :post + match 'manager_auth_proc' => "module_apps_new_interface#user_list" ,:as => :manager_auth_show,:via => :put resources :app_auths do member do match 'remove/:type/:target_id' ,:action=> 'remove',:via => "delete",:as =>:remove @@ -76,6 +97,7 @@ Orbit::Application.routes.draw do resources :page_parts do member do get 'reload_widgets' + get 'reload_r_tag_options' end end resources :purchases do @@ -90,7 +112,13 @@ Orbit::Application.routes.draw do get 'add_sub_role' get 'add_attribute_field' end - resources :sites + resources :sites do + get 'site_info' + get 'system_info' + get 'language' + get 'mail_setting' + get 'ui_theme' + end resources :snippets resources :tags resources :translations @@ -172,9 +200,14 @@ Orbit::Application.routes.draw do match '/desktop_appstore/widgets_settings'=>'desktop_appstore#widgets_settings' match '/desktop_orbit/orbit' => 'desktop_orbit#orbit' + match '/desktop_orbit/eventajaxload'=> 'desktop_orbit#eventajaxload' match '/desktop_orbit/getevents' => 'desktop_orbit#getevents' - #match '/desktop_orbit/getevents' => '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 '/desktop/temp_func/'=>'desktop#temp_func' match '/panel/:app_name/front_end/:app_action/:id' => 'pages#show_from_link', :constraints => lambda { |request| @@ -197,4 +230,4 @@ Orbit::Application.routes.draw do root :to => 'pages#index' -end \ No newline at end of file +end diff --git a/dump.rdb b/dump.rdb new file mode 100644 index 000000000..748293b8f Binary files /dev/null and b/dump.rdb differ diff --git a/lib/orbit_core_lib.rb b/lib/orbit_core_lib.rb index bcde17e0c..f3cd2cd51 100644 --- a/lib/orbit_core_lib.rb +++ b/lib/orbit_core_lib.rb @@ -19,6 +19,26 @@ module OrbitCoreLib end + def cur_user_is_sub_manager_of(title) + authed_users(title).include?(User.current) + end + + def app_auth + ModuleApp.first(conditions: {:title => self.class::APP_NAME} ) + end + + def pp_object + "Object Auth method 'pp_object' need to be defined for class #{self.class}" + end + + def get_object_auth_by_title(title) + oa = self.object_auths.where({title: title }).first + if oa.nil? && (self.class::ObjectAuthTitlesOptions.include? title) + oa = self.object_auths.create title: title + end + oa + end + def authed_users(title=nil) users = [] users = case title @@ -33,7 +53,7 @@ module OrbitCoreLib [] end else - self.object_auths.where(title: title).first.auth_users rescue [] + get_object_auth_by_title(title).auth_users rescue [] end users end @@ -59,6 +79,7 @@ module OrbitCoreLib module PermissionUnility private def check_permission(type = :use) + setup_vars permission_grant = current_user.admin?? true : false module_app = @module_app.nil?? find_module_app_by_token(params[:token]) : @module_app unless permission_grant diff --git a/lib/parsers/parser_back_end.rb b/lib/parsers/parser_back_end.rb index 24b6c59f4..aed8f36bd 100644 --- a/lib/parsers/parser_back_end.rb +++ b/lib/parsers/parser_back_end.rb @@ -14,7 +14,7 @@ module ParserBackEnd # }.join(' | ') # end # c.define_tag 'link' do |tag| - # item = Item.first(:conditions => { :full_name => tag.attr['name'] }) + # item = Item.first(:conditions => { :path => tag.attr['name'] }) # ret = '' # ret << "" - else - part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil - ret << "
    " if part - ret << "' - case part.kind - when 'text' - ret << part.i18n_variable[I18n.locale] rescue '' - when 'module_widget' - if part[:category] - ret << "
    " - else - ret << "
    " - end - when 'public_r_tag' - ret << "" - public_r_tags << part.public_r_tag - else - '' - end if part - end - scope = "<#{content.name}" - content.attributes.each_pair do |key, value| - scope << " #{key}='#{value}'" - end - scope << ">#{ret}" - fragment = Nokogiri::HTML::DocumentFragment.new(body, scope) - content.swap(fragment) - end - public_r_tags.uniq - end - - def self.included(base) base.send :helper_method, :parse_page_edit_noko if base.respond_to? :helper_method end diff --git a/lib/parsers/parser_common.rb b/lib/parsers/parser_common.rb index 93ea26085..32820a6f5 100644 --- a/lib/parsers/parser_common.rb +++ b/lib/parsers/parser_common.rb @@ -1,58 +1,61 @@ module ParserCommon - - def menu_level(page, current, menu, edit = false) + include ActionView::Helpers::TagHelper + + def menu_level(page, current_page, current, menu, edit = false) res = '' - if menu.levels > 0 && current <= menu.levels - if current != 0 - res << "
    " - item = rand(100000) - res << "#{page.i18n_variable[I18n.locale]}" - if page.children.size > 0 - res << "
    " - res << "
      " - i = nil - i = 1 if menu.values["li_incremental_#{current}"] - page.children.each do |child| - res << menu_li(child, current, menu, i, edit) - i += 1 if i - end - res << "
    " - res << "
    " - end - res << "
    " - else - res << '' + if page.visible_children.size > 0 + res << "" end + res end - def menu_li(page, current, menu, i, edit) - res = "" end # ad_banners - def parse_ad_banners(body = nil, page = nil, id = nil) + def parse_ad_banners(body = nil, page = nil, edit=nil) body.css('ad_banner').each do |banner| res = '' ad_banner = AdBanner.find(banner["id"]) rescue nil if ad_banner res << "" + res << "" res << "
    " printable_ad_images = [] ad_banner.ad_images.each do |ad_image| @@ -65,8 +68,8 @@ module ParserCommon printable_ad_images.shuffle! printable_ad_images.each do |ad_image| #TODO Need Reflact res << " 0 + res << "
    " + res << "

    #{menu_page.i18n_variable[I18n.locale]}

    " + res << "" + res << "" + res << "
    " + end + fragment = Nokogiri::HTML::DocumentFragment.new(body, res) + sub_menu.swap(fragment) + end + end + + # page_footer + def parse_footer(body, page) + page_footer = body.css('.page_footer').first + if page_footer + res = "
    " + res << @site.footer[I18n.locale] rescue nil + res << "
    " + fragment = Nokogiri::HTML::DocumentFragment.new(body ,res) + page_footer.swap(fragment) rescue nil + else + '' + end + end + + # page_sub_menu + def parse_sub_menu(body, page) + page_sub_menu = body.css('.page_sub_menu').first + if page_sub_menu + res = "
    " + res << @site.sub_menu[I18n.locale] rescue nil + res << "
    " + fragment = Nokogiri::HTML::DocumentFragment.new(body ,res) + page_sub_menu.swap(fragment) rescue nil + else + '' + end + end + + # page_contents + def parse_contents(body, page, edit=nil) + public_r_tags = [] + body.css('.page_content').each do |content| + ret = '' + category = params[:category_id].blank? ? page[:category] : params[:category_id] + tag = params[:tag_id].blank? ? page[:tag] : params[:tag_id] + if (content["main"] == "true" && !page.module_app.nil?) + ret << "
    " + else + part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil + part_title = part.title[I18n.locale] rescue nil + if edit + ret << "
    " if part + ret << "' + end + case part.kind + when 'text' + ret << part.i18n_variable[I18n.locale] rescue '' + when 'module_widget' + url = "/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true" + options = "&category_id=#{!part[:category].blank? ? part[:category].blank? : category}&tag_id=#{!part[:tag].blank? ? part[:tag] : tag}&page=#{params[:page]}&part_title=#{Rack::Utils.escape(part_title).gsub("+", "%20") rescue nil}" + ret << "
    " + when 'public_r_tag' + ret << "" + public_r_tags << part.public_r_tag + else + '' + end if part + end + scope = "<#{content.name}" + content.attributes.each_pair do |key, value| + scope << " #{key}='#{value}'" + end + scope << ">#{ret}" + fragment = Nokogiri::HTML::DocumentFragment.new(body, scope) + content.swap(fragment) + end + public_r_tags.uniq + end + end diff --git a/lib/parsers/parser_front_end.rb b/lib/parsers/parser_front_end.rb index dfec0dd9a..3d39bd5f8 100644 --- a/lib/parsers/parser_front_end.rb +++ b/lib/parsers/parser_front_end.rb @@ -11,7 +11,7 @@ module ParserFrontEnd # }.join(' | ') # end # c.define_tag 'link' do |tag| - # item = Item.first(:conditions => { :full_name => tag.attr['name'] }) + # item = Item.first(:conditions => { :path => tag.attr['name'] }) # ret = '' # ret << "" # ret << item.i18n_variable[I18n.locale] @@ -21,57 +21,18 @@ module ParserFrontEnd require 'nokogiri' - def parse_page_noko(page, id = nil) + def parse_page_noko(page) body = Nokogiri::HTML(page.design.layout.body) parse_menu(body, page) - public_r_tags = parse_contents(body, page, id) + public_r_tags = parse_contents(body, page) parse_images(body, page) - + parse_footer(body, page) + parse_sub_menu(body, page) public_r_tags.each do |tag| - send("parse_#{tag}s", body, page,id) + send("parse_#{tag}s", body, page) end body.to_html end - - # page_contents - def parse_contents(body, page, id) - public_r_tags = [] - body.css('.page_content').each do |content| - ret = '' - if (content["main"] == "true" && !page.module_app.nil?) - ret << "
    " - else - part = page.page_parts.detect{ |p| p.name.to_s == content['name'].to_s } rescue nil - case part.kind - when 'text' - ret << part.i18n_variable[I18n.locale] rescue '' - when 'module_widget' - if part[:category] - ret << "
    " - else - ret << "
    " - end - when 'public_r_tag' - ret << "" - public_r_tags << part.public_r_tag - else - '' - end if part - end - scope = "<#{content.name}" - content.attributes.each_pair do |key, value| - scope << " #{key}='#{value}'" - end - scope << ">#{ret}" - fragment = Nokogiri::HTML::DocumentFragment.new(body, scope) - content.swap(fragment) - end - public_r_tags.uniq - end end diff --git a/lib/tasks/anc_tasks.rake b/lib/tasks/anc_tasks.rake index cd534b939..a97e1830e 100644 --- a/lib/tasks/anc_tasks.rake +++ b/lib/tasks/anc_tasks.rake @@ -1,3 +1,4 @@ +require 'resque_scheduler/tasks' # encoding: utf-8 namespace :anc do diff --git a/lib/tasks/designs.rake b/lib/tasks/designs.rake new file mode 100644 index 000000000..c8940e226 --- /dev/null +++ b/lib/tasks/designs.rake @@ -0,0 +1,12 @@ +# encoding: utf-8 + +namespace :designs do + task :change_to, [:design_id] => [:environment] do |t, args| + design = Design.find(args[:design_id]) + theme_id = design.themes.first.id + Page.all.each do |page| + page.update_attributes({design_id: args[:design_id], theme_id: (theme_id unless page.root?)}) + end + end + +end \ No newline at end of file diff --git a/lib/tasks/items.rake b/lib/tasks/items.rake new file mode 100644 index 000000000..7d94332ed --- /dev/null +++ b/lib/tasks/items.rake @@ -0,0 +1,19 @@ +# encoding: utf-8 + +namespace :items do + task :tree_changes => :environment do + Item.all.each do |item| + item.position -= item.position > 5 ? 2 : 1 + item.parent_ids = ancestors(item) + item.rename(:full_name, :path) + item.save + end + end + + def ancestors(item) + node, nodes = item, [] + nodes << node = node.parent while !node.parent.blank? rescue nil + nodes.reverse + end + +end \ No newline at end of file diff --git a/lib/tasks/resque.rake b/lib/tasks/resque.rake new file mode 100644 index 000000000..66841c724 --- /dev/null +++ b/lib/tasks/resque.rake @@ -0,0 +1,39 @@ +# require "resque/tasks" +# require 'resque/scheduler' +# require 'resque/scheduler' + +# +# task "resque:setup" => :environment +# Resque tasks +require 'resque/tasks' +require 'resque_scheduler/tasks' + +namespace :resque do + task :setup => :environment do + require 'resque' + require 'resque_scheduler' + require 'resque/scheduler' + + # you probably already have this somewhere + Resque.redis = 'localhost:6379' + + # If you want to be able to dynamically change the schedule, + # uncomment this line. A dynamic schedule can be updated via the + # Resque::Scheduler.set_schedule (and remove_schedule) methods. + # When dynamic is set to true, the scheduler process looks for + # schedule changes and applies them on the fly. + # Note: This feature is only available in >=2.0.0. + #Resque::Scheduler.dynamic = true + + # The schedule doesn't need to be stored in a YAML, it just needs to + # be a hash. YAML is usually the easiest. + Resque.schedule = YAML.load_file('config/resque_schedule.yml') + + # If your schedule already has +queue+ set for each job, you don't + # need to require your jobs. This can be an advantage since it's + # less code that resque-scheduler needs to know about. But in a small + # project, it's usually easier to just include you job classes here. + # So, someting like this: + #require 'jobs' + end +end \ No newline at end of file diff --git a/public/static/Other.xml b/public/static/Other.xml index 22c41bbb7..859cfafca 100644 --- a/public/static/Other.xml +++ b/public/static/Other.xml @@ -5,140 +5,636 @@ 其他類別-最新活動 zh-tw - 國立政治大學101學年度碩士班暨碩士在職專班招生考試 - + IEEE Computer Society與ACM資料庫教育訓練 + - + - 101/02/25-101/02/26 07:00-17:00 - - - 國立中正大學101學年度碩士班招生考試 - - - - - 101/03/10 07:00-17:00 - - - 「樂活飲食•健康之鑰」系列活動--膳食纖維的功用及食物來源 - - - - - 101/02/29 12:00-14:00 - - - 「樂活飲食•健康之鑰」系列活動-美味的代價與健康問題之探討 - - - - - 101/03/08 12:00-14:00 - - - 「樂活飲食•健康之鑰」系列活動--代謝症候群與檢康飲食 - - - - - 101/03/22 12:00-14:00 + 101/04/26 13:00-15:00 「學生健康體位控制班」 - + - + 101/03/01-101/05/03 18:00-20:30 - 學生大使志工團- 2012 Field Trip-Must Sea+ FUN舟趣 - + 傳播沙龍:從南加大電影藝術學院看美國電影創作教育 + - - - 101/03/17-101/03/18 08:00-20:00 + + + 101/04/26 12:30-14:00 - 職場勞資關係講座-你知道自己的權益嗎? - + 傳播沙龍:從南加大電影藝術學院看美國電影創作教育 + - + - 101/03/05 18:30-21:00 + 101/04/26 12:30-14:00 - 職場「面面」觀 - 談職場趨勢與面試 - + IEEE Computer Society與ACM資料庫教育訓練 + - + - 101/03/06 18:30-21:00 + 101/04/26 13:00-15:00 - 「自」銷不要「滯」銷~一窺自我行銷術的秘密 - + ScienceDirect Online資料庫教育訓練 + - + - 101/03/07 18:30-21:00 + 101/04/27 12:30-14:00 - 職涯經驗談-開創職涯的一片天 - + 傳播沙龍:心健的心劍--新媒體藝術創作與教學 + - + - 101/03/08 18:30-21:00 + 101/04/27 12:30-14:00 + + + 智財論壇:智財生態變革及研發創新經營 + + + + + 101/04/30 10:10-11:50 - 2012徵政好企業說明會--花旗銀行 - + EICP東方線上資料庫教育訓練 + - + - 101/03/05 12:15-14:00 + 101/04/30 13:00-15:00 - 2012徵政好企業說明會--日商野村總合研究所 - + 職場講座「數位文本實務課程」 + - + - 101/03/09 12:15-14:00 + 101/04/24-101/05/15 12:20-13:50 - 2012徵政好企業說明會--渣打銀行 - + EBSCO教育心理資料庫教育訓練 + - + - 101/03/06 12:15-14:00 + 101/05/02 12:30-14:00 - 2012徵政好企業說明會--台新金控 - + 傳播沙龍:建制內的多元解讀:諜戰劇迷群體、文化表徵與中國語境 + - + - 101/03/07 12:15-14:00 + 101/05/03 12:30-14:00 - 2012徵政好企業說明會--第一銀行 - + 職場講座「數位文本實務課程」 + - + - 101/03/08 12:15-14:00 + 101/04/24-101/05/15 12:20-13:50 - 101年生命教育師資培訓課程研習會 - + 教發中心五月份數位教材製作工作坊_錄影後製與剪輯 05/09 + - + - 101/03/24-101/03/25 07:30-17:40 + 101/05/09 12:00-14:00 + + 文獻蒐集與報告撰寫入門 + + + + + 101/05/11 13:00-15:00 + + + 「2012台北-莫斯科論壇:新政展望」國際學術研討會 + + + + + 101/05/12-101/05/13 08:30-17:30 + + + 「2012台北-莫斯科論壇:新政展望」國際學術研討會 + + + + + 101/05/12-101/05/13 08:30-17:30 + + + 職場講座「數位文本實務課程」 + + + + + 101/04/24-101/05/15 12:20-13:50 + + + 文化講座「破戒:關於『色•戒』的實與虛」 + + + + + 101/05/24 12:20-14:00 + + + John,我愛你-Suming彈唱會-跨國現場獨立音樂表演系列 + + + + + 101/04/27 19:00-21:00 + + + 藝文中心【電影】2012國際民族誌影展巡演-《牛糞》 + + + + + 101/04/30 19:00-20:20 + + + 波蘭前衛流行女聲-噶芭.庫爾卡(跨國現場獨立音樂表演系列) + + + + + 101/05/04 19:00-20:00 + + + Bleuel 雙重奏--薩克斯風與鋼琴 + + + + + 101/05/10 19:30-20:30 + + + 「東張西望」林語堂生活展,政大校園站開幕茶會 + + + + + 101/05/02 11:00-12:00 + + + 文化參訪「故宮特展:西方神話與傳說—羅浮宮珍藏展」 + + + + + 101/05/07 08:30-12:00 + + +「學生健康體位控制班」 + + + + +101/03/01-101/05/03 18:00-20:30 + + +心靈陪伴工作坊 + + + + +101/04/28 09:30-16:30 + + +2012年福祿貝爾恩物親子戲遊成長團體(下午) + + + + +101/04/07-101/06/09 14:00-16:00 + + +2012年福祿貝爾恩物親子戲遊成長團體(上午) + + + + +101/04/07-101/06/02 09:00-11:00 + + +2012年世界狂歡節-環友世界 + + + + +101/05/01-101/05/10 00:00-23:59 + + +2012年世界狂歡節-「框」住瞬間「框」住世界 + + + + +101/05/01-101/05/08 00:00-23:59 + + +2012年世界狂歡節-從政大看台灣 + + + + +101/05/01-101/05/10 08:00-22:00 + + +2012年世界狂歡節-環友世界 + + + + +101/05/01-101/05/10 00:00-23:59 + + +2012年世界狂歡節-「框」住瞬間「框」住世界 + + + + +101/05/01-101/05/08 00:00-23:59 + + +2012年世界狂歡節-從政大看台灣 + + + + +101/05/01-101/05/10 08:00-22:00 + + +2012年世界狂歡節-「框」住瞬間「框」住世界 + + + + +101/05/01-101/05/08 00:00-23:59 + + +2012年世界狂歡節-環友世界 + + + + +101/05/01-101/05/10 00:00-23:59 + + +2012年世界狂歡節-從政大看台灣 + + + + +101/05/01-101/05/10 08:00-22:00 + + +校外租屋法律座談會 + + + + +101/05/03 12:00-14:00 + + +紅紙廊期中工作坊-帶遊戲的言談藝術 + + + + +101/05/03 12:10-14:00 + + +「學生健康體位控制班」 + + + + +101/03/01-101/05/03 18:00-20:30 + + +2012年世界狂歡節-「框」住瞬間「框」住世界 + + + + +101/05/01-101/05/08 00:00-23:59 + + +2012年世界狂歡節-環友世界 + + + + +101/05/01-101/05/10 00:00-23:59 + + +2012年世界狂歡節-從政大看台灣 + + + + +101/05/01-101/05/10 08:00-22:00 + + +身心放輕鬆 (教職員工心靈SPA講座) + + + + +101/05/04 12:00-13:30 + + +2012年世界狂歡節- 五粵天粵語歌唱比賽『光輝歲月』 + + + + +101/05/04 18:00-22:00 + + +2012年世界狂歡節-環友世界 + + + + +101/05/01-101/05/10 00:00-23:59 + + +2012年世界狂歡節-「框」住瞬間「框」住世界 + + + + +101/05/01-101/05/08 00:00-23:59 + + +2012年世界狂歡節-從政大看台灣 + + + + +101/05/01-101/05/10 08:00-22:00 + + +2012年福祿貝爾恩物親子戲遊成長團體(上午) + + + + +101/04/07-101/06/02 09:00-11:00 + + +2012年福祿貝爾恩物親子戲遊成長團體(下午) + + + + +101/04/07-101/06/09 14:00-16:00 + + +2012年世界狂歡節-「框」住瞬間「框」住世界 + + + + +101/05/01-101/05/08 00:00-23:59 + + +2012年世界狂歡節-環友世界 + + + + +101/05/01-101/05/10 00:00-23:59 + + +2012年世界狂歡節-從政大看台灣 + + + + +101/05/01-101/05/10 08:00-22:00 + + +2012年世界狂歡節-「框」住瞬間「框」住世界 + + + + +101/05/01-101/05/08 00:00-23:59 + + +2012年世界狂歡節-環友世界 + + + + +101/05/01-101/05/10 00:00-23:59 + + +2012年世界狂歡節-從政大看台灣 + + + + +101/05/01-101/05/10 08:00-22:00 + + +2012年世界狂歡節-世界服裝大遊行 + + + + +101/05/07 12:00-13:00 + + +2012年世界狂歡節-環友世界 + + + + +101/05/01-101/05/10 00:00-23:59 + + +2012年世界狂歡節-「框」住瞬間「框」住世界 + + + + +101/05/01-101/05/08 00:00-23:59 + + +2012年世界狂歡節-從政大看台灣 + + + + +101/05/01-101/05/10 08:00-22:00 + + +2012年世界狂歡節-美食嘉年華 + + + + +101/05/08-101/05/10 12:00-14:00 + + +2012年世界狂歡節-開幕式 + + + + +101/05/08 12:10-13:30 + + +2012年世界狂歡節-「原,夜」晚會 + + + + +101/05/08 19:00-21:00 + + +2012年世界狂歡節-環友世界 + + + + +101/05/01-101/05/10 00:00-23:59 + + +2012年世界狂歡節-從政大看台灣 + + + + +101/05/01-101/05/10 08:00-22:00 + + +2012年世界狂歡節-美食嘉年華 + + + + +101/05/08-101/05/10 12:00-14:00 + + +2012年世界狂歡節-環友世界 + + + + +101/05/01-101/05/10 00:00-23:59 + + +2012年世界狂歡節-從政大看台灣 + + + + +101/05/01-101/05/10 08:00-22:00 + + +2012年世界狂歡節-美食嘉年華 + + + + +101/05/08-101/05/10 12:00-14:00 + + +2012年世界狂歡節-閉幕式 + + + + +101/05/10 12:00-13:20 + + +國立政治大學101學年度博士班招生考試 + + + + +101/05/12 07:00-17:00 + + +2012年福祿貝爾恩物親子戲遊成長團體(上午) + + + + +101/04/07-101/06/02 09:00-11:00 + + +2012年福祿貝爾恩物親子戲遊成長團體(下午) + + + + +101/04/07-101/06/09 14:00-16:00 + + +2012年福祿貝爾恩物親子戲遊成長團體(上午) + + + + +101/04/07-101/06/02 09:00-11:00 + + +2012年福祿貝爾恩物親子戲遊成長團體(下午) + + + + +101/04/07-101/06/09 14:00-16:00 + + +2012年福祿貝爾恩物親子戲遊成長團體(上午) + + + + +101/04/07-101/06/02 09:00-11:00 + + +TOEIC英語測驗校園考 + + + + +101/05/26 09:30-12:00 + + +2012年福祿貝爾恩物親子戲遊成長團體(下午) + + + + +101/04/07-101/06/09 14:00-16:00 + diff --git a/public/static/nccu_calendar.xml b/public/static/nccu_calendar.xml new file mode 100644 index 000000000..0a78dc7f5 --- /dev/null +++ b/public/static/nccu_calendar.xml @@ -0,0 +1,64 @@ + + + 國立政治大學校園活動行事曆 + + 本日最新活動 + zh-tw + + 2012年世界狂歡節-「框」住瞬間「框」住世界 + + + + + 101/05/01-101/05/08 00:00-23:59 + + + 2012年世界狂歡節-環友世界 + + + + + 101/05/01-101/05/10 00:00-23:59 + + + 2012年世界狂歡節-從政大看台灣 + + + + + 101/05/01-101/05/10 08:00-22:00 + + + 2012年世界狂歡節-美食嘉年華 + + + + + 101/05/08-101/05/10 12:00-14:00 + + + 2012年世界狂歡節-「原,夜」晚會 + + + + + 101/05/08 19:00-21:00 + + + 2012年世界狂歡節-開幕式 + + + + + 101/05/08 12:10-13:30 + + + 職場講座「數位文本實務課程」 + + + + + 101/04/24-101/05/15 12:20-13:50 + + + diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb new file mode 100644 index 000000000..a41c27acf --- /dev/null +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/approvals_controller.rb @@ -0,0 +1,62 @@ +class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendController + before_filter :authenticate_user! + before_filter :is_admin? + include AdminHelper + # layout 'admin' + def preview_and_approve + @bulletin = Bulletin.find params[:bulletin_id] + end + + # def approve + # + # end + + def setting + @sys_users = User.all(conditions: {admin: false}).includes(:avatar) + @bulletin_categorys = BulletinCategory.all + @options_from_collection_for_select_bulletin_categorys = @bulletin_categorys.collect{|bc| [bc.i18n_variable[I18n.locale],bc.id] } + if params.has_key? :category + @bulletin_category = BulletinCategory.find params[:category][:id] + else + @bulletin_category = @bulletin_categorys.first + end + preload_object_auth = @bulletin_category.get_object_auth_by_title('fact_check') + @users_array = preload_object_auth.privilege_users rescue [] + respond_to do |format| + format.html + format.js + end + end + + def update_setting + object_auth = update_setting_by_params + if object_auth.save! + flash[:notice] = t("admin.object_auth.update_done") + else + flash[:notice] = t("admin.object_auth.update_failed") + end + end + + def user_list + @bulletin_category = BulletinCategory.find params[:category][:id] + end + + protected + def update_setting_by_params + category = BulletinCategory.find params[:category][:id] + privilege_users = params[:users].collect{|key,value| User.find key } rescue [] + object_auth_ary = category.object_auths.where(title: 'fact_check') || (category.object_auths.create :title=> 'fact_check') + object_auth = object_auth_ary.first + object_auth.privilege_users = privilege_users + object_auth + end + + def get_categorys(id = nil) + @bulletin_categorys = [] + if(is_manager? || is_admin?) + @bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.excludes('disabled' => true)) + elsif is_sub_manager? + @bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit_new') + end + end +end diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb index 0e3894b9d..65359763c 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletin_categorys_controller.rb @@ -1,5 +1,7 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendController - + before_filter :for_app_manager,:except => [:index] + + def index @bulletin_categorys = BulletinCategory.all @bulletin_category = BulletinCategory.new(:display => 'List') @@ -53,7 +55,6 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendCo # GET /bulletins/1/edit def edit @bulletin_category = BulletinCategory.find(params[:id]) - @i18n_variable = @bulletin_category.i18n_variable @url = panel_announcement_back_end_bulletin_category_path(@bulletin_category) diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb index e66c51a44..d11ea301f 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb @@ -1,8 +1,9 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController before_filter :authenticate_user! - before_filter :is_admin? - +# before_filter :for_admin_only,:only => [:] +# before_filter :for_app_manager,:only => [:index,:show,] + before_filter :for_app_sub_manager,:except => [:index,:show,:get_sorted_and_filtered_bulletins] def index # @bulletins = Bulletin.all # @bulletins = Bulletin.desc("postdate desc") @@ -30,7 +31,10 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController # @bulletins = Bulletin.search(params[:search], params[:category_id]) # @bulletins = Bulletin.all.order_by([params[:sort], params[:direction]]) - @bulletins = (params[:sort] || @filter) ? get_sorted_and_filtered_bulletins : Bulletin.all.page(params[:page]).per(10) + + + # @bulletins = (params[:sort] || @filter) ? get_sorted_and_filtered_bulletins : Bulletin.all.page(params[:page]).per(10) + @bulletins = (params[:sort] || @filter) ? get_sorted_and_filtered("bulletin") : get_viewable("bulletin") @bulletin_categories = BulletinCategory.all @bulletin_link = BulletinLink.new @@ -38,7 +42,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController @bulletin_file = BulletinFile.new @file_url = panel_announcement_back_end_bulletins_path - + respond_to do |format| format.html # index.html.erb format.js { } @@ -76,25 +80,32 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController # @bulletin.bulletin_files.build # @bulletin.bulletin_files.new - - get_categorys - get_tags - respond_to do |format| - format.html # new.html.erb - format.xml { render :xml => @bulletin } - end + if get_categorys.empty? + flash[:alert] = t("announcement.error.no_avilb_cate_for_posting") + redirect_to :action => :index + else + get_tags + respond_to do |format| + format.html # new.html.erb + format.xml { render :xml => @bulletin } + end + end end # GET /bulletins/1/edit def edit @bulletin = Bulletin.find(params[:id]) - # @summary_variable = @bulletin.summary_variable - - @link_url = panel_announcement_back_end_bulletin_path(@bulletin) - - get_categorys - get_tags + if !current_user.admin? && (@bulletin.is_rejected? || @bulletin.is_checked?) + redirect_to :action => :index + else + # @summary_variable = @bulletin.summary_variable + + @link_url = panel_announcement_back_end_bulletin_path(@bulletin) + + get_categorys + get_tags + end end # POST /bulletins @@ -124,6 +135,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController else @bulletin = Bulletin.new(params[:bulletin]) + @bulletin.deadline = nil if (@bulletin.deadline < @bulletin.postdate rescue nil) @bulletin.create_user_id = current_user.id @bulletin.update_user_id = current_user.id @@ -232,6 +244,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController else @bulletin = Bulletin.find(params[:id]) + @bulletin.deadline = nil if (@bulletin.deadline < @bulletin.postdate rescue nil) @bulletin.update_user_id = current_user.id @@ -243,12 +256,14 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController # end respond_to do |format| - if @bulletin.update_attributes(params[:bulletin]) && @bulletin.save + if @bulletin.update_attributes(params[:bulletin]) # format.html { redirect_to(panel_announcement_back_end_bulletin_url(@bulletin), :notice => t('bulletin.update_bulletin_success')) } format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('bulletin.update_bulletin_success')) } format.js { render 'toggle_enable' } format.xml { head :ok } else + get_tags + get_categorys format.html { render :action => "edit" } format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity } end @@ -294,7 +309,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController if params[:to_delete] bulletins = Bulletin.any_in(:_id => params[:to_delete]).delete_all end - redirect_to panel_announcement_back_end_bulletins_url(:filter => params[:filter], :direction => params[:direction], :sort => params[:sort]) + redirect_to panel_announcement_back_end_bulletins_url(:filter => params[:filter], :direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]) end @@ -302,10 +317,11 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController def get_categorys(id = nil) @bulletin_categorys = [] + #@unit_list_for_anc = UnitListForAnc.all if(is_manager? || is_admin?) @bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.excludes('disabled' => true)) elsif is_sub_manager? - @bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit_new') + @bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit') end end @@ -313,80 +329,5 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController module_app = ModuleApp.first(:conditions => {:key => 'announcement'}) @tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc) end - - def get_sorted_and_filtered_bulletins - bulletins = Bulletin.all - case params[:sort] - when 'postdate', 'deadline' - bulletins = bulletins.order_by([params[:sort], params[:direction]]) - when 'category' - category_ids = bulletins.distinct(:bulletin_category_id) - categories = BulletinCategory.find(category_ids) rescue nil - if categories - h = Hash.new - categories.each { |category| h[category.i18n_variable[I18n.locale]] = category.id } - sorted = params[:direction].eql?('asc') ? h.sort : h.sort.reverse! - sorted_categorys = sorted.collect {|a| bulletins.where(:bulletin_category_id => a[1]).entries } - bulletins = sorted_categorys.flatten! - end - when 'title' - h = Array.new - bulletins.each { |bulletin| h << [bulletin.title[I18n.locale].downcase, bulletin] } - sorted = params[:direction].eql?('asc') ? h.sort : h.sort.reverse! - bulletins = sorted.collect {|a| a[1] } - when 'status' - bulletins = bulletins.order_by(:is_top, params[:direction]).order_by(:is_hot, params[:direction]).order_by(:is_hidden, params[:direction]) - when 'update_user_id' - user_ids = bulletins.distinct(:update_user_id) - users = User.find(user_ids) rescue nil - if users - h = Array.new - users.each { |user| h << [user.name, user.id] } - sorted = params[:direction].eql?('asc') ? h.sort : h.sort.reverse! - sorted_users = sorted.collect {|a| bulletins.where(:update_user_id => a[1]).entries } - bulletins = sorted_users.flatten - end - when 'tags' - a = Array.new - AnnouncementTag.all.order_by(I18n.locale, params[:direction]).each { |tag| a << tag.bulletins } - a.flatten! - a.uniq! - tmp = Array.new - bulletins.where(:tag_ids => []).each { |bulletin| tmp << [bulletin.title[I18n.locale].downcase, bulletin] } - sorted = params[:direction].eql?('asc') ? tmp.sort : tmp.sort.reverse! - sorted_titles = sorted.collect {|a| a[1] } - a = params[:direction].eql?('asc') ? (sorted_titles + a) : (a + sorted_titles) - bulletins = a.flatten - end - if @filter - @filter.each do |key, value| - case key - when 'status' - a = Array.new - bulletins.each do |bulletin| - value.each do |v| - a << bulletin if bulletin[v] - end - end - bulletins = a - when 'categories' - a = Array.new - bulletins.each do |bulletin| - a << bulletin if value.include?(bulletin.bulletin_category.id.to_s) - end - bulletins = a - when 'tags' - a = Array.new - bulletins.each do |bulletin| - bulletin.tags.each do |tag| - a << bulletin if value.include?(tag.id.to_s) - end - end - bulletins = a - end if value.size > 0 - end - end - Kaminari.paginate_array(bulletins).page(params[:page]).per(10) - end end diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/fact_checks_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/fact_checks_controller.rb deleted file mode 100644 index 606225e9d..000000000 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/fact_checks_controller.rb +++ /dev/null @@ -1,75 +0,0 @@ -class Panel::Announcement::BackEnd::FactChecksController < OrbitBackendController - before_filter :authenticate_user! - include AdminHelper - # layout 'admin' - - def setting - @bulletin_categorys = BulletinCategory.all - if params.has_key?(:category_id) - first_category = BulletinCategory.find params[:category_id] - if params[:commit] == 'Update' - privilege_users = params[:users].collect{|key,value| User.find key } rescue [] - preload_object_auth_ary = first_category.object_auths.where(title: 'fact_check') || (first_category.object_auths.create :title=> 'fact_check') - preload_object_auth = preload_object_auth_ary.first - preload_object_auth.privilege_users = privilege_users - preload_object_auth.save! - end - else - first_category = @bulletin_categorys.first - end - preload_object_auth = first_category.object_auths.where(title: 'fact_check').empty?? (first_category.object_auths.create! :title=> 'fact_check') : first_category.object_auths.where(title: 'fact_check') - @users_array = preload_object_auth.first.privilege_users rescue [] - respond_to do |format| - format.html - format.js - end - end - - def update_setting - - end - # def index - # get_categorys(params[:bulletin_category_id]) - # - # @bulletins = params[:sort] ? get_sorted_bulletins : Bulletin.all - # @bulletin_categories = BulletinCategory.all - # - # module_app = ModuleApp.first(:conditions => {:key => 'announcement'}) - # @tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc) - # - # respond_to do |format| - # format.html # index.html.erb - # format.js - # format.xml { render :xml => @bulletins } - # end - # end - # - # def new - # - # end - # - # def create - # - # end - # - # def update - # - # end - # - # def edit - # - # end - # - # def destroy - # - # end - protected - def get_categorys(id = nil) - @bulletin_categorys = [] - if(is_manager? || is_admin?) - @bulletin_categorys = (id ? BulletinCategory.find(id).to_a : BulletinCategory.excludes('disabled' => true)) - elsif is_sub_manager? - @bulletin_categorys = BulletinCategory.authed_for_user(current_user,'submit_new') - end - end -end diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb index 3ba0e666e..9fd97b9b9 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb @@ -11,22 +11,34 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController def index date_now = Time.now - if params[:category_id] - @bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10) + if !params[:category_id].blank? + @bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10) + @current_category = BulletinCategory.from_id(params[:category_id]) rescue nil + elsif !params[:tag_id].blank? + @tag = AnnouncementTag.find(params[:tag_id]) rescue nil + @tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag + @bulletins = @tag.bulletins.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10) else - @bulletins = Bulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10) + @bulletins = Bulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page_main]).per(10) end - - get_categorys - @current_category = BulletinCategory.from_id(params[:category_id]) rescue nil end def show - @bulletin = Bulletin.can_display.where.where(_id: params[:id]) - get_categorys + if params[:preview] == "true" + preview_content + else + @bulletin = Bulletin.can_display.where(_id: params[:id]).first + impressionist(@bulletin) + get_categorys + end + end + def preview_content + @bulletin = Bulletin.find params[:id] + get_categorys + end protected diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb index 96277c5ee..316a715b4 100644 --- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb +++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/widget/bulletins_controller.rb @@ -9,26 +9,28 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController # GET /bulletins.xml def index - - # deadline - # @bulletin_categorys = BulletinCategory.first; - # @bulletins = Bulletin.widget_datas(@bulletin_categorys.id).limit(9) - if params[:category_id] - @bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).widget_datas.limit(9) + @title = params[:part_title] + date_now = Time.now + if !params[:category_id].blank? + @bulletins = Bulletin.can_display.where(:bulletin_category_id => params[:category_id]).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10) + @current_category = BulletinCategory.from_id(params[:category_id]) rescue nil + elsif !params[:tag_id].blank? + @tag = AnnouncementTag.find(params[:tag_id]) rescue nil + @tag = AnnouncementTag.where(key: params[:tag_id])[0] unless @tag + @bulletins = @tag.bulletins.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10) else - @bulletins = Bulletin.can_display.widget_datas.limit(9) + @bulletins = Bulletin.can_display.any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate).page( params[:page]).per(10) end - - get_categorys - + + get_categorys + end def bulletins_and_web_links - @tags = AnnouncementTag.all + @tags = AnnouncementTag.any_in(key: ['students', 'alumni', 'employee', 'guest']) @selected_tag = AnnouncementTag.find(params[:id]) rescue @tags[0] @bulletins = @selected_tag.get_visible_bulletins.can_display.page(params[:page]).per(5) rescue nil @web_links = WebResourceTag.first(:conditions => {:en => @selected_tag[:en]}).get_visible_links.page(params[:page]).per(5) rescue nil - render :layout => 'module_widget' end def reload_bulletins @@ -40,6 +42,11 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController @selected_tag = AnnouncementTag.find(params[:tag_id]) @web_links = WebResourceTag.first(:conditions => {:en => @selected_tag[:en]}).get_visible_links.page(params[:page]).per(5) rescue nil end + + def bulletins_side_bar + @tags = AnnouncementTag.all + get_categorys + end protected diff --git a/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletin_categorys_helper.rb b/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletin_categorys_helper.rb new file mode 100644 index 000000000..926049854 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletin_categorys_helper.rb @@ -0,0 +1,16 @@ +module Panel::Announcement::BackEnd::BulletinCategorysHelper +include ActionView::Helpers::UrlHelper + + + def show_anc_cate_permission_link(bulletin_category) + type = 'submit' + oa = bulletin_category.get_object_auth_by_title(type) + if oa.nil? + bulletin_category.object_auths.new(title: type ).save + oa = bulletin_category.get_object_auth_by_title(type) + end +# link_to t('announcement.bulletin.cate_auth'), edit_admin_object_auth_path(oa) + link_to t('announcement.bulletin.cate_auth'),admin_object_auth_ob_auth_path(oa) + end + +end \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb b/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb new file mode 100644 index 000000000..c384bc8f7 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb @@ -0,0 +1,9 @@ +module Panel::Announcement::BackEnd::BulletinsHelper + + def show_approval_link(bulletin) + by_bulletin = (!bulletin.is_expired? and !bulletin.is_checked?) + by_user = ((bulletin.bulletin_category.authed_users('fact_check').include?(current_user) rescue nil) or is_manager? or is_admin?) + by_bulletin and by_user + end + +end \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/models/bulletin.rb b/vendor/built_in_modules/announcement/app/models/bulletin.rb index 4808b3a9f..589da3208 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin.rb @@ -4,22 +4,29 @@ class Bulletin include Mongoid::Document include Mongoid::Timestamps include Mongoid::MultiParameterAttributes + include Impressionist::Impressionable + + is_impressionable :counter_cache => { :column_name => :view_count } has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy has_one :subtitle, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy has_one :text, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy has_and_belongs_to_many :tags, :class_name => "AnnouncementTag" - field :postdate , :type => Date - field :deadline , :type => Date + field :postdate , :type => DateTime + field :deadline , :type => DateTime # field :url field :create_user_id - field :update_user_id + field :update_user_id, :class_name => "User" field :is_top, :type => Boolean, :default => false field :is_hot, :type => Boolean, :default => false field :is_hidden, :type => Boolean, :default => false - field :is_checked, :type => Boolean, :default => nil + field :is_checked, :type => Boolean, :default => false + field :is_pending, :type => Boolean, :default => true + field :is_rejected, :type => Boolean, :default => false + + field :view_count, :type => Integer, :default => 0 field :not_checked_reason @@ -30,6 +37,7 @@ class Bulletin mount_uploader :image, ImageUploader belongs_to :bulletin_category +# belongs_to :unit_list_for_anc # embeds_many :bulletin_links, :cascade_callbacks => true # embeds_many :bulletin_files, :cascade_callbacks => true @@ -42,7 +50,7 @@ class Bulletin validates_presence_of :title - before_save :set_key + before_save :set_key, :update_status after_save :save_bulletin_links after_save :save_bulletin_files @@ -79,17 +87,6 @@ class Bulletin end - def status - case self.is_checked - when nil - I18n.t('announcement.bulletin.fact_check_pending') - when true - I18n.t('announcement.bulletin.fact_check_pass') - when false - I18n.t('announcement.bulletin.fact_check_not_pass') - end - end - def is_expired? Date.today > self.deadline ? true : false rescue false #some dates might sat as nil so rescue false @@ -110,9 +107,13 @@ class Bulletin def is_checked? self.is_checked end - - def is_check_rejected? - self.is_checked == false + + def is_pending? + self.is_pending + end + + def is_rejected? + self.is_rejected end @@ -159,16 +160,28 @@ class Bulletin protected def set_key - if title.new_record? + if title && title.new_record? title.key = 'title' end - if subtitle.new_record? + if subtitle && subtitle.new_record? subtitle.key = 'subtitle' end - if text.new_record? + if text && text.new_record? text.key = 'text' end end + + def update_status + if !self.is_pending && !self.is_checked + self.is_pending = false + self.is_rejected = true + self.is_checked = false + elsif self.is_checked + self.is_pending = false + self.is_rejected = false + self.is_checked = true + end + end end \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/models/bulletin_category.rb b/vendor/built_in_modules/announcement/app/models/bulletin_category.rb index 7daaf6db0..ff0e0a9cb 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin_category.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin_category.rb @@ -10,7 +10,7 @@ class BulletinCategory # include Mongoid::MultiParameterAttributes PAYMENT_TYPES = [ "List", "Picture" ] - + APP_NAME = 'Announcement' field :key field :display @@ -18,6 +18,10 @@ class BulletinCategory has_many :bulletins + def pp_object + i18n_variable[I18n.locale] + end + def self.from_id(id) BulletinCategory.find(id) rescue nil end diff --git a/vendor/built_in_modules/announcement/app/models/bulletin_file.rb b/vendor/built_in_modules/announcement/app/models/bulletin_file.rb index c4d60b9b8..a30ec1311 100644 --- a/vendor/built_in_modules/announcement/app/models/bulletin_file.rb +++ b/vendor/built_in_modules/announcement/app/models/bulletin_file.rb @@ -29,10 +29,10 @@ class BulletinFile protected def set_key - if filetitle.new_record? + if filetitle && filetitle.new_record? filetitle.key = 'filetitle' end - if description.new_record? + if description && description.new_record? description.key = 'description' end end diff --git a/vendor/built_in_modules/announcement/app/models/bulletin_tag.rb b/vendor/built_in_modules/announcement/app/models/bulletin_tag.rb new file mode 100644 index 000000000..9cb29038b --- /dev/null +++ b/vendor/built_in_modules/announcement/app/models/bulletin_tag.rb @@ -0,0 +1,11 @@ +class AnnouncementTag < Tag + + has_and_belongs_to_many :bulletins + + + def get_visible_bulletins(sort = :name) + date_now = Time.now + self.bulletins.where(:is_hidden => false).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc(:is_top, sort) + end + +end \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/models/unit_list_for_anc.rb b/vendor/built_in_modules/announcement/app/models/unit_list_for_anc.rb new file mode 100644 index 000000000..5261f6a2a --- /dev/null +++ b/vendor/built_in_modules/announcement/app/models/unit_list_for_anc.rb @@ -0,0 +1,12 @@ +class UnitListForAnc + include Mongoid::Document + include Mongoid::Timestamps + + field :order + field :ut_code + field :up_ut_code + + has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true + + +end \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_modal_approve.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_modal_approve.html.erb new file mode 100644 index 000000000..35049b981 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_modal_approve.html.erb @@ -0,0 +1,69 @@ + <% if bulletin -%> + +
    + + + +<% end -%> diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_modal_list.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_modal_list.html.erb new file mode 100644 index 000000000..e51a11d65 --- /dev/null +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/approvals/_modal_list.html.erb @@ -0,0 +1,44 @@ +<% if bulletin_category -%> + + \ No newline at end of file +
    + +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "sort_header" %> +<% end %> \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_filter_categories.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_filter_categories.html.erb index 7ffb08f57..7856f74b4 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_filter_categories.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_filter_categories.html.erb @@ -1,6 +1,6 @@
    <% @bulletin_categories.each do |category| -%> - <%= link_to category.i18n_variable[I18n.locale], panel_announcement_back_end_bulletins_path(:filter => @filter, :new_filter => {:type => 'categories', :id => category.id}, :sort => params[:sort], :direction => params[:direction]), :class => "btn js_history#{is_filter_active?('categories', category.id)}" %> + <%= link_to category.i18n_variable[I18n.locale], panel_announcement_back_end_bulletins_path(:filter => @filter, :new_filter => {:type => 'categories', :id => category.id}, :sort => params[:sort], :direction => params[:direction], :sort_options => params[:sort_options]), :class => "btn js_history#{is_filter_active?('categories', category.id)}" %> <% end -%>
    <%= render :partial => 'clear_filters', :locals => {:type => 'categories'} %> \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_filter_status.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_filter_status.html.erb index 15a982c11..6adba1415 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_filter_status.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_filter_status.html.erb @@ -1,7 +1,9 @@
    - <%= link_to t(:is_top), panel_announcement_back_end_bulletins_path(:filter => @filter, :new_filter => {:type => 'status', :id => 'is_top'}, :sort => params[:sort], :direction => params[:direction]), :class => "btn js_history#{is_filter_active?('status', 'is_top')}" %> - <%= link_to t(:is_hot), panel_announcement_back_end_bulletins_path(:filter => @filter, :new_filter => {:type => 'status', :id => 'is_hot'}, :sort => params[:sort], :direction => params[:direction]), :class => "btn js_history#{is_filter_active?('status', 'is_hot')}" %> - <%= link_to t(:is_hidden), panel_announcement_back_end_bulletins_path(:filter => @filter, :new_filter => {:type => 'status', :id => 'is_hidden'}, :sort => params[:sort], :direction => params[:direction]), :class => "btn js_history#{is_filter_active?('status', 'is_hidden')}" %> - <%= link_to t(:is_checked), panel_announcement_back_end_bulletins_path(:filter => @filter, :new_filter => {:type => 'status', :id => 'is_checked'}, :sort => params[:sort], :direction => params[:direction]), :class => "btn js_history#{is_filter_active?('status', 'is_checked')}" %> + <%= link_to t(:top), panel_announcement_back_end_bulletins_path(:filter => @filter, :new_filter => {:type => 'status', :id => 'is_top'}, :sort => params[:sort], :direction => params[:direction], :sort_options => params[:sort_options]), :class => "btn js_history#{is_filter_active?('status', 'is_top')}" %> + <%= link_to t(:hot), panel_announcement_back_end_bulletins_path(:filter => @filter, :new_filter => {:type => 'status', :id => 'is_hot'}, :sort => params[:sort], :direction => params[:direction], :sort_options => params[:sort_options]), :class => "btn js_history#{is_filter_active?('status', 'is_hot')}" %> + <%= link_to t(:hidden), panel_announcement_back_end_bulletins_path(:filter => @filter, :new_filter => {:type => 'status', :id => 'is_hidden'}, :sort => params[:sort], :direction => params[:direction], :sort_options => params[:sort_options]), :class => "btn js_history#{is_filter_active?('status', 'is_hidden')}" %> + <%= link_to t(:pending), panel_announcement_back_end_bulletins_path(:filter => @filter, :new_filter => {:type => 'status', :id => 'is_pending'}, :sort => params[:sort], :direction => params[:direction], :sort_options => params[:sort_options]), :class => "btn js_history#{is_filter_active?('status', 'is_pending')}" %> + <%= link_to t(:passed), panel_announcement_back_end_bulletins_path(:filter => @filter, :new_filter => {:type => 'status', :id => 'is_checked'}, :sort => params[:sort], :direction => params[:direction], :sort_options => params[:sort_options]), :class => "btn js_history#{is_filter_active?('status', 'is_checked')}" %> + <%= link_to t(:rejected), panel_announcement_back_end_bulletins_path(:filter => @filter, :new_filter => {:type => 'status', :id => 'is_rejected'}, :sort => params[:sort], :direction => params[:direction], :sort_options => params[:sort_options]), :class => "btn js_history#{is_filter_active?('status', 'is_rejected')}" %>
    <%= render :partial => 'clear_filters', :locals => {:type => 'status'} %> \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_filter_tags.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_filter_tags.html.erb index b2f118344..b3771a1a6 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_filter_tags.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_filter_tags.html.erb @@ -1,6 +1,6 @@
    <% @tags.each do |tag| -%> - <%= link_to tag[I18n.locale], panel_announcement_back_end_bulletins_path(:filter => @filter, :new_filter => {:type => 'tags', :id => tag.id}, :sort => params[:sort], :direction => params[:direction]), :class => "btn js_history#{is_filter_active?('tags', tag.id)}" %> + <%= link_to tag[I18n.locale], panel_announcement_back_end_bulletins_path(:filter => @filter, :new_filter => {:type => 'tags', :id => tag.id}, :sort => params[:sort], :direction => params[:direction], :sort_options => params[:sort_options]), :class => "btn js_history#{is_filter_active?('tags', tag.id)}" %> <% end -%>
    <%= render :partial => 'clear_filters', :locals => {:type => 'tags'} %> \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb index ef437e4da..c515dc656 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_form.html.erb @@ -4,23 +4,31 @@ <%= f.error_messages %>
    -
    +

    Picture

    - - -
    -
    + +
    @@ -40,13 +50,13 @@
    - <%= f.date_select :postdate, {:use_month_numbers => true, :prompt => { :month => 'Month', :day => 'Day', :year => 'Year'}, :order => [:day, :month, :year] }, {:class => 'input-small'} %> + <%= f.datetime_select :postdate, {:use_month_numbers => true, :order => [:day, :month, :year] }, {:class => 'span1'} %>
    - <%= f.date_select :deadline, {:use_month_numbers => true, :prompt => { :month => 'Month', :day => 'Day', :year => 'Year'}, :order => [:day, :month, :year] }, {:class => 'input-small'} %> + <%= f.datetime_select :deadline, {:use_month_numbers => true, :prompt => { :month => 'Month', :day => 'Day', :year => 'Year'}, :order => [:day, :month, :year] }, {:class => 'span1'} %>
    @@ -81,42 +91,22 @@

    Tags

    - <% @tags.each do |tag| %> - <%= content_tag :label,:class => "checkbox inline" do -%> - <%= check_box_tag 'bulletin[tag_ids][]', tag.id, @bulletin.tag_ids.include?(tag.id)%> - <%= tag[I18n.locale] %> +

    + <% @tags.each do |tag| %> + <%= content_tag :label,:class => "checkbox inline" do -%> + <%= check_box_tag 'bulletin[tag_ids][]', tag.id, @bulletin.tag_ids.include?(tag.id)%> + <%= tag[I18n.locale] %> + <% end %> <% end %> - <% end %> +

    -
    +
    <% if params[:action] != 'new' %>
    -

    Audit

    -
    - - <% if is_manager? || @bulletin.bulletin_category.authed_users('fact_check').include?(current_user) || current_user.admin? %> -
    - <%= f.label :fact_check_stat, t('announcement.bulletin.fact_check_stat') %> - <%= content_tag :label,:class => "radio inline" do -%> - <%= f.radio_button :is_checked, true , {:class => 'privacy'} %> - <%= t('announcement.bulletin.fact_check_pass') %> - <% end -%> - <%= content_tag :label,:class => "radio inline" do -%> - <%= f.radio_button :is_checked, false, (@bulletin.is_checked.nil?? {:checked => true, :class => 'privacy'} : {})%> - <%= t('announcement.bulletin.fact_check_not_pass') %> - <% end -%> -
    - <%= label :is_checked_false, t('announcement.bulletin.fact_check_not_pass_reason') %> - <%= f.text_field :not_checked_reason %> -
    - -
    - <% end %> -
    <% elsif current_user.admin? %> <%= f.hidden_field :is_checked,:value => true%> @@ -129,11 +119,15 @@
    + + <%#= f.label :unit_list_for_anc%> + <%#= f.select :unit_list_for_anc_id,@unit_list_for_anc.collect{|t| [ t.title[I18n.locale], t.id ]}, {}, :class => "input-medium" %> <%= f.label :category %> <%= f.select :bulletin_category_id, @bulletin_categorys.collect{|t| [ t.i18n_variable[I18n.locale], t.id ]}, {}, :class => "input-medium" %>