diff --git a/app/helpers/posts_helper.rb b/app/helpers/posts_helper.rb index eb5455d74..0ee595eb4 100644 --- a/app/helpers/posts_helper.rb +++ b/app/helpers/posts_helper.rb @@ -20,15 +20,24 @@ module PostsHelper def post_source_tag(post) if post.source =~ %r!http://img\d+\.pixiv\.net/img/([^\/]+)/! text = "pixiv/#{$1}" - link_to(text, post.normalized_source) + 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}" - link_to(text, post.normalized_source) + source_link = link_to(text, post.normalized_source) + source_search = "source:#{text}" elsif post.source =~ /^http/ text = truncate(post.normalized_source.sub(/^https?:\/\/(?:www)?/, "")) - link_to(truncate(text, :length => 20), post.normalized_source) + source_link = link_to(truncate(text, :length => 20), post.normalized_source) + source_search = "source:#{post.source.sub(/[^\/]*$/, "")}" else - truncate(post.source, :length => 100) + source_link = truncate(post.source, :length => 100) + end + + if CurrentUser.is_builder? && !source_search.blank? + source_link + " " + link_to("»".html_safe, posts_path(:tags => source_search)) + else + source_link end end end diff --git a/app/views/posts/partials/show/_information.html.erb b/app/views/posts/partials/show/_information.html.erb index 19c96c9ac..5bfa117ca 100644 --- a/app/views/posts/partials/show/_information.html.erb +++ b/app/views/posts/partials/show/_information.html.erb @@ -1,6 +1,6 @@