Unverified Commit 339c25f3 authored by Steffen van Bergerem's avatar Steffen van Bergerem
Browse files

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

Display @ before mentions
parents 99351bd1 5c444e62
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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

+1 −1
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@ source "https://rails-assets.org" do

  gem "rails-assets-markdown-it",                         "8.2.2"
  gem "rails-assets-markdown-it-hashtag",                 "0.4.0"
  gem "rails-assets-markdown-it-diaspora-mention",        "1.1.1"
  gem "rails-assets-markdown-it-diaspora-mention",        "1.2.0"
  gem "rails-assets-markdown-it-sanitizer",               "0.4.3"
  gem "rails-assets-markdown-it--markdown-it-for-inline", "0.1.1"
  gem "rails-assets-markdown-it-sub",                     "1.0.0"
+2 −2
Original line number Diff line number Diff line
@@ -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)!
+2 −2
Original line number Diff line number Diff line
@@ -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
+13 −12
Original line number Diff line number Diff line
@@ -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

Loading