]> git.openstreetmap.org Git - rails.git/blobdiff - app/helpers/application_helper.rb
Merge branch 'master' into moderation
[rails.git] / app / helpers / application_helper.rb
index c5b08e515dcfd3279961607f9ff399e9acac963e..adcf5c6c011ec6fdcc31821b2c0af3b74065c083 100644 (file)
@@ -3,9 +3,9 @@ module ApplicationHelper
 
   def linkify(text)
     if text.html_safe?
-      Rinku.auto_link(text, :urls, tag_options(:rel => "nofollow")).html_safe
+      Rinku.auto_link(text, :urls, tag_builder.tag_options(:rel => "nofollow")).html_safe
     else
-      Rinku.auto_link(text, :urls, tag_options(:rel => "nofollow"))
+      Rinku.auto_link(text, :urls, tag_builder.tag_options(:rel => "nofollow"))
     end
   end
 
@@ -21,12 +21,12 @@ module ApplicationHelper
     css = ""
 
     css << ".hidden { display: none !important }"
-    css << ".hide_unless_logged_in { display: none !important }" unless @user
-    css << ".hide_if_logged_in { display: none !important }" if @user
-    css << ".hide_if_user_#{@user.id} { display: none !important }" if @user
-    css << ".show_if_user_#{@user.id} { display: inline !important }" if @user
-    css << ".hide_unless_administrator { display: none !important }" unless @user && @user.administrator?
-    css << ".hide_unless_moderator { display: none !important }" unless @user && @user.moderator?
+    css << ".hide_unless_logged_in { display: none !important }" unless current_user
+    css << ".hide_if_logged_in { display: none !important }" if current_user
+    css << ".hide_if_user_#{current_user.id} { display: none !important }" if current_user
+    css << ".show_if_user_#{current_user.id} { display: inline !important }" if current_user
+    css << ".hide_unless_administrator { display: none !important }" unless current_user && current_user.administrator?
+    css << ".hide_unless_moderator { display: none !important }" unless current_user && current_user.moderator?
 
     content_tag(:style, css, :type => "text/css")
   end
@@ -40,9 +40,7 @@ module ApplicationHelper
   end
 
   def if_user(user, tag = :div, &block)
-    if user
-      content_tag(tag, capture(&block), :class => "hidden show_if_user_#{user.id}")
-    end
+    content_tag(tag, capture(&block), :class => "hidden show_if_user_#{user.id}") if user
   end
 
   def unless_user(user, tag = :div, &block)
@@ -107,12 +105,10 @@ module ApplicationHelper
       :preferred_editor => preferred_editor
     }
 
-    if @user
-      data[:user] = @user.id.to_json
+    if current_user
+      data[:user] = current_user.id.to_json
 
-      unless @user.home_lon.nil? || @user.home_lat.nil?
-        data[:user_home] = { :lat => @user.home_lat, :lon => @user.home_lon }
-      end
+      data[:user_home] = { :lat => current_user.home_lat, :lon => current_user.home_lon } unless current_user.home_lon.nil? || current_user.home_lat.nil?
     end
 
     data[:location] = session[:location] if session[:location]