filter and new line to br

This commit is contained in:
Harry Bomrah 2017-08-07 17:14:05 +08:00
parent b336730f9d
commit 81870c9412
1 changed files with 3 additions and 3 deletions

View File

@ -3,7 +3,7 @@ class EPapersController < ApplicationController
def index def index
params = OrbitHelper.params params = OrbitHelper.params
page = Page.where(:page_id => params[:page_id]).first rescue nil page = Page.where(:page_id => params[:page_id]).first rescue nil
papers = Paper.can_display.order_by(:order_position => "asc").filter_by_categories papers = Paper.can_display.filter_by_categories.desc(:period)
f = papers.collect do |paper| f = papers.collect do |paper|
statuses = paper.statuses_with_classname.collect do |status| statuses = paper.statuses_with_classname.collect do |status|
{ {
@ -24,7 +24,7 @@ class EPapersController < ApplicationController
"link_to_show" => OrbitHelper.url_to_show(paper.to_param), "link_to_show" => OrbitHelper.url_to_show(paper.to_param),
"title" => paper.title, "title" => paper.title,
"period" => paper.period, "period" => paper.period,
"description" => paper.description, "description" => paper.description.gsub(/(?:\n\r?|\r\n?)/, '<br>'),
"category" => paper.category.title, "category" => paper.category.title,
"topic" => topics "topic" => topics
} }
@ -51,7 +51,7 @@ class EPapersController < ApplicationController
paper = Paper.find_by(:uid => params[:uid]) paper = Paper.find_by(:uid => params[:uid])
paper_thumb = !paper.image.nil? && !paper.image.url.nil? ? paper.image.thumb.url : "http://www.placehold.it/400x400/EFEFEF/AAAAAA" paper_thumb = !paper.image.nil? && !paper.image.url.nil? ? paper.image.thumb.url : "http://www.placehold.it/400x400/EFEFEF/AAAAAA"
paper_full = !paper.image.nil? && !paper.image.url.nil? ? paper.image.url : "http://www.placehold.it/1000x1000/EFEFEF/AAAAAA" paper_full = !paper.image.nil? && !paper.image.url.nil? ? paper.image.url : "http://www.placehold.it/1000x1000/EFEFEF/AAAAAA"
topics = paper.topics.collect do |topic| topics = paper.topics.asc(:created_at).collect do |topic|
desc = ActionView::Base.full_sanitizer.sanitize(topic.content) desc = ActionView::Base.full_sanitizer.sanitize(topic.content)
timg = !topic.image.nil? && !topic.image.url.nil? ? topic.image.thumb.url : "http://www.placehold.it/400x400/EFEFEF/AAAAAA" timg = !topic.image.nil? && !topic.image.url.nil? ? topic.image.thumb.url : "http://www.placehold.it/400x400/EFEFEF/AAAAAA"
fimg = !topic.image.nil? && !topic.image.url.nil? ? topic.image.url : "http://www.placehold.it/1000x1000/EFEFEF/AAAAAA" fimg = !topic.image.nil? && !topic.image.url.nil? ? topic.image.url : "http://www.placehold.it/1000x1000/EFEFEF/AAAAAA"