Compare commits
25
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e6511cbcdd | ||
|
|
f664c3715c | ||
|
|
fa1c731ad3 | ||
|
|
2c24e788b0 | ||
|
|
26a8be2f0f | ||
|
|
fa51d16879 | ||
|
|
ceff21fd1f | ||
|
|
1357124f6f | ||
|
|
8c3fb43bf5 | ||
|
|
71e8b3c042 | ||
|
|
b37643147f | ||
|
|
ec57cbff1c | ||
|
|
7d6df11873 | ||
|
|
8043573370 | ||
|
|
f025c98ffa | ||
|
|
3a91c92bf7 | ||
|
|
b1d8a87256 | ||
|
|
c7ac4e2485 | ||
|
|
3467868607 | ||
|
|
ceac2b842c | ||
|
|
c763817ebf | ||
|
|
3c3bba514a | ||
|
|
837dc3ea7b | ||
|
|
ea5d89e0e1 | ||
|
|
aea15fa622 |
No files matched your search
@@ -48,7 +48,7 @@ gem 'sinatra'
|
||||
gem 'sprockets'
|
||||
gem 'social-share-button'
|
||||
|
||||
gem 'tinymce-rails', "~> 3.5.8"
|
||||
gem 'tinymce-rails', '3.5.8.3'
|
||||
gem 'therubyracer' if RUBY_PLATFORM.downcase.include?("linux")
|
||||
gem 'libv8', '~> 3.11.8' if RUBY_PLATFORM.downcase.include?("linux")
|
||||
gem 'mongoid-encryptor', :require => 'mongoid/encryptor'
|
||||
|
||||
@@ -12,22 +12,22 @@ class DefaultWidgetController< OrbitWidgetController
|
||||
|
||||
def query_for_default_widget
|
||||
|
||||
@ori_class_name = @default_widget["query"].split('.')[0]
|
||||
@ori_class_name = @default_widget["query"].split('.')[0]
|
||||
@ori_query = @default_widget["query"]
|
||||
result = nil
|
||||
result_objects = nil
|
||||
|
||||
if !params["tag_id"].blank?
|
||||
if params["category_id"].blank? #has tag no cate
|
||||
result = @ori_class_name.constantize.where(:tagged_ids.in => params["tag_id"])
|
||||
result = eval("#{@ori_query}.where(:tagged_ids.in => params['tag_id'])")
|
||||
else #has tag and cate
|
||||
result = eval("#{@ori_class_name}.where(:#{get_category_field_name}.in=>params['category_id'], :tagged_ids.in => params['tag_id'])")
|
||||
result = eval("#{@ori_query}.where(:#{get_category_field_name}.in=>params['category_id'], :tagged_ids.in => params['tag_id'])")
|
||||
end
|
||||
elsif params["category_id"].blank? #no tag no cate
|
||||
result = eval(@default_widget["query"])
|
||||
result = eval(@ori_query)
|
||||
else #no tag has cate
|
||||
result = eval("#{@ori_class_name}.where(:#{get_category_field_name}.in=>params['category_id'])")
|
||||
result = eval("#{@ori_query}.where(:#{get_category_field_name}.in=>params['category_id'])")
|
||||
end
|
||||
result.available_for_lang(I18n.locale).can_display.desc(:is_top, :postdate)
|
||||
result.available_for_lang(I18n.locale).can_display
|
||||
end
|
||||
|
||||
def search_result
|
||||
|
||||
@@ -7,4 +7,10 @@ class OrbitFrontendComponentController< ApplicationController
|
||||
@app_title = request.fullpath.split('/')[2]
|
||||
end
|
||||
|
||||
def delay_impressionist(item)
|
||||
user_id = current_user.nil? ? nil : current_user.id
|
||||
Resque.enqueue(DelayedImpressionist,:request=>DelayImpressionistRequest.new(request),:obj=>item,:class=>item.class.to_s,:controller_name=>controller_name,:action_name=>action_name,:user=>user_id)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -44,29 +44,13 @@ class PagesController < ApplicationController
|
||||
# render :file => "#{Rails.root}/public/404.html", :status => :not_found
|
||||
#end
|
||||
end
|
||||
|
||||
def convert_array_param(key,array)
|
||||
array.collect{|t| "#{key}[]=#{t}"}.join("&")
|
||||
end
|
||||
|
||||
def index_from_link
|
||||
url = "/#{@item.path}"
|
||||
options = ''
|
||||
options << "#{options.blank? ? '?' : '&'}page_main=#{params[:page_main]}" unless params[:page_main].blank?
|
||||
|
||||
if params[:category_id].is_a? Array
|
||||
options << "#{options.blank? ? '?' : '&'}#{convert_array_param('category_id',params[:category_id])}" unless params[:category_id].blank?
|
||||
elsif params[:category_id].is_a? String
|
||||
options << "#{options.blank? ? '?' : '&'}category_id=#{params[:category_id]}" unless params[:category_id].blank?
|
||||
end
|
||||
|
||||
if params[:tag_id].is_a? Array
|
||||
options << "#{options.blank? ? '?' : '&'}#{convert_array_param('tag_id',params[:tag_id])}" unless params[:tag_id].blank?
|
||||
elsif params[:category_id].is_a? String
|
||||
options << "#{options.blank? ? '?' : '&'}tag_id=#{params[:tag_id]}" unless params[:tag_id].blank?
|
||||
end
|
||||
|
||||
|
||||
options << "#{options.blank? ? '?' : '&'}#{convert_array_param('category_id', params[:category_id])}" unless params[:category_id].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}#{convert_array_param('tag_id', params[:tag_id])}" unless params[:tag_id].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}search_query=#{params[:search_query]}" unless params[:search_query].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}name=#{params[:name]}" unless params[:name].blank?
|
||||
uri = URI::escape(url + options)
|
||||
@@ -78,8 +62,8 @@ class PagesController < ApplicationController
|
||||
url = "/#{@item.path}"
|
||||
options = ''
|
||||
options << "#{options.blank? ? '?' : '&'}id=#{params[:id]}" unless params[:id].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}category_id=#{params[:category_id]}" unless params[:category_id].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}tag_id=#{params[:tag_id]}" unless params[:tag_id].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}#{convert_array_param('category_id', params[:category_id])}" unless params[:category_id].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}#{convert_array_param('tag_id', params[:tag_id])}" unless params[:tag_id].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}preview=#{params[:preview]}" unless params[:preview].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}controller_action=#{params[:controller_action]}" unless params[:controller_action].blank?
|
||||
options << "#{options.blank? ? '?' : '&'}clicked_field_name=#{params[:clicked_field_name]}" unless params[:clicked_field_name].blank?
|
||||
@@ -98,23 +82,43 @@ class PagesController < ApplicationController
|
||||
elsif params[:same_page_id]
|
||||
@item = Item.find(params[:same_page_id])
|
||||
else
|
||||
category_ids = params[:category_id].is_a?(Array) ? params[:category_id] : [params[:category_id]]
|
||||
tag_ids = params[:tag_id].is_a?(Array) ? params[:tag_id] : [params[:tag_id]]
|
||||
category_ids = Array(params[:category_id]) unless params[:category_id].nil?
|
||||
tag_ids = Array(params[:tag_id]) unless params[:tag_id].nil?
|
||||
module_app = ModuleApp.first(:conditions => {:key => params[:app_name]})
|
||||
|
||||
default_query = { is_published: true, module_app_id: module_app.id, :app_frontend_url.in => [params[:app_action], 'default_widget'] }
|
||||
specific_categories = { :category => category_ids }
|
||||
in_categories = { :category.in => category_ids }
|
||||
nil_categories = { :category.in => [nil, []] }
|
||||
specific_tags = { :tag => tag_ids }
|
||||
in_tags = { :tag.in => tag_ids }
|
||||
nil_tags = { :tag.in => [nil, []] }
|
||||
|
||||
if !category_ids.blank? && !tag_ids.blank?
|
||||
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category.in => category_ids, :tag.in => tag_ids})
|
||||
@item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action], :category.in => category_ids, :tag.in => [nil, []]}) unless @item
|
||||
@item = Item.where(default_query.merge(specific_categories).merge(specific_tags)).first
|
||||
@item = Item.where(default_query.merge(specific_categories).merge(in_tags)).first unless @item
|
||||
@item = Item.where(default_query.merge(specific_categories).merge(nil_tags)).first unless @item
|
||||
@item = Item.where(default_query.merge(specific_tags).merge(in_categories)).first unless @item
|
||||
@item = Item.where(default_query.merge(specific_tags).merge(nil_categories)).first unless @item
|
||||
@item = Item.where(default_query.merge(in_categories).merge(in_tags)).first unless @item
|
||||
@item = Item.where(default_query.merge(in_categories).merge(nil_tags)).first unless @item
|
||||
@item = Item.where(default_query.merge(in_tags).merge(nil_categories)).first unless @item
|
||||
elsif !category_ids.blank?
|
||||
@item = Item.where(module_app_id: module_app.id, app_frontend_url: params[:app_action], :category.in => category_ids).any_in(tag: [nil, []]).first
|
||||
@item = Item.where(default_query.merge(specific_categories).merge(nil_tags)).first
|
||||
@item = Item.where(default_query.merge(specific_categories)).first unless @item
|
||||
@item = Item.where(default_query.merge(in_categories).merge(nil_tags)).first unless @item
|
||||
@item = Item.where(default_query.merge(in_categories)).first unless @item
|
||||
elsif !tag_ids.blank?
|
||||
@item = Item.where(module_app_id: module_app.id, app_frontend_url: params[:app_action], :tag.in => tag_ids).any_in(category: [nil, []]).first
|
||||
@item = Item.where(default_query.merge(specific_tags).merge(nil_categories)).first
|
||||
@item = Item.where(default_query.merge(specific_tags)).first unless @item
|
||||
@item = Item.where(default_query.merge(in_tags).merge(nil_categories)).first unless @item
|
||||
@item = Item.where(default_query.merge(in_tags)).first unless @item
|
||||
end
|
||||
@item = Item.find(params[:orig_page]) unless @item || params[:orig_page].blank?
|
||||
@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
|
||||
@item = Item.where(module_app_id: module_app.id, app_frontend_url: 'default_widget').first unless @item
|
||||
@item = Item.where(module_app_id: module_app.id, app_frontend_url: params[:app_action]).first unless @item
|
||||
@item = Item.where(default_query.merge(nil_categories).merge(nil_tags)).first unless @item
|
||||
@item = Item.where(default_query).first unless @item
|
||||
end
|
||||
raise PageError,'Missing Frontend Page' if @item.nil?
|
||||
raise PageError, 'Missing Frontend Page' if @item.nil?
|
||||
end
|
||||
|
||||
def save_from_no_lang_for_page
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
module ApplicationHelper
|
||||
|
||||
include OrbitApp::Module::VisitorCounter
|
||||
FLASH_NOTICE_KEYS = [:error, :notice, :warning]
|
||||
|
||||
|
||||
@@ -7,8 +7,10 @@ module ApplicationHelper
|
||||
request.referer.include?('?') ? [request.referer,param_hash.to_param].join('&') : [request.referer,param_hash.to_param].join('?')
|
||||
end
|
||||
|
||||
def delayed_impressionist(object)
|
||||
# Resque.enqueue_at(1.minute.from_now,DelayedImpressionist,object)
|
||||
def delayed_impressionist(item)
|
||||
user_id = current_user.nil? ? nil : current_user.id
|
||||
request = DelayImpressionistRequest.new(request)
|
||||
Resque.enqueue(DelayedImpressionist,:request=>request,:obj=>item,:class=>item.class.to_s,:controller_name=>controller_name,:action_name=>action_name,:user=>user_id)
|
||||
end
|
||||
|
||||
def check_user_role_enable(attribute_fields)
|
||||
@@ -242,25 +244,27 @@ module ApplicationHelper
|
||||
"#{t(:view_count)}: #{object.view_count}"
|
||||
end
|
||||
|
||||
def display_visitors(options={})
|
||||
Impression.where(options).and(:referrer.ne => nil).distinct(:session_hash).count
|
||||
end
|
||||
# def display_visitors(options={})
|
||||
# # Impression.where(options).and(:referrer.ne => nil).distinct(:session_hash).count
|
||||
# impressions = Impression.where(options).and(:referrer.ne => nil)
|
||||
# impressions.map{|i| i[:session_hash]}.uniq.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_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_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_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
|
||||
# def display_visitors_this_year
|
||||
# display_visitors(created_at: {'$gte' => Date.today.beginning_of_year, '$lte' => Date.today.end_of_year})
|
||||
# end
|
||||
|
||||
def display_date_time(object)
|
||||
object.strftime("%Y-%m-%d %H:%M")
|
||||
@@ -311,4 +315,8 @@ module ApplicationHelper
|
||||
link_to title, params.merge({direction: direction, sort: column, sort_options: column}), {:class => "#{css_class} sortable", :remote => options[:remote]}
|
||||
end
|
||||
|
||||
def convert_array_param(key, array)
|
||||
Array(array).collect{|t| "#{key}[]=#{t}"}.join("&")
|
||||
end
|
||||
|
||||
end
|
||||
@@ -3,6 +3,13 @@ module DefaultWidgetHelper
|
||||
I18n.t("#{@page_part.module_app.key}.default_widget.#{field}")
|
||||
end
|
||||
|
||||
def get_top_hot_class(row_data)
|
||||
class_attr = []
|
||||
class_attr << 'data_is_hot' if( row_data.is_hot? rescue false )
|
||||
class_attr << 'data_is_top' if( row_data.is_top? rescue false)
|
||||
return class_attr.join(" ")
|
||||
end
|
||||
|
||||
def link_to_field(row_data,field, switch, options=nil)
|
||||
method_ary = @page_part.module_app.widget_fields_link_method
|
||||
field = field.to_sym
|
||||
@@ -77,4 +84,13 @@ module DefaultWidgetHelper
|
||||
content_tag(:span,get_display(row_data,field_setting),:class=>field_setting[:class])
|
||||
end
|
||||
end
|
||||
|
||||
def get_row_category(row_data)
|
||||
row_data.send("#{row_data.class.to_s.underscore}_category_id") rescue nil
|
||||
end
|
||||
|
||||
def get_row_tags(row_data)
|
||||
row_data.tagged_ids rescue nil
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,36 +1,21 @@
|
||||
class DashboardCounter < Resque::Plugins::RestrictionJob
|
||||
extend OrbitApp::Module::VisitorCounterEval
|
||||
|
||||
@queue = :high
|
||||
|
||||
def self.perform(*args)
|
||||
site = Site.first
|
||||
obj = new(*args)
|
||||
site.dashboard_counter[:visitors_this_week] = obj.display_visitors_this_week
|
||||
site.dashboard_counter[:visitors_this_month] = obj.display_visitors_this_month
|
||||
site.dashboard_counter[:visitors_this_year] = obj.display_visitors_this_year
|
||||
site.visitor_counters[:total] = display_visitors
|
||||
site.visitor_counters[:today] = display_visitors_today
|
||||
site.visitor_counters[:this_week] = display_visitors_this_week
|
||||
site.visitor_counters[:this_month] = display_visitors_this_month
|
||||
site.visitor_counters[:this_year] = display_visitors_this_year
|
||||
site.save
|
||||
OrbitLogger.info "DashboardCounter done #{site.dashboard_counter.to_s}"
|
||||
end
|
||||
OrbitLogger.info "DashboardCounter done #{site.visitor_counters.to_s}"
|
||||
|
||||
|
||||
def display_visitors(options={})
|
||||
impressions = Impression.where(options).and(:referrer.ne => nil)
|
||||
impressions.map{|i| i[:session_hash]}.uniq.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})
|
||||
#Notice this is mainly used at user dashbroad. however the code there is currentlly using realtime evaluation.
|
||||
#and the site model will need a field call dashboard_counter to complete this job.
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,7 +1,45 @@
|
||||
class DelayedImpressionist
|
||||
@queue = :low
|
||||
def self.perform(object)
|
||||
impressionist(object)
|
||||
true
|
||||
end
|
||||
class DelayedImpressionist
|
||||
def self.before_filter(*args)
|
||||
return
|
||||
end
|
||||
|
||||
include ImpressionistController::InstanceMethods
|
||||
@queue = :low
|
||||
|
||||
def initialize(request,controller_name,action_name,user,obj)
|
||||
@controller_name = controller_name
|
||||
@action_name = action_name
|
||||
@user = User.find user unless user.nil?
|
||||
@request = request
|
||||
end
|
||||
|
||||
def self.perform(*args)
|
||||
arg = args[0]
|
||||
@request= DelayImpressionistRequest.new
|
||||
@request.restore(arg["request"])
|
||||
request = @request
|
||||
obj = eval("#{arg["class"]}.find '#{arg['obj']['_id']}'")
|
||||
# imp = new(@request,arg["controller_name"],arg["action_name"],arg["user"],obj)
|
||||
new_impression = obj.impressions.build(:user_id=>arg["user"],:controller_name=>arg["controller_name"],:action_name=>arg["action_name"],:ip_address=>@request.remote_ip,:referrer=>@request.referer)
|
||||
new_impression.save
|
||||
obj.update_attribute(:view_count,obj.impression_count)
|
||||
end
|
||||
|
||||
private
|
||||
def user
|
||||
@user
|
||||
end
|
||||
|
||||
def action_name
|
||||
@action_name
|
||||
end
|
||||
|
||||
def controller_name
|
||||
@controller_name
|
||||
end
|
||||
|
||||
def request
|
||||
@request
|
||||
end
|
||||
|
||||
end
|
||||
@@ -3,7 +3,7 @@ class UpdateTagCloud
|
||||
|
||||
def self.perform()
|
||||
Tag.all.each do |tag|
|
||||
tag.update_attribute(:cloud_view_count, tag.impressionist_count(:created_at.gte => 14.days.ago, :created_at.lte => Time.now))
|
||||
tag.update_attribute(:cloud_view_count, tag.get_impressionist)
|
||||
end
|
||||
OrbitLogger.info "UpdateTagCloud Done"
|
||||
end
|
||||
|
||||
@@ -140,7 +140,7 @@ class ModuleApp
|
||||
def sorted_tags_for_cloud
|
||||
temp_tags = {}
|
||||
self.tags.each{ |tag|
|
||||
temp_tags.merge!({tag => Tag.get_impressionist(tag)})
|
||||
temp_tags.merge!({tag => tag.cloud_view_count})
|
||||
}
|
||||
if !temp_tags.blank?
|
||||
sorted_tags = temp_tags.sort{|a,b| a[1]<=>b[1]}.reverse
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ class Page < Item
|
||||
include Impressionist::Impressionable
|
||||
include ParserFrontEnd
|
||||
|
||||
is_impressionable :counter_cache => { :column_name => :view_count }
|
||||
is_impressionable #:counter_cache => { :column_name => :view_count }
|
||||
|
||||
field :content, localize: true
|
||||
field :app_frontend_url
|
||||
|
||||
@@ -18,6 +18,7 @@ class Site
|
||||
field :title_always_on, :type => Boolean, :default => false
|
||||
field :dashbroad_allow_visitor, :type => Boolean, :default => false
|
||||
field :mail_settings, :type => Hash
|
||||
field :visitor_counters,:type=> Hash,:default=>{:total=>0,:today=>0,:this_week=>0,:this_month=>0,:this_year=>0}
|
||||
|
||||
field :disk_space, :type => String
|
||||
field :system_package_info, :type => Hash,:default=>{}
|
||||
|
||||
+1
-25
@@ -8,7 +8,7 @@ class Tag
|
||||
include Mongoid::Timestamps
|
||||
include Impressionist::Impressionable
|
||||
|
||||
is_impressionable :counter_cache => { :column_name => :view_count }
|
||||
is_impressionable #:counter_cache => { :column_name => :view_count }
|
||||
|
||||
field :name, localize: true
|
||||
field :view_count, :type => Integer, :default => 0
|
||||
@@ -17,30 +17,6 @@ class Tag
|
||||
belongs_to :module_tag, polymorphic: true
|
||||
has_many :taggings, dependent: :destroy
|
||||
|
||||
#field :cloud_amper,:type: Integer,:default=> 0
|
||||
|
||||
# def self.sorted_for_cloud
|
||||
# tags = {}
|
||||
# self.all.each{ |tag|
|
||||
# tags.merge!({tag => self.get_impressionist(tag)})
|
||||
# }
|
||||
# if !tags.blank?
|
||||
# sorted_tags = tags.sort{|a,b| a[1]<=>b[1]}.reverse
|
||||
# sorted_tags[0][1] = :hot1
|
||||
# offset = (sorted_tags.size - 1) / 3
|
||||
# i = 1
|
||||
# class_i = 2
|
||||
# sorted_tags[1..-1].collect!{ |x|
|
||||
# x[1] = "hot#{class_i}"
|
||||
# i == offset ? i = 1 : i += 1 if class_i < 4
|
||||
# class_i += 1 if i == offset && class_i < 4
|
||||
# }
|
||||
# sorted_tags
|
||||
# else
|
||||
# []
|
||||
# end
|
||||
# end
|
||||
|
||||
protected
|
||||
|
||||
def self.get_impressionist(item_tag = self)
|
||||
|
||||
@@ -3,7 +3,7 @@ class User
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :registerable, :validatable #, :timeoutable
|
||||
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable #, :timeoutable
|
||||
|
||||
mount_uploader :avatar, AvatarUploader
|
||||
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
<%= content_tag :div,:class=>@tag_class do%>
|
||||
<%= content_tag :div, class: @tag_class do %>
|
||||
<div class="default_widget_type_A">
|
||||
<table class="default_widget_tb" border="0" cellpadding="0" cellspacing="0" >
|
||||
<thead>
|
||||
<tr>
|
||||
<% @frontend_field_names.each_with_index do |field,index|%>
|
||||
<%= content_tag(:th,content_tag(:span,get_field_header(field),:class=>@frontend_classes[index]))unless field.blank?%>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
<% @data.each do |row_data| %>
|
||||
<thead>
|
||||
<tr>
|
||||
<% @frontend_field_names.each_with_index do |field,index|%>
|
||||
<%= content_tag(:td,content_tag(:span,link_to_field(row_data,field, @frontend_sat_to_links[index], {orig_page: @page_id.to_s}),:class=>@frontend_classes[index]))unless field.blank?%>
|
||||
<% @frontend_field_names.each_with_index do |field, index| %>
|
||||
<%= content_tag(:th, content_tag(:span, get_field_header(field), class: @frontend_classes[index])) unless field.blank? %>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @data.each do |row_data| %>
|
||||
<tr class="<%= get_top_hot_class(row_data) %>">
|
||||
<% @frontend_field_names.each_with_index do |field, index|%>
|
||||
<%= content_tag(:td, content_tag(:span, link_to_field(row_data, field, @frontend_sat_to_links[index], {orig_page: @page_id.to_s, category_id: get_row_category(row_data), tag_id: get_row_tags(row_data)}), class: @frontend_classes[index])) unless field.blank? %>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -1,13 +1,13 @@
|
||||
<%= content_tag :div,:class=>@tag_class do%>
|
||||
<%= content_tag :div, class: @tag_class do %>
|
||||
<ul class="default_widget_list">
|
||||
<% @data.each do |row_data| %>
|
||||
<%= content_tag(:li) do %>
|
||||
<%= content_tag(:li, class: get_top_hot_class(row_data)) do %>
|
||||
<div class="img app-pic">
|
||||
<%= image_tag row_data.send(@widget_image_field)%>
|
||||
<%= image_tag row_data.send(@widget_image_field) %>
|
||||
</div>
|
||||
<div class="wrap">
|
||||
<% @frontend_field_names.each_with_index do |field,index|%>
|
||||
<%= content_tag(:span,link_to_field(row_data,field, @frontend_sat_to_links[index], {orig_page: @page_id.to_s}),:class=>@frontend_classes[index]) unless field.blank?%>
|
||||
<% @frontend_field_names.each_with_index do |field, index| %>
|
||||
<%= content_tag(:span, link_to_field(row_data,field, @frontend_sat_to_links[index], {orig_page: @page_id.to_s, category_id: get_row_category(row_data), tag_id: get_row_tags(row_data)}), class: @frontend_classes[index]) unless field.blank? %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<%= content_tag :div,:class=>@tag_class do%>
|
||||
<%= content_tag :div, class: @tag_class do %>
|
||||
<div class="img app-pic">
|
||||
<%= image_tag @data.first.send(@widget_image_field)%>
|
||||
<%= image_tag @data.first.send(@widget_image_field) %>
|
||||
</div>
|
||||
<ul class="default_widget_list">
|
||||
<% @data.each do |row_data| %>
|
||||
<%= content_tag(:li) do %>
|
||||
<% @frontend_field_names.each_with_index do |field,index|%>
|
||||
<%= content_tag(:span, link_to_field(row_data,field, @frontend_sat_to_links[index], {orig_page: @page_id.to_s}),:class=>@frontend_classes[index]) unless field.blank?%>
|
||||
<%= content_tag(:li, class: get_top_hot_class(row_data)) do %>
|
||||
<% @frontend_field_names.each_with_index do |field, index|%>
|
||||
<%= content_tag(:span, link_to_field(row_data, field, @frontend_sat_to_links[index], {orig_page: @page_id.to_s, category_id: get_row_category(row_data), tag_id: get_row_tags(row_data)}), class: @frontend_classes[index]) unless field.blank? %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
dashboard_counter_cache:
|
||||
cron: 0 * * * * *
|
||||
class: DashboardCounter
|
||||
args:
|
||||
description: DashboardCounterCache
|
||||
|
||||
update_tag_cloud:
|
||||
cron: 0 0 [0,12] * * *
|
||||
class: UpdateTagCloud
|
||||
@@ -14,4 +20,4 @@ email_cron:
|
||||
cron: 0 0 [10,16,22] * * *
|
||||
class: EmailCron
|
||||
args:
|
||||
description: EmailCron
|
||||
description: EmailCron
|
||||
@@ -0,0 +1,18 @@
|
||||
class DelayImpressionistRequest
|
||||
attr_accessor :session_options,:remote_ip,:referer,:user_agent
|
||||
def initialize(request=nil)
|
||||
if request
|
||||
self.session_options=request.session_options
|
||||
self.remote_ip=request.remote_ip
|
||||
self.referer=request.referer
|
||||
self.user_agent=request.user_agent
|
||||
end
|
||||
end
|
||||
|
||||
def restore(args)
|
||||
args.each do |key,value|
|
||||
self.send("#{key}=", value)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -6,15 +6,14 @@ module DefaultWidgetTagHelper
|
||||
@request = req
|
||||
params.delete :inner
|
||||
@params = params
|
||||
|
||||
params_str ="?"
|
||||
params_str = "?"
|
||||
params.each do |index,param|
|
||||
if param.is_a?(Array) and !param.blank?
|
||||
params_str << "&" unless params_str.eql?("?")
|
||||
params_str << param.collect{|t| "#{index}[]=#{t}"}.join("&")
|
||||
params.delete index
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
params_str = params_str + (params_str.eql?("?") ? params.to_param : "&#{params.to_param}" )
|
||||
content_tag :div,:class=> 'more' do
|
||||
link_to I18n.t(@more_link[:label_i18n]),[eval("#{@more_link[:path_method]}"),params_str].join()
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
module OrbitApp
|
||||
module Module
|
||||
module VisitorCounter
|
||||
Version = "0.1"
|
||||
|
||||
def display_visitors(options={})
|
||||
Site.first.visitor_counters["total"]
|
||||
end
|
||||
|
||||
def display_visitors_today
|
||||
Site.first.visitor_counters["today"]
|
||||
end
|
||||
|
||||
def display_visitors_this_week
|
||||
Site.first.visitor_counters["this_week"]
|
||||
end
|
||||
|
||||
def display_visitors_this_month
|
||||
Site.first.visitor_counters["this_month"]
|
||||
end
|
||||
|
||||
def display_visitors_this_year
|
||||
Site.first.visitor_counters["this_year"]
|
||||
end
|
||||
|
||||
end # of VisitorCounter
|
||||
end # of Module
|
||||
end # of OrbitApp
|
||||
@@ -0,0 +1,27 @@
|
||||
module OrbitApp
|
||||
module Module
|
||||
module VisitorCounterEval
|
||||
Version = "0.1"
|
||||
|
||||
def display_visitors(options={})
|
||||
impressions = Impression.where(options).and(:referrer.ne => nil).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 of VisitorCounterEval
|
||||
end # of Module
|
||||
end # of OrbitApp
|
||||
@@ -43,6 +43,7 @@ module OrbitTag
|
||||
def tags=(tag_ids)
|
||||
ids = [tag_ids].flatten
|
||||
tag_ids.delete('')
|
||||
self.tagged_ids = tag_ids
|
||||
ids = self.taggings.blank? ? [] : self.taggings.map{|t| t.tag.id}
|
||||
tag_ids.each do |tag_id|
|
||||
unless ids.include? tag_id
|
||||
@@ -58,9 +59,6 @@ module OrbitTag
|
||||
|
||||
def tag_ids=(ids)
|
||||
self.tags = ids
|
||||
ids = [ids].flatten
|
||||
ids.delete('')
|
||||
self.tagged_ids = ids
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -310,4 +310,20 @@ namespace :migrate do
|
||||
Rake::Task["web_link_url:web_link_url_i18n"].execute
|
||||
end
|
||||
|
||||
task :fix_tagged_ids => :environment do
|
||||
Tag.all.each do |tag|
|
||||
tag.taggings.each do |tagging|
|
||||
tagged_ids = tagging.taggable.tagged_ids
|
||||
unless tagged_ids.include?(tag.id.to_s)
|
||||
tagged_ids << tag.id.to_s
|
||||
tagging.taggable.update_attribute(:tagged_ids, tagged_ids)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
task :clear_news_tags => :environment do
|
||||
`mongo #{Mongoid.config.database.name} --eval "db.tags.remove({_type: {$ne: 'Tag'}})"`
|
||||
end
|
||||
|
||||
end
|
||||
+6
-1
@@ -26,6 +26,7 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
|
||||
end
|
||||
|
||||
def index
|
||||
|
||||
@item = Page.find(params[:page_id]) rescue nil
|
||||
if @item
|
||||
if @item.frontend_data_count
|
||||
@@ -60,7 +61,11 @@ 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
|
||||
delayed_impressionist(@tag) if @tag
|
||||
if params["tag_id"]
|
||||
params["tag_id"].each do |tag_id|
|
||||
delayed_impressionist(Tag.find tag_id) rescue nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -14,7 +14,7 @@ class Bulletin
|
||||
include OrbitTag::Taggable
|
||||
taggable
|
||||
|
||||
is_impressionable :counter_cache => { :column_name => :view_count }
|
||||
is_impressionable #:counter_cache => { :column_name => :view_count }
|
||||
|
||||
field :title, localize: true
|
||||
field :subtitle, localize: true
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ module Announcement
|
||||
end
|
||||
|
||||
category ["BulletinCategory"]
|
||||
data_count 3..10
|
||||
data_count 1..10
|
||||
|
||||
taggable
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
@@ -11,6 +11,19 @@ var galleryAPI = function(){
|
||||
this.loadArea = null;
|
||||
this.tagList = $("ul#gallery_tag_list");
|
||||
this.initialize = function(callbackFn){
|
||||
if(g.loadArea == "theater"){
|
||||
if(rcom.getInternetExplorerVersion()!=-1){
|
||||
var photo_id = window.location.hash.replace("#","");
|
||||
if(photo_id){
|
||||
var url = window.location.href;
|
||||
var params = url.split("/");
|
||||
// params[params.length-1] = photo_id;
|
||||
url = url.replace(params[params.length-1],photo_id);
|
||||
|
||||
window.location.href = url;
|
||||
}
|
||||
}
|
||||
}
|
||||
$(document).ready(function(){
|
||||
bindHandlers();
|
||||
})
|
||||
@@ -437,19 +450,19 @@ var galleryAPI = function(){
|
||||
bindHandlers();
|
||||
})
|
||||
}
|
||||
if(rcom.getInternetExplorerVersion()!=-1){
|
||||
var url_constructor = window.location.href.split("/");
|
||||
var url = "";
|
||||
for(x=0;x<=url_constructor.length-1;x++){
|
||||
if(x == url_constructor.length-1){
|
||||
url+="#!/"+url_constructor[x];
|
||||
}else{
|
||||
url+=url_constructor[x]+"/";
|
||||
}
|
||||
}
|
||||
// if(rcom.getInternetExplorerVersion()!=-1){
|
||||
// var url_constructor = window.location.href.split("/");
|
||||
// var url = "";
|
||||
// for(x=0;x<=url_constructor.length-1;x++){
|
||||
// if(x == url_constructor.length-1){
|
||||
// url+="#!/"+url_constructor[x];
|
||||
// }else{
|
||||
// url+=url_constructor[x]+"/";
|
||||
// }
|
||||
// }
|
||||
|
||||
window.location.href = url;
|
||||
}
|
||||
// window.location.href = url;
|
||||
// }
|
||||
|
||||
var albumid = $("#main_pic").attr("data-content");
|
||||
g.albumArea.find(".bt-back").attr("href","../albums/"+albumid);
|
||||
|
||||
+33
-13
@@ -12,11 +12,23 @@ var galleryAPI = function(){
|
||||
this.tagList = $(".taglist ul");
|
||||
// this.authenticated = false;
|
||||
this.initialize = function(callbackFn){
|
||||
$(document).ready(function(){
|
||||
//bindHandlers();
|
||||
})
|
||||
var bindHandlers = function(){
|
||||
|
||||
if(g.loadArea == "theater"){
|
||||
if(rcom.getInternetExplorerVersion()!=-1){
|
||||
var photo_id = window.location.hash.replace("#","");
|
||||
if(photo_id){
|
||||
var params = rcom.getUrlVars();
|
||||
var url = window.location.href.split("?")[0];
|
||||
params["id"] = photo_id;
|
||||
for(i=0;i<params.length;i++){
|
||||
if(i == 0)
|
||||
url+="?"+params[i]+"="+params[params[i]];
|
||||
else
|
||||
url+="&"+params[i]+"="+params[params[i]];
|
||||
|
||||
}
|
||||
window.location.href = url;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +81,7 @@ var galleryAPI = function(){
|
||||
this.loadImages = function(id){
|
||||
g.albumArea.addClass('o_album');
|
||||
g.albumArea.find("#imgholder").empty();
|
||||
$.getJSON("panel/gallery/front_end/albums/"+id+"/imgs",{inner:true},function(album){
|
||||
$.getJSON("/panel/gallery/front_end/albums/"+id+"/imgs",{inner:true},function(album){
|
||||
$.each(album.images,function(i,image){
|
||||
var thumb = image.file.thumb.url;
|
||||
image.description = (image.description?image.description:"<%= I18n.t('gallery.no_description') %>")
|
||||
@@ -198,9 +210,13 @@ var galleryAPI = function(){
|
||||
|
||||
$img.fadeOut(200,function(){
|
||||
if($rslide.hasClass("fullscreen"))
|
||||
$img.attr({"src":dom.attr("data-content")}).css("height","100%");
|
||||
$img.attr({"src":dom.attr("data-content")}).css("height","100%").load(function(){
|
||||
|
||||
});
|
||||
else
|
||||
$img.attr({"src":dom.attr("data-content")}).css("height","auto");
|
||||
$img.attr({"src":dom.attr("data-content")}).css("height","auto").load(function(){
|
||||
|
||||
});
|
||||
$img.fadeIn(200);
|
||||
if($rslide.hasClass("fullscreen")){
|
||||
$img.css({"padding":($rslide.height()-$img.height())/2})
|
||||
@@ -218,7 +234,8 @@ var galleryAPI = function(){
|
||||
}
|
||||
// $(".slideinfo b.info").text(imageArray[imagecount].title);
|
||||
updatePhotoTag();
|
||||
$(".slideinfo .info").text(imageArray[imagecount].description);
|
||||
if(imageArray[imagecount].description)
|
||||
$(".slideinfo .info").text(imageArray[imagecount].description);
|
||||
if(imageArray.length > 1)
|
||||
updateNavigation();
|
||||
})
|
||||
@@ -244,7 +261,7 @@ var galleryAPI = function(){
|
||||
}
|
||||
|
||||
var preparestage = function(albumid){
|
||||
$.getJSON("panel/gallery/front_end/albums/"+albumid+"/imgs",{"inner":true},function(album){
|
||||
$.getJSON("/panel/gallery/front_end/albums/"+albumid+"/imgs",{"inner":true},function(album){
|
||||
imageArray = eval(album.images);
|
||||
$.each(album.images,function(i,image){
|
||||
if(image._id == id)
|
||||
@@ -253,7 +270,8 @@ var galleryAPI = function(){
|
||||
bindHandlers();
|
||||
})
|
||||
}
|
||||
if(rcom.getInternetExplorerVersion()!=-1){
|
||||
var url_constructor = function(){
|
||||
if(rcom.getInternetExplorerVersion()!=-1){
|
||||
var url_constructor = window.location.href.split("/");
|
||||
var url = "";
|
||||
for(x=0;x<=url_constructor.length-1;x++){
|
||||
@@ -263,10 +281,12 @@ var galleryAPI = function(){
|
||||
url+=url_constructor[x]+"/";
|
||||
}
|
||||
}
|
||||
|
||||
window.location.href = url;
|
||||
return url;
|
||||
// window.location.href = url;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var albumid = $("#main_pic").attr("data-content");
|
||||
g.albumArea.css("margin-bottom","0");
|
||||
// picHeight = $(window).height() - ($("#orbit-bar").outerHeight() + $("#orbit_gallery .form-actions").outerHeight());
|
||||
|
||||
Vendored
+2
-2
@@ -85,8 +85,8 @@ class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController
|
||||
@albumid = @image.gallery_album_id
|
||||
@album = GalleryAlbum.find(@albumid)
|
||||
@images = @album.gallery_images.all
|
||||
tags = @album.tag_ids
|
||||
@tagnames = Tag.find(tags.tagged_ids).map{|t| t.name}
|
||||
# tags = @album.tag_ids
|
||||
@tagnames = @album.tags.map{|t|t.name}
|
||||
@back_link = panel_gallery_front_end_album_path(@albumid)
|
||||
end
|
||||
end
|
||||
Vendored
+1
-1
@@ -106,8 +106,8 @@
|
||||
<script type="text/javascript">
|
||||
galleryAPI.prototype.locale = "<%= I18n.locale %>";
|
||||
var gallery = new galleryAPI();
|
||||
gallery.loadArea = "theater";
|
||||
gallery.initialize();
|
||||
gallery.loadArea = "theater";
|
||||
gallery.loadTheater("<%= params[:id] %>");
|
||||
</script>
|
||||
|
||||
|
||||
+2
-1
@@ -56,8 +56,9 @@
|
||||
<script type="text/javascript">
|
||||
galleryAPI.prototype.locale = "<%= I18n.locale %>";
|
||||
var gallery = new galleryAPI();
|
||||
gallery.loadArea = "theater";
|
||||
gallery.initialize();
|
||||
gallery.loadArea = "theater";
|
||||
|
||||
gallery.loadTheater("<%= params[:id] %>");
|
||||
</script>
|
||||
|
||||
|
||||
+23
-11
@@ -22,20 +22,32 @@ class Panel::WebResource::FrontEnd::WebLinksController < OrbitWidgetController
|
||||
|
||||
date_now = Time.now
|
||||
|
||||
@archive_file_categorys = WebLinkCategory.all
|
||||
|
||||
if !params[:category_id].blank?
|
||||
@web_links = WebLink.all.can_display.any_in(:web_link_category_id => params[:category_id]).merge(WebLinkCategory.excludes('disable' => true)).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
|
||||
@web_link_categorys = WebLinkCategory.any_in(:_id => params[:category_id]).excludes('disable' => true)
|
||||
elsif !params[:tag_id].blank?
|
||||
@web_links = WebLink.all.can_display.any_in(:tagged_ids => params[:tag_id]).merge(WebLinkCategory.excludes('disable' => true)).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
|
||||
|
||||
if params[:category_id].blank?
|
||||
get_categorys
|
||||
@sorted_by_category = @web_link_categorys.inject({}) do |categories, category|
|
||||
unless category.web_links.blank?
|
||||
if params[:tag_id].blank?
|
||||
categories[category.title] = category.web_links.can_display.desc( :is_top, :created_at )
|
||||
else
|
||||
categories[category.title] = category.web_links.can_display.any_in(:tagged_ids => params[:tag_id]).desc( :is_top, :created_at )
|
||||
end
|
||||
end
|
||||
categories
|
||||
end
|
||||
else
|
||||
@web_links = WebLink.all.can_display.merge(WebLinkCategory.excludes('disable' => true)).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
|
||||
|
||||
get_categorys
|
||||
selected_categories = WebLinkCategory.any_in(:_id => params[:category_id]).excludes('disable' => true).entries
|
||||
@sorted_by_category = selected_categories.inject({}) do |categories, category|
|
||||
unless category.web_links.blank?
|
||||
if params[:tag_id].blank?
|
||||
categories[category.title] = category.web_links.can_display.desc( :is_top, :created_at )
|
||||
else
|
||||
categories[category.title] = category.web_links.can_display.any_in(:tagged_ids => params[:tag_id]).desc( :is_top, :created_at )
|
||||
end
|
||||
end
|
||||
categories
|
||||
end
|
||||
end
|
||||
@web_links = Kaminari.paginate_array(@sorted_by_category.values.map{|web_links| web_links.entries}.flatten).page(params[:page_main]).per(@page_num)
|
||||
|
||||
end
|
||||
|
||||
|
||||
+24
-8
@@ -28,17 +28,33 @@ class Panel::WebResource::Widget::WebLinksController < OrbitWidgetController
|
||||
@category_id = @part.category
|
||||
|
||||
date_now = Time.now
|
||||
|
||||
if !params[:category_id].blank?
|
||||
@web_links = WebLink.all.can_display.any_in(:web_link_category_id => params[:category_id]).merge(WebLinkCategory.excludes('disable' => true)).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
|
||||
@web_link_categorys = WebLinkCategory.any_in(:_id => params[:category_id]).excludes('disable' => true)
|
||||
elsif !params[:tag_id].blank?
|
||||
@web_links = WebLink.all.can_display.any_in(:tagged_ids => params[:tag_id]).merge(WebLinkCategory.excludes('disable' => true)).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
|
||||
|
||||
if params[:category_id].blank?
|
||||
get_categorys
|
||||
@sorted_by_category = @web_link_categorys.inject({}) do |categories, category|
|
||||
unless category.web_links.blank?
|
||||
if params[:tag_id].blank?
|
||||
categories[category.title] = category.web_links.can_display.desc( :is_top, :created_at )
|
||||
else
|
||||
categories[category.title] = category.web_links.can_display.any_in(:tagged_ids => params[:tag_id]).desc( :is_top, :created_at )
|
||||
end
|
||||
end
|
||||
categories
|
||||
end
|
||||
else
|
||||
@web_links = WebLink.all.can_display.merge(WebLinkCategory.excludes('disable' => true)).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
|
||||
get_categorys
|
||||
selected_categories = WebLinkCategory.any_in(:_id => params[:category_id]).excludes('disable' => true).entries
|
||||
@sorted_by_category = selected_categories.inject({}) do |categories, category|
|
||||
unless category.web_links.blank?
|
||||
if params[:tag_id].blank?
|
||||
categories[category.title] = category.web_links.can_display.desc( :is_top, :created_at )
|
||||
else
|
||||
categories[category.title] = category.web_links.can_display.any_in(:tagged_ids => params[:tag_id]).desc( :is_top, :created_at )
|
||||
end
|
||||
end
|
||||
categories
|
||||
end
|
||||
end
|
||||
@web_links = Kaminari.paginate_array(@sorted_by_category.values.map{|web_links| web_links.entries}.flatten).page(params[:page_main]).per(@page_num)
|
||||
|
||||
end
|
||||
|
||||
|
||||
vendor/built_in_modules/web_resource/app/views/panel/web_resource/front_end/web_links/index.html.erb
Vendored
+16
-21
@@ -3,28 +3,23 @@
|
||||
<div class="o-links">
|
||||
<div class="o-links-content">
|
||||
<ul>
|
||||
|
||||
<% @web_link_categorys.each do |wlcg| %>
|
||||
<% if wlcg.web_links.count > 0 %>
|
||||
<li>
|
||||
<h3 class="o-links-category"><%= wlcg.title rescue nil%></h3>
|
||||
<div class="o-links-list">
|
||||
<ul>
|
||||
|
||||
<% wlcg.web_links.can_display.desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num).each do |post| %>
|
||||
<li>
|
||||
<%= link_to post.title, post.url, {:target => '_blank', :title => post.title, :class=>"o-links-title"} %>
|
||||
<div class="o-links-description"><%= post.context %></div>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<% @sorted_by_category.each do |title, web_links| %>
|
||||
<% if web_links.count > 0 %>
|
||||
<li>
|
||||
<h3 class="o-links-category"><%= title rescue nil%></h3>
|
||||
<div class="o-links-list">
|
||||
<ul>
|
||||
<% web_links.page(params[:page_main]).per(@page_num).each do |web_link| %>
|
||||
<li>
|
||||
<%= link_to web_link.title, web_link.url, {:target => '_blank', :title => web_link.title, :class=>"o-links-title"} %>
|
||||
<div class="o-links-description"><%= web_link.context %></div>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Vendored
+18
-27
@@ -1,36 +1,27 @@
|
||||
<div class="o-links">
|
||||
<div class="o-links-content">
|
||||
<ul>
|
||||
|
||||
<% @web_link_categorys.each do |wlcg| %>
|
||||
<% if wlcg.web_links.count > 0 %>
|
||||
<li>
|
||||
<h3 class="o-links-category"><%= wlcg.title rescue nil%></h3>
|
||||
<div class="o-links-list">
|
||||
<ul>
|
||||
|
||||
<% wlcg.web_links.can_display.desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num).each do |post| %>
|
||||
<li>
|
||||
<%= link_to post.title, post.url, {:target => '_blank', :title => post.title, :class=>"o-links-title"} %>
|
||||
<div class="o-links-description"><%= post.context %></div>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<% @sorted_by_category.each do |title, web_links| %>
|
||||
<% if web_links.count > 0 %>
|
||||
<li>
|
||||
<h3 class="o-links-category"><%= title rescue nil%></h3>
|
||||
<div class="o-links-list">
|
||||
<ul>
|
||||
<% web_links.page(params[:page_main]).per(@page_num).each do |web_link| %>
|
||||
<li>
|
||||
<%= link_to web_link.title, web_link.url, {:target => '_blank', :title => web_link.title, :class=>"o-links-title"} %>
|
||||
<div class="o-links-description"><%= web_link.context %></div>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pull_right">
|
||||
<% if !params[:category_id].blank? %>
|
||||
<%= link_to t(:more_plus), panel_web_resource_front_end_web_links_path(:category_id => @part.category) %>
|
||||
<% else %>
|
||||
<%= link_to t(:more_plus), panel_web_resource_front_end_web_links_path %>
|
||||
<% end %>
|
||||
<div class="pull_right">
|
||||
<%= link_to t(:more_plus), panel_web_resource_front_end_web_links_path(category_id: params[:category_id], tag_id: params[:tag_id]) %>
|
||||
</div>
|
||||
Reference in new issue
Block a user