diff --git a/app/controllers/admin/page_parts_controller.rb b/app/controllers/admin/page_parts_controller.rb
index de212e50..f5f499c2 100644
--- a/app/controllers/admin/page_parts_controller.rb
+++ b/app/controllers/admin/page_parts_controller.rb
@@ -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
diff --git a/app/controllers/front_controller.rb b/app/controllers/front_controller.rb
index be975ffa..02098f8a 100644
--- a/app/controllers/front_controller.rb
+++ b/app/controllers/front_controller.rb
@@ -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)
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index fa052911..3eaefaf6 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -3,7 +3,7 @@ module ApplicationHelper
FLASH_NOTICE_KEYS = [:error, :notice, :warning]
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)
diff --git a/app/models/module_app.rb b/app/models/module_app.rb
index 649e135d..bcbc56cd 100644
--- a/app/models/module_app.rb
+++ b/app/models/module_app.rb
@@ -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
diff --git a/app/models/tag.rb b/app/models/tag.rb
index 30acb4c8..d183b90b 100644
--- a/app/models/tag.rb
+++ b/app/models/tag.rb
@@ -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
diff --git a/app/views/front/show_tag_cloud.html.erb b/app/views/front/show_tag_cloud.html.erb
new file mode 100644
index 00000000..d7e8308f
--- /dev/null
+++ b/app/views/front/show_tag_cloud.html.erb
@@ -0,0 +1,10 @@
+<% unless @tags.blank? %>
+
+
<%= t(:tag_cloud) %>
+
+ <% @tags.each do |tag| %>
+ <%= link_to tag[0].name, '#?' + {:tag_id => tag[0].id, :category_id => params[:category_id]}.to_param, :class => "#{tag[1]} #{tag[0].id.to_s.eql?(params[:tag_id]) ? 'active' : nil} " %>
+ <% end %>
+
+
+<% end %>
\ No newline at end of file
diff --git a/config/list.yml b/config/list.yml
index e0fc1914..c49de9f4 100644
--- a/config/list.yml
+++ b/config/list.yml
@@ -43,6 +43,7 @@ public_r_tags:
- sub_menu
- sitemap
- breadcrumb
+ - tag_cloud
page_part_kinds:
- text
diff --git a/config/mongoid.yml b/config/mongoid.yml
index 2fa55a36..99a719c6 100644
--- a/config/mongoid.yml
+++ b/config/mongoid.yml
@@ -8,7 +8,7 @@ defaults: &defaults
development:
<<: *defaults
- database: test_site
+ database: production_7
test:
<<: *defaults
database: test_site
diff --git a/config/routes.rb b/config/routes.rb
index 2f084967..1ddc7ffe 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -262,7 +262,7 @@ Orbit::Application.routes.draw do
end
end
- controller_paths :front, %w[show_breadcrumb show_banner show_footer show_menu show_page_sub_menu show_site_sub_menu show_sitemap]
+ controller_paths :front, %w[show_breadcrumb show_banner show_footer show_menu show_page_sub_menu show_site_sub_menu show_sitemap show_tag_cloud]
# controller_paths :mobile, %w[index announcement announcement_content dialog_contact dialog_copyright dialog_language map page page_content]
# scope 'app' do
diff --git a/lib/orbit_app/module/registration.rb b/lib/orbit_app/module/registration.rb
index 0b767c5a..05e590d0 100644
--- a/lib/orbit_app/module/registration.rb
+++ b/lib/orbit_app/module/registration.rb
@@ -28,7 +28,7 @@ module OrbitApp
end
class DataSheet
- attr_reader :name,:key,:base_path,:module_label,:data_count
+ attr_reader :name,:key,:base_path,:module_label,:data_count, :has_tag
def initialize(name, &block)
@name = name
@@ -37,6 +37,7 @@ module OrbitApp
@front_end_app_pages = nil
@module_label = 'rulingcom.errors.init.module_app_noname'
@data_count = 1..15 # as default
+ @has_tag = nil
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
setup_module_app
end
@@ -144,6 +145,14 @@ module OrbitApp
define_method(field){|var| instance_variable_set( "@" + field, var)}
end
+ def taggable
+ @has_tag = true
+ end
+
+ def get_has_tags
+ @has_tag.nil? ? false : true
+ end
+
end # of class DataSheet
end
diff --git a/lib/parsers/parser_common.rb b/lib/parsers/parser_common.rb
index 044f9b9a..88bf6a34 100644
--- a/lib/parsers/parser_common.rb
+++ b/lib/parsers/parser_common.rb
@@ -1,5 +1,6 @@
module ParserCommon
- include ActionView::Helpers::TagHelper
+ include ActionView::Helpers::TagHelper
+ # include ActionView::Helpers::UrlHelper
def menu_level(page, current_page, current, menu, edit = false)
res = ''
@@ -170,6 +171,30 @@ module ParserCommon
end
end
+ # tag_cloud
+ def parse_tag_clouds_edit(body = nil, page = nil, edit=nil)
+ body.css('tag_cloud').each do |tag_cloud|
+ module_app = ModuleApp.find(tag_cloud["id"]) rescue nil
+ res = ''
+ if module_app
+ res << ""
+ res << "
#{t(:tag_cloud)}
"
+ res << "
"
+
+ module_app.sorted_tags_for_cloud.each do |tag|
+ # res << link_to(tag[0].name, ('/' + {:tag_id => tag[0].id, :category_id => params[:category_id]}.to_param), :class => "#{tag[1]} #{tag[0].id.to_s.eql?(params[:tag_id]) ? 'active' : nil} ")
+ res << ""
+ res << tag[0].name
+ res << ""
+ end
+ res << "
"
+ res << "
"
+ end
+ fragment = Nokogiri::HTML::DocumentFragment.new(body, res)
+ tag_cloud.swap(fragment)
+ end
+ end
+
# page_footer
def parse_footer_edit(body, page)
page_footer = body.css('.page_footer').first
diff --git a/lib/parsers/parser_front_end.rb b/lib/parsers/parser_front_end.rb
index 1ad15540..a4b1b53d 100644
--- a/lib/parsers/parser_front_end.rb
+++ b/lib/parsers/parser_front_end.rb
@@ -210,4 +210,9 @@ module ParserFrontEnd
def generate_breadcrumbs(*args)
""
end
+
+ # tag_cloud
+ def generate_tag_clouds(*args)
+ ""
+ end
end
diff --git a/vendor/built_in_modules/announcement/init.rb b/vendor/built_in_modules/announcement/init.rb
index 8469cf54..45f4c18a 100644
--- a/vendor/built_in_modules/announcement/init.rb
+++ b/vendor/built_in_modules/announcement/init.rb
@@ -25,6 +25,8 @@ module Announcement
category ["BulletinCategory"]
data_count 3..10
+ taggable
+
widgets do
default_widget do
query 'Bulletin.any_of( {deadline: nil,:postdate.lte => Time.now} , {:deadline.gte => Time.now,:postdate.lte => Time.now} )'
diff --git a/vendor/built_in_modules/archive/init.rb b/vendor/built_in_modules/archive/init.rb
index ab3bbd16..b2c6ab86 100644
--- a/vendor/built_in_modules/archive/init.rb
+++ b/vendor/built_in_modules/archive/init.rb
@@ -19,6 +19,8 @@ module Archive
category ["ArchiveFileCategory"]
+ taggable
+
widgets do
# default_widget do
# query 'ArchiveFile.all'
diff --git a/vendor/built_in_modules/faq/init.rb b/vendor/built_in_modules/faq/init.rb
index d90b3545..5f9fd1f6 100644
--- a/vendor/built_in_modules/faq/init.rb
+++ b/vendor/built_in_modules/faq/init.rb
@@ -19,6 +19,8 @@ module Faq
category ["QaCategory"]
data_count 1..20
+ taggable
+
widgets do
default_widget do
query 'Qa.all'
diff --git a/vendor/built_in_modules/web_resource/init.rb b/vendor/built_in_modules/web_resource/init.rb
index 3b234b02..a0aa3262 100644
--- a/vendor/built_in_modules/web_resource/init.rb
+++ b/vendor/built_in_modules/web_resource/init.rb
@@ -16,6 +16,8 @@ module WebResource
end
end
+ taggable
+
widgets do
# default_widget do
# query 'Bulletin.all'