Add hovercards for mentions

This commit is contained in:
Steffen van Bergerem 2015-02-11 00:46:00 +01:00
parent 1c202db3ce
commit 7112cb112b
4 changed files with 22 additions and 8 deletions

View file

@ -89,9 +89,9 @@ gem 'rails-assets-jquery', '1.11.1' # Should be kep
gem 'js_image_paths', '0.0.1'
gem 'js-routes', '0.9.9'
gem 'rails-assets-punycode', '1.3.2'
gem 'rails-assets-markdown-it', '3.0.3'
gem 'rails-assets-markdown-it', '3.0.5'
gem 'rails-assets-markdown-it-hashtag', '0.2.3'
gem 'rails-assets-markdown-it-diaspora-mention', '0.1.2'
gem 'rails-assets-markdown-it-diaspora-mention', '0.2.0'
gem 'rails-assets-markdown-it-sanitizer', '0.2.0'
gem 'rails-assets-markdown-it--markdown-it-for-inline', '0.1.0'
gem 'rails-assets-markdown-it-sub', '0.1.0'

View file

@ -444,8 +444,8 @@ GEM
rails-assets-jquery.slimscroll (1.3.3)
rails-assets-jquery (>= 1.7)
rails-assets-markdown-it--markdown-it-for-inline (0.1.0)
rails-assets-markdown-it (3.0.3)
rails-assets-markdown-it-diaspora-mention (0.1.2)
rails-assets-markdown-it (3.0.5)
rails-assets-markdown-it-diaspora-mention (0.2.0)
rails-assets-markdown-it-hashtag (0.2.3)
rails-assets-markdown-it-sanitizer (0.2.0)
rails-assets-markdown-it-sub (0.1.0)
@ -698,9 +698,9 @@ DEPENDENCIES
rails-assets-jquery-idletimer (= 1.0.1)
rails-assets-jquery-placeholder (= 2.0.8)
rails-assets-jquery-textchange (= 0.2.3)
rails-assets-markdown-it (= 3.0.3)
rails-assets-markdown-it (= 3.0.5)
rails-assets-markdown-it--markdown-it-for-inline (= 0.1.0)
rails-assets-markdown-it-diaspora-mention (= 0.1.2)
rails-assets-markdown-it-diaspora-mention (= 0.2.0)
rails-assets-markdown-it-hashtag (= 0.2.3)
rails-assets-markdown-it-sanitizer (= 0.2.0)
rails-assets-markdown-it-sub (= 0.1.0)

View file

@ -59,7 +59,11 @@
});
var mentionPlugin = window.markdownitDiasporaMention;
md.use(mentionPlugin, mentions);
md.use(mentionPlugin, {
mentions: mentions,
allowHovercards: true,
currentUserId: app.currentUser.get('guid')
});
var subPlugin = window.markdownitSub;
md.use(subPlugin);

View file

@ -33,12 +33,14 @@ describe("app.helpers.textFormatter", function(){
this.alice = factory.author({
name : "Alice Smith",
diaspora_id : "alice@example.com",
guid: "555",
id : "555"
});
this.bob = factory.author({
name : "Bob Grimm",
diaspora_id : "bob@example.com",
guid: "666",
id : "666"
});
@ -70,12 +72,20 @@ describe("app.helpers.textFormatter", function(){
expect(wrapper.find("a[href='googlebot.com']").text()).toContain(freshBob.name);
});
it('returns the name of the mention if the mention does not exist in the array', function(){
it("returns the name of the mention if the mention does not exist in the array", function(){
var text = "hey there @{Chris Smith; chris@example.com}";
var formattedText = this.formatter(text, []);
expect(formattedText.match(/<a/)).toBeNull();
expect(formattedText).toContain('Chris Smith');
});
it("makes mentions hovercardable unless the current user has been mentioned", function() {
app.currentUser.get = jasmine.createSpy().and.returnValue(this.alice.guid);
var formattedText = this.formatter(this.statusMessage.get("text"), this.statusMessage.get("mentioned_people"));
var wrapper = $("<div>").html(formattedText);
expect(wrapper.find("a[href='/people/" + this.alice.guid + "']")).not.toHaveClass('hovercardable');
expect(wrapper.find("a[href='/people/" + this.bob.guid + "']")).toHaveClass('hovercardable');
});
});
context("markdown", function(){