tag links as ugc rather than nofollow
This commit is contained in:
parent
2b494c5181
commit
feea257c64
|
@ -29,7 +29,7 @@
|
|||
<td><%= hh.to_html_label %></td>
|
||||
<td>
|
||||
<% if hh.link.to_s.match(/^http/) %>
|
||||
<a href="<%= hh.link %>" rel="nofollow"><%= hh.link %></a>
|
||||
<a href="<%= hh.link %>" rel="ugc"><%= hh.link %></a>
|
||||
<% elsif hh.link.blank? %>
|
||||
<span class="na">None</span>
|
||||
<% else %>
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
<% if hr.link.to_s.match(/^http/) %>
|
||||
<br>
|
||||
<%= f.label :link, "Link:", :class => "required" %>
|
||||
<a href="<%= hr.link %>" rel="nofollow"><%= hr.link %></a>
|
||||
<a href="<%= hr.link %>" rel="ugc"><%= hr.link %></a>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<p>
|
||||
An official real-time discussion channel is available to members and guests
|
||||
of the site, hosted on the
|
||||
<a href="http://www.freenode.net" rel="nofollow">Freenode IRC network</a>
|
||||
<a href="http://www.freenode.net">Freenode IRC network</a>
|
||||
in <tt>#lobsters</tt>. This channel was originally
|
||||
<a href="/s/2hdoop">created</a>
|
||||
by
|
||||
|
|
|
@ -156,8 +156,7 @@ class="story <%= story.vote && story.vote[:vote] == 1 ? "upvoted" : "" %>
|
|||
<% end %>
|
||||
<% if story.url.present? %>
|
||||
|
|
||||
<a href="<%= story.archive_url %>" rel="nofollow"
|
||||
target="_blank">cached</a>
|
||||
<a href="<%= story.archive_url %>" rel="ugc" target="_blank">cached</a>
|
||||
<% end %>
|
||||
<% if !story.is_gone? || @user.try(:is_moderator?) %>
|
||||
<span class="comments_label">
|
||||
|
|
|
@ -116,7 +116,7 @@
|
|||
|
||||
<span class="d">
|
||||
<a href="<%= h(@showing_user.homepage) %>"
|
||||
rel="me nofollow"><%= h(@showing_user.homepage) %></a>
|
||||
rel="me ugc"><%= h(@showing_user.homepage) %></a>
|
||||
</span>
|
||||
<br>
|
||||
<% end %>
|
||||
|
@ -126,7 +126,7 @@
|
|||
|
||||
<span class="d">
|
||||
<a href="https://github.com/<%= h(@showing_user.github_username) %>"
|
||||
rel="me nofollow">https://github.com/<%= h(@showing_user.github_username)
|
||||
rel="me ugc">https://github.com/<%= h(@showing_user.github_username)
|
||||
%></a>
|
||||
</span>
|
||||
<br>
|
||||
|
@ -137,7 +137,7 @@
|
|||
|
||||
<span class="d">
|
||||
<a href="https://twitter.com/<%= h(@showing_user.twitter_username) %>"
|
||||
rel="me nofollow">@<%= h(@showing_user.twitter_username) %></a>
|
||||
rel="me ugc">@<%= h(@showing_user.twitter_username) %></a>
|
||||
</span>
|
||||
<br>
|
||||
<% end %>
|
||||
|
|
|
@ -18,12 +18,12 @@ class Markdowner
|
|||
h.name = "strong"
|
||||
end
|
||||
|
||||
# This should happen before adding rel=nofollow to all links
|
||||
# This should happen before adding rel=ugc to all links
|
||||
convert_images_to_links(ng) unless opts[:allow_images]
|
||||
|
||||
# make links have rel=nofollow
|
||||
# make links have rel=ugc
|
||||
ng.css("a").each do |h|
|
||||
h[:rel] = "nofollow" unless (URI.parse(h[:href]).host.nil? rescue false)
|
||||
h[:rel] = "ugc" unless (URI.parse(h[:href]).host.nil? rescue false)
|
||||
end
|
||||
|
||||
if ng.at_css("body")
|
||||
|
|
|
@ -10,7 +10,7 @@ describe Markdowner do
|
|||
create(:user, :username => "blahblah")
|
||||
|
||||
expect(Markdowner.to_html("hi @blahblah test"))
|
||||
.to eq("<p>hi <a href=\"https://example.com/u/blahblah\" rel=\"nofollow\">" +
|
||||
.to eq("<p>hi <a href=\"https://example.com/u/blahblah\" rel=\"ugc\">" +
|
||||
"@blahblah</a> test</p>\n")
|
||||
|
||||
expect(Markdowner.to_html("hi @flimflam test"))
|
||||
|
@ -20,7 +20,7 @@ describe Markdowner do
|
|||
# bug#209
|
||||
it "keeps punctuation inside of auto-generated links when using brackets" do
|
||||
expect(Markdowner.to_html("hi <http://example.com/a.> test"))
|
||||
.to eq("<p>hi <a href=\"http://example.com/a.\" rel=\"nofollow\">" +
|
||||
.to eq("<p>hi <a href=\"http://example.com/a.\" rel=\"ugc\">" +
|
||||
"http://example.com/a.</a> test</p>\n")
|
||||
end
|
||||
|
||||
|
@ -29,21 +29,21 @@ describe Markdowner do
|
|||
create(:user, :username => "blahblah")
|
||||
|
||||
expect(Markdowner.to_html("hi http://example.com/@blahblah/ test"))
|
||||
.to eq("<p>hi <a href=\"http://example.com/@blahblah/\" rel=\"nofollow\">" +
|
||||
.to eq("<p>hi <a href=\"http://example.com/@blahblah/\" rel=\"ugc\">" +
|
||||
"http://example.com/@blahblah/</a> test</p>\n")
|
||||
|
||||
expect(Markdowner.to_html("hi [test](http://example.com/@blahblah/)"))
|
||||
.to eq("<p>hi <a href=\"http://example.com/@blahblah/\" rel=\"nofollow\">" +
|
||||
.to eq("<p>hi <a href=\"http://example.com/@blahblah/\" rel=\"ugc\">" +
|
||||
"test</a></p>\n")
|
||||
end
|
||||
|
||||
it "correctly adds nofollow" do
|
||||
it "correctly adds ugc" do
|
||||
expect(Markdowner.to_html("[ex](http://example.com)"))
|
||||
.to eq("<p><a href=\"http://example.com\" rel=\"nofollow\">" +
|
||||
.to eq("<p><a href=\"http://example.com\" rel=\"ugc\">" +
|
||||
"ex</a></p>\n")
|
||||
|
||||
expect(Markdowner.to_html("[ex](//example.com)"))
|
||||
.to eq("<p><a href=\"//example.com\" rel=\"nofollow\">" +
|
||||
.to eq("<p><a href=\"//example.com\" rel=\"ugc\">" +
|
||||
"ex</a></p>\n")
|
||||
|
||||
expect(Markdowner.to_html("[ex](/u/abc)"))
|
||||
|
@ -61,7 +61,7 @@ describe Markdowner do
|
|||
let(:title_text) { nil }
|
||||
|
||||
def target_html inner_text = nil
|
||||
"<p><a href=\"#{fake_img_url}\" rel=\"nofollow\">#{inner_text}</a></p>\n"
|
||||
"<p><a href=\"#{fake_img_url}\" rel=\"ugc\">#{inner_text}</a></p>\n"
|
||||
end
|
||||
|
||||
context "with no alt text, title text" do
|
||||
|
@ -115,11 +115,11 @@ describe Markdowner do
|
|||
it 'turns all inline images into links' do
|
||||
expect(subject).to eq(
|
||||
"<p>" \
|
||||
"<a href=\"#{fake_img_url}\" rel=\"nofollow\">#{fake_img_url}</a>" \
|
||||
"<a href=\"#{fake_img_url}\" rel=\"nofollow\">#{fake_img_url}</a>" \
|
||||
"<a href=\"#{fake_img_url}\" rel=\"nofollow\">alt text</a>" \
|
||||
"<a href=\"#{fake_img_url}\" rel=\"nofollow\">title text</a>" \
|
||||
"<a href=\"#{fake_img_url}\" rel=\"nofollow\">title text 2</a>" \
|
||||
"<a href=\"#{fake_img_url}\" rel=\"ugc\">#{fake_img_url}</a>" \
|
||||
"<a href=\"#{fake_img_url}\" rel=\"ugc\">#{fake_img_url}</a>" \
|
||||
"<a href=\"#{fake_img_url}\" rel=\"ugc\">alt text</a>" \
|
||||
"<a href=\"#{fake_img_url}\" rel=\"ugc\">title text</a>" \
|
||||
"<a href=\"#{fake_img_url}\" rel=\"ugc\">title text 2</a>" \
|
||||
"</p>\n"
|
||||
)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue