Merge branch 'member_plugin' of https://github.com/Rulingcom/orbit into member_plugin

This commit is contained in:
unknown committed 2013-01-18 10:39:29 +08:00
commit 90c6c88f2f
378 files changed
+13884 -3186

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
@@ -3,7 +3,7 @@ class Admin::ModuleAppsController < ApplicationController
before_filter :user_has_sub_manager_privilege?, :only => [ :assign_sub_manager, :remove_sub_manager ]
layout "new_admin"
helper Admin::PagePartsHelper
def index
@module_apps = ModuleApp.all.entries
end
@@ -4,7 +4,6 @@ class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController
def setting
@sys_users = User.all(conditions: {admin: false}).includes(:avatar).not_guest_user
@ob_auth = ObjectAuth.find params[:object_auth_id]
@options_from_collection_for_select_ob_auth = @ob_auth.siblings.collect{|oa| [oa.auth_obj.pp_object,oa.id] }
@@ -60,6 +59,7 @@ class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController
def force_order
authenticate_user!
setup_vars
check_if_user_can_do_object_auth
end
@@ -76,15 +76,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
+12 -8
View File
@@ -26,6 +26,7 @@ class Admin::PagePartsController < ApplicationController
@part = PagePart.find(params[:id])
@module_apps = ModuleApp.excludes(widgets: nil).where(enable_frontend: true).order_by(:title, :asc)
@module_app = @part.module_app ? @part.module_app : @module_apps[0]
@user_choose = @part.widget_path
@r_tag = @part.public_r_tag.blank? ? LIST[:public_r_tags][0] : @part.public_r_tag
@tag_objects = @r_tag.classify.constantize.all rescue nil
@@ -39,9 +40,9 @@ 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
@tags = []
when 'web_resource'
@categories = WebLinkCategory.all
@tags = WebResourceTag.all
@@ -90,6 +91,7 @@ class Admin::PagePartsController < ApplicationController
end
def reload_widgets
@part = PagePart.find params[:part_id]
@categories =[]
@module_app = ModuleApp.find(params[:id])
@@ -101,9 +103,9 @@ 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
@tags = []
when 'web_resource'
@categories = WebLinkCategory.all
@tags = WebResourceTag.all
@@ -112,6 +114,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
@@ -119,9 +122,10 @@ class Admin::PagePartsController < ApplicationController
def reload_widget_styles
@module_app = ModuleApp.find(params[:module_app_id])
@part = PagePart.find params[:part_id]
@user_choose =@widget_path= params[:id]
@widget_style = @module_app.widgets[params[:id]]
respond_to do |format|
format.js {}
end
+1 -1
View File
@@ -1,5 +1,5 @@
class Admin::PagesController < Admin::ItemsController
helper Admin::PagePartsHelper
def show
@item = Page.find(params[:id])
respond_to do |format|
+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
+38 -4
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
helper :admin, :orbit_form
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,28 @@ 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] = if request.path =~ /mobile/
'1'
elsif params[:mobile]
params[:mobile]
else
session[:mobile_param]
end
request.format = :mobile if mobile_device?
end
end
end
@@ -0,0 +1,40 @@
class DefaultWidgetController< OrbitWidgetController
def front_end_available(var)
@page_part = PagePart.find params[:part_id]
@page_part.module_app.enable_frontend?
end
def default_widget
@tag_class = nil
@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)
@fields = @page_part.widget_field
case params[:type]
when "typeA"
@tag_class = 'default_widget_typeA'
render "typeA"
when /typeB_/
@tag_class = "default_widget_#{params[:type]}"
render "typeB"
when "typeC"
@tag_class = 'default_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"}
end
end
@@ -1,63 +0,0 @@
class Desktop::CoAuthorRelationsController < ApplicationController
def index
@co_author_relations = CoAuthorRelation.all
new
respond_to do |format|
format.html {render layout: false }
end
end
def edit
@co_author_relation = CoAuthorRelation.find(params[:id])
respond_to do |format|
format.html { render :layout => false}
end
end
def new
@co_author_relation = CoAuthorRelation.new
end
def create
@co_author_relation = CoAuthorRelation.new(params[:co_author_relation])
@co_author_relations = CoAuthorRelation.all
if @co_author_relation.save
newv = render_to_string partial: "show_form", object: @co_author_relations
render json: {success: true, msg: "New Relation successfully saved!", newvalue: newv}.to_json
else
error_msg = @co_author_relation.errors.full_messages.join("<br />")
render json: {success: false, msg: error_msg}.to_json
end
end
def update
@co_author_relation = CoAuthorRelation.find(params[:id])
if @co_author_relation.update_attributes(params[:co_author_relation])
@co_author_relations = CoAuthorRelation.all
newv = render_to_string partial: "show_form", object: @co_author_relations
render json: {success: true, msg: "New Relation successfully updated!", newvalue: newv}.to_json
else
error_msg = @co_author.errors.full_messages.join("<br />")
render json: {success: false, msg: error_msg}.to_json
end
end
def destroy
@co_author_relation = CoAuthorRelation.find(params[:id])
@co_author_relation.destroy
reset_co_author_relation
render :json => {success: true, msg: "deleted successfully!"}
end
private
def reset_co_author_relation
co_author = CoAuthor.where(co_author_relations_id: @co_author_relation.id)
co_author.map do |c|
c.update_attributes(co_author_relations_id: nil)
end
end
end
@@ -1,59 +0,0 @@
class Desktop::CoAuthorsController < ApplicationController
def index
nils, not_nils = CoAuthor.where(name_id: current_user.id)\
.asc(:co_author).partition{|p| p.email.nil?}
@co_authors = not_nils + nils
@co_author_relations = CoAuthorRelation.all
respond_to do |format|
format.html { render :layout => false}
end
end
def new
@co_author = CoAuthor.new
@co_author_relations = CoAuthorRelation.all
respond_to do |format|
format.html { render :layout => false}
end
end
def edit
@co_author = CoAuthor.find(params[:id])
@co_author_relations = CoAuthorRelation.all
respond_to do |format|
format.html { render :layout => false}
end
end
def create
@co_author = CoAuthor.new(params[:co_author])
@co_author.name_id= current_user.id
if @co_author.save
render json: {success:true, msg: t('create.sucess.co_author')}.to_json
else
error_msg = @co_author.errors.full_messages.join("<br />")
render json: {success: false, msg: error_msg}.to_json
end
end
def update
@co_author = CoAuthor.find(params[:id])
if @co_author.update_attributes(params[:co_author])
render json: {success:true, msg: t('update.sucess.co_author')}.to_json
else
error_msg = @co_author.errors.full_messages.join("<br />")
render json: {success: false, msg: error_msg}.to_json
end
end
def destroy
@co_author = CoAuthor.find(params[:id])
@co_author.destroy
render :json => {success: true, msg: "Co-author deleted successfully!"}
end
end
@@ -1,18 +0,0 @@
class Desktop::JournalListsController < ApplicationController
def index
level_types = JournalLevelType.all
all_journal_lists = WritingJournal.where(create_user_id: current_user.id)
all_journal_lists = all_journal_lists.map do |j|
[ j.journal_title,
j.journal_level_type_ids.map do |type|
level_types.find(type).title
end]
end
@journal_lists = all_journal_lists.uniq
respond_to do |format|
format.html { render :layout => false}
end
end
end
@@ -1,107 +0,0 @@
class Desktop::JournalPagesController < ApplicationController
def index
@writing_journal = WritingJournal.where(create_user_id: current_user.id)
@level_types = JournalLevelType.all
respond_to do |format|
format.html { render :layout => false}
end
end
def new
@writing_journal = WritingJournal.new
@level_types = JournalLevelType.all
@author_types = JournalAuthorType.all
@paper_types= JournalPaperType.all
@co_author_candidate =
CoAuthor.where(name_id: current_user.id).map{|c|c.co_author}
@journal_candidate =
WritingJournal.where(create_user_id: current_user.id).map{|j|j.journal_title}.uniq
respond_to do |format|
format.html { render :layout => false}
end
end
def edit
@writing_journal = WritingJournal.find(params[:id])
@level_types = JournalLevelType.all
@author_types = JournalAuthorType.all
@paper_types= JournalPaperType.all
respond_to do |format|
format.html { render :layout => false}
end
end
def create
params[:writing_journal][:create_user_id] = current_user.id
@writing_journal = WritingJournal.new(params[:writing_journal])
if @writing_journal.save
render json: {success: true, msg: t('create.success.paper')}.to_json
else
error_msg = @writing_journal.errors.full_messages.join("<br />")
render json: {success: false, msg: error_msg}.to_json
end
end
def update
params[:writing_journal][:update_user_id] = current_user.id
@writing_journal= WritingJournal.find(params[:id])
if @writing_journal.update_attributes(params[:writing_journal])
render json: {success: true, msg: t('update.success.paper')}.to_json
else
error_msg = @writing_journal.errors.full_messages.join("<br />")
render json: {success: false, msg: error_msg}.to_json
end
end
def check_file_type file
if not file.nil?
file_type = MIME::Types.type_for(file).first.to_s.split("/")[1]
file_type = "/assets/ft-icons/#{file_type}/#{file_type}-48_32.png"
else
file_type = ""
end
end
def destroy
@writing_journal = WritingJournal.find(params[:id])
@writing_journal.destroy
render :json => {success: true, msg: t('delete.success.paper')}
end
def get_journals_json
publications = WritingJournal.where(create_user_id: current_user.id)
sort_publications= Hash.new
data = Array.new
publications.each do |publication|
if sort_publications[publication.journal_title].nil?
sort_publications[publication.journal_title] = Array.new
end
sort_publications[publication.journal_title] <<
{ title: publication.paper_title,
keywords: publication.keywords,
abstract: publication.abstract,
coauthors: publication.authors,
year: publication.year,
url_edit: edit_desktop_journal_page_path(publication),
url_delete: desktop_journal_page_path(publication),
files: publication.writing_journal_files.collect{|file|
{title: file.title, url: file.file.url, icon: check_file_type(file.file.url)}
}
}
end
sort_publications.each do |journal, papers|
data << {title: journal, papers: papers}
end
render json: JSON.pretty_generate(data)
end
end
+3 -3
View File
@@ -117,8 +117,8 @@ class DesktopController< ApplicationController
widge = DesktopWidget.find(tile.desktop_widget_id.to_s)
# data_content = widge.widget_layout.file
data_content = "/desktop/widget_layout?id="+tile.desktop_widget_id.to_s
jsfile = widge.javascripts.collect{|js| js.file}
cssfile = widge.css_default.file
jsfile = widge.javascripts.collect{|js| js.file.as_json[:file]}
cssfile = widge.css_default.file.as_json[:file]
shape = widge.shape
title = widge.name
else
@@ -212,4 +212,4 @@ class DesktopController< ApplicationController
render :xml=>feed
end
end
end
@@ -1,9 +1,9 @@
require 'mime/types'
class DesktopPublicationsController< ApplicationController
def journal_p
render "desktop/journal_p", :layout => false
end
#def journal_p
# render "desktop/journal_p", :layout => false
#end
def books
render "desktop/books", :layout => false
+5 -1
View File
@@ -28,6 +28,10 @@ class FrontController < ApplicationController
@page_id = params[:page_id]
end
def show_inner_ad_image
@ad_image = AdImage.find(params[:id]) rescue nil
@ad_images = AdImage.all
end
private
@@ -39,7 +43,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
+60
View File
@@ -0,0 +1,60 @@
class MobileController < ApplicationController
layout 'mobile'
before_filter :no_footer_for_app
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
protected
def no_footer_for_app
@no_footer = true if request.path.starts_with?("/app")
end
end
@@ -13,6 +13,7 @@ class OrbitBackendController < ApplicationController
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
+2 -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
@@ -75,7 +74,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