Merge branch 'next-minor' into develop

This commit is contained in:
Benjamin Neff 2017-03-04 21:08:18 +01:00
commit e1bf447aad
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
7 changed files with 1456 additions and 458 deletions

View file

@ -30,6 +30,7 @@
* Remove whitespace from author link [#7330](https://github.com/diaspora/diaspora/pull/7330)
* Fix autosize in modals [#7339](https://github.com/diaspora/diaspora/pull/7339)
* Only display invite link on contacts page if invitations are enabled [#7342](https://github.com/diaspora/diaspora/pull/7342)
* Fix regex for hashtags for some languages [#7350](https://github.com/diaspora/diaspora/pull/7350)
## Features
* Add support for [Liberapay](https://liberapay.com) donations [#7290](https://github.com/diaspora/diaspora/pull/7290)

View file

@ -37,7 +37,14 @@
var hashtagPlugin = window.markdownitHashtag;
md.use(hashtagPlugin, {
// compare tag_text_regexp in app/models/acts_as_taggable_on-tag.rb
hashtagRegExp: "[" + PosixBracketExpressions.alnum + "_\\-]+|<3",
hashtagRegExp: "[" + PosixBracketExpressions.word +
"\\u055b" + // Armenian emphasis mark
"\\u055c" + // Armenian exclamation mark
"\\u055e" + // Armenian question mark
"\\u058a" + // Armenian hyphen
"_" +
"\\-" +
"]+|<3",
// compare tag_strings in lib/diaspora/taggabe.rb
preceding: "^|\\s"
});

View file

@ -4,7 +4,7 @@ module ActsAsTaggableOn
self.include_root_in_json = false
def self.tag_text_regexp
@@tag_text_regexp ||= "[[:alnum:]]_-"
@tag_text_regexp ||= "[[:word:]]\u055b\u055c\u055e\u058a_-"
end
def self.autocomplete(name)

File diff suppressed because it is too large Load diff

View file

@ -9,21 +9,46 @@ describe("app.helpers.textFormatter", function(){
// https://github.com/svbergerem/markdown-it-hashtag/tree/master/test
context("hashtags", function() {
beforeEach(function() {
this.tags = [
this.goodTags = [
"tag",
"diaspora",
"PARTIES",
"<3"
"<3",
"diaspora-dev",
"diaspora_dev",
// issue #5765
"മലയാണ്മ",
// issue #5815
"ինչո՞ւ",
"այո՜ո",
"սեւ֊սպիտակ",
"գժանո՛ց"
];
this.badTags = [
"tag.tag",
"hash:tag",
"hash*tag"
];
});
it("renders tags as links", function() {
var formattedText = this.formatter('#'+this.tags.join(" #"));
_.each(this.tags, function(tag) {
var link ='<a href="/tags/'+tag.toLowerCase()+'" class="tag">#'+tag.replace("<","&lt;")+'</a>';
it("renders good tags as links", function() {
var self = this;
this.goodTags.forEach(function(tag) {
var formattedText = self.formatter("#newhashtag #" + tag + " test");
var link = "<a href=\"/tags/" + tag.toLowerCase() + "\" class=\"tag\">#" + tag.replace("<", "&lt;") + "</a>";
expect(formattedText).toContain(link);
});
});
it("doesn't render bad tags as links", function() {
var self = this;
this.badTags.forEach(function(tag) {
var formattedText = self.formatter("#newhashtag #" + tag + " test");
var link = "<a href=\"/tags/" + tag.toLowerCase() + "\" class=\"tag\">#" + tag.replace("<", "&lt;") + "</a>";
expect(formattedText).not.toContain(link);
});
});
});
// Some basic specs. For more detailed specs see

View file

@ -27,6 +27,42 @@ describe Diaspora::Taggable do
expect(text).to eq("<a class=\"tag\" href=\"/tags/l\">#l</a> <a class=\"tag\" href=\"/tags/lol\">#lol</a>")
end
end
context "good tags" do
it "autolinks" do
good_tags = [
"tag",
"diaspora",
"PARTIES",
"diaspora-dev",
"diaspora_dev",
# issue #5765
"മലയാണ്മ",
# issue #5815
"ինչո՞ւ",
"այո՜ո",
"սեւ֊սպիտակ",
"գժանո՛ց"
]
good_tags.each do |tag|
text = Diaspora::Taggable.format_tags("#newhashtag ##{tag} #newhashtag")
expect(text).to match("<a class=\"tag\" href=\"/tags/#{tag}\">##{tag}</a>")
end
end
end
context "bad tags" do
it "doesn't autolink" do
bad_tags = [
"tag.tag",
"hash:tag"
]
bad_tags.each do |tag|
text = Diaspora::Taggable.format_tags("#newhashtag ##{tag} #newhashtag")
expect(text).not_to match("<a class=\"tag\" href=\"/tags/#{tag}\">##{tag}</a>")
end
end
end
end
describe "#format_tags_for_mail" do

View file

@ -10,23 +10,35 @@ shared_examples_for "it is taggable" do
link_to "##{s}", "/tags/#{s}", :class => 'tag'
end
describe '.format_tags' do
describe ".format_tags" do
let(:tag_list) {
[
"what",
"hey",
"vöglein",
"മലയാണ്മ",
"գժանո՛ց"
]
}
before do
@str = '#what #hey #vöglein'
@str = tag_list.map {|tag| "##{tag}" }.join(" ")
@object.send(@object.class.field_with_tags_setter, @str)
@object.build_tags
@object.save!
end
it "supports non-ascii characters" do
expect(@object.tags(true).map(&:name)).to include('vöglein')
tag_list.each do |tag|
expect(@object.tags(true).map(&:name)).to include(tag)
end
end
it 'links each tag' do
it "links each tag" do
formatted_string = Diaspora::Taggable.format_tags(@str)
expect(formatted_string).to include(tag_link('what'))
expect(formatted_string).to include(tag_link('hey'))
expect(formatted_string).to include(tag_link('vöglein'))
tag_list.each do |tag|
expect(formatted_string).to include(tag_link(tag))
end
end
it 'responds to plain_text' do