diff --git a/Gemfile b/Gemfile index d1afdb8c..d6129092 100644 --- a/Gemfile +++ b/Gemfile @@ -19,6 +19,9 @@ 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' diff --git a/Gemfile.lock b/Gemfile.lock index 71742974..16acce21 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -153,6 +153,20 @@ GEM 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) @@ -182,6 +196,8 @@ GEM 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) @@ -222,6 +238,8 @@ GEM 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) @@ -259,6 +277,9 @@ DEPENDENCIES radius rails (>= 3.1.0, < 3.2.0) rake + resque + resque-restriction + resque-scheduler rspec (~> 2.0) rspec-rails (~> 2.0) ruby-debug19 diff --git a/Rakefile b/Rakefile index 9a495de7..e0dc9c5b 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/images/Thumbs.db b/app/assets/images/Thumbs.db new file mode 100644 index 00000000..20b6d49e Binary files /dev/null and b/app/assets/images/Thumbs.db differ diff --git a/app/assets/images/ncculogo.ico b/app/assets/images/ncculogo.ico new file mode 100644 index 00000000..3aa5e1c6 Binary files /dev/null and b/app/assets/images/ncculogo.ico differ diff --git a/app/assets/javascripts/event.js b/app/assets/javascripts/event.js index afe558d8..7db3e47c 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/stylesheets/banner_nav.css b/app/assets/stylesheets/banner_nav.css new file mode 100644 index 00000000..ed613576 --- /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/inc/permission-checkbox.css.erb b/app/assets/stylesheets/inc/permission-checkbox.css.erb index 7e3f5bff..a5a50a17 100644 --- a/app/assets/stylesheets/inc/permission-checkbox.css.erb +++ b/app/assets/stylesheets/inc/permission-checkbox.css.erb @@ -10,7 +10,7 @@ } .checkbox{ padding: 5px; - margin: 0; + margin: 10px; display: inline-block; color:#777777; text-shadow: 0 1px 0px rgba(255,255,255,.4); @@ -20,7 +20,7 @@ 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:-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); @@ -28,7 +28,7 @@ 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;*/ + -webkit-border-radius: 3px; } .checkbox .check-icon { display: none; @@ -79,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/style.css.erb b/app/assets/stylesheets/style.css.erb index b4410a47..9bba5765 100644 --- a/app/assets/stylesheets/style.css.erb +++ b/app/assets/stylesheets/style.css.erb @@ -113,6 +113,7 @@ background-image: none; overflow: hidden; width: 28px; + margin-bottom: 0; position: relative; } #orbit-bar .nav > li > a.orbit-bar-home { @@ -579,6 +580,35 @@ .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; +} + /*icons*/ .the-icons i:after { content: attr(class); @@ -652,6 +682,9 @@ resize: none; max-height: 500px; } +#banner [id^="slideshow-"] { + z-index: 2 !important; +} [class^="icons-"] { display: inline-block; width: 16px; @@ -734,15 +767,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; @@ -803,20 +920,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; @@ -846,21 +1053,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 { @@ -888,14 +1164,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- { @@ -940,5 +1252,5 @@ } /*21*/ .icons- { - background-position: -0px -640px -} + background-position: -0px -640px; +} \ No newline at end of file diff --git a/app/controllers/admin/dashboards_controller.rb b/app/controllers/admin/dashboards_controller.rb index b7f377d3..6bfb91ba 100644 --- a/app/controllers/admin/dashboards_controller.rb +++ b/app/controllers/admin/dashboards_controller.rb @@ -5,6 +5,35 @@ class Admin::DashboardsController < ApplicationController # 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') + 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) + end + end + sorted_objects = a.sort {|a,b| b[1]<=>a[1]} + sorted_objects[0..9] end end diff --git a/app/controllers/admin/page_parts_controller.rb b/app/controllers/admin/page_parts_controller.rb index 600a289b..7ebcbe44 100644 --- a/app/controllers/admin/page_parts_controller.rb +++ b/app/controllers/admin/page_parts_controller.rb @@ -43,8 +43,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 ) @@ -86,5 +86,14 @@ class Admin::PagePartsController < ApplicationController 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/helpers/admin/dashboard_helper.rb b/app/helpers/admin/dashboard_helper.rb new file mode 100644 index 00000000..4b750fb8 --- /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_back_end_bulletins_path + when 'news_bulletin' + panel_news_back_end_news_bulletins_path + when'page_context' + panel_page_content_back_end_page_contexts_path + when'web_link' + panel_web_resource_back_end_web_links_path + end + end + + def get_link_to_object(object) + case object._type.underscore + when 'bulletin' + panel_announcement_back_end_bulletin_path(object) + when 'news_bulletin' + panel_news_back_end_news_bulletin_path(object) + when'page_context' + panel_page_content_back_end_page_context_path(object) + when'web_link' + panel_web_resource_back_end_web_link_path(object) + end + end + +end \ No newline at end of file diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e72b2b82..74d3e662 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -132,7 +132,7 @@ module ApplicationHelper stylesheets << "\n" end stylesheets << "\n" if page.design.reset_css - # stylesheets << "\n" + stylesheets << "\n" stylesheets << "\n" if page.design.default_css theme = page.design.themes.detect{ |d| d.id == page.theme_id } stylesheets << "\n" if theme diff --git a/app/jobs/fetch_time.rb b/app/jobs/fetch_time.rb new file mode 100644 index 00000000..5fce3036 --- /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 00000000..1848c691 --- /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/sync_db.rb b/app/jobs/sync_db.rb new file mode 100644 index 00000000..d4bda790 --- /dev/null +++ b/app/jobs/sync_db.rb @@ -0,0 +1,15 @@ +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] + puts "SyncDb Synced" + end +end diff --git a/app/mailer/cron_mail.rb b/app/mailer/cron_mail.rb new file mode 100644 index 00000000..bda1d063 --- /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/item.rb b/app/models/item.rb index c8b7812c..cea088fc 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -31,6 +31,17 @@ class Item nodes << node = node.parent while !node.parent.blank? rescue nil nodes.reverse end + + # Get an array of ancestor's id + def ancestor_ids + node, nodes = self, [] + while !node.parent.blank? do + node = node.parent rescue nil + nodes << node.id if node + end + # nodes << node = node.parent while !node.parent.blank? rescue nil + nodes.reverse + end # Build the url from the array of ancestors def url diff --git a/app/models/page.rb b/app/models/page.rb index d98f3a4e..5a742e92 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -28,8 +28,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 42f8b775..8bb1bc72 100644 --- a/app/models/page_part.rb +++ b/app/models/page_part.rb @@ -8,6 +8,7 @@ class PagePart field :kind field :public_r_tag 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 diff --git a/app/models/site.rb b/app/models/site.rb index a3e0513d..55d6bfaf 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -12,12 +12,15 @@ class Site 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 @@ -33,7 +36,6 @@ 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 @@ -46,6 +48,10 @@ class Site @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) @@ -66,6 +72,7 @@ class Site 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 f77f24c1..f621de6a 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/views/admin/dashboards/index.html.erb b/app/views/admin/dashboards/index.html.erb index e22d7dac..ee0bc920 100644 --- a/app/views/admin/dashboards/index.html.erb +++ b/app/views/admin/dashboards/index.html.erb @@ -1,8 +1,8 @@
-

<%= t(:content) %>

-
-

<%= t(:all_content) %>9,517

+

<%= t(:content) %>

+
+

<%= t(:all_content) %><%= @module_app_contents_total %>

@@ -23,46 +23,12 @@
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + <% @module_app_contents.each do |module_app_content| %> + + + + + <% end %>
公告2,304
新聞783
連結45
連結62
連結52
新聞20
公告41
公告37
公告41
公告20
<%= link_to t("dashboard.#{module_app_content[0]}"), get_link(module_app_content[0]) %><%= module_app_content[1] %>
@@ -70,7 +36,7 @@
-
+ + + @@ -515,11 +480,10 @@ - + -->
-

<%= t(:recent_update) %>

-
- +

<%= t(:recent_update) %>

+
@@ -540,46 +504,12 @@
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + <% @recent_updated.each do |object| %> + + + + + <% end %>
Title1公告
Title2頁面
Title3頁面
Title4公告
Title5公告
Title6頁面
Title7頁面
Title8公告
Title9頁面
Title10公告
<%= link_to ((object[0].title[I18n.locale] rescue nil) || (object[0].page.i18n_variable[I18n.locale] rescue nil)), get_link_to_object(object[0]) %><%= link_to t("dashboard.#{object[0]._type.underscore}"), get_link(object[0]._type.underscore) %>
diff --git a/app/views/admin/page_parts/_public_r_tag.html.erb b/app/views/admin/page_parts/_public_r_tag.html.erb index d8422e9d..d2d4d9b9 100644 --- a/app/views/admin/page_parts/_public_r_tag.html.erb +++ b/app/views/admin/page_parts/_public_r_tag.html.erb @@ -4,7 +4,8 @@ <% if @r_tag.eql?('sub_menu') %> - <%= f.select :public_r_tag_object_id, options_for_select([t(:horizontal), t(:vertical)], t(:horizontal)) %> + <%= f.hidden_field :public_r_tag_object_id, :value => @part.page.id %> + <%#= f.select :public_r_tag_object_id, options_for_select([t(:horizontal), t(:vertical)], t(:horizontal)) %> <% else %> <%= f.select :public_r_tag_object_id, options_from_collection_for_select(@tag_objects, :id, :title, :selected => @part.public_r_tag_object_id) %> <% end %> diff --git a/app/views/admin/page_parts/reload_r_tag_options.js.erb b/app/views/admin/page_parts/reload_r_tag_options.js.erb index a2eaf483..550d6127 100644 --- a/app/views/admin/page_parts/reload_r_tag_options.js.erb +++ b/app/views/admin/page_parts/reload_r_tag_options.js.erb @@ -1,5 +1,5 @@ <% if @r_tag.eql?('sub_menu') %> - $('#name_list select').html("<%= j options_for_select(t(:horizontal) => :horizontal, t(:vertical) => :vertical) %>") + // $('#name_list select').html("<%= j options_for_select(t(:horizontal) => :horizontal, t(:vertical) => :vertical) %>") <% else %> $('#name_list select').html("<%= j options_from_collection_for_select(@tag_objects, :id, :title) %>") <% end %> \ No newline at end of file diff --git a/app/views/admin/sites/_side_bar.html.erb b/app/views/admin/sites/_side_bar.html.erb new file mode 100644 index 00000000..1ad8ae43 --- /dev/null +++ b/app/views/admin/sites/_side_bar.html.erb @@ -0,0 +1,12 @@ +<%= content_tag :li, :class => active_for_controllers('sites') do -%> + <%= link_to content_tag(:i, nil, :class => 'icons-cog') + t('admin.site_settings'), admin_site_site_info_path(@site) %> + + <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('sites')) do -%> + <%= content_tag :li, link_to(t('admin.site_info'), admin_site_site_info_path(@site)), :class => active_for_action('sites', 'site_info') %> + <%#= content_tag :li, link_to(t('admin.system_info'), admin_site_system_info_path(@site)), :class => active_for_action('sites', 'system_info') %> + <%#= content_tag :li, link_to(t('admin.site_language'), admin_site_language_path(@site)), :class => active_for_action('sites', 'language') %> + <%= content_tag :li, link_to(t('admin.mail_setting'), admin_site_mail_setting_path(@site)), :class => active_for_action('sites', 'mail_setting') %> + <%#= content_tag :li, link_to(t('admin.ui_theme'), admin_site_ui_theme_path(@site)), :class => active_for_action('sites', 'ui_theme') %> + <% end -%> + +<% end -%> diff --git a/app/views/admin/sites/language.html.erb b/app/views/admin/sites/language.html.erb index ceb9b012..2b626564 100644 --- a/app/views/admin/sites/language.html.erb +++ b/app/views/admin/sites/language.html.erb @@ -1 +1,5 @@ +<% content_for :side_bar do %> + <%= render 'side_bar' %> +<% end %> + language.html.erb \ No newline at end of file diff --git a/app/views/admin/sites/mail_setting.html.erb b/app/views/admin/sites/mail_setting.html.erb index 3a52ede2..72ec6787 100644 --- a/app/views/admin/sites/mail_setting.html.erb +++ b/app/views/admin/sites/mail_setting.html.erb @@ -1 +1,76 @@ -mail_setting.html.erb \ No newline at end of file +<% content_for :side_bar do %> + <%= render 'side_bar' %> +<% end %> + +
+<%= form_for @site, :url => admin_site_path(@site), :html => {:class => "clear"} do |f| %> +
+
+ <%= f.fields_for :site_settings, @site['site_settings'] do |f| %> +
+
+ +
+ <%= f.text_field :address, :value => (@site['site_settings']['address'] rescue nil) %> + +
+
+
+ +
+ <%= f.text_field :port, :value => (@site['site_settings']['port'] rescue nil) %> + +
+
+
+ +
+ <%= f.text_field :domain, :value => (@site['site_settings']['domain'] rescue nil) %> + +
+
+
+ +
+ <%= f.text_field :authentication, :value => (@site['site_settings']['authentication'] rescue nil) %> + +
+
+
+ +
+ <%= f.text_field :user_name, :value => (@site['site_settings']['user_name'] rescue nil) %> + +
+
+
+ +
+ <%= f.text_field :password, :value => (@site['site_settings']['password'] rescue nil) %> + +
+
+
+ +
+ <%= f.check_box :tls, :checked => (@site['site_settings']['tls'].eql?('1') rescue false) %> + +
+
+
+ +
+ <%= f.check_box 'enable_starttls_auto', :checked => (@site['site_settings']['enable_starttls_auto'].eql?('1') rescue false) %> + +
+
+
+ <% end %> +
+
+
+ <%= f.submit t("submit"), :class => "btn btn-primary" %> + <%= f.submit t("cancel"), :class => "btn ", :type => 'reset' %> +
+<% end %> +
\ No newline at end of file diff --git a/app/views/admin/sites/site_info.html.erb b/app/views/admin/sites/site_info.html.erb index 64916d4d..e19307ca 100644 --- a/app/views/admin/sites/site_info.html.erb +++ b/app/views/admin/sites/site_info.html.erb @@ -1,3 +1,7 @@ +<% content_for :side_bar do %> + <%= render 'side_bar' %> +<% end %> +
<%= form_for @site, :url => admin_site_path(@site), :html => {:class => "clear"} do |f| %>
@@ -9,20 +13,22 @@ <% end %>
-
- +
- <%= f.check_box :title_always_on %> <%= t 'admin.always_display_title' %> +
<% @site_valid_locales.each do |locale|%> <%= content_tag :div, :class => "tab-pane fade #{active_when_current_locale_eq locale} #{locale}" do %>
+
<%= f.fields_for :title, @site.title do |f| %> <%= f.text_field locale, :class => "input-xxlarge" %> <% end %> -

In addition to freeform text, any HTML5 text-based input appears like so.

+

<%= (t 'admin.site_title_help').html_safe %>

<% end %> @@ -30,12 +36,12 @@ <% @site_valid_locales.each do |locale|%> <%= content_tag :div, :class => "tab-pane fade #{active_when_current_locale_eq locale} #{locale}" do %>
- +
<%= f.fields_for :keywords, @site.keywords do |f| %> <%= f.text_area locale, :class => "input-xxlarge textarea-height-s" %> <% end %> -

In addition to freeform text, any HTML5 text-based input appears like so.

+

<%= (t 'admin.site_keywords_help').html_safe %>

@@ -44,7 +50,7 @@ <%= f.fields_for :description, @site.description do |f| %> <%= f.text_area locale, :class => "input-xxlarge textarea-height-s" %> <% end %> -

In addition to freeform text, any HTML5 text-based input appears like so.

+

<%= (t 'admin.site_description_help').html_safe %>

@@ -53,6 +59,15 @@ <%= f.fields_for :footer, @site.footer do |f| %> <%= f.text_area locale, :class => "tinymce_textarea input-xxlarge" %> <% end %> +

<%= (t 'admin.site_footer_help').html_safe %>

+
+
+
+ +
+ <%= f.fields_for :sub_menu, @site.sub_menu do |f| %> + <%= f.text_area locale, :class => "tinymce_textarea input-xxlarge" %> + <% end %>
<% end %> diff --git a/app/views/admin/sites/system_info.html.erb b/app/views/admin/sites/system_info.html.erb index 45535dac..dc9d45c9 100644 --- a/app/views/admin/sites/system_info.html.erb +++ b/app/views/admin/sites/system_info.html.erb @@ -1 +1,5 @@ +<% content_for :side_bar do %> + <%= render 'side_bar' %> +<% end %> + system_info.html.erb \ No newline at end of file diff --git a/app/views/admin/sites/ui_theme.html.erb b/app/views/admin/sites/ui_theme.html.erb index 222f5969..540405da 100644 --- a/app/views/admin/sites/ui_theme.html.erb +++ b/app/views/admin/sites/ui_theme.html.erb @@ -1 +1,5 @@ +<% content_for :side_bar do %> + <%= render 'side_bar' %> +<% end %> + ui_theme.html.erb \ No newline at end of file diff --git a/app/views/layouts/_orbit_bar.html.erb b/app/views/layouts/_orbit_bar.html.erb index 46f2b712..23085046 100644 --- a/app/views/layouts/_orbit_bar.html.erb +++ b/app/views/layouts/_orbit_bar.html.erb @@ -10,12 +10,13 @@
  • <%#= link_to content_tag(:i, nil, :class => 'icons-asset') + t('admin.asset'), admin_assets_path %>
  • <%= link_to content_tag(:i, nil, :class => 'icons-structure') + t('admin.structure'), admin_items_path %>
  • +
  • <%= link_to content_tag(:i, nil, :class => 'icons-cog') + t('admin.site_settings'), admin_site_site_info_path(@site) %>
  • <%#= link_to content_tag(:i, nil, :class => 'icons-plus-cube') + t('admin.add_item') %>
  • <%= t('announcement.tag_cloud') %>

    -
      +
      <% @tags.each do |tag| %> -
    • - <%= link_to tag[I18n.locale], panel_announcement_front_end_bulletins_path(:tag_id => tag.id) %> -
    • - <% end %> -
    + <%= link_to tag[I18n.locale], panel_announcement_front_end_bulletins_path(:tag_id => tag.id), :class => "hot#{rand(4) + 1} #{(tag.id.to_s.eql?(params[:tag_id]) || tag.key.eql?(params[:tag_id])) ? 'active' : nil}" %> + <% end %> +
    - -<%#= link_back %> diff --git a/vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/news_bulletins_side_bar.html.erb b/vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/news_bulletins_side_bar.html.erb index 84e58f40..5ea1a930 100644 --- a/vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/news_bulletins_side_bar.html.erb +++ b/vendor/built_in_modules/news/app/views/panel/news/widget/news_bulletins/news_bulletins_side_bar.html.erb @@ -3,7 +3,7 @@

    <%= t('announcement.categories') %>