New widget for tag cloud

This commit is contained in:
chris authored and Matt K. Fu committed 2013-06-06 17:17:45 +08:00
1 parent 30824d1620
commit 253cca06cc
16 files changed
+122 -27

No files matched your search

+10 -1
View File
@@ -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
+26 -1
View File
@@ -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 << "<div class='tag_cloud'>"
res << "<h3 class='h3'>#{t(:tag_cloud)}</h3>"
res << "<div class='cloud'>"
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 << "<span class='#{tag[1]} #{tag[0].id.to_s.eql?(params[:tag_id]) ? 'active' : nil}'>"
res << tag[0].name
res << "</span>"
end
res << "</div>"
res << "</div>"
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
+5
View File
@@ -210,4 +210,9 @@ module ParserFrontEnd
def generate_breadcrumbs(*args)
"<div class='dymanic_load' path='#{front_show_breadcrumb_path(args[1])}'></div>"
end
# tag_cloud
def generate_tag_clouds(*args)
"<div class='dymanic_load' path='#{front_show_tag_cloud_path(args[0])}'></div>"
end
end