some changes for frontend parser

This commit is contained in:
Harry Bomrah 2014-05-14 19:51:17 +08:00
parent 12a62c26b5
commit 420a302ee8
1 changed files with 10 additions and 7 deletions

View File

@ -6,12 +6,15 @@ class AnnouncementsController < ApplicationController
{ {
"title" => a.title, "title" => a.title,
"subtitle" => a.subtitle, "subtitle" => a.subtitle,
"postdate" => a.postdate.strftime("%b %d, %Y at %I:%M %p"),
"link_to_show" => OrbitHelper.url_to_show(a.to_param), "link_to_show" => OrbitHelper.url_to_show(a.to_param),
"more" => "More", "img_src" => a.image.thumb.url || "http://placehold.it/100x100",
"more" => "More"
} }
end end
{ {
"data" => anns "announcements" => anns,
"extras" => {"widget-title"=>"Announcements"}
} }
end end
@ -36,17 +39,17 @@ class AnnouncementsController < ApplicationController
params = OrbitHelper.params params = OrbitHelper.params
announcement = Bulletin.can_display.find_by(:uid=>params[:uid]) announcement = Bulletin.can_display.find_by(:uid=>params[:uid])
tags = announcement.tags.map{|tag| { "tag" => tag.name } } tags = announcement.tags.map{|tag| { "tag" => tag.name } } rescue []
files = announcement.bulletin_files.map{|file| { "file_url" => file.file.url, "file_title" => file.title } } files = announcement.bulletin_files.map{|file| { "file_url" => file.file.url, "file_title" => file.title } } rescue []
links = announcement.bulletin_links.map{|link| { "link_url" => link.url, "link_title" => link.title } } links = announcement.bulletin_links.map{|link| { "link_url" => link.url, "link_title" => link.title } } rescue []
update_user = announcement.update_user.member_profile.name rescue ""
{ {
"tags" => tags, "tags" => tags,
"bulletin_files" => files, "bulletin_files" => files,
"bulletin_links" => links, "bulletin_links" => links,
"data" => { "data" => {
"title" => announcement.title, "title" => announcement.title,
"update_user" => announcement.update_user.member_profile.name, "update_user" => update_user,
"updated_at" => announcement.updated_at.strftime('%Y-%m-%d %H:%M'), "updated_at" => announcement.updated_at.strftime('%Y-%m-%d %H:%M'),
"body" =>announcement.text, "body" =>announcement.text,
"image" => announcement.image.url "image" => announcement.image.url