auto format

This commit is contained in:
EricTYL 2019-10-29 14:48:02 +08:00
parent 862dc14449
commit 82ab7c40ec
1 changed files with 13 additions and 13 deletions

View File

@ -27,7 +27,7 @@ class BulletinsController < ApplicationController
else else
bulletins = bulletins bulletins = bulletins
end end
bulletins = bulletins.where(:is_preview.in=>[false,nil]) bulletins = bulletins.where(:is_preview.in=>[false,nil])
bulletins = bulletins.where(:approved.ne => false , :rejected.ne => true) bulletins = bulletins.where(:approved.ne => false , :rejected.ne => true)
bulletins = bulletins.where(:postdate.lt=>Time.now) bulletins = bulletins.where(:postdate.lt=>Time.now)
@ -35,7 +35,7 @@ class BulletinsController < ApplicationController
bulletins = bulletins.collect do |b| bulletins = bulletins.collect do |b|
image = request.protocol + request.host_with_port + b.image.url rescue nil image = request.protocol + request.host_with_port + b.image.url rescue nil
links = b.bulletin_links.collect do |bl| links = b.bulletin_links.collect do |bl|
{ {
"title" => bl.title_translations, "title" => bl.title_translations,
@ -44,7 +44,7 @@ class BulletinsController < ApplicationController
end rescue nil end rescue nil
files = b.bulletin_files.collect do |bf| files = b.bulletin_files.collect do |bf|
file = request.protocol + request.host_with_port + bf.file.url rescue nil file = request.protocol + request.host_with_port + bf.file.url rescue nil
{ {
"title" => bf.title_translations, "title" => bf.title_translations,
"description" => bf.description_translations, "description" => bf.description_translations,
@ -106,17 +106,17 @@ class BulletinsController < ApplicationController
def smart_convertor(text) def smart_convertor(text)
html_string = text html_string = text
links = html_string.scan(/img.*?src="(.*?)"/i) links = html_string.scan(/img.*?src="(.*?)"/i)
links.each do |link| links.each do |link|
l = link.first l = link.first
new_link = nil new_link = nil
if l.starts_with?("/") if l.starts_with?("/")
new_link = request.protocol + request.host_with_port + l new_link = request.protocol + request.host_with_port + l
elsif l.starts_with?("..") elsif l.starts_with?("..")
l1 = l.gsub("../","") l1 = l.gsub("../","")
new_link = request.protocol + request.host_with_port + "/" + l1 new_link = request.protocol + request.host_with_port + "/" + l1
end
html_string = html_string.sub(l,new_link) if !new_link.nil?
end end
html_string = html_string.sub(l,new_link) if !new_link.nil?
end
return html_string return html_string
end end