From f9e9a0521d933e49e1e1f581130a84e50e4abb37 Mon Sep 17 00:00:00 2001
From: Flaburgan <flaburgan@geexxx.fr>
Date: Tue, 9 Dec 2014 15:39:48 +0100
Subject: [PATCH] Add followed tags to the mobile menu

---
 Changelog.md                              |  2 +-
 app/assets/javascripts/mobile.js          |  6 ++++++
 app/helpers/tags_helper.rb                | 13 ++++++-------
 app/views/layouts/application.mobile.haml |  7 +++++++
 4 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/Changelog.md b/Changelog.md
index 3de3e3bd83..06ee0d61d1 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -129,7 +129,7 @@ This is disabled by default since it requires the installation of additional pac
 * Make the source code URL configurable [#5410](https://github.com/diaspora/diaspora/pull/5410)
 * Prefill publisher on the tag pages [#5442](https://github.com/diaspora/diaspora/pull/5442)
 * Allows users to export their data in JSON format from their user settings page [#5354](https://github.com/diaspora/diaspora/pull/5354)
-
+* Add followed tags in the mobile menu [#5468](https://github.com/diaspora/diaspora/pull/5468)
 
 # 0.4.1.2
 
diff --git a/app/assets/javascripts/mobile.js b/app/assets/javascripts/mobile.js
index 3584bf001e..53177a20ff 100644
--- a/app/assets/javascripts/mobile.js
+++ b/app/assets/javascripts/mobile.js
@@ -40,6 +40,12 @@ $(document).ready(function(){
     $("#all_aspects + li").toggleClass('hide');
   });
 
+  /* Show / hide followed tags in the drawer */
+  $('#followed_tags').bind("tap click", function(evt){
+    evt.preventDefault();
+    $("#followed_tags + li").toggleClass('hide');
+  });
+
   /* Heart toggle */
   $(".like_action", ".stream").bind("tap click", function(evt){
     evt.preventDefault();
diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb
index a01acd3615..28f46f7191 100644
--- a/app/helpers/tags_helper.rb
+++ b/app/helpers/tags_helper.rb
@@ -1,17 +1,16 @@
 module TagsHelper
   def looking_for_tag_link
-    return if search_query.include?('@') || normalized_tag_name.blank?
+    return if search_query.include?('@') || normalize_tag_name(search_query).blank?
     content_tag('small') do
-      t('people.index.looking_for', :tag_link => tag_link).html_safe
+      t('people.index.looking_for', tag_link: tag_link(search_query)).html_safe
     end
   end
 
-  def normalized_tag_name
-    ActsAsTaggableOn::Tag.normalize(search_query)
+  def normalize_tag_name(tag)
+    ActsAsTaggableOn::Tag.normalize(tag.to_s)
   end
 
-  def tag_link
-    tag = normalized_tag_name
-    link_to("##{tag}", tag_path(:name => tag))
+  def tag_link(tag)
+    link_to("##{tag}", tag_path(name: normalize_tag_name(tag)))
   end
 end
diff --git a/app/views/layouts/application.mobile.haml b/app/views/layouts/application.mobile.haml
index 967a8f63fc..77d722894c 100644
--- a/app/views/layouts/application.mobile.haml
+++ b/app/views/layouts/application.mobile.haml
@@ -91,6 +91,13 @@
                   - current_user.aspects.each do |aspect|
                     %li
                       = link_to aspect.name, aspects_stream_path(a_ids: [aspect.id])
+              %li#followed_tags
+                = link_to t('streams.followed_tag.title'), "#"
+              %li.no_border.hide
+                %ul
+                  - current_user.followed_tags.each do |tag|
+                    %li
+                      = tag_link(tag)
               %li
                 = link_to user_profile_path(current_user.username) do
                   = t('layouts.header.profile')
-- 
GitLab