added psot date and deadline and also converts shit urls to proper ones
This commit is contained in:
parent
e4e3d66f32
commit
1420f75391
|
@ -51,13 +51,18 @@ class UpgradeController < ApplicationController
|
||||||
"name" => t.name_translations
|
"name" => t.name_translations
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
text = {"en" => "", "zh_tw" => ""}
|
||||||
|
text["en"] = smart_convertor(b.text_translations["en"])
|
||||||
|
text["zh_tw"] = smart_convertor(b.text_translations["zh_tw"])
|
||||||
|
|
||||||
{
|
{
|
||||||
"id" => b.id.to_s,
|
"id" => b.id.to_s,
|
||||||
"title" => b.title_translations,
|
"title" => b.title_translations,
|
||||||
"subtitle" => b.subtitle_translations,
|
"subtitle" => b.subtitle_translations,
|
||||||
"text" => b.text_translations,
|
"text" => text,
|
||||||
"public" => b.public,
|
"public" => b.public,
|
||||||
|
"postdate" => b.postdate,
|
||||||
|
"deadline" => b.deadline,
|
||||||
"email_sent" => b.email_sent,
|
"email_sent" => b.email_sent,
|
||||||
"email_sentdate" => b.email_sentdate,
|
"email_sentdate" => b.email_sentdate,
|
||||||
"other_mailaddress" => b.other_mailaddress,
|
"other_mailaddress" => b.other_mailaddress,
|
||||||
|
@ -71,4 +76,21 @@ class UpgradeController < ApplicationController
|
||||||
|
|
||||||
return {"announcements" => bulletins, "categories" => categories, "tags" => tags, "success" => true}
|
return {"announcements" => bulletins, "categories" => categories, "tags" => tags, "success" => true}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def smart_convertor(text)
|
||||||
|
html_string = text
|
||||||
|
links = html_string.scan(/img.*?src="(.*?)"/i)
|
||||||
|
links.each do |link|
|
||||||
|
l = link.first
|
||||||
|
new_link = nil
|
||||||
|
if l.starts_with?("/")
|
||||||
|
new_link = request.protocol + request.host_with_port + l
|
||||||
|
elsif l.starts_with?("..")
|
||||||
|
l1 = l.gsub("../","")
|
||||||
|
new_link = request.protocol + request.host_with_port + "/" + l1
|
||||||
|
end
|
||||||
|
html_string = html_string.sub(l,new_link) if !new_link.nil?
|
||||||
|
end
|
||||||
|
return html_string
|
||||||
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue