Merge branch 'brauliomartinezlm-4058_redirect_to_downcase_version_of_tags' into develop
This commit is contained in:
commit
f272c7ed03
7 changed files with 48 additions and 2 deletions
|
|
@ -116,6 +116,7 @@ by them self.
|
||||||
* Fix default image url in profiles table. [#3795](https://github.com/diaspora/diaspora/issues/3795)
|
* Fix default image url in profiles table. [#3795](https://github.com/diaspora/diaspora/issues/3795)
|
||||||
* Fix mobile buttons are only clickable when scrolled to the top. [#4102](https://github.com/diaspora/diaspora/issues/4102)
|
* Fix mobile buttons are only clickable when scrolled to the top. [#4102](https://github.com/diaspora/diaspora/issues/4102)
|
||||||
* Fix regression in bookmarklet causing uneditable post contents. [#4057](https://github.com/diaspora/diaspora/issues/4057)
|
* Fix regression in bookmarklet causing uneditable post contents. [#4057](https://github.com/diaspora/diaspora/issues/4057)
|
||||||
|
* Redirect all mixed case tags to the lower case equivalents [#4058](https://github.com/diaspora/diaspora/issues/4058)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,8 @@ $(function() {
|
||||||
textFormatter.hashtagify = function hashtagify(text){
|
textFormatter.hashtagify = function hashtagify(text){
|
||||||
var utf8WordCharcters =/(\s|^|>)#([\u0080-\uFFFF|\w|-]+|<3)/g
|
var utf8WordCharcters =/(\s|^|>)#([\u0080-\uFFFF|\w|-]+|<3)/g
|
||||||
return text.replace(utf8WordCharcters, function(hashtag, preceeder, tagText) {
|
return text.replace(utf8WordCharcters, function(hashtag, preceeder, tagText) {
|
||||||
return preceeder + "<a href='/tags/" + tagText + "' class='tag'>#" + tagText + "</a>"
|
return preceeder + "<a href='/tags/" + tagText.toLowerCase() +
|
||||||
|
"' class='tag'>#" + tagText + "</a>"
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ app.Router = Backbone.Router.extend({
|
||||||
|
|
||||||
if(name) {
|
if(name) {
|
||||||
var followedTagsAction = new app.views.TagFollowingAction(
|
var followedTagsAction = new app.views.TagFollowingAction(
|
||||||
{tagText: decodeURIComponent(name)}
|
{tagText: decodeURIComponent(name).toLowerCase()}
|
||||||
);
|
);
|
||||||
$("#author_info").prepend(followedTagsAction.render().el)
|
$("#author_info").prepend(followedTagsAction.render().el)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@ class TagsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
redirect_to(:action => :show, :name => downcased_tag_name) && return if tag_has_capitals?
|
||||||
|
|
||||||
if user_signed_in?
|
if user_signed_in?
|
||||||
gon.tagFollowings = tags
|
gon.tagFollowings = tags
|
||||||
end
|
end
|
||||||
|
|
@ -45,6 +47,15 @@ class TagsController < ApplicationController
|
||||||
TagFollowing.user_is_following?(current_user, params[:name])
|
TagFollowing.user_is_following?(current_user, params[:name])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def tag_has_capitals?
|
||||||
|
mb_tag = params[:name].mb_chars
|
||||||
|
mb_tag.downcase != mb_tag
|
||||||
|
end
|
||||||
|
|
||||||
|
def downcased_tag_name
|
||||||
|
params[:name].mb_chars.downcase.to_s
|
||||||
|
end
|
||||||
|
|
||||||
def prep_tags_for_javascript
|
def prep_tags_for_javascript
|
||||||
@tags.map! do |tag|
|
@tags.map! do |tag|
|
||||||
{ :name => ("#" + tag.name) }
|
{ :name => ("#" + tag.name) }
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,17 @@ describe TagsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#show' do
|
describe '#show' do
|
||||||
|
context 'tag with capital letters' do
|
||||||
|
before do
|
||||||
|
sign_in :user, alice
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'redirect to the downcase tag uri' do
|
||||||
|
get :show, :name => 'DiasporaRocks!'
|
||||||
|
response.should redirect_to(:action => :show, :name => 'diasporarocks!')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'signed in' do
|
context 'signed in' do
|
||||||
before do
|
before do
|
||||||
sign_in :user, alice
|
sign_in :user, alice
|
||||||
|
|
|
||||||
|
|
@ -214,6 +214,12 @@ describe("app.helpers.textFormatter", function(){
|
||||||
expect(wrapper.find("h1").length).toBe(0)
|
expect(wrapper.find("h1").length).toBe(0)
|
||||||
expect(wrapper.find("a[href='/tags/parties']").text()).toContain("#parties")
|
expect(wrapper.find("a[href='/tags/parties']").text()).toContain("#parties")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("and the resultant link has the tags name downcased", function(){
|
||||||
|
var formattedText = this.formatter.hashtagify("#PARTIES, I love")
|
||||||
|
|
||||||
|
expect(formattedText).toContain("/tags/parties")
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,5 +15,21 @@ describe('app.Router', function () {
|
||||||
expect(followed_tags).toHaveBeenCalled();
|
expect(followed_tags).toHaveBeenCalled();
|
||||||
expect(tag_following_action).toHaveBeenCalledWith({tagText: 'օբյեկտիվ'});
|
expect(tag_following_action).toHaveBeenCalledWith({tagText: 'օբյեկտիվ'});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('navigates to the downcase version of the corresponding tag', function () {
|
||||||
|
var followed_tags = spyOn(app.router, 'followed_tags').andCallThrough();
|
||||||
|
var tag_following_action = spyOn(app.views, 'TagFollowingAction').andCallFake(function(data) {
|
||||||
|
return {render: function() { return {el: ""}}};
|
||||||
|
});
|
||||||
|
spyOn(window.history, 'pushState').andCallFake(function (data, title, url) {
|
||||||
|
var route = app.router._routeToRegExp("tags/:name");
|
||||||
|
var args = app.router._extractParameters(route, url.replace(/^\//, ""));
|
||||||
|
app.router.followed_tags(args[0]);
|
||||||
|
});
|
||||||
|
window.preloads = {tagFollowings: []};
|
||||||
|
app.router.navigate('/tags/'+encodeURIComponent('SomethingWithCapitalLetters'));
|
||||||
|
expect(followed_tags).toHaveBeenCalled();
|
||||||
|
expect(tag_following_action).toHaveBeenCalledWith({tagText: 'somethingwithcapitalletters'});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue