Merge branch 'stable' into develop

This commit is contained in:
Dennis Schubert 2015-05-12 04:00:12 +02:00
commit aac0a2582e
13 changed files with 165 additions and 22 deletions

View file

@ -50,6 +50,7 @@ Ruby 2.0 is no longer officially supported.
* Gracefully handle missing `og:url`s [#5926](https://github.com/diaspora/diaspora/pull/5926)
* Remove private post content from "also commented" mails [#5931](https://github.com/diaspora/diaspora/pull/5931)
* Add a button to follow/unfollow tags to the mobile interface [#5941](https://github.com/diaspora/diaspora/pull/5941)
* Add a "Manage followed tags" page to mass unfollow tags in the mobile interface [#5945](https://github.com/diaspora/diaspora/pull/5945)
# 0.5.0.1

View file

@ -1,7 +1,8 @@
$(document).ready(function(){
$(".tag_following_action").bind("tap click", function(evt){
evt.preventDefault();
var button = $(this),
var tagFollowing,
button = $(this),
tagName = button.data("name");
if(button.hasClass("btn-success")){
@ -19,11 +20,11 @@ $(document).ready(function(){
button.removeClass("btn-success").addClass("btn-danger");
button.text(Diaspora.I18n.t("stream.tags.stop_following", {tag: tagName}));
}).fail(function() {
alert(Diaspora.I18n.t("stream.tags.follow_error", {name: "#" + tagName}));
alert(Diaspora.I18n.t("stream.tags.follow_error", {tag: tagName}));
});
}
else if(button.hasClass("btn-danger")){
var tagFollowing = _.findWhere(gon.preloads.tagFollowings,{name: tagName});
tagFollowing = _.findWhere(gon.preloads.tagFollowings, {name: tagName});
if(!tagFollowing) { return; }
$.ajax({
url: Routes.tagFollowing(tagFollowing.id),
@ -36,7 +37,28 @@ $(document).ready(function(){
button.removeClass("btn-danger").addClass("btn-success");
button.text(Diaspora.I18n.t("stream.tags.follow", {tag: tagName}));
}).fail(function() {
alert(Diaspora.I18n.t("stream.tags.stop_following_error", {name: "#" + tagName}));
alert(Diaspora.I18n.t("stream.tags.stop_following_error", {tag: tagName}));
});
}
else if(button.hasClass("only-delete")){
tagFollowing = _.findWhere(gon.preloads.tagFollowings, {name: tagName});
if(!tagFollowing ||
!confirm(Diaspora.I18n.t("stream.tags.stop_following_confirm", {tag: tagName}))) { return; }
$.ajax({
url: Routes.tagFollowing(tagFollowing.id),
dataType: "json",
type: "DELETE",
headers: {
"Accept": "application/json, text/javascript, */*; q=0.01"
}
}).done(function() {
button.closest("li").remove();
if($("ul.followed_tags li").length === 0){
$(".well").removeClass("hidden");
}
}).fail(function() {
alert(Diaspora.I18n.t("stream.tags.stop_following_error", {tag: tagName}));
});
}
});

View file

@ -6,6 +6,7 @@
@import "_flash_messages";
@import "header";
@import "mobile/tags";
a {
color: #2489ce;

View file

@ -0,0 +1,28 @@
ul.followed_tags {
list-style: none;
margin: 0px;
> li {
background-color: $white;
border: 1px solid $border-grey;
border-radius: 5px;
box-shadow: 0 1px 2px rgba($border-dark-grey, 0.5);
font-weight: bold;
margin-bottom: 10px;
padding: 10px;
.tag_name {
margin-right: 30px;
word-break: break-all;
}
.tag_following_action {
font-size: 30px;
font-weight: bold;
line-height: 10px;
margin: 0;
padding: 0;
&:hover { text-decoration: none }
}
}
}

View file

@ -7,6 +7,7 @@ class TagFollowingsController < ApplicationController
before_action :authenticate_user!
respond_to :json
respond_to :html, only: [:manage]
# POST /tag_followings
# POST /tag_followings.xml
@ -48,4 +49,9 @@ class TagFollowingsController < ApplicationController
format.json{ render(:json => tags.to_json, :status => 200) }
end
end
def manage
redirect_to followed_tags_stream_path unless request.format == :mobile
gon.preloads[:tagFollowings] = tags
end
end

View file

@ -98,6 +98,9 @@
- current_user.followed_tags.each do |tag|
%li
= tag_link(tag)
- if current_user.followed_tags.length > 0
%li.manage_followed_tags
= link_to t("tag_followings.manage.title"), manage_tag_followings_path
%li
= link_to user_profile_path(current_user.username) do
= t('layouts.header.profile')

View file

@ -0,0 +1,18 @@
%h3= t("tag_followings.manage.title")
-if current_user.followed_tags.length == 0
.well
%h4
= t("tag_followings.manage.no_tags")
-else
.well.hidden
%h4
= t("tag_followings.manage.no_tags")
%ul.followed_tags
- current_user.followed_tags.each do |tag|
%li
.pull-right.btn.btn-link.only-delete.tag_following_action{data: {name: tag}}
&times;
.tag_name
= "##{tag}"

View file

@ -1262,6 +1262,9 @@ en:
destroy:
success: "Alas! You arent following #%{name} any more."
failure: "Failed to stop following #%{name}. Maybe you already stopped following it?"
manage:
title: "Manage followed tags"
no_tags: "You aren't following any tags."
streams:
community_spotlight_stream: "Community spotlight"

View file

@ -206,8 +206,9 @@ en:
follow: "Follow #<%= tag %>"
following: "Following #<%= tag %>"
stop_following: "Stop following #<%= tag %>"
follow_error: "Couldnt follow <%= name %> :("
stop_following_error: "Couldnt stop following <%= name %> :("
stop_following_confirm: "Stop following #<%= tag %>?"
follow_error: "Couldnt follow #<%= tag %> :("
stop_following_error: "Couldnt stop following #<%= tag %> :("
header:
home: "Home"

View file

@ -94,7 +94,11 @@ Diaspora::Application.routes.draw do
resources :tags, :only => [:index]
resources "tag_followings", :only => [:create, :destroy, :index]
resources "tag_followings", only: %i(create destroy index) do
collection do
get :manage
end
end
get 'tags/:name' => 'tags#show', :as => 'tag'

View file

@ -72,6 +72,18 @@ Feature: Navigate between pages using the header menu and the drawer
And I follow "#boss"
Then I should see "bob is da #boss" within "#main_stream"
Scenario: navigate to the manage followed tags page
Given "bob@bob.bob" has a public post with text "bob is da #boss"
And I toggle the mobile view
And I search for "#boss"
And I press "Follow #boss"
And I toggle the mobile view
When I open the drawer
And I follow "#Followed tags"
Then I should see "Manage followed tags" within "#followed_tags + li > ul"
And I follow "Manage followed tags"
Then I should see "#boss" within "ul.followed_tags"
Scenario: navigate to my profile page
When I open the drawer
And I follow "Profile"

View file

@ -30,3 +30,15 @@ Feature: Interacting with tags
Then I should see "Follow #newhere" within ".tag_following_action"
When I am on the home page
Then I should not see "Hello! I am #newhere"
Scenario: Manage tags
When I click on selector ".tag_following_action"
Then I should see "Stop following #newhere" within ".tag_following_action"
When I am on the manage tag followings page
Then I should see "#newhere" within "ul.followed_tags"
When I click on selector ".tag_following_action.only-delete"
And I confirm the alert
Then I should see "You aren't following any tags."
When I am on the home page
Then I should not see "Hello! I am #newhere"

View file

@ -0,0 +1,32 @@
require "spec_helper"
describe TagFollowingsController, type: :controller do
describe "#manage" do
context "not signed in" do
it "redirects html requests" do
get :manage
expect(response).to redirect_to new_user_session_path
end
it "redirects mobile requests" do
get :manage, format: :mobile
expect(response).to redirect_to new_user_session_path(format: :mobile)
end
end
context "signed in" do
before do
sign_in :user, alice
end
it "redirects html requests" do
get :manage
expect(response).to redirect_to followed_tags_stream_path
end
it "does not redirect mobile requests" do
get :manage, format: :mobile
expect(response).not_to be_redirect
end
end
end
end