Commit 339c25f3 authored by Steffen van Bergerem's avatar Steffen van Bergerem

Merge pull request #7324 from SuperTux88/at-before-mention-links

Display @ before mentions
parents 99351bd1 5c444e62
......@@ -3,6 +3,7 @@
## Refactor
* Make the mention syntax more flexible [#7305](https://github.com/diaspora/diaspora/pull/7305)
* Display @ before mentions [#7324](https://github.com/diaspora/diaspora/pull/7324)
## Bug fixes
......
......@@ -551,7 +551,7 @@ GEM
rails-assets-jquery (>= 1.6)
rails-assets-markdown-it--markdown-it-for-inline (0.1.1)
rails-assets-markdown-it (8.2.2)
rails-assets-markdown-it-diaspora-mention (1.1.1)
rails-assets-markdown-it-diaspora-mention (1.2.0)
rails-assets-markdown-it-hashtag (0.4.0)
rails-assets-markdown-it-sanitizer (0.4.3)
rails-assets-markdown-it-sub (1.0.0)
......@@ -881,7 +881,7 @@ DEPENDENCIES
rails-assets-jquery-textchange (= 0.2.3)!
rails-assets-markdown-it (= 8.2.2)!
rails-assets-markdown-it--markdown-it-for-inline (= 0.1.1)!
rails-assets-markdown-it-diaspora-mention (= 1.1.1)!
rails-assets-markdown-it-diaspora-mention (= 1.2.0)!
rails-assets-markdown-it-hashtag (= 0.4.0)!
rails-assets-markdown-it-sanitizer (= 0.4.3)!
rails-assets-markdown-it-sub (= 1.0.0)!
......
......@@ -32,7 +32,7 @@ module Diaspora::Mentionable
name, diaspora_id = mention_attrs(match_str)
person = people.find {|p| p.diaspora_handle == diaspora_id }
ERB::Util.h(MentionsInternal.mention_link(person, name, diaspora_id, opts))
"@#{ERB::Util.h(MentionsInternal.mention_link(person, name, diaspora_id, opts))}"
}
end
......@@ -64,7 +64,7 @@ module Diaspora::Mentionable
if person && allowed_people.include?(person.id)
match_str
else
MentionsInternal.profile_link(person, name, diaspora_id)
"@#{MentionsInternal.profile_link(person, name, diaspora_id)}"
end
}
end
......
......@@ -44,7 +44,8 @@ STR
fmt_msg = Diaspora::Mentionable.format(test_text_with_names, people)
[people, names].transpose.each do |person, name|
expect(fmt_msg).to include person_link(person, class: "mention hovercardable", display_name: name)
link = person_link(person, class: "mention hovercardable", display_name: name)
expect(fmt_msg).to include "@#{link}"
end
end
......@@ -52,7 +53,8 @@ STR
fmt_msg = Diaspora::Mentionable.format(test_text_without_names, people)
people.each do |person|
expect(fmt_msg).to include person_link(person, class: "mention hovercardable", display_name: person.name)
link = person_link(person, class: "mention hovercardable", display_name: person.name)
expect(fmt_msg).to include "@#{link}"
end
end
......@@ -80,7 +82,7 @@ STR
fmt_msg = Diaspora::Mentionable.format(test_text_with_names, people, plain_text: true)
names.each do |name|
expect(fmt_msg).to include CGI.escapeHTML(name)
expect(fmt_msg).to include "@#{CGI.escapeHTML(name)}"
end
expect(fmt_msg).not_to include "<a", "</a>", "hovercardable"
end
......@@ -89,9 +91,9 @@ STR
it "leaves the names of people that cannot be found" do
test_txt_plain = <<-STR
This post contains a lot of mentions
one Alice A,
two Bob B and finally
three &quot;Eve&gt; E.
one @Alice A,
two @Bob B and finally
three @&quot;Eve&gt; E.
STR
fmt_msg = Diaspora::Mentionable.format(test_text_with_names, [])
......@@ -101,9 +103,9 @@ STR
it "uses the diaspora ID when the person cannot be found" do
test_txt_plain = <<-STR
This post contains a lot of mentions
one #{people[0].diaspora_handle},
two #{people[1].diaspora_handle} and finally
three #{people[2].diaspora_handle}.
one @#{people[0].diaspora_handle},
two @#{people[1].diaspora_handle} and finally
three @#{people[2].diaspora_handle}.
STR
fmt_msg = Diaspora::Mentionable.format(test_text_without_names, [])
......@@ -180,8 +182,7 @@ STR
user_a.aspects.where(name: "generic").first.contacts.map(&:person_id)
)
expect(txt).to include("user C")
expect(txt).to include(local_or_remote_person_path(user_c.person))
expect(txt).to include("@[user C](#{local_or_remote_person_path(user_c.person)}")
expect(txt).not_to include("href")
expect(txt).not_to include(mention)
end
......@@ -203,7 +204,7 @@ STR
mention = "@{non_existing_user@example.org}"
txt = Diaspora::Mentionable.filter_people("mentioning #{mention}", [])
expect(txt).to eq "mentioning non_existing_user@example.org"
expect(txt).to eq "mentioning @non_existing_user@example.org"
end
end
......
......@@ -195,17 +195,17 @@ describe Diaspora::MessageRenderer do
context "with mention" do
it "contains the name of the mentioned person" do
msg = message("@{#{alice.diaspora_handle}} is cool", mentioned_people: alice.person)
expect(msg.plain_text_without_markdown).to eq "#{alice.name} is cool"
expect(msg.plain_text_without_markdown).to eq "@#{alice.name} is cool"
end
it "uses the name from mention when the mention contains a name" do
msg = message("@{Alice; #{alice.diaspora_handle}} is cool", mentioned_people: alice.person)
expect(msg.plain_text_without_markdown).to eq "Alice is cool"
expect(msg.plain_text_without_markdown).to eq "@Alice is cool"
end
it "uses the diaspora ID when the person cannot be found" do
msg = message("@{#{alice.diaspora_handle}} is cool", mentioned_people: [])
expect(msg.plain_text_without_markdown).to eq "#{alice.diaspora_handle} is cool"
expect(msg.plain_text_without_markdown).to eq "@#{alice.diaspora_handle} is cool"
end
end
end
......
......@@ -16,7 +16,7 @@ describe Publisher do
describe '#text' do
it 'is a formatted version of the prefill' do
p = Publisher.new(alice, prefill: "@{alice; #{alice.diaspora_handle}}")
expect(p.text).to eq("alice")
expect(p.text).to eq("@alice")
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment