Merge branch 'clean_development' into lukas/picked_ques
This commit is contained in:
commit
8c1e65994a
24 files changed
+204
-46
No files matched your search
@@ -22,6 +22,11 @@ class Admin::PagePartsController < OrbitBackendController
|
||||
@part = PagePart.find(params[:id])
|
||||
@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
|
||||
if @r_tag.eql?('tag_cloud')
|
||||
@tag_objects = ModuleApp.where(has_tag: true)
|
||||
else
|
||||
@tag_objects = @r_tag.classify.constantize.all rescue nil
|
||||
end
|
||||
|
||||
@module_apps = ModuleApp.for_widget_select
|
||||
@categories = nil
|
||||
@@ -119,7 +124,11 @@ class Admin::PagePartsController < OrbitBackendController
|
||||
def reload_r_tag_options
|
||||
@part = PagePart.find params[:id]
|
||||
@r_tag = params[:type]
|
||||
@tag_objects = @r_tag.classify.constantize.all rescue nil
|
||||
if params[:type].eql?('tag_cloud')
|
||||
@tag_objects = ModuleApp.where(has_tag: true)
|
||||
else
|
||||
@tag_objects = @r_tag.classify.constantize.all rescue nil
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js {}
|
||||
end
|
||||
|
||||
@@ -110,7 +110,7 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
|
||||
# Render the page
|
||||
def render_page(args=nil)
|
||||
def render_page(args={})
|
||||
if @item
|
||||
respond_to do |format|
|
||||
format.html { render :text => parse_page_content(@item,args), :layout => 'page_layout' }
|
||||
|
||||
@@ -38,6 +38,11 @@ class FrontController < ApplicationController
|
||||
@ad_images = AdImage.all
|
||||
end
|
||||
|
||||
def show_tag_cloud
|
||||
module_app = ModuleApp.find(params[:id]) rescue nil
|
||||
@tags = module_app.sorted_tags_for_cloud
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def menu_level(page, current_page, current, menu)
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
class OrbitWidgetController< OrbitFrontendComponentController
|
||||
include FrontEndArrayParamsHelper
|
||||
before_filter {get_tags_and_cates(params)}
|
||||
|
||||
def get_tags_and_cates(params)
|
||||
params = tags_and_cates(params)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -32,7 +32,7 @@ class PagesController < ApplicationController
|
||||
if params[:clicked_field_name]
|
||||
render_page({"clicked_field_name"=>params["clicked_field_name"]}) unless save_from_no_lang_for_page
|
||||
else
|
||||
render_page unless save_from_no_lang_for_page
|
||||
render_page(params) unless save_from_no_lang_for_page
|
||||
end
|
||||
when 'Link'
|
||||
redirect_to(@item[:url]) unless save_from_no_lang_for_page
|
||||
@@ -45,12 +45,28 @@ class PagesController < ApplicationController
|
||||
#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?
|
||||
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?
|
||||
|
||||
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? ? '?' : '&'}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)
|
||||
|
||||
@@ -2,8 +2,13 @@ module ApplicationHelper
|
||||
|
||||
FLASH_NOTICE_KEYS = [:error, :notice, :warning]
|
||||
|
||||
|
||||
def current_path(param_hash)
|
||||
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)
|
||||
# Resque.enqueue_at(1.minute.from_now,DelayedImpressionist,object)
|
||||
end
|
||||
|
||||
def check_user_role_enable(attribute_fields)
|
||||
|
||||
@@ -19,6 +19,7 @@ class ModuleApp
|
||||
self[:get_widget_style] = reg.get_widgets
|
||||
self[:using_default_widget] = !reg.get_default_widget.blank?
|
||||
self[:widgets] = reg.get_widgets
|
||||
self[:has_tag] = reg.get_has_tags
|
||||
end
|
||||
|
||||
|
||||
@@ -135,5 +136,27 @@ class ModuleApp
|
||||
def self.find_by_key(key)
|
||||
self.where(key: key)[0] rescue nil
|
||||
end
|
||||
|
||||
def sorted_tags_for_cloud
|
||||
temp_tags = {}
|
||||
self.tags.each{ |tag|
|
||||
temp_tags.merge!({tag => Tag.get_impressionist(tag)})
|
||||
}
|
||||
if !temp_tags.blank?
|
||||
sorted_tags = temp_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
|
||||
|
||||
end
|
||||
+21
-21
@@ -19,27 +19,27 @@ class Tag
|
||||
|
||||
#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
|
||||
# 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
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<% unless @tags.blank? %>
|
||||
<div class="tag_cloud">
|
||||
<h3 class="h3"><%= t(:tag_cloud) %></h3>
|
||||
<div class="cloud">
|
||||
<% @tags.each do |tag| %>
|
||||
<%= link_to tag[0].name, current_path({:tag_id => tag[0].id, :category_id => params[:category_id]}), :class => "#{tag[1]} #{tag[0].id.to_s.eql?(params[:tag_id]) ? 'active' : nil} " %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
Reference in new issue
Block a user