fixes #80: Clicking Pixiv source address at the information panel
This commit is contained in:
@@ -23,8 +23,8 @@ module PostsHelper
|
|||||||
|
|
||||||
def post_source_tag(post)
|
def post_source_tag(post)
|
||||||
if post.source =~ /^http/
|
if post.source =~ /^http/
|
||||||
text = truncate(post.source.sub(/^https?:\/\//, ""))
|
text = truncate(post.normalized_source.sub(/^https?:\/\//, ""))
|
||||||
link_to(truncate(text, :length => 15), post.source)
|
link_to(truncate(text, :length => 15), post.normalized_source)
|
||||||
else
|
else
|
||||||
truncate(post.source, :length => 100)
|
truncate(post.source, :length => 100)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -319,6 +319,20 @@ class Post < ActiveRecord::Base
|
|||||||
"Safe"
|
"Safe"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def normalized_source
|
||||||
|
if source =~ /pixiv\.net\/img\//
|
||||||
|
img_id = source[/(\d+)(_s|_m|(_big)?_p\d+)?\.[\w\?]+\s*$/, 1]
|
||||||
|
|
||||||
|
if $2 =~ /_p/
|
||||||
|
"http://www.pixiv.net/member_illust.php?mode=manga&illust_id=#{img_id}"
|
||||||
|
else
|
||||||
|
"http://www.pixiv.net/member_illust.php?mode=medium&illust_id=#{img_id}"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
source
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module TagMethods
|
module TagMethods
|
||||||
|
|||||||
Reference in New Issue
Block a user