diff --git a/app/assets/images/announcement-default.jpg b/app/assets/images/announcement-default.jpg
new file mode 100644
index 0000000..b6b82f0
Binary files /dev/null and b/app/assets/images/announcement-default.jpg differ
diff --git a/app/controllers/announcements_controller.rb b/app/controllers/announcements_controller.rb
index 92acbdb..64bc8d8 100644
--- a/app/controllers/announcements_controller.rb
+++ b/app/controllers/announcements_controller.rb
@@ -1,4 +1,5 @@
class AnnouncementsController < ApplicationController
+ ViewRootDir = File.expand_path("../../views", __FILE__)
include AnnouncementsHelper
DefaultImgSrc = "/assets/announcement-default.jpg\" onerror=\"this.src="/assets/announcement-default-2.jpg";this.onerror='';"
def initialize
@@ -29,6 +30,12 @@ class AnnouncementsController < ApplicationController
AnnouncementSetting.first.enable_manually_sort rescue false
end
end
+ def render_400
+ render(:file => "#{ViewRootDir}/announcements/400.html", :layout => false, :status => 400, :formats => [:html])
+ end
+ def render_404
+ render(:file => "#{Rails.root}/app/views/errors/404.html", :layout => false, :status => 404, :formats => [:html])
+ end
def comment
@bulletin = Bulletin.where(:uid=>params[:uid]).first
comment_val = params['comment']
@@ -38,6 +45,8 @@ class AnnouncementsController < ApplicationController
b.bulletin_id = @bulletin.id
b.save
render :json => {}
+ else
+ render_404
end
end
def index
@@ -1018,6 +1027,15 @@ class AnnouncementsController < ApplicationController
},
"total_pages" => total_pages
}
+ @layout_type = params[:layout_type]
+ if @layout_type.blank?
+ @layout_type = 'annc_index1'
+ else
+ @layout_type = @layout_type.to_s
+ if File.dirname(@layout_type) != '.'
+ render_400 and return
+ end
+ end
render :layout => false
end
diff --git a/app/views/announcements/400.html b/app/views/announcements/400.html
new file mode 100644
index 0000000..f84cc9f
--- /dev/null
+++ b/app/views/announcements/400.html
@@ -0,0 +1,63 @@
+
+
+
+
+ Bad Request
+
+
+
+
+
+
+ 400
+ Bad Request
+ Your request is invalid,
+ get back to your home planet by clicking here!
+
+
+
+
\ No newline at end of file
diff --git a/temp_file/config/application.rb b/temp_file/config/application.rb
index 5621d83..a06f663 100644
--- a/temp_file/config/application.rb
+++ b/temp_file/config/application.rb
@@ -170,6 +170,20 @@ else
self.to_bson_key.bson_int64?
end
end
+ if Mongoid::VERSION.to_i >= 7
+ begin
+ require 'mongoid/association/relatable'
+ module Mongoid::Association::Relatable
+ alias_method :org_initialize, :initialize
+ attr_reader :macro
+ def initialize(*args, &block)
+ @macro = self.class.to_s.demodulize.underscore.to_sym
+ org_initialize(*args, &block)
+ end
+ end
+ rescue ScriptError => e
+ end
+ end
end
module Mongoid
module Findable
@@ -248,7 +262,10 @@ module Orbit
alias_method :org_call, :call
def call(env)
request = ActionDispatch::Request.new(env)
- request_path = env["REQUEST_PATH"].to_s.sub(/^\/#{I18n.locale}\//, '/')
+ request_path = env["REQUEST_PATH"].to_s
+ I18n.available_locales.each do |locale|
+ request_path = request_path.sub(/^\/#{locale}\//, '/')
+ end
session = env["rack.session"]
if (Site::DEBUG rescue false) || (Rails.env != "production" && request_path.start_with?('/admin') && (@current_user = (session[:user_id] ? User.find(session[:user_id]) : nil) rescue nil))
exception = env['action_dispatch.exception']
diff --git a/temp_file/config/boot.rb b/temp_file/config/boot.rb
new file mode 100644
index 0000000..d01d340
--- /dev/null
+++ b/temp_file/config/boot.rb
@@ -0,0 +1,5 @@
+# Set up gems listed in the Gemfile.
+puts 'boot'
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
+
+require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
diff --git a/temp_file/config/do_on_startup.rb b/temp_file/config/do_on_startup.rb
new file mode 100644
index 0000000..c18d3eb
--- /dev/null
+++ b/temp_file/config/do_on_startup.rb
@@ -0,0 +1,726 @@
+OrbitApp.cleanup_modules
+begin
+ OrbitApp.check_module_permissions
+rescue Exception => e
+end
+include BundlerHelper
+current_locale = I18n.locale
+extra_langs = File.read('config/extra_lang.txt').scan(/.*extra_.*/).select{|v| v.exclude? '#'}[0].to_s.split(/extra_language.*:|,| /).select{|v| !v.empty?}.map{|v| v.to_sym} rescue []
+
+site = Site.first
+if (site.password_failed_lock_num.nil? rescue false)
+ site.update({:password_failed_lock_num=> site.fields['password_failed_lock_num'].options[:default]})
+end
+site.reset_cache
+if ModuleApp.where(:key=>'member_sign_up').count > 1
+ ModuleApp.where(:key=>'member_sign_up')[0...1].each{|m| m.destroy}
+end
+
+if (site.page_sets.count==0 rescue false)
+ site.page_sets.create()
+elsif site.page_sets.count > 1
+ site.page_sets.skip(1).destroy
+end
+$member_extra_url = site.member_extra_url
+if File.basename($0) != 'rake'
+ crontab_email=%x[crontab -l|grep 'bundle exec rake email:deliver_all'|grep `pwd`]
+ crontab_email_all = crontab_email.split("\n")
+ if crontab_email_all.count >= 1
+ crontab_jobs=%x[crontab -l|grep -v "cd `pwd`.*bundle exec rake email:deliver_all"].gsub(/^\n$/,'').gsub(/'/,"'\"'\"'")
+ system("echo '#{crontab_jobs}' | crontab -")
+ end
+ CronWorker.cron_every_minute(Email.method(:deliver_all))
+ nginx_exe = %x[ps -o args -C nginx| grep -E 'daemon|master'| awk '{print $4}'].split("\n")[0]
+ if !nginx_exe.nil?
+ nginx_config = %x[#{nginx_exe} -V 2>&1 | grep -o '\\-\\-conf-path=\\(.*conf\\)' | cut -d '=' -f2].sub("\n",'')
+ orbit_sites_config = %x[grep orbit_sites #{nginx_config}].scan(/^[\t ]*include(.*);/)[0][0].gsub(/ /,'')
+ current_site_config = %x[grep -H `pwd` #{orbit_sites_config}|grep -E ':\s\+root'].split(':')[0]
+ current_site_config_content = current_site_config.present? ? %x[cat #{current_site_config}] : ""
+ config_domain = site.site_settings['domain'] rescue nil
+ server_names = current_site_config_content.scan(/^[\t ]*server_name[\t ]*(.*);/).flatten.collect{|v| v.to_s.split(/[\t ]+/)}.flatten.sort_by{|v| v==config_domain ? 0 : v.split(".").count}.reverse
+ ip = UDPSocket.open {|s| s.connect("8.8.8.8", 1); s.addr.last} rescue nil
+ new_server_names = server_names.uniq.select{|server_name| ip == (IPSocket.getaddress(server_name) rescue nil)}
+ server_name = new_server_names.select{|server_name| ip != server_name}.first
+ if server_name.nil?
+ if new_server_names.count != 0
+ server_name = new_server_names.first
+ else
+ server_name = server_names.first
+ if server_name.nil?
+ server_name = ip || (`ip route get 8.8.8.8|xargs|awk '{print $7}'`.strip)
+ end
+ end
+ end
+ ports = current_site_config_content.scan(/^[\t ]*listen[\t ]*(.*);/).flatten.collect{|v| v.split(/[\t ]+/)}.flatten.select{|v| v.to_i.to_s == v}
+ port = ports.blank? ? '80' : (ports.select{|v| v=='443'}.blank? ? ports.sort_by{|v| v.to_i==80 ? -1 : v.to_i}[0] : '443')
+ root_url = (port=='443' ? "https://#{server_name}" : (port=='80' ? "http://#{server_name}" : "http://#{server_name}:#{port}"))
+ site.update_attributes(root_url: root_url)
+ end
+ if ShowForAdminMessage.first.nil?
+ ShowForAdminMessage.create()
+ end
+
+ if site.template.nil?
+ site.template = (Dir.glob("#{Rails.root}/app/templates/*").collect{|temp| temp.split('/').last}-['mobile']).first
+ site.save
+ end
+
+ if Page.count == 0
+ home = Page.new
+ extra_trans = {}
+ extra_langs.each do |extra_lang|
+ extra_trans[extra_lang] = 'Home'
+ end
+ home.name_translations = {:en=>"Home",:zh_tw=>"首頁"}.merge(extra_trans)
+ home.url = "/"
+ home.save
+ end
+
+ if Page.where(:module=>"sitemap").blank?
+ sitemap = Page.new
+ sitemap.module = "sitemap"
+ sitemap.page_id = "sitemap"
+ extra_trans = {}
+ extra_langs.each do |extra_lang|
+ extra_trans[extra_lang] = 'Sitemap'
+ end
+ sitemap.name_translations = {:en=>"Sitemap",:zh_tw=>"網站導覽"}.merge(extra_trans)
+ sitemap.enabled_for = ["en", "zh_tw"]
+ sitemap.menu_enabled_for = []
+ sitemap.url = "/sitemap"
+ sitemap.parent_page_id = Page.root.id
+ sitemap.save
+ end
+ termofuse = Page.where(:page_id=>'termofuse').first
+ page = termofuse.page_contexts.order(:version=>-1).first rescue nil
+ default_content_translations = {}
+ ac = ActionController::Base.new()
+ site.in_use_locales.each do |locale|
+ I18n.with_locale(locale) do
+ content = ac.render_to_string(:partial=>"pages/default_term_of_use",locals: {:current_site=>site})
+ default_content_translations[locale] = content
+ end
+ end
+ if page.nil?
+ page = PageContext.new
+ extra_trans = {}
+ extra_langs.each do |extra_lang|
+ extra_trans[extra_lang] = ''
+ end
+ page.content_translations = default_content_translations
+ page.version = 1
+ page.save
+ else
+ change_flag = false
+ new_content_translations = {}
+ site.in_use_locales.each do |locale|
+ if page.content_translations[locale].blank?
+ change_flag = true
+ new_content_translations[locale] = default_content_translations[locale]
+ end
+ end
+ if change_flag
+ page.content_translations = page.content_translations.merge(new_content_translations)
+ page.save
+ end
+ end
+ if termofuse.nil?
+ termofuse = Page.new
+ termofuse.module = "page_content"
+ termofuse.page_id = "termofuse"
+ termofuse.page_contexts << page
+ extra_trans = {}
+ extra_langs.each do |extra_lang|
+ extra_trans[extra_lang] = 'Term of use'
+ end
+ termofuse.name_translations = {:en=>"Term of use",:zh_tw=>"使用規則"}.merge(extra_trans)
+ termofuse.enabled_for = ["en", "zh_tw"]
+ termofuse.menu_enabled_for = []
+ termofuse.url = "/termofuse"
+ termofuse.parent_page_id = Page.root.id
+ termofuse.save
+ site.terms_of_use_link = "/termofuse"
+ site.save
+ end
+
+ if Workgroup.count == 0
+ groups = [{"title"=>"Administrator", "key"=>"admin"},
+ {"title"=>"Sub Managers", "key"=>"sub_managers"},
+ {"title"=>"Managers", "key"=>"managers"}]
+ groups.each do |group|
+ workgroup = Workgroup.new
+ workgroup.title = group["title"]
+ workgroup.key = group["key"]
+ workgroup.save
+ end
+ end
+
+ if Role.count==0
+
+ #teacher
+ role = Role.new
+ role.key = 'teacher'
+ role.title_translations = {:en=>'Teacher', :zh_tw=>'老師'}
+ role.save
+
+ role_status = RoleStatus.new
+ role_status.key = 'Full-Time'
+ role_status.role_id = role.id
+ role_status.title_translations = {:en=>'Full-Time', :zh_tw=>'專任'}
+ role_status.save
+
+ role_status = RoleStatus.new
+ role_status.key = 'Adjunct'
+ role_status.role_id = role.id
+ role_status.title_translations = {:en=>'Adjunct', :zh_tw=>'兼任'}
+ role_status.save
+
+ role_status = RoleStatus.new
+ role_status.key = 'appointment'
+ role_status.role_id = role.id
+ role_status.title_translations = {:en=>'appointment', :zh_tw=>'合聘'}
+ role_status.save
+
+ attribute_field = AttributeField.new
+ attribute_field.key = 'job_title'
+ attribute_field.role_id = role.id
+ attribute_field.title_translations = {:en=>'Job Title', :zh_tw=>'職稱'}
+ attribute_field.markup = 'select'
+ attribute_field.option_list = {
+ "0" => { "zh_tw" => "教授兼系主任",
+ "en" => "Professor and Chairman" },
+ "1" => { "zh_tw" => "教授",
+ "en" => "Professor" },
+ "2" => { "zh_tw" => "副教授",
+ "en" => "Associate Professor" },
+ "3" => { "zh_tw" => "助理教授",
+ "en" => "Assistant Professor" },
+ "4" => { "zh_tw" => "講師",
+ "en" => "Lecturer" }
+ }
+
+ attribute_field.typeB = {
+ "initial" => { "zh_tw" => "",
+ "en" => "" },
+ "option_list" => {
+ "0" => { "zh_tw" => "教授兼系主任",
+ "en" => "Professor and Chairman" },
+ "1" => { "zh_tw" => "教授",
+ "en" => "Professor" },
+ "2" => { "zh_tw" => "副教授",
+ "en" => "Associate Professor" },
+ "3" => { "zh_tw" => "助理教授",
+ "en" => "Assistant Professor" },
+ "4" => { "zh_tw" => "講師",
+ "en" => "Lecturer" }
+ } }
+
+ attribute_field.save
+
+ attribute_field = AttributeField.new
+ attribute_field.key = 'Research_Expertise'
+ attribute_field.role_id = role.id
+ attribute_field.title_translations = {:en=>'Research Expertise', :zh_tw=>'研究專長'}
+ attribute_field.markup = 'text_area'
+ attribute_field.save
+
+ attribute_field = AttributeField.new
+ attribute_field.key = 'Teaching_Field'
+ attribute_field.role_id = role.id
+ attribute_field.title_translations = {:en=>'Teaching Field', :zh_tw=>'授課領域'}
+ attribute_field.markup = 'text_area'
+ attribute_field.save
+
+ #satff
+ role = Role.new
+ role.key = 'staff'
+ role.title_translations = {:en=>'Staff', :zh_tw=>'行政人員'}
+ role.save
+
+ role_status = RoleStatus.new
+ role_status.key = 'Full-Time'
+ role_status.role_id = role.id
+ role_status.title_translations = {:en=>'Full-Time', :zh_tw=>'全職'}
+ role_status.save
+
+ role_status = RoleStatus.new
+ role_status.key = 'Part-time'
+ role_status.role_id = role.id
+ role_status.title_translations = {:en=>'Part-time', :zh_tw=>'兼職'}
+ role_status.save
+
+ role_status = RoleStatus.new
+ role_status.key = 'Contracted'
+ role_status.role_id = role.id
+ role_status.title_translations = {:en=>'Contracted', :zh_tw=>'約聘'}
+ role_status.save
+
+ attribute_field = AttributeField.new
+ attribute_field.key = 'job_title'
+ attribute_field.role_id = role.id
+ attribute_field.title_translations = {:en=>'Job Title', :zh_tw=>'職稱'}
+ attribute_field.markup = 'select'
+ attribute_field.option_list = {
+ "0" => { "zh_tw" => "組長",
+ "en" => "Group Leader" },
+ "1" => { "zh_tw" => "編審",
+ "en" => "Editor" },
+ "2" => { "zh_tw" => "技士",
+ "en" => "Technician" },
+ "3" => { "zh_tw" => "幹事",
+ "en" => "Assistant" },
+ "4" => { "zh_tw" => "組員",
+ "en" => "Clerk" } ,
+ "5" => { "zh_tw" => "工讀",
+ "en" => "Work-study" }
+ }
+
+ attribute_field.typeB = {
+ "initial" => { "zh_tw" => "",
+ "en" => "" },
+ "option_list" => {
+ "0" => { "zh_tw" => "組長",
+ "en" => "Group Leader" },
+ "1" => { "zh_tw" => "編審",
+ "en" => "Editor" },
+ "2" => { "zh_tw" => "技士",
+ "en" => "Technician" },
+ "3" => { "zh_tw" => "幹事",
+ "en" => "Assistant" },
+ "4" => { "zh_tw" => "組員",
+ "en" => "Clerk" } ,
+ "5" => { "zh_tw" => "工讀",
+ "en" => "Work-study" }
+ } }
+
+ attribute_field.save
+
+ attribute_field = AttributeField.new
+ attribute_field.key = 'Duties'
+ attribute_field.role_id = role.id
+ attribute_field.title_translations = {:en=>'Duties', :zh_tw=>'承辦業務'}
+ attribute_field.markup = 'text_area'
+ attribute_field.save
+
+ attribute_field = AttributeField.new
+ attribute_field.key = 'Deputy'
+ attribute_field.role_id = role.id
+ attribute_field.title_translations = {:en=>'Deputy', :zh_tw=>'代理人'}
+ attribute_field.markup = 'text_area'
+ attribute_field.save
+
+ end
+
+ if User.all.count==0
+ group = Workgroup.where(:key=>'admin').first
+ profile = MemberProfile.new
+ profile.first_name_translations = {:en=>'Digital', :zh_tw=>'Digital'}
+ profile.last_name_translations = {:en=>'Ruling', :zh_tw=>'Ruling'}
+ profile.email = "orbit@rulingcom.com"
+ profile.is_hidden = true
+ profile.save
+
+ user = User.new
+ user.workgroup = group
+ user.member_profile = profile
+ user.user_name = "rulingcom"
+ user.password_digest = "$2a$12$ODoNQJc22aU.U6HpWhUJIeKRYIf/3xcfzym8V.4tqt/V7pM2c9alq"
+ user.email = "orbit@rulingcom.com"
+ user.approved = true
+ user.beta_tester = true
+ user.save(:validate=>false)
+
+ profile = MemberProfile.new
+ profile.first_name_translations = {:en=>'Admin', :zh_tw=>'Admin'}
+ profile.last_name_translations = {:en=>'Admin', :zh_tw=>'Admin'}
+ profile.email = "service@rulingcom.com"
+ profile.save
+
+ user = User.new
+ user.workgroup = group
+ user.member_profile = profile
+ user.user_name = "admin"
+ user.password_digest = "$2a$12$zCT/qE6TdMUcYzA8NHhM/.G150JlazF1PRThjOuuxYt3Oi7DBrHrK"
+ user.email = "service@rulingcom.com"
+ user.approved = true
+ user.save(:validate=>false)
+ end
+ MemberProfileDefaultField.get_field_to_set
+ MemberIndexCache.destroy_all
+ env_pwd = ENV['PWD']
+ dir_name = env_pwd.split('/')[-1]
+ watch_dog = %x[screen -ls auto_reopen_#{dir_name}]
+ all_css_files = Dir["app/templates/**/*.css","app/templates/**/*.scss"]
+ contents = all_css_files.collect do |css_file|
+ [css_file,File.open(css_file, "r") { |f| f.read }]
+ end
+ s=contents.collect do |f,c|
+ c_tp = c
+ tmp = []
+ flag = false
+ c_tp = c_tp.gsub(/(^[ \t]*background(?:(?!\R).)*:[ \t]*linear-gradient(?:(?!\R|;).)*;[ \r]*(?:\/\/(?:(?!\R|;).)*)*)[ \r\t]*[\n]*([\t ]*(?:(?!\R|;).)*(?:$|;))/m) do |m|
+ var1 = $1
+ var2 = $2
+ if !var2.to_s.match(/^[ \t]*-pie-background/)
+ get_indent = var1.scan(/([ \t]*)background/).flatten[0].to_s
+ t = var1.sub(/background.*:/,'-pie-background:')
+ m = "#{var1}\n#{t}\n#{get_indent}behavior: url(\"/assets/ie_support/PIE2/PIE.htc\");\n#{var2}"
+ tmp << m
+ flag = true
+ end
+ m
+ end
+ c_tp = c_tp.gsub(/^([ \t]*border-radius:[ \t]*\d+(?:em|px|%|cm|pt|rem|vw|vh)(?:(?!\R|;).)*;[ \r]*(?:\/\/(?:(?!\R|;).)*)*)[ \r\t]*[\n]*([\t ]*(?:(?!\R|;).)*(?:$|;))/m) do |m|
+ var1 = $1
+ var2 = $2
+ if !var2.to_s.match(/^[ \t]*behavior: url\(\"\/assets\/ie_support\/PIE2\/PIE.htc\"\);/)
+ get_indent = var1.scan(/([ \t]*)border-radius/).flatten[0].to_s
+ m = "#{var1}\n#{get_indent}behavior: url(\"/assets/ie_support/PIE2/PIE.htc\");\n#{var2}"
+ tmp << m
+ flag = true
+ end
+ m
+ end
+ if flag
+ File.open(f, "w") { |f| f.write c_tp }
+ end
+ flag ? [f,tmp] : nil
+ end.compact
+
+ def gsub_block(c,rg,block)
+ return c.scan(rg) if !block
+ result = c.gsub(rg) do |str|
+ block.call(str)
+ end
+ end
+
+ def get_js_include_name(c,name,&block)
+ gsub_block(c,/^[ \t]*(?: