This commit is contained in:
r888888888
2014-02-28 17:57:33 -08:00
parent c85f615773
commit b523ed471c

View File

@@ -17,13 +17,17 @@ module PostsHelper
end
end
def wordbreakify(string)
string.gsub(/(.{15})/, "\\1<wbr>")
end
def post_source_tag(post)
if post.source =~ %r!http://img\d+\.pixiv\.net/img/([^\/]+)/!
text = "pixiv/#{$1}"
text = "pixiv/<wbr>#{wordbreakify($1)}"
source_link = link_to(text, post.normalized_source)
source_search = "source:#{text}/"
elsif post.source =~ %r!http://i\d\.pixiv\.net/img\d+/img/([^\/]+)/!
text = "pixiv/#{$1}"
text = "pixiv/<wbr>#{wordbreakify($1)}"
source_link = link_to(text, post.normalized_source)
source_search = "source:#{text}/"
elsif post.source =~ %r{\Ahttps?://}