new output structure for view render
This commit is contained in:
parent
3847ed9a43
commit
b1585a5e4c
|
@ -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
|
||||
|
||||
|
||||
|
@ -35,4 +41,5 @@ class AnnouncementsController < ApplicationController
|
|||
"body" => announcement.body
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue