add new widget method

This commit is contained in:
manson 2014-08-12 11:40:06 +08:00
parent c65d1da3bf
commit cd2865c6b8
2 changed files with 31 additions and 2 deletions

View File

@ -44,7 +44,7 @@ class AnnouncementsController < ApplicationController
"title" => a.title,
"subtitle" => a.subtitle,
"statuses" => statuses,
"postdate" => a.postdate.strftime("%b %d, %Y at %I:%M %p"),
"postdate" => a.postdate.strftime("%d"),
"link_to_show" => OrbitHelper.widget_item_url(a.to_param),
"img_src" => a.image.thumb.url || "http://placehold.it/100x100",
}
@ -57,6 +57,35 @@ class AnnouncementsController < ApplicationController
}
end
def widget1
announcements = Bulletin.where(:is_preview.in=>[false,nil]).can_display.order_by(:created_at=>'desc').filter_by_widget_categories.filter_by_tags(OrbitHelper.widget_tags)
anns = announcements.collect do |a|
statuses = a.statuses_with_classname.collect do |status|
{
"status" => status["name"],
"status-class" => "status-#{status['classname']}"
}
end
{
"title" => a.title,
"subtitle" => a.subtitle,
"statuses" => statuses,
"week" => a.postdate.strftime("%A"),
"day" => a.postdate.strftime("%d"),
"month" => a.postdate.strftime("%b"),
"year" => a.postdate.strftime("%Y"),
"link_to_show" => OrbitHelper.widget_item_url(a.to_param),
"img_src" => a.image.thumb.url || "http://placehold.it/100x100",
}
end
{
"announcements" => anns,
"extras" => {
"more_url"=>OrbitHelper.widget_more_url
}
}
end
def show
params = OrbitHelper.params

View File

@ -4,7 +4,7 @@ module Announcement
OrbitApp.registration "Announcement", :type => "ModuleApp" do
module_label "announcement.announcement"
base_url File.expand_path File.dirname(__FILE__)
widget_methods ["widget"]
widget_methods ["widget","widget1"]
widget_settings [{"data_count"=>10}]
taggable "Bulletin"
categorizable