mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
Changed our minds: Let's track internal links, just never to users. Something like FAQ is useful.
This commit is contained in:
parent
4e87289249
commit
09e53c72d4
2 changed files with 16 additions and 4 deletions
|
@ -47,11 +47,12 @@ class TopicLink < ActiveRecord::Base
|
||||||
internal = true
|
internal = true
|
||||||
|
|
||||||
route = Rails.application.routes.recognize_path(parsed.path)
|
route = Rails.application.routes.recognize_path(parsed.path)
|
||||||
|
|
||||||
|
# We aren't interested in tracking internal links to users
|
||||||
|
next if route[:controller] == 'users'
|
||||||
|
|
||||||
topic_id = route[:topic_id]
|
topic_id = route[:topic_id]
|
||||||
post_number = route[:post_number] || 1
|
post_number = route[:post_number] || 1
|
||||||
|
|
||||||
# We aren't interested in tracking internal links to non-topics
|
|
||||||
next unless topic_id
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Skip linking to ourselves
|
# Skip linking to ourselves
|
||||||
|
|
|
@ -143,7 +143,7 @@ describe TopicLink do
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "link to a non-topic on discourse" do
|
context "link to a user on discourse" do
|
||||||
let(:post) { @topic.posts.create(user: @user, raw: "<a href='/users/#{@user.username_lower}'>user</a>") }
|
let(:post) { @topic.posts.create(user: @user, raw: "<a href='/users/#{@user.username_lower}'>user</a>") }
|
||||||
before do
|
before do
|
||||||
TopicLink.extract_from(post)
|
TopicLink.extract_from(post)
|
||||||
|
@ -154,6 +154,17 @@ describe TopicLink do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "link to a discourse resource like a FAQ" do
|
||||||
|
let(:post) { @topic.posts.create(user: @user, raw: "<a href='/faq'>faq link here</a>") }
|
||||||
|
before do
|
||||||
|
TopicLink.extract_from(post)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not extract a link' do
|
||||||
|
@topic.topic_links.should be_present
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "@mention links" do
|
context "@mention links" do
|
||||||
let(:post) { @topic.posts.create(user: @user, raw: "Hey @#{@user.username_lower}") }
|
let(:post) { @topic.posts.create(user: @user, raw: "Hey @#{@user.username_lower}") }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue