Merge branch 'sidebar_config' into ntu
Conflicts: app/controllers/admin/object_auths_new_interface_controller.rb app/controllers/orbit_backend_controller.rb app/controllers/orbit_widget_controller.rb app/models/module_app.rb app/views/admin/page_parts/_module_widget.html.erb config/locales/zh_tw.yml lib/parsers/parser_common.rb lib/parsers/parser_front_end.rb
This commit is contained in:
commit
76296ab29b
160 files changed
+8659
-1037
No files matched your search
@@ -0,0 +1,14 @@
|
||||
|
||||
# require "#{File.dirname(__FILE__)}/module_app_error_handler.rb"
|
||||
# require "#{File.dirname(__FILE__)}/object_auth_error_handler.rb"
|
||||
# require "#{File.dirname(__FILE__)}/module_app_error_handler.rb"
|
||||
# require "#{File.dirname(__FILE__)}/page_error_handler.rb"
|
||||
|
||||
|
||||
# module OrbitApp
|
||||
# module ErrorHandlers
|
||||
# module ApplicationsErrorHandler
|
||||
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
@@ -0,0 +1,17 @@
|
||||
module OrbitApp
|
||||
module ErrorHandlers
|
||||
module ModuleAppErrorHandler
|
||||
|
||||
|
||||
def render_module_app_error(exception = nil)
|
||||
default_message = 'ModuleAppErrorHandler'
|
||||
meaasge = ''
|
||||
|
||||
if exception
|
||||
meaasge = default_message +" " + exception.message
|
||||
end
|
||||
render :text=>meaasge
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,16 @@
|
||||
module OrbitApp
|
||||
module ErrorHandlers
|
||||
module ObjectAuthErrorHandler
|
||||
|
||||
|
||||
def render_object_auth_error(exception = nil)
|
||||
default_message = 'This is a render_object_auth_error'
|
||||
meaasge = ''
|
||||
if exception
|
||||
meaasge = default_message +" " + exception.message
|
||||
end
|
||||
render :text=>meaasge
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,16 @@
|
||||
module OrbitApp
|
||||
module ErrorHandlers
|
||||
module PageErrorHandler
|
||||
|
||||
|
||||
def render_page_error(exception = nil)
|
||||
default_message = 'ModuleAppErrorHandler'
|
||||
meaasge = ''
|
||||
if exception
|
||||
meaasge = default_message +" " + exception.message
|
||||
end
|
||||
render :text=>meaasge
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -140,7 +140,7 @@ module OrbitCoreLib
|
||||
|
||||
protected
|
||||
def generate_token
|
||||
self.s_token = ActiveSupport::SecureRandom.hex(16)
|
||||
self.s_token = SecureRandom.hex(16)
|
||||
self.save!
|
||||
end
|
||||
end
|
||||
|
||||
@@ -30,6 +30,7 @@ module ParserBackEnd
|
||||
parse_images_edit(body, page)
|
||||
parse_footer_edit(body, page)
|
||||
parse_sub_menu_edit(body, page)
|
||||
parse_counter_edit(body)
|
||||
public_r_tags.each do |tag|
|
||||
send("parse_#{tag}s_edit", body, page, true)
|
||||
end
|
||||
|
||||
@@ -9,7 +9,7 @@ module ParserCommon
|
||||
res << "'>"
|
||||
i = nil
|
||||
i = 1 if menu.values["li_incremental_#{current}"]
|
||||
children = current == 1 ? page.visible_children.reverse : page.visible_children
|
||||
children = current == 1 ? page.visible_children : page.visible_children
|
||||
children.each do |child|
|
||||
res << menu_li(child, current_page, current, menu, i, edit)
|
||||
i += 1 if i
|
||||
@@ -207,13 +207,13 @@ module ParserCommon
|
||||
ret << part.content rescue ''
|
||||
when 'module_widget'
|
||||
url = case part.widget_path
|
||||
when 'default_widget'
|
||||
"/panel/orbit_app/widget/#{part.widget_style}?inner=true"
|
||||
else
|
||||
"/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true"
|
||||
end
|
||||
|
||||
options = "&category_id=#{!part[:category].blank? ? part[:category].blank? : category}&tag_id=#{!part[:tag].blank? ? part[:tag] : tag}&page=#{params[:page]}&search_query=#{params[:search_query]}&part_title=#{Rack::Utils.escape(part_title).gsub("+", "%20") rescue nil}&part_id=#{part.id}"
|
||||
when 'default_widget'
|
||||
"/panel/orbit_app/widget/#{part.widget_style}?inner=true"
|
||||
else
|
||||
raise ModuleAppError,"PagePart can't find ModuleApp" if part.module_app.nil?
|
||||
"/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true"
|
||||
end
|
||||
options = "&part_id=#{part.id}&category_id=#{!part[:category].blank? ? part[:category].blank? : category}&tag_id=#{!part[:tag].blank? ? part[:tag] : tag}&page=#{params[:page]}&search_query=#{params[:search_query]}&part_title=#{Rack::Utils.escape(part_title).gsub("+", "%20") rescue nil}"
|
||||
ret << "<div class='dymanic_load widget' path='#{url + options}'></div>"
|
||||
when 'public_r_tag'
|
||||
ret << "<r:#{part.public_r_tag} id='#{part.public_r_tag_object_id}'/>"
|
||||
@@ -234,7 +234,7 @@ module ParserCommon
|
||||
end
|
||||
|
||||
# page_counter
|
||||
def parse_counter(body = nil, page = nil, edit=nil)
|
||||
def parse_counter_edit(body = nil)
|
||||
body.css('.page_counter').each do |counter|
|
||||
res = ''
|
||||
case counter['option']
|
||||
@@ -249,7 +249,7 @@ module ParserCommon
|
||||
when 'this_year'
|
||||
res << display_visitors_this_year.to_s
|
||||
end
|
||||
fragment = Nokogiri::HTML::DocumentFragment.new(body, res)
|
||||
fragment = Nokogiri::HTML::DocumentFragment.new(body, "<div id='#{counter['id']}' class='#{counter['class']}'>#{res}</div>")
|
||||
counter.swap(fragment)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,6 +11,7 @@ module ParserFrontEnd
|
||||
parse_images(body, page)
|
||||
parse_menu(body, page)
|
||||
parse_sub_menu(body, page, site)
|
||||
parse_counter(body)
|
||||
i18n.merge!({locale => body.to_html})
|
||||
end
|
||||
i18n
|
||||
@@ -21,10 +22,14 @@ module ParserFrontEnd
|
||||
tag = params[:tag_id].blank? ? page[:tag] : params[:tag_id]
|
||||
body = Nokogiri::HTML(page.content)
|
||||
body.css('orbit_front').each do |front|
|
||||
ret = ''
|
||||
part = PagePart.find(front['part_id']) if front['part_id']
|
||||
ret << eval("\"#{front['path']}\"") rescue ''
|
||||
fragment = Nokogiri::HTML::DocumentFragment.new(body, "<div class='dymanic_load widget' path='#{ret}'></div>")
|
||||
if front['value']
|
||||
fragment = Nokogiri::HTML::DocumentFragment.new(body, "<div id='#{front['id']}' class='#{front['class']}'>#{eval(front['value']).to_s}</div>")
|
||||
else
|
||||
ret = ''
|
||||
part = PagePart.find(front['part_id']) if front['part_id']
|
||||
ret << eval("\"#{front['path']}\"") rescue ''
|
||||
fragment = Nokogiri::HTML::DocumentFragment.new(body, "<div class='dymanic_load widget' path='#{ret}'></div>")
|
||||
end
|
||||
front.swap(fragment)
|
||||
end
|
||||
body.to_html
|
||||
@@ -111,7 +116,7 @@ module ParserFrontEnd
|
||||
else
|
||||
"/panel/\#{part.module_app.key}/widget/\#{part.widget_path}?inner=true"
|
||||
end
|
||||
|
||||
|
||||
options = "&part_id=\#{part.id}&category_id=\#{!part[:category].blank? ? part[:category].blank? : category}&tag_id=\#{!part[:tag].blank? ? part[:tag] : tag}&page=\#{params[:page]}&search_query=\#{params[:search_query]}&part_title=\#{Rack::Utils.escape(part_title).gsub(\"\+\", \"\%20\") rescue nil}"
|
||||
ret << "<orbit_front path='#{url + options}' part_id=#{part.id} class='dymanic_load widget'></orbit_front>"
|
||||
|
||||
@@ -131,6 +136,26 @@ module ParserFrontEnd
|
||||
end
|
||||
end
|
||||
|
||||
def parse_counter(body = nil)
|
||||
body.css('.page_counter').each do |counter|
|
||||
ret = ''
|
||||
case counter['option']
|
||||
when 'all'
|
||||
ret << "display_visitors"
|
||||
when 'today'
|
||||
ret << "display_visitors_today"
|
||||
when 'this_week'
|
||||
ret << "display_visitors_this_week"
|
||||
when 'this_month'
|
||||
ret << "display_visitors_this_month"
|
||||
when 'this_year'
|
||||
ret << "display_visitors_this_year"
|
||||
end
|
||||
fragment = Nokogiri::HTML::DocumentFragment.new(body, "<orbit_front id='#{counter['id']}' class='#{counter['class']}' value='#{ret}'></orbit_front>")
|
||||
counter.swap(fragment)
|
||||
end
|
||||
end
|
||||
|
||||
# ad_banners
|
||||
def generate_ad_banners(*args)
|
||||
"<div class='dymanic_load' path='#{front_show_banner_path(args[0])}'></div>"
|
||||
|
||||
@@ -312,4 +312,76 @@ namespace :migrate do
|
||||
end
|
||||
end
|
||||
|
||||
task :recreate_page_parts => :environment do
|
||||
Page.all.each do |page|
|
||||
page.create_parts
|
||||
page.save
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
task :add_widget_options_to_gallery => :environment do
|
||||
a = ModuleApp.where(:key=>'gallery').first
|
||||
a.widget_options = {"widget1"=>{"vertical"=>[1, 2], "horizontal"=>[1, 2, 3, 4, 5, 6]}}
|
||||
a.widget_options_fields_i18n = {"widget1"=>{"vertical"=>"gallery.widget_option.vertical", "horizontal"=>"gallery.widget_option.horizontal"}}
|
||||
a.save
|
||||
|
||||
end
|
||||
|
||||
task :clean_object_auth => :environment do
|
||||
ObjectAuth.destroy_all
|
||||
end
|
||||
|
||||
task :correct_gallery_widget => :environment do
|
||||
@module_app = ModuleApp.where(:key=>'gallery').first
|
||||
@module_app.widgets=["widget1"]
|
||||
@module_app.save
|
||||
end
|
||||
|
||||
task :reinstall_calendar => :environment do
|
||||
old_calendar = ModuleApp.where(key: "calendar")
|
||||
old_calendar.destroy_all unless old_calendar.empty?
|
||||
ModuleApp.new.from_json(File.open("#{Rails.root}/vendor/built_in_modules/calendar/calendar.json").read).save
|
||||
end
|
||||
|
||||
task :reinstall_gallery => :environment do
|
||||
old_gallery = ModuleApp.where(key: "gallery")
|
||||
old_gallery.destroy_all unless old_gallery.empty?
|
||||
ModuleApp.new.from_json(File.open("#{Rails.root}/vendor/built_in_modules/gallery/gallery.json").read).save
|
||||
end
|
||||
|
||||
|
||||
task :make_default_widget_work_config => :environment do
|
||||
a = ModuleApp.where(:key=>'announcement').first
|
||||
a.widgets[:default_widget] = ['typeA','typeC','typeB_style2','typeB_style3','typeB_style4']
|
||||
a.widget_fields = [
|
||||
["title","announcement.default_widget.title"],
|
||||
["bulletin_category_with_title","announcement.default_widget.bulletin_category_with_title"],
|
||||
["postdate","announcement.default_widget.postdate"]
|
||||
]
|
||||
a.get_default_widget = {:query=>'Bulletin.all',:image=> 'image'}
|
||||
a.widget_fields_link_method = {
|
||||
"title"=>{:method => 'panel_announcement_front_end_bulletin_path',
|
||||
:args=>:self},
|
||||
"bulletin_category_with_title"=>{
|
||||
:method => 'panel_announcement_front_end_bulletins_path',
|
||||
:args=>{:category_id => [:bulletin_category,:id]}}
|
||||
}
|
||||
a.save
|
||||
end
|
||||
|
||||
|
||||
task :reorder_items => :environment do
|
||||
reorder_children(Item.root)
|
||||
end
|
||||
|
||||
def reorder_children(parent)
|
||||
parent.children.each_with_index do |child, i|
|
||||
child.position = i
|
||||
child.save
|
||||
reorder_children(child) if child.children
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
Reference in new issue
Block a user