Add impressionist

This commit is contained in:
Christophe Vilayphiou committed 2012-05-15 21:26:09 +08:00
1 parent 53a0fbddf0
commit e54f4409fb
21 files changed
+212 -83

No files matched your search

@@ -7,6 +7,7 @@ class Admin::DashboardsController < ApplicationController
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')
@most_visited = get_most_visited('bulletin', 'news_bulletin', 'page_context')
end
protected
@@ -35,5 +36,18 @@ class Admin::DashboardsController < ApplicationController
sorted_objects = a.sort {|a,b| b[1]<=>a[1]}
sorted_objects[0..9]
end
def get_most_visited(*args)
a = {}
args.each do |module_app|
module_app_class = module_app.classify.constantize
objects = module_app_class.order_by(:view_count, :desc).limit(10)
objects.each do |object|
a.merge!(object => object.view_count) if object.view_count > 0
end
end
sorted_objects = a.sort {|a,b| b[1]<=>a[1]}
sorted_objects[0..9]
end
end
@@ -1,9 +1,7 @@
class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController
include OrbitCoreLib::PermissionUnility
layout "new_admin"
before_filter :force_order
layout "new_admin"
before_filter :force_order
def setting
+15 -17
View File
@@ -7,6 +7,7 @@ class PagesController < ApplicationController
def index
@item = Page.find_by_name('home')
if @item
impressionist(@item)
render_page
else
render :text => 'You need a home page'
@@ -14,18 +15,19 @@ class PagesController < ApplicationController
end
def show
#begin
@item = Item.first(:conditions => {:path => params[:page_name]})
if @item && @item.is_published && (@item.enabled_for.nil? ? true : @item.enabled_for.include?(I18n.locale.to_s))
case @item._type
when 'Page'
render_page
when 'Link'
redirect_to @item[:url]
end
else
render :file => "#{Rails.root}/public/404.html", :status => :not_found
end
#begin
@item = Item.first(:conditions => {:path => params[:page_name]})
if @item && @item.is_published && (@item.enabled_for.nil? ? true : @item.enabled_for.include?(I18n.locale.to_s))
impressionist(@item)
case @item._type
when 'Page'
render_page
when 'Link'
redirect_to @item[:url]
end
else
render :file => "#{Rails.root}/public/404.html", :status => :not_found
end
#rescue
# render :file => "#{Rails.root}/public/404.html", :status => :not_found
#end
@@ -55,11 +57,7 @@ class PagesController < ApplicationController
def get_item
module_app = ModuleApp.first(:conditions => {:key => params[:app_name]})
# if params[:category_id]
# @item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category => params[:category_id]})
# else
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action]})
# end
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action]})
end
end