added tag cloud widget
This commit is contained in:
parent
c06e87fb05
commit
0e1123396b
|
@ -178,6 +178,35 @@ class AnnouncementsController < ApplicationController
|
|||
pack_data(announcements, top_anns)
|
||||
end
|
||||
|
||||
def tag_cloud
|
||||
ma = ModuleApp.where(:key => "announcement").first
|
||||
temp = []
|
||||
ma.tags.each do |tag|
|
||||
t1 = tag.taggings.collect{|t| t.taggable_id.to_s}
|
||||
count = Bulletin.where(:id.in => t1).can_display.count
|
||||
temp << {
|
||||
"tag-name" => tag.name,
|
||||
"count" => count,
|
||||
"tag-url" => OrbitHelper.widget_more_url + "?tags[]=" + tag.id.to_s
|
||||
}
|
||||
end
|
||||
max = temp.max_by{|t| t["count"]}["count"]
|
||||
min = temp.min_by{|t| t["count"]}["count"]
|
||||
tags = []
|
||||
temp.each do |tag|
|
||||
if tag["count"] > 0
|
||||
percent = (tag["count"] * 100) / max
|
||||
font_size = ((percent / 10).ceil) + 11
|
||||
tag["font-size"] = font_size
|
||||
tags << tag
|
||||
end
|
||||
end
|
||||
{
|
||||
"tags" => tags,
|
||||
"extras" => {}
|
||||
}
|
||||
end
|
||||
|
||||
def pack_data(announcements, top_anns = [])
|
||||
page = Page.where(:module => "announcement").first rescue nil
|
||||
feeds_anns = get_feed_announcements("widget")
|
||||
|
|
|
@ -79,6 +79,6 @@ zh_tw:
|
|||
mail_time: 時間
|
||||
image_upload_size_note: 建議檔案小於%{image_upload_size}
|
||||
resend_mail: 重新寄送提醒
|
||||
is_external_link: 開啟內部連結
|
||||
is_external_link: 連結外部網址
|
||||
external_link: 外部連結
|
||||
external_link_hint: "確定連結開頭為http://"
|
||||
|
|
|
@ -5,7 +5,7 @@ module Announcement
|
|||
OrbitApp.registration "Announcement", :type => "ModuleApp" do
|
||||
module_label "announcement.announcement"
|
||||
base_url File.expand_path File.dirname(__FILE__)
|
||||
widget_methods ["widget","random_announcement_widget"]
|
||||
widget_methods ["widget","random_announcement_widget", "tag_cloud"]
|
||||
widget_settings [{"data_count"=>30}]
|
||||
taggable "Bulletin"
|
||||
categorizable
|
||||
|
|
Loading…
Reference in New Issue