Add impressionist
This commit is contained in:
parent
53a0fbddf0
commit
e54f4409fb
2
Gemfile
2
Gemfile
|
@ -31,6 +31,8 @@ gem 'sprockets'
|
||||||
gem 'tinymce-rails'
|
gem 'tinymce-rails'
|
||||||
gem 'therubyracer' if RUBY_PLATFORM.downcase.include?("linux")
|
gem 'therubyracer' if RUBY_PLATFORM.downcase.include?("linux")
|
||||||
|
|
||||||
|
gem "impressionist", :require => "impressionist", :path => "vendor/impressionist"
|
||||||
|
|
||||||
# Gems used only for assets and not required
|
# Gems used only for assets and not required
|
||||||
# in production environments by default.
|
# in production environments by default.
|
||||||
group :assets do
|
group :assets do
|
||||||
|
|
|
@ -7,6 +7,13 @@ GIT
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
railties (>= 3.0.0)
|
railties (>= 3.0.0)
|
||||||
|
|
||||||
|
PATH
|
||||||
|
remote: vendor/impressionist
|
||||||
|
specs:
|
||||||
|
impressionist (1.1.1)
|
||||||
|
httpclient (~> 2.2)
|
||||||
|
nokogiri (~> 1.5)
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: http://rubygems.org/
|
remote: http://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
|
@ -92,6 +99,7 @@ GEM
|
||||||
hike (1.2.1)
|
hike (1.2.1)
|
||||||
hoe (2.16.1)
|
hoe (2.16.1)
|
||||||
rake (~> 0.8)
|
rake (~> 0.8)
|
||||||
|
httpclient (2.2.5)
|
||||||
i18n (0.6.0)
|
i18n (0.6.0)
|
||||||
jquery-rails (1.0.19)
|
jquery-rails (1.0.19)
|
||||||
railties (~> 3.0)
|
railties (~> 3.0)
|
||||||
|
@ -273,6 +281,7 @@ DEPENDENCIES
|
||||||
exception_notification
|
exception_notification
|
||||||
execjs
|
execjs
|
||||||
factory_girl_rails
|
factory_girl_rails
|
||||||
|
impressionist!
|
||||||
jquery-rails
|
jquery-rails
|
||||||
jquery-ui-rails
|
jquery-ui-rails
|
||||||
kaminari!
|
kaminari!
|
||||||
|
|
|
@ -7,6 +7,7 @@ class Admin::DashboardsController < ApplicationController
|
||||||
def index
|
def index
|
||||||
@module_app_contents, @module_app_contents_total = get_module_app_count('bulletin', 'news_bulletin', 'page_context', 'web_link')
|
@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')
|
@recent_updated = get_recently_updated('bulletin', 'news_bulletin', 'page_context', 'web_link')
|
||||||
|
@most_visited = get_most_visited('bulletin', 'news_bulletin', 'page_context')
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
@ -35,5 +36,18 @@ class Admin::DashboardsController < ApplicationController
|
||||||
sorted_objects = a.sort {|a,b| b[1]<=>a[1]}
|
sorted_objects = a.sort {|a,b| b[1]<=>a[1]}
|
||||||
sorted_objects[0..9]
|
sorted_objects[0..9]
|
||||||
end
|
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
|
end
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController
|
class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController
|
||||||
include OrbitCoreLib::PermissionUnility
|
include OrbitCoreLib::PermissionUnility
|
||||||
layout "new_admin"
|
|
||||||
before_filter :force_order
|
|
||||||
|
|
||||||
layout "new_admin"
|
before_filter :force_order
|
||||||
|
|
||||||
|
|
||||||
def setting
|
def setting
|
||||||
|
|
|
@ -7,6 +7,7 @@ class PagesController < ApplicationController
|
||||||
def index
|
def index
|
||||||
@item = Page.find_by_name('home')
|
@item = Page.find_by_name('home')
|
||||||
if @item
|
if @item
|
||||||
|
impressionist(@item)
|
||||||
render_page
|
render_page
|
||||||
else
|
else
|
||||||
render :text => 'You need a home page'
|
render :text => 'You need a home page'
|
||||||
|
@ -14,18 +15,19 @@ class PagesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
#begin
|
#begin
|
||||||
@item = Item.first(:conditions => {:path => params[:page_name]})
|
@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))
|
if @item && @item.is_published && (@item.enabled_for.nil? ? true : @item.enabled_for.include?(I18n.locale.to_s))
|
||||||
case @item._type
|
impressionist(@item)
|
||||||
when 'Page'
|
case @item._type
|
||||||
render_page
|
when 'Page'
|
||||||
when 'Link'
|
render_page
|
||||||
redirect_to @item[:url]
|
when 'Link'
|
||||||
end
|
redirect_to @item[:url]
|
||||||
else
|
end
|
||||||
render :file => "#{Rails.root}/public/404.html", :status => :not_found
|
else
|
||||||
end
|
render :file => "#{Rails.root}/public/404.html", :status => :not_found
|
||||||
|
end
|
||||||
#rescue
|
#rescue
|
||||||
# render :file => "#{Rails.root}/public/404.html", :status => :not_found
|
# render :file => "#{Rails.root}/public/404.html", :status => :not_found
|
||||||
#end
|
#end
|
||||||
|
@ -55,11 +57,7 @@ class PagesController < ApplicationController
|
||||||
|
|
||||||
def get_item
|
def get_item
|
||||||
module_app = ModuleApp.first(:conditions => {:key => params[:app_name]})
|
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]})
|
||||||
# @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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,26 +3,26 @@ module Admin::DashboardHelper
|
||||||
def get_link(title)
|
def get_link(title)
|
||||||
case title
|
case title
|
||||||
when 'bulletin'
|
when 'bulletin'
|
||||||
panel_announcement_back_end_bulletins_path
|
panel_announcement_front_end_bulletins_path
|
||||||
when 'news_bulletin'
|
when 'news_bulletin'
|
||||||
panel_news_back_end_news_bulletins_path
|
panel_news_front_end_news_bulletins_path
|
||||||
when'page_context'
|
when'page_context'
|
||||||
panel_page_content_back_end_page_contexts_path
|
panel_page_content_front_end_page_contexts_path
|
||||||
when'web_link'
|
when'web_link'
|
||||||
panel_web_resource_back_end_web_links_path
|
panel_web_resource_front_end_web_links_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_link_to_object(object)
|
def get_link_to_object(object)
|
||||||
case object._type.underscore
|
case object._type.underscore
|
||||||
when 'bulletin'
|
when 'bulletin'
|
||||||
panel_announcement_back_end_bulletin_path(object)
|
panel_announcement_front_end_bulletin_path(object)
|
||||||
when 'news_bulletin'
|
when 'news_bulletin'
|
||||||
panel_news_back_end_news_bulletin_path(object)
|
panel_news_front_end_news_bulletin_path(object)
|
||||||
when'page_context'
|
when'page_context'
|
||||||
panel_page_content_back_end_page_context_path(object)
|
panel_page_content_front_end_page_context_path(object)
|
||||||
when'web_link'
|
when'web_link'
|
||||||
panel_web_resource_back_end_web_link_path(object)
|
panel_web_resource_front_end_web_link_path(object)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,6 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def visible_for_controllers(*controller_names)
|
def visible_for_controllers(*controller_names)
|
||||||
puts controller_names
|
|
||||||
(controller_names.include?(controller.controller_name) || controller_names.include?(request.fullpath)) ? '' : 'hide'
|
(controller_names.include?(controller.controller_name) || controller_names.include?(request.fullpath)) ? '' : 'hide'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -173,4 +172,28 @@ module ApplicationHelper
|
||||||
locale.to_sym == I18n.locale ? 'active in': ''
|
locale.to_sym == I18n.locale ? 'active in': ''
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def dislpay_view_count(object)
|
||||||
|
"#{t(:view_count)}: #{object.view_count}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def display_visitors(options={})
|
||||||
|
Impression.where(options).distinct(:session_hash).count
|
||||||
|
end
|
||||||
|
|
||||||
|
def display_visitors_today
|
||||||
|
display_visitors(created_at: {'$gte' => Date.today.beginning_of_day, '$lte' => Date.today.end_of_day})
|
||||||
|
end
|
||||||
|
|
||||||
|
def display_visitors_this_week
|
||||||
|
display_visitors(created_at: {'$gte' => Date.today.beginning_of_week, '$lte' => Date.today.end_of_week})
|
||||||
|
end
|
||||||
|
|
||||||
|
def display_visitors_this_month
|
||||||
|
display_visitors(created_at: {'$gte' => Date.today.beginning_of_month, '$lte' => Date.today.end_of_month})
|
||||||
|
end
|
||||||
|
|
||||||
|
def display_visitors_this_year
|
||||||
|
display_visitors(created_at: {'$gte' => Date.today.beginning_of_year, '$lte' => Date.today.end_of_year})
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
class Page < Item
|
class Page < Item
|
||||||
|
include Impressionist::Impressionable
|
||||||
|
|
||||||
|
is_impressionable :counter_cache => { :column_name => :view_count }
|
||||||
|
|
||||||
field :content
|
field :content
|
||||||
field :app_frontend_url
|
field :app_frontend_url
|
||||||
field :theme_id, :type => BSON::ObjectId, :default => nil
|
field :theme_id, :type => BSON::ObjectId, :default => nil
|
||||||
field :category
|
field :category
|
||||||
field :tag
|
field :tag
|
||||||
|
field :view_count, :type => Integer, :default => 0
|
||||||
|
|
||||||
belongs_to :design
|
belongs_to :design
|
||||||
belongs_to :module_app
|
belongs_to :module_app
|
||||||
|
|
|
@ -380,49 +380,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="item element">
|
|
||||||
<h3><i class="icons-"></i><a href=""><%= t(:traffic) %></a></h3>
|
|
||||||
<div class="detail w-a h-a">
|
|
||||||
<p class="totle"><span><%= t(:total_visitors) %></span>438,913</p>
|
|
||||||
<table class="table table-striped">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th><%= t(:item) %></th>
|
|
||||||
<th class="span2"><%= t(:data) %></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
</table>
|
|
||||||
<div class="detal-list my_scroll">
|
|
||||||
<div class="scrollbar">
|
|
||||||
<div class="track">
|
|
||||||
<div class="thumb">
|
|
||||||
<div class="end"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="viewport">
|
|
||||||
<div class="overview">
|
|
||||||
<table class="table table-striped">
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>Visitors Today</td>
|
|
||||||
<td>2,304</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Visitors This Month</td>
|
|
||||||
<td>783</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Visitor This Tear</td>
|
|
||||||
<td>45</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="item element">
|
<div class="item element">
|
||||||
<h3><i class="icons-"></i><a href=""><%= t(:site_info) %></a></h3>
|
<h3><i class="icons-"></i><a href=""><%= t(:site_info) %></a></h3>
|
||||||
<div class="detail noStatistics w-b h-a">
|
<div class="detail noStatistics w-b h-a">
|
||||||
|
@ -481,6 +439,56 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div> -->
|
</div> -->
|
||||||
|
|
||||||
|
|
||||||
|
<div class="item element">
|
||||||
|
<h3><i class="icons-"></i><%= t(:traffic) %></h3>
|
||||||
|
<div class="detail w-a h-a">
|
||||||
|
<p class="totle"><span><%= t(:total_visitors) %></span><%= display_visitors %></p>
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><%= t(:item) %></th>
|
||||||
|
<th class="span2"><%= t(:data) %></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
</table>
|
||||||
|
<div class="detal-list my_scroll">
|
||||||
|
<div class="scrollbar">
|
||||||
|
<div class="track">
|
||||||
|
<div class="thumb">
|
||||||
|
<div class="end"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="viewport">
|
||||||
|
<div class="overview">
|
||||||
|
<table class="table table-striped">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td><%= t(:visitors_today) %></td>
|
||||||
|
<td><%= display_visitors_today %></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><%= t(:visitors_this_week) %></td>
|
||||||
|
<td><%= display_visitors_this_week %></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><%= t(:visitors_this_month) %></td>
|
||||||
|
<td><%= display_visitors_this_month %></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><%= t(:visitors_this_year) %></td>
|
||||||
|
<td><%= display_visitors_this_year %></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="item element">
|
<div class="item element">
|
||||||
<h3><i class="icons-"></i><%= t(:recent_update) %></h3>
|
<h3><i class="icons-"></i><%= t(:recent_update) %></h3>
|
||||||
<div class="detail noStatistics w-b h-a">
|
<div class="detail noStatistics w-b h-a">
|
||||||
|
@ -517,4 +525,43 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="item element">
|
||||||
|
<h3><i class="icons-"></i><a href=""><%= t(:most_visited_page) %></a></h3>
|
||||||
|
<div class="detail noStatistics w-b h-a">
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><%= t(:title) %></th>
|
||||||
|
<th class="span2"><%= t(:module) %></th>
|
||||||
|
<th class="span2"><%= t(:hits) %></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
</table>
|
||||||
|
<div class="detal-list my_scroll">
|
||||||
|
<div class="scrollbar">
|
||||||
|
<div class="track">
|
||||||
|
<div class="thumb">
|
||||||
|
<div class="end"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="viewport">
|
||||||
|
<div class="overview">
|
||||||
|
<table class="table table-striped">
|
||||||
|
<tbody>
|
||||||
|
<% @most_visited.each do |object| %>
|
||||||
|
<tr>
|
||||||
|
<td><%= link_to ((object[0].title[I18n.locale] rescue nil) || (object[0].page.i18n_variable[I18n.locale] rescue nil)), get_link_to_object(object[0]) %></td>
|
||||||
|
<td class="span2"><%= link_to t("dashboard.#{object[0]._type.underscore}"), get_link(object[0]._type.underscore) %></td>
|
||||||
|
<td class="span2"><%= object[1] %></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
|
@ -0,0 +1,6 @@
|
||||||
|
# Use this hook to configure impressionist parameters
|
||||||
|
Impressionist.setup do |config|
|
||||||
|
# Define ORM. Could be :active_record (default) and :mongo_mapper
|
||||||
|
# config.orm = :active_record
|
||||||
|
config.orm = :mongoid
|
||||||
|
end
|
|
@ -42,6 +42,7 @@ en:
|
||||||
sure?: Are you sure?
|
sure?: Are you sure?
|
||||||
update: Update
|
update: Update
|
||||||
view: View
|
view: View
|
||||||
|
view_count: View count
|
||||||
yes_: "Yes"
|
yes_: "Yes"
|
||||||
|
|
||||||
all_content: All Content
|
all_content: All Content
|
||||||
|
@ -67,6 +68,11 @@ en:
|
||||||
total_visitors: Total Visitors
|
total_visitors: Total Visitors
|
||||||
traffic: Traffic
|
traffic: Traffic
|
||||||
|
|
||||||
|
visitors_today: Today's visitors
|
||||||
|
visitors_this_week: This week's visitors
|
||||||
|
visitors_this_month: This month's visitors
|
||||||
|
visitors_this_year: This year's visitors
|
||||||
|
|
||||||
admin:
|
admin:
|
||||||
access:
|
access:
|
||||||
denied:
|
denied:
|
||||||
|
|
|
@ -36,11 +36,12 @@ zh_tw:
|
||||||
sure?: 您肯定嗎?
|
sure?: 您肯定嗎?
|
||||||
update: 更新
|
update: 更新
|
||||||
view: 檢視
|
view: 檢視
|
||||||
|
view_count: 查看次數
|
||||||
yes_: "Yes"
|
yes_: "Yes"
|
||||||
|
|
||||||
all_content: 全部內容有:
|
all_content: 全部內容有
|
||||||
all_file: 全部檔案有:
|
all_file: 全部檔案有
|
||||||
all_member: 成員總數:
|
all_member: 成員總數
|
||||||
content: 內容
|
content: 內容
|
||||||
data: 數據
|
data: 數據
|
||||||
file: 檔案
|
file: 檔案
|
||||||
|
@ -58,9 +59,14 @@ zh_tw:
|
||||||
site_name: 網站名稱
|
site_name: 網站名稱
|
||||||
statistics: 統計
|
statistics: 統計
|
||||||
title: 標題
|
title: 標題
|
||||||
total_visitors: 造訪次數:
|
total_visitors: 造訪次數
|
||||||
traffic: 流量
|
traffic: 流量
|
||||||
|
|
||||||
|
visitors_today: 今日造訪
|
||||||
|
visitors_this_week: 本星期造訪
|
||||||
|
visitors_this_month: 本月造訪
|
||||||
|
visitors_this_year: 今年造訪
|
||||||
|
|
||||||
admin:
|
admin:
|
||||||
access:
|
access:
|
||||||
denied:
|
denied:
|
||||||
|
|
|
@ -29,6 +29,7 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
|
||||||
preview_content
|
preview_content
|
||||||
else
|
else
|
||||||
@bulletin = Bulletin.can_display.where(_id: params[:id]).first
|
@bulletin = Bulletin.can_display.where(_id: params[:id]).first
|
||||||
|
impressionist(@bulletin)
|
||||||
get_categorys
|
get_categorys
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,9 @@ class Bulletin
|
||||||
include Mongoid::Document
|
include Mongoid::Document
|
||||||
include Mongoid::Timestamps
|
include Mongoid::Timestamps
|
||||||
include Mongoid::MultiParameterAttributes
|
include Mongoid::MultiParameterAttributes
|
||||||
|
include Impressionist::Impressionable
|
||||||
|
|
||||||
|
is_impressionable :counter_cache => { :column_name => :view_count }
|
||||||
|
|
||||||
has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
|
has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
|
||||||
has_one :subtitle, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
|
has_one :subtitle, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
|
||||||
|
@ -23,6 +26,7 @@ class Bulletin
|
||||||
field :is_pending, :type => Boolean, :default => true
|
field :is_pending, :type => Boolean, :default => true
|
||||||
field :is_rejected, :type => Boolean, :default => false
|
field :is_rejected, :type => Boolean, :default => false
|
||||||
|
|
||||||
|
field :view_count, :type => Integer, :default => 0
|
||||||
|
|
||||||
field :not_checked_reason
|
field :not_checked_reason
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
<span class="date"><%= @bulletin.postdate %></span>
|
<span class="date"><%= @bulletin.postdate %></span>
|
||||||
|
|
|
|
||||||
<a href="" class="unit"><%= User.find(@bulletin.create_user_id).sub_roles.collect{|t| t.key}.join(" ") rescue '' %></a>
|
<a href="" class="unit"><%= User.find(@bulletin.create_user_id).sub_roles.collect{|t| t.key}.join(" ") rescue '' %></a>
|
||||||
|
<span><%= dislpay_view_count(@bulletin) %></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="news_image">
|
<div class="news_image">
|
||||||
|
|
|
@ -30,6 +30,7 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController
|
||||||
preview_content
|
preview_content
|
||||||
else
|
else
|
||||||
@news_bulletin = NewsBulletin.can_display.where(_id: params[:id]).first
|
@news_bulletin = NewsBulletin.can_display.where(_id: params[:id]).first
|
||||||
|
impressionist(@news_bulletin)
|
||||||
get_categorys
|
get_categorys
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,10 @@
|
||||||
class NewsBulletin
|
class NewsBulletin
|
||||||
include Mongoid::Document
|
include Mongoid::Document
|
||||||
include Mongoid::Timestamps
|
include Mongoid::Timestamps
|
||||||
include Mongoid::MultiParameterAttributes
|
include Mongoid::MultiParameterAttributes
|
||||||
|
include Impressionist::Impressionable
|
||||||
|
|
||||||
|
is_impressionable :counter_cache => { :column_name => :view_count }
|
||||||
|
|
||||||
has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
|
has_one :title, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
|
||||||
has_one :subtitle, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
|
has_one :subtitle, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
|
||||||
|
@ -23,6 +26,7 @@ class NewsBulletin
|
||||||
field :is_pending, :type => Boolean, :default => true
|
field :is_pending, :type => Boolean, :default => true
|
||||||
field :is_rejected, :type => Boolean, :default => false
|
field :is_rejected, :type => Boolean, :default => false
|
||||||
|
|
||||||
|
field :view_count, :type => Integer, :default => 0
|
||||||
|
|
||||||
field :not_checked_reason
|
field :not_checked_reason
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
<span class="date"><%= @news_bulletin.postdate %></span>
|
<span class="date"><%= @news_bulletin.postdate %></span>
|
||||||
|
|
|
|
||||||
<a href="" class="unit"><%= @news_bulletin.unit_list_for_anc.title[I18n.locale] rescue '' %></a>
|
<a href="" class="unit"><%= @news_bulletin.unit_list_for_anc.title[I18n.locale] rescue '' %></a>
|
||||||
|
<span><%= dislpay_view_count(@news_bulletin) %></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="news_image">
|
<div class="news_image">
|
||||||
|
|
|
@ -6,10 +6,10 @@ class Panel::PageContent::FrontEnd::PageContextsController < OrbitWidgetControll
|
||||||
end
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
# @page_context = PageContext.where("page_id" => params[:page_id], :archived => false)
|
||||||
# @page_context = PageContext.where("page_id" => params[:page_id], :archived => false)
|
@page_context = PageContext.first(conditions: { page_id: params[:page_id], :archived => false })
|
||||||
@page_context = PageContext.first(conditions: { page_id: params[:page_id], :archived => false })
|
impressionist(@page_context)
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html # index.html.erb
|
format.html # index.html.erb
|
||||||
format.xml { render :xml => @page_contexts }
|
format.xml { render :xml => @page_contexts }
|
||||||
|
|
|
@ -4,15 +4,17 @@ class PageContext
|
||||||
include Mongoid::Document
|
include Mongoid::Document
|
||||||
include Mongoid::Timestamps
|
include Mongoid::Timestamps
|
||||||
include Mongoid::MultiParameterAttributes
|
include Mongoid::MultiParameterAttributes
|
||||||
|
include Impressionist::Impressionable
|
||||||
include OrbitCoreLib::ObjectAuthable
|
include OrbitCoreLib::ObjectAuthable
|
||||||
|
|
||||||
|
is_impressionable :counter_cache => { :column_name => :view_count }
|
||||||
|
|
||||||
has_one :context, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
|
has_one :context, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy
|
||||||
|
|
||||||
field :create_user_id
|
field :create_user_id
|
||||||
field :update_user_id
|
field :update_user_id
|
||||||
field :version, :type => Integer , :default => 0
|
field :version, :type => Integer , :default => 0
|
||||||
|
field :view_count, :type => Integer, :default => 0
|
||||||
|
|
||||||
field :archived, :type => Boolean, :default => false
|
field :archived, :type => Boolean, :default => false
|
||||||
# field :current, :type => Boolean, :default => false
|
# field :current, :type => Boolean, :default => false
|
||||||
|
|
|
@ -6,3 +6,5 @@
|
||||||
<h1 class="h1"><%= @page_context.page.i18n_variable[I18n.locale] rescue nil %></h1>
|
<h1 class="h1"><%= @page_context.page.i18n_variable[I18n.locale] rescue nil %></h1>
|
||||||
|
|
||||||
<div class="page_content"><%= @page_context.context[I18n.locale].html_safe rescue nil %></div>
|
<div class="page_content"><%= @page_context.context[I18n.locale].html_safe rescue nil %></div>
|
||||||
|
|
||||||
|
<div><%= dislpay_view_count(@page_context) %></div>
|
||||||
|
|
Loading…
Reference in New Issue