fix design index bug when start start from blank DB.
add delay impressionist. add several i18n vars
This commit is contained in:
parent
37aa950028
commit
54a35b30be
|
@ -14,7 +14,7 @@ class PagesController < ApplicationController
|
|||
@item = Page.find_by_name('home')
|
||||
|
||||
if @item
|
||||
impressionist(@item)
|
||||
delayed_impressionist(@item)
|
||||
render_page
|
||||
else
|
||||
redirect_to '/admin/dashboards',:notice=>t(:need_home)
|
||||
|
@ -26,7 +26,7 @@ class PagesController < ApplicationController
|
|||
#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)
|
||||
delayed_impressionist(@item)
|
||||
case @item.class.to_s
|
||||
when 'Page'
|
||||
if params[:clicked_field_name]
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
module ApplicationHelper
|
||||
|
||||
FLASH_NOTICE_KEYS = [:error, :notice, :warning]
|
||||
|
||||
def delayed_impressionist(object)
|
||||
Resque.enqueue_at(1.minute.from_now,DelayedImpressionist,object)
|
||||
end
|
||||
|
||||
def check_user_role_enable(attribute_fields)
|
||||
@user.attribute_values.collect{|t| attribute_fields.include?(t.attribute_field) }.include?(true) rescue false
|
||||
end
|
||||
|
||||
def show_attribute_value(value)
|
||||
if value.kind_of? Hash
|
||||
result = []
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
class DelayedImpressionist
|
||||
@queue = :low
|
||||
def self.perform(object)
|
||||
impressionist(object)
|
||||
true
|
||||
end
|
||||
end
|
|
@ -26,7 +26,7 @@ class Item
|
|||
after_save :rebuild_children_path, :if => "path_changed?"
|
||||
|
||||
def enabled_for_lang(lang)
|
||||
enabled_for.include?(lang)
|
||||
enabled_for.include?(lang) rescue false
|
||||
end
|
||||
|
||||
def self.find_by_name(item_name)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<table class="table">
|
||||
<tr>
|
||||
<th>時間</th>
|
||||
<th>使用帳號</th>
|
||||
<th>頁面</th>
|
||||
<th><%= I18n.t 'user_action.time' %></th>
|
||||
<th><%= I18n.t 'user_action.name' %></th>
|
||||
<th><%= I18n.t 'user_action.page' %></th>
|
||||
</tr>
|
||||
|
||||
<% @user_actions.each do |user_action| %>
|
||||
|
|
|
@ -465,6 +465,10 @@ en:
|
|||
url: URL
|
||||
use_status: Use Statue
|
||||
user: User
|
||||
user_action:
|
||||
time: Time
|
||||
name: Account
|
||||
page: Access Page and Action
|
||||
users:
|
||||
admin_change_password: You cannot change your own password here!
|
||||
avatar: Profile Picture
|
||||
|
|
|
@ -466,6 +466,10 @@ zh_tw:
|
|||
url: 網址
|
||||
use_status: 使用狀態
|
||||
user: 使用者
|
||||
user_action:
|
||||
time: 時間
|
||||
name: 使用帳號
|
||||
page: 頁面
|
||||
users:
|
||||
admin_change_password: 您不能在此處修改自己的密碼!
|
||||
avatar: 大頭貼照
|
||||
|
|
|
@ -25,7 +25,7 @@ num_workers.times do |num|
|
|||
end
|
||||
|
||||
w.env = {"QUEUE"=>queue, "RAILS_ENV"=>rails_env}
|
||||
w.start = "HOME=#{user_home} QUEUE=* RAILS_ENV=#{rails_env}" rake -f #{rails_root}/Rakefile resque:work
|
||||
w.start = "HOME=#{user_home} QUEUE=* RAILS_ENV=#{rails_env} rake -f #{rails_root}/Rakefile resque:work"
|
||||
|
||||
w.uid = (rails_env == 'production' )? "root" : development_uid
|
||||
w.gid = (rails_env == 'production' )? "root" : development_gid
|
||||
|
|
|
@ -10,7 +10,7 @@ development_gid = ''
|
|||
w.group = 'resque'
|
||||
w.interval = 30.seconds
|
||||
w.env = {"QUEUE"=>"critical,high,low", "RAILS_ENV"=>rails_env}
|
||||
w.start = "HOME= #{user_home} QUEUE=* RAILS_ENV=#{rails_env}" rake -f #{rails_root}/Rakefile resque:scheduler
|
||||
w.start = "HOME= #{user_home} QUEUE=* RAILS_ENV=#{rails_env} rake -f #{rails_root}/Rakefile resque:scheduler"
|
||||
|
||||
w.uid = (rails_env == 'production' )? "root" : development_uid
|
||||
w.gid = (rails_env == 'production' )? "root" : development_gid
|
||||
|
|
|
@ -23,6 +23,9 @@ namespace :site do
|
|||
|
||||
# home_trans = I18nVariable.create!( :document_class => 'Home', :key => 'home', :en => 'Homepage', :zh_tw => '首頁')
|
||||
design = Design.first
|
||||
site = Site.first
|
||||
site.design = design
|
||||
site.save
|
||||
theme = design.themes.first
|
||||
home = Page.new( :design_id => design.id, :name => 'home', :is_published => true, :theme_id => theme.id )
|
||||
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb
|
||||
index a6535c5..a89f60e 100644
|
||||
--- a/app/controllers/pages_controller.rb
|
||||
+++ b/app/controllers/pages_controller.rb
|
||||
@@ -7,7 +7,7 @@ class PagesController < ApplicationController
|
||||
@item = Page.find_by_name('home')
|
||||
|
||||
if @item
|
||||
- impressionist(@item)
|
||||
+ delayed_impressionist(@item)
|
||||
render_page
|
||||
else
|
||||
render :text => t(:need_home)
|
||||
@@ -18,7 +18,7 @@ class PagesController < ApplicationController
|
||||
#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)
|
||||
+ delayed_impressionist(@item)
|
||||
case @item.class.to_s
|
||||
when 'Page'
|
||||
render_page unless save_from_no_lang_for_page
|
||||
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
|
||||
index e20a0c2..b4aa12b 100644
|
||||
--- a/app/helpers/application_helper.rb
|
||||
+++ b/app/helpers/application_helper.rb
|
||||
@@ -278,4 +278,8 @@ module ApplicationHelper
|
||||
end
|
||||
end
|
||||
|
||||
+ def delayed_impressionist(object)
|
||||
+ Resque.enqueue_at(1.minute.from_now,DelayedImpressionist,object)
|
||||
+ end
|
||||
+
|
||||
end
|
||||
diff --git a/app/jobs/delayed_impressionist.rb b/app/jobs/delayed_impressionist.rb
|
||||
new file mode 100644
|
||||
index 0000000..65a4a6d
|
||||
--- /dev/null
|
||||
+++ b/app/jobs/delayed_impressionist.rb
|
||||
@@ -0,0 +1,7 @@
|
||||
+class DelayedImpressionist
|
||||
+ @queue = :low
|
||||
+ def self.perform(object)
|
||||
+ impressionist(object)
|
||||
+ true
|
||||
+ end
|
||||
+end
|
||||
diff --git a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb
|
||||
index 2fe0f71..72fe43b 100644
|
||||
--- a/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb
|
||||
+++ b/vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb
|
||||
@@ -53,7 +53,7 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
|
||||
else
|
||||
@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(@page_num)
|
||||
end
|
||||
- impressionist(@tag) if @tag
|
||||
+ delayed_impressionist(@tag) if @tag
|
||||
end
|
||||
|
||||
end
|
||||
@@ -66,7 +66,7 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
|
||||
@bulletin = Bulletin.all.can_display.where(_id: params[:id]).first
|
||||
if @bulletin and !@bulletin.disable? and !@bulletin.is_rejected
|
||||
if @bulletin.enabled_for_lang(I18n.locale.to_s)
|
||||
- impressionist(@bulletin)
|
||||
+ delayed_impressionist(@bulletin)
|
||||
get_categorys
|
||||
else
|
||||
render :text => "<div class='alert alert-error'>#{t('sys.can_not_display_due_to_no_context')}</div>".html_safe
|
||||
diff --git a/vendor/built_in_modules/page_content/app/controllers/panel/page_content/front_end/page_contexts_controller.rb b/vendor/built_in_modules/page_content/app/controllers/panel/page_content/front_end/page_contexts_controller.rb
|
||||
index e1e98c7..90a079e 100644
|
||||
--- a/vendor/built_in_modules/page_content/app/controllers/panel/page_content/front_end/page_contexts_controller.rb
|
||||
+++ b/vendor/built_in_modules/page_content/app/controllers/panel/page_content/front_end/page_contexts_controller.rb
|
||||
@@ -8,7 +8,7 @@ class Panel::PageContent::FrontEnd::PageContextsController < OrbitWidgetControll
|
||||
def index
|
||||
# @page_context = PageContext.where("page_id" => params[:page_id], :archived => false)
|
||||
@page_context = PageContext.first(conditions: { page_id: params[:page_id], :archived => false })
|
||||
- impressionist(@page_context)
|
||||
+ delayed_impressionist(@page_context)
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
|
@ -19,10 +19,10 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
|
|||
with(:frontend_search,true)
|
||||
with(:available_lang).any_of([I18n.locale.to_s])
|
||||
end
|
||||
|
||||
search_result = @search.results.collect{|result| result.id}
|
||||
|
||||
@bulletins = Bulletin.all.available_for_lang(I18n.locale).can_display.any_in(_id:search_result).page( params[:page_main]).per(@page_num)
|
||||
render 'index'
|
||||
end
|
||||
|
||||
def index
|
||||
|
@ -61,7 +61,7 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
|
|||
else
|
||||
@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(@page_num)
|
||||
end
|
||||
impressionist(@tag) if @tag
|
||||
delayed_impressionist(@tag) if @tag
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -74,7 +74,7 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
|
|||
@bulletin = Bulletin.all.can_display.where(_id: params[:id]).first
|
||||
if @bulletin and !@bulletin.disable? and !@bulletin.is_rejected
|
||||
if @bulletin.enabled_for_lang(I18n.locale.to_s)
|
||||
impressionist(@bulletin)
|
||||
delayed_impressionist(@bulletin)
|
||||
get_categorys
|
||||
else
|
||||
render :text => "<div class='alert alert-error'>#{t('sys.can_not_display_due_to_no_context')}</div>".html_safe
|
||||
|
|
|
@ -108,7 +108,7 @@ class Bulletin
|
|||
end
|
||||
|
||||
def enabled_for_lang(lang)
|
||||
eval("self.available_for_#{lang}")
|
||||
eval("self.available_for_#{lang}") rescue false
|
||||
end
|
||||
|
||||
def publish_month
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
<% # encoding: utf-8 %>
|
||||
|
||||
<%= flash_messages %>
|
||||
|
||||
<h1 class="h1"><%= @page.title rescue nil %></h1>
|
||||
|
||||
<table class="table table-bordered">
|
||||
<tr>
|
||||
<%= content_tag (:th) do %>
|
||||
<%= t('announcement.bulletin.category') %>
|
||||
<% end if (!params[:search_query].blank? or params[:category_id].blank?)-%>
|
||||
<th><%= t('announcement.bulletin.title') %></th>
|
||||
<th><%= t('announcement.bulletin.postdate') %></th>
|
||||
</tr>
|
||||
|
||||
<% if !params[:name].blank?%>
|
||||
<%= t("search.unit_get",:unit_name => params[:name],:item_num=>@bulletins.count) %>
|
||||
<% end %>
|
||||
|
||||
<% if @bulletins.blank? and !params[:search_query].blank? %>
|
||||
<%=render :partial => 'shared/search_not_found' %>
|
||||
<% elsif !params[:search_query].blank? %>
|
||||
<%= t("search.result_get",:search_word => params[:search_query],:item_num=>@bulletins.count) unless (@bulletins.count == 30) %>
|
||||
<%= t("search.too_many",:search_word => params[:search_query],:exceed_num=>@bulletins.count) if (@bulletins.count ==30) %>
|
||||
<% end %>
|
||||
|
||||
<% @bulletins.each do |post| %>
|
||||
<tr>
|
||||
<td><%= post.bulletin_category.title rescue nil %></td>
|
||||
<td><%= link_to post.title, panel_announcement_front_end_bulletin_path(post, :category_id => post.bulletin_category_id) %>
|
||||
<%#= link_to post.title, panel_announcement_back_end_bulletin_path(post) %>
|
||||
</td>
|
||||
<td><%= display_date_time(post.postdate) %></td>
|
||||
</tr>
|
||||
|
||||
<% end %>
|
||||
|
||||
</table>
|
||||
|
||||
|
|
@ -25,6 +25,7 @@ en:
|
|||
file_name: File Name
|
||||
frontend:
|
||||
bulletins: Announcement front-end
|
||||
search_result: Search result
|
||||
link_name: Link Name
|
||||
new_bulletin_category: New Bulletin Category
|
||||
picture: Cover Picture
|
||||
|
|
|
@ -25,6 +25,7 @@ zh_tw:
|
|||
file_name: 檔案名稱
|
||||
frontend:
|
||||
bulletins: 公告前台
|
||||
search_result: 搜尋結果頁
|
||||
link_name: 連結名稱
|
||||
new_bulletin_category: 新增公告類別
|
||||
picture: 刊頭圖片
|
||||
|
|
|
@ -12,6 +12,10 @@ module Announcement
|
|||
update_info 'some update_info'
|
||||
|
||||
front_end do
|
||||
app_page 'search_result' do
|
||||
frontend_i18n "announcement.frontend.search_result"
|
||||
end
|
||||
|
||||
app_page 'bulletins' do
|
||||
frontend_i18n "announcement.frontend.bulletins"
|
||||
style ["1","2","3"]
|
||||
|
|
|
@ -8,7 +8,7 @@ class Panel::PageContent::FrontEnd::PageContextsController < OrbitWidgetControll
|
|||
def index
|
||||
# @page_context = PageContext.where("page_id" => params[:page_id], :archived => false)
|
||||
@page_context = PageContext.first(conditions: { page_id: params[:page_id], :archived => false })
|
||||
impressionist(@page_context)
|
||||
delayed_impressionist(@page_context)
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
|
|
Loading…
Reference in New Issue