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:
Fu Matthew committed 2013-01-08 14:17:21 +08:00
commit 76296ab29b
160 files changed
+8659 -1037

No files matched your search

+6 -1
View File
@@ -94,7 +94,12 @@ class Admin::DesignsController < OrbitBackendController
def destroy
@design = Design.find(params[:id])
@design.destroy
if @site.design == @design
flash[:error] = "Failed! You can not delete a design that used by default "
else
@design.destroy
flash[:notice] = "Successfully deleted design."
end
redirect_to admin_designs_url
end
@@ -64,6 +64,7 @@ class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController
def force_order
authenticate_user!
set_module_app
setup_vars
check_if_user_can_do_object_auth
end
@@ -80,15 +81,25 @@ class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController
end
def setup_vars
if request.env['HTTP_REFERER'].split('/')[4] == "object_auths"
http_referer = request.env['HTTP_REFERER'] || ''
if http_referer.split('/')[4] == "object_auths"
@app_key = params[:app_key]
else
@app_key = request.env['HTTP_REFERER'].split('/')[4]
@app_key = http_referer.split('/')[4]
end
#@app_key = request.fullpath.split('/')[1] if(@app_key == "back_end")
@app_key.gsub!(/[?].*/,'')
@module_app = ModuleApp.first(conditions: {:key => @app_key} )
if @app_key
@app_key.gsub!(/[?].*/,'')
@module_app = ModuleApp.first(conditions: {:key => @app_key} )
if @module_app.nil?
raise ObjectAuthError, 'Auth procress failed, module_app not exist '
end
else
raise ObjectAuthError, 'Auth procress failed, pls redo your sop'
end
end
end
+14 -6
View File
@@ -37,13 +37,18 @@ class Admin::PagePartsController < ApplicationController
# @widget_style = @module_app.widgets[@widget_path] if !@widget_path.blank? && !@module_app.widgets.blank?
# end
@widget_path = @part.widget_path ? @part.widget_path : @module_app.widgets.keys[0]
if @module_app.widgets.any?{|b| b.class == Array}
@widget_style = @module_app.widgets[@widget_path] if !@widget_path.blank? && !@module_app.widgets.blank?
end
# TODO 應該要有一些東西來決定 @categories @tags
# case @module_app.key
# when 'announcement'
# @categories = BulletinCategory.all
# @tags = AnnouncementTag.all
# when 'news'
# @categories = NewsBulletinCategory.all
# @tags = NewsTag.all
# when 'gallery'
# @albums = GalleryAlbum.all
# when 'web_resource'
# @categories = WebLinkCategory.all
# @tags = WebResourceTag.all
@@ -51,6 +56,8 @@ class Admin::PagePartsController < ApplicationController
# @categories = ArchiveFileCategory.all
# @tags = ArchiveTag.all
# end
end
def create
@@ -92,6 +99,7 @@ class Admin::PagePartsController < ApplicationController
end
def reload_widgets
@part = PagePart.find params[:part_id]
@categories =[]
@module_app = ModuleApp.find(params[:id])
@@ -103,9 +111,8 @@ class Admin::PagePartsController < ApplicationController
when 'announcement'
@categories = BulletinCategory.all
@tags = AnnouncementTag.all
when 'news'
@categories = NewsBulletinCategory.all
@tags = NewsTag.all
when 'gallery'
@albums = GalleryAlbum.all
when 'web_resource'
@categories = WebLinkCategory.all
@tags = WebResourceTag.all
@@ -114,6 +121,7 @@ class Admin::PagePartsController < ApplicationController
@tags = ArchiveTag.all
end
@part.widget_path = @module_app.widgets.first if @module_app.needs_to_widget_option?
respond_to do |format|
format.js {}
end
+8 -4
View File
@@ -46,12 +46,16 @@ class Admin::TagsController < OrbitBackendController
protected
def set_module_app
@module_app ||= ModuleApp.first(:conditions => {:key => @app_title.underscore}) rescue nil
end
def get_tags
@tags = (@module_app ? @module_app.tags : Tag.all)
end
def setup_vars
@app_key = request.env['HTTP_REFERER'].split('/')[4]
if @app_key
@app_key.gsub!(/[?].*/, '')
@module_app = ModuleApp.first(conditions: {:key => @app_key})
end
end
end
@@ -8,6 +8,12 @@ class Admin::UsersNewInterfaceController < OrbitBackendController
before_filter :force_order_for_user,:except => [:index,:show]
before_filter :set_attribute,:except => [:index,:show]
def setup_vars
# @app_title ||= controller_path.split('/')[1].singularize
# @module_app ||= ModuleApp.first(conditions: {:key => @app_title} )
# raise ModuleAppError, 'Can not find ModuleApp' if @module_app.nil?
end
def index
get_tags
get_sub_roles
+30 -2
View File
@@ -2,14 +2,23 @@ class ApplicationController < ActionController::Base
protect_from_forgery
include ParserFrontEnd, ParserBackEnd, ApplicationHelper
include OrbitApp::ErrorHandlers::PageErrorHandler
include OrbitApp::ErrorHandlers::ObjectAuthErrorHandler
include OrbitApp::ErrorHandlers::ModuleAppErrorHandler
rescue_from ObjectAuthError, :with => :render_object_auth_error
rescue_from ModuleAppError, :with => :render_module_app_error
rescue_from PageError, :with => :render_page_error
layout :layout_by_resource
helper :admin
before_filter :set_locale, :set_site
before_filter :set_locale, :set_site, :prepare_for_mobile
helper_attr :site_valid_locales
def set_current_user
User.current = current_or_guest_user
end
@@ -121,6 +130,7 @@ class ApplicationController < ActionController::Base
respond_to do |format|
format.html { render :text => parse_page_content(@item), :layout => 'page_layout' }
format.rss { render_main_rss }
format.mobile { redirect_to mobile_path }
end
else
render :text => '404 Not Found'
@@ -228,4 +238,22 @@ class ApplicationController < ActionController::Base
redirect_to ret
end
private
def mobile_device?
if session[:mobile_param]
session[:mobile_param] == "1"
else
request.user_agent =~ /iPhone|iPod|Android/
end
end
def prepare_for_mobile
if @site.mobile_on
session[:mobile_param] = params[:mobile] if params[:mobile]
request.format = :mobile if mobile_device?
end
end
end
+12 -24
View File
@@ -11,33 +11,21 @@ class DefaultWidgetController< OrbitWidgetController
@default_widget = @page_part.module_app.get_default_widget
@widget_image_field = @default_widget[:image]
data_limit = @page_part.widget_data_count.is_a?(Fixnum) ? @page_part.widget_data_count : (@page_part.widget_data_count.to_i rescue 3)
@data = eval(@default_widget[:query]).limit(data_limit).includes(@widget_image_field)
@data = eval(@default_widget["query"]).limit(data_limit).includes(@widget_image_field)
@fields = @page_part.widget_field
case params[:type]
when "typeA"
@tag_class = 'defulat_widget_typeA'
render "typeA"
when /typeB_/
@tag_class = "defulat_widget_#{params[:type]}"
render "typeB"
when "typeC"
@tag_class = 'defulat_widget_typeC'
render "typeC"
end
# {"inner"=>"true",
# "category_id"=>"false",
# "tag_id"=>"",
# "page"=>"",
# "search_query"=>"",
# "part_title"=>"",
# "part_id"=>"50ac426f83e75219d20000a7",
# "controller"=>"default_widget",
# "action"=>"default_widget",
# "type"=>"typeA"}
when "typeA"
@tag_class = 'defulat_widget_typeA'
render "typeA"
when /typeB_/
@tag_class = "defulat_widget_#{params[:type]}"
render "typeB"
when "typeC"
@tag_class = 'defulat_widget_typeC'
render "typeC"
end
end
end
+1 -1
View File
@@ -39,7 +39,7 @@ class FrontController < ApplicationController
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)
i += 1 if i
+52
View File
@@ -0,0 +1,52 @@
class MobileController < ApplicationController
layout 'mobile'
def index
date_now = Time.now
@bulletins = Bulletin.all.available_for_lang(I18n.locale).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(15)
@ad_banner = AdBanner.where(title: "Banner")[0]
end
def announcement
@page_title = t('mobile.bulletin')
date_now = Time.now
@bulletins = Bulletin.all.available_for_lang(I18n.locale).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(15)
end
def announcement_content
@bulletin = Bulletin.find(params[:id]) rescue nil
@page_title = @bulletin.title
end
def dialog_contact
@no_menu = @no_footer = true
@page_title = t('mobile.contact')
end
def dialog_copyright
@no_menu = @no_footer = true
@page_title = t('mobile.copyright')
end
def dialog_language
@no_menu = @no_footer = true
@page_title = t('mobile.language')
end
def map
@no_menu = @no_footer = true
@page_title = t('mobile.location')
end
def page
@page_title = t('mobile.page')
@page_contexts = PageContext.where(:archived => false).page(params[:page_main]).per(15)
end
def page_content
@page_context = PageContext.first(conditions: { id: params[:id], :archived => false }) rescue nil
@page_title = @page_context.page.title
end
end
@@ -6,6 +6,33 @@ class OrbitBackendController < ApplicationController
layout 'new_admin'
def setup_vars
@app_title ||= controller_path.split('/')[1].singularize
@module_app ||= ModuleApp.first(conditions: {:key => @app_title} )
raise ModuleAppError, 'Can not find ModuleApp' if @module_app.nil?
end
private
def force_order_for_visitor
setup_vars
set_current_user
end
def force_order_for_user
setup_vars
set_current_user
authenticate_user!
check_user_can_use
end
def check_user_can_use
unless check_permission
#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)
+3 -2
View File
@@ -17,7 +17,6 @@ class PagesController < ApplicationController
def show
#begin
@item = Item.first(:conditions => {:path => params[:page_name]})
#binding.pry
if @item && @item.is_published && (@item.enabled_for.nil? ? true : @item.enabled_for.include?(I18n.locale.to_s))
impressionist(@item)
case @item.class.to_s
@@ -66,6 +65,7 @@ class PagesController < ApplicationController
def get_item
module_app = ModuleApp.first(:conditions => {:key => params[:app_name]})
if !params[:category_id].blank? && !params[:tag_id].blank?
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id], :tag => params[:tag_id]})
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id], :tag => ''}) unless @item
@@ -75,7 +75,8 @@ class PagesController < ApplicationController
@item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action],tag: params[:tag_id]).any_in(category: [nil,'']).first
end
@item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action]).all_of("tag" => {"$in" => [nil,'']},"category" => { "$in" => [nil,'']}).first unless @item
#TODO 需要做 error handler 處理沒有新增該模組頁面導致錯誤的可能性
@item = Item.where(module_app_id: module_app.id,app_frontend_url:params[:app_action]).first unless @item
raise PageError,'Missing Frontend Page' if @item.nil?
end
def save_from_no_lang_for_page