/posts: word wrap long sources in sidebar.

* Don't truncate long sources in the sidebar on the post show page. Word
  wrap them instead.
* Word wrap long external links in general (mainly links in dtext).
* Turn sources into links on modqueue page.
This commit is contained in:
evazion
2019-10-13 18:53:46 -05:00
parent ee6f7a1d7e
commit 20f28910da
5 changed files with 12 additions and 4 deletions

View File

@@ -85,7 +85,7 @@ module ApplicationHelper
text = text.truncate(truncate) if truncate text = text.truncate(truncate) if truncate
if url =~ %r!\Ahttps?://!i if url =~ %r!\Ahttps?://!i
link_to text, url, rel: "noreferrer nofollow", **link_options link_to text, url, rel: "external noreferrer nofollow", **link_options
else else
url url
end end

View File

@@ -61,9 +61,9 @@ module PostsHelper
def post_source_tag(post) def post_source_tag(post)
# Only allow http:// and https:// links. Disallow javascript: links. # Only allow http:// and https:// links. Disallow javascript: links.
if post.source =~ %r!\Ahttps?://!i if post.source =~ %r!\Ahttps?://!i
external_link_to(post.normalized_source, strip: :subdomain, truncate: 20) + " ".html_safe + link_to("»", post.source, rel: "noreferrer nofollow") external_link_to(post.normalized_source, strip: :subdomain) + " ".html_safe + link_to("»", post.source, rel: "external noreferrer nofollow")
else else
truncate(post.source, length: 100) post.source
end end
end end

View File

@@ -25,3 +25,7 @@ a.active {
a.wiki-link { a.wiki-link {
margin-right: 0.3em; margin-right: 0.3em;
} }
a[rel*="external"] {
word-break: break-all;
}

View File

@@ -311,6 +311,10 @@ div#c-posts {
font-weight: bold; font-weight: bold;
} }
#post-info-source {
word-break: break-all;
}
.recommended-posts { .recommended-posts {
margin-top: 1em; margin-top: 1em;
} }

View File

@@ -27,7 +27,7 @@
<li> <li>
<strong>Hidden</strong>: <%= render "post_disapprovals/compact_counts", :disapprovals => post.disapprovals, :post => post %> <strong>Hidden</strong>: <%= render "post_disapprovals/compact_counts", :disapprovals => post.disapprovals, :post => post %>
</li> </li>
<li class="mod-queue-post-source"><strong>Source</strong>: <%= post.source %></li> <li class="mod-queue-post-source"><strong>Source</strong>: <%= post_source_tag(post) %></li>
<% if post.has_active_pools? %> <% if post.has_active_pools? %>
<li><strong>Pools</strong>: <%= render "pools/inline_list", pools: post.pools.undeleted %></li> <li><strong>Pools</strong>: <%= render "pools/inline_list", pools: post.pools.undeleted %></li>
<% end %> <% end %>