From 8dd1ab32c144b1fb22e76282e83c42160d68881f Mon Sep 17 00:00:00 2001 From: "Matthew K. Fu JuYuan" Date: Mon, 4 Jun 2012 16:51:29 +0800 Subject: [PATCH] Add this toolbar, and nccu calendar fix --- Gemfile.lock | 2 ++ app/jobs/backup_server.rb | 4 ++++ app/jobs/nccu_calendar.rb | 14 ++++++++++---- app/views/shared/_addthis_toolbox | 14 ++++++++++++++ config/dump.rdb | Bin 1474 -> 0 bytes config/locales/en.yml | 3 ++- config/locales/zh_tw.yml | 2 ++ config/mongoid.yml | 4 ++-- config/resque.god | 2 +- dump.rdb | Bin 716 -> 0 bytes lib/resque_ext.rb | 8 ++++++++ .../front_end/bulletins/show.html.erb | 2 +- .../news/front_end/news_bulletins/show.html.erb | 2 +- 13 files changed, 47 insertions(+), 10 deletions(-) create mode 100644 app/views/shared/_addthis_toolbox delete mode 100644 config/dump.rdb delete mode 100644 dump.rdb create mode 100644 lib/resque_ext.rb diff --git a/Gemfile.lock b/Gemfile.lock index 776d0b32..e21da804 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -168,6 +168,7 @@ GEM rdoc (~> 3.4) thor (~> 0.14.6) rake (0.9.2.2) + rb-readline (0.4.2) rdoc (3.12) json (~> 1.4) redis (2.2.2) @@ -301,6 +302,7 @@ DEPENDENCIES radius rails (>= 3.1.0, < 3.2.0) rake + rb-readline resque resque-restriction resque-scheduler diff --git a/app/jobs/backup_server.rb b/app/jobs/backup_server.rb index f76eaac8..f600d342 100644 --- a/app/jobs/backup_server.rb +++ b/app/jobs/backup_server.rb @@ -3,6 +3,10 @@ class BackupServer def self.perform() CronMail.time_check("Going to backup Orbit").deliver + dbhost = Mongoid.config.database.connection.primary.join ':' + dbname = Mongoid.config.database.name + dbdirectory = "#{Rails.root}/tmp/#{dbname}-"+Time.now.strftime("%Y-%m-%d-%H-%M") + %x[mongodump -h dbhost -d dbname -o dbdirectory ] # %x[touch #{Rails.root}/tmp/restart] end end diff --git a/app/jobs/nccu_calendar.rb b/app/jobs/nccu_calendar.rb index ffd89ca8..e0676627 100644 --- a/app/jobs/nccu_calendar.rb +++ b/app/jobs/nccu_calendar.rb @@ -5,11 +5,17 @@ class NccuCalendar @queue = :high def self.perform() - temp_file = Tempfile.new('new_cal') - temp_file << open('http://events.nccu.edu.tw/Month').read + # temp_file = Tempfile.new('new_cal') + # open('http://events.nccu.edu.tw/Month').read{|data| + # temp_file << data + # } - FileUtils.mv(temp_file, File.join(Rails.root, 'public/static', 'nccu_calendar.xml')) +open(File.join(Rails.root, 'public/static', 'nccu_calendar.xml'), 'wb') do |fo| + fo.print open('http://events.nccu.edu.tw/Month').read +end - puts "NccuCalendar Synced" + # FileUtils.mv(temp_file, File.join(Rails.root, 'public/static', 'nccu_calendar.xml')) + + puts "NccuCalendar Synced4" end end diff --git a/app/views/shared/_addthis_toolbox b/app/views/shared/_addthis_toolbox new file mode 100644 index 00000000..c58ff2eb --- /dev/null +++ b/app/views/shared/_addthis_toolbox @@ -0,0 +1,14 @@ + +
+<%= t("addthis_tools.add_to_bookmark")%> +| + + + + + +
+ + + diff --git a/config/dump.rdb b/config/dump.rdb deleted file mode 100644 index 3e3002a93aaf0d4a4ed5f79d8657491d9cb10478..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1474 zcmdVaO>Y}T7zgm#b>6mVc&XF|Bt#|?+mXQbzI2^5qe?hVT*1LUG@u@mbUnMC*n@X> zmYH!v+6E51_vwsQjQu@fH_dDx~&OM3gELCa^Q_I1YXTTs+w!6;U`5JfKq2*1R7f@w8}-h3~d{`3)n5gH?1p{^>>G-Z*Zp5 zfuT*DWF6l|e^@2gzMQ&^j!TaygwY_zw94in#=-VHzC2lmODpf90!qks$Vm&~+b9T$ zl&~<~2!h@c32EFS0#55hwBf~x)%BeMq8|n{QH;lx+&NySs>53~A$TPZXmj*DM!mR2 zH&{$tFltU+fX&tQS-8Okj9G{qEL;jJ8|MnhCqY*U5>U7{h0OP4e*|WiFvZPf9`qs_ zD{0oZZ}f*F6F^~p*yO@z>i+N$NfI-vq$9!%1dqMS_+&}=*q*~IhRrrro}@~#xGiU4 zH+}1-<}5UC8j3~K3pzCDrekZbmBeObwrM0y(et;9c4?vH6ccB`s)$|)?~MjL@;a2X zc4ssaEY?9XZA=s|m+X>jhRipKFBd1rlo#+=2_9CCGCq-X_eU__+#5ZC;=%m%y|lBh zId+=aPrZ+TK%Z+=OfN4Qnp;lazFS@Hmxr0p$hyCVIvNjW>RQ4ocfefQx$_;+-FY`{ z|C)kZVD9ek28)?uBxJYf;nm*`FZEKe1Ii!&pvQD8?QVYZXvmA0lxQ~{+dF#w!SMUs zmu8&vG%xt7S*?RBM|K_ay9Go5g-<)ZJqE+xrXN~9POz%6(zOvuU-mj5r@T^U jmoYlcDEsJ`k^6*^{^au-=%P{^8t4KS&VI57#-D!y*_-Rn diff --git a/config/locales/en.yml b/config/locales/en.yml index cb638475..fd08be49 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -46,7 +46,8 @@ en: view: View view_count: View count yes_: "Yes" - + addthis_tools: + add_to_bookmark: Add this to bookmark all_content: All Content all_file: All File all_member: All Member diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 0b06f844..0eb12ba1 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -44,6 +44,8 @@ zh_tw: view_count: 查看次數 yes_: "Yes" + addthis_tools: + add_to_bookmark: 加入書籤 all_content: 全部內容有 all_file: 全部檔案有 all_member: 成員總數 diff --git a/config/mongoid.yml b/config/mongoid.yml index f333e2e6..16405831 100644 --- a/config/mongoid.yml +++ b/config/mongoid.yml @@ -8,7 +8,7 @@ defaults: &defaults development: <<: *defaults - database: prototype_r4_development + database: prototype_r4_ldap0229 test: <<: *defaults @@ -22,4 +22,4 @@ production: # password: <%= ENV['MONGOID_PASSWORD'] %> # database: <%= ENV['MONGOID_DATABASE'] %> <<: *defaults - database: prototype_r4_development + database: prototype_r4_ldap0229 diff --git a/config/resque.god b/config/resque.god index 6c4e4bde..6f331dd8 100644 --- a/config/resque.god +++ b/config/resque.god @@ -1,5 +1,5 @@ rails_env = 'development' #ENV['RAILS_ENV'] || "production" -rails_root = ENV['RAILS_ROOT'] || "/Users/kaito/Documents/MyWorkspeace/orbit/orbit" +rails_root = ENV['RAILS_ROOT'] || "/Users/kaito/Documents/MyWorkspeace/NCCU" num_workers = rails_env == 'production' ? 5 : 2 num_workers.times do |num| diff --git a/dump.rdb b/dump.rdb deleted file mode 100644 index 748293b8fe7d0506c035ed140046de46e5d7b109..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 716 zcmaKqKTpFj6vUm-l?4fj0f8_b8SFMS#VaimO9#S+7+mMkL~{RNC!$r=?-sro)I|}^ z^1R;9clRXU%XsvhGRF81iEb>o&kAI!bI2+KcDz>el>zBRFPr68biJk8DCel8Pf+Uo zwU`6Fqsq>_^!C1sPn(QCi;FvXG0RW9lbkicm8z5qoVRaU*`)^OAp7oi(C!4kiysn^HXiZ~P~VW@O!PyUB9MtQ!S4e; soC!WeeS$yKB%;Cpl82SV^ti2w*43jju*j5c&+GE|B;73ZXxfIqd)@ZyTL1t6 diff --git a/lib/resque_ext.rb b/lib/resque_ext.rb new file mode 100644 index 00000000..9717aa9c --- /dev/null +++ b/lib/resque_ext.rb @@ -0,0 +1,8 @@ +module ResqueExt + # + # ResqueExt.unregister_workers_for_host("ec210-250-192-51") + # + def self.unregister_workers_for_host(host) + Resque.workers.select{|worker| worker.id.split(':').first==host}.each(&:unregister_worker) + end +end \ No newline at end of file diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb index 2ece4b02..24c61043 100644 --- a/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb +++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/front_end/bulletins/show.html.erb @@ -39,5 +39,5 @@ <% end %>
- + <%= render "shared/addthis_toolbox"%>
diff --git a/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb b/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb index df391c54..32660567 100644 --- a/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb +++ b/vendor/built_in_modules/news/app/views/panel/news/front_end/news_bulletins/show.html.erb @@ -40,5 +40,5 @@
- + <%= render "shared/addthis_toolbox"%>