new output structure for view render

This commit is contained in:
Harry Bomrah 2014-04-02 14:44:36 +08:00
parent 3847ed9a43
commit b1585a5e4c
3 changed files with 18 additions and 12 deletions

View File

@ -2,28 +2,34 @@ class AnnouncementsController < ApplicationController
def index
announcements = Bulletin.all
announcements.collect do |a|
anns = announcements.collect do |a|
{
"title" => a.title,
"body" => a.body,
"link_to_show" => OrbitHelper.url_to_show(a.uid,a.title.parameterize),
"more" => "More"
"link_to_show" => OrbitHelper.url_to_show(a.to_param),
"more" => "More",
}
end
{
"data" => anns
}
end
def widget
announcements = Bulletin.all
announcements.collect do |a|
anns = announcements.collect do |a|
{
"title" => a.title,
"subtitle" => a.body,
"link_to_show" => OrbitHelper.url_to_show(a.uid,a.title.parameterize),
"link_to_show" => OrbitHelper.url_to_show(a.to_param),
"more" => "More",
"link_to_index" => "index"
}
end
{
"extras" => {"link_to_index" => "index","name" => "Harry"},
"data" => anns
}
end
@ -34,5 +40,6 @@ class AnnouncementsController < ApplicationController
"title" => announcement.title,
"body" => announcement.body
}
end
end
end

View File

@ -7,11 +7,9 @@ class Bulletin
field :uid, type: String
# include Slug
def to_param
I18n.locale
title.parameterize
end
def to_param
self.title.gsub(/[ "'*@#$%^&()+=;:.,?>|\\<~_!]/,'-').gsub(/-{2,}/,'-')+'-'+self.uid
end
def self.find_by_param(input)
self.find_by(uid: input)

View File

@ -4,6 +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"]
end
end
end