diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 1f323be2b..e033828f5 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -5,7 +5,6 @@ class NotificationsController < VannaController include NotificationsHelper - def update(opts=params) note = Notification.where(:recipient_id => current_user.id, :id => opts[:id]).first if note @@ -31,8 +30,16 @@ class NotificationsController < VannaController pager.replace(result) end - - notifications.each{|n| n[:actors] = n.actors} + notifications.each do |n| + n[:actors] = n.actors + n[:translation_key] = n.popup_translation_key + if n.translation_key == "notifications.mentioned" + n[:post] = Mention.find(n.target_id).post + else + n[:post] = Post.find(n.target_id) + end + # Go find out if the post exists, and set the target_id to nil if it doesn't + end group_days = notifications.group_by{|note| I18n.l(note.created_at, :format => I18n.t('date.formats.fullmonth_day')) } {:group_days => group_days, :notifications => notifications} end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0cd6d4062..5425d5d61 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -22,10 +22,11 @@ module ApplicationHelper object = object.model if object.instance_of? PostsFake::Fake if object.respond_to?(:activity_streams?) && object.activity_streams? class_name = object.class.name.underscore.split('/') - eval("#{class_name.first}_#{class_name.last}_path(object, opts)") + method_sym = "#{class_name.first}_#{class_name.last}_path".to_sym else - eval("#{object.class.name.underscore}_path(object, opts)") + method_sym = "#{object.class.name.underscore}_path".to_sym end + self.send(method_sym, object, opts) end def object_fields(object) diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb index 31ca1a3e9..a646fb8f3 100644 --- a/app/helpers/notifications_helper.rb +++ b/app/helpers/notifications_helper.rb @@ -1,30 +1,25 @@ + module NotificationsHelper - def object_link(note, actors) - target_type = note.popup_translation_key - actors_count = note.actors.count - if note.instance_of?(Notifications::Mentioned) - post = Mention.find(note.target_id).post + def object_link(translation_key, post) + if translation_key == "notifications.mentioned" if post - translation(target_type, :actors => actors, :count => actors_count, :post_link => link_to(t('notifications.post'), object_path(post)).html_safe) + "#{translation(translation_key)} #{link_to t('notifications.post'), object_path(post)}".html_safe else - t('notifications.mentioned_deleted', :actors => actors, :count => actors_count).html_safe + "#{translation(translation_key)} #{t('notifications.deleted')} #{t('notifications.post')}" end - elsif note.instance_of?(Notifications::CommentOnPost) - post = Post.where(:id => note.target_id).first + elsif translation_key == "notifications.comment_on_post" if post - translation(target_type, :actors => actors, :count => actors_count, :post_link => link_to(t('notifications.post'), object_path(post), 'data-ref' => post.id, :class => 'hard_object_link').html_safe) + "#{translation(translation_key)} #{link_to t('notifications.post'), object_path(post), 'data-ref' => post.id, :class => 'hard_object_link'}".html_safe + else + "#{translation(translation_key)} #{t('notifications.deleted')} #{t('notifications.post')}" + end + elsif translation_key == "notifications.also_commented" + if post + "#{translation(translation_key, post.author.name)} #{link_to t('notifications.post'), object_path(post), 'data-ref' => post.id, :class => 'hard_object_link'}".html_safe else t('notifications.also_commented_deleted', :actors => actors, :count => actors_count).html_safe end - elsif note.instance_of?(Notifications::AlsoCommented) - post = Post.where(:id => note.target_id).first - if post - translation(target_type, :actors => actors, :count => actors_count, :post_author => h(post.author.name), :post_link => link_to(t('notifications.post'), object_path(post), 'data-ref' => post.id, :class => 'hard_object_link').html_safe) - else - t('notifications.also_commented_deleted', :actors => actors, :count => actors_count).html_safe - end - elsif note.instance_of?(Notifications::Liked) - post = note.target + elsif translation_key == "notifications.liked" post = post.post if post.is_a? Like if post translation(target_type, :actors => actors, :count => actors_count, :post_author => h(post.author.name), :post_link => link_to(t('notifications.post'), object_path(post), 'data-ref' => post.id, :class => 'hard_object_link').html_safe) diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 9ea037efd..767002379 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -3063,7 +3063,7 @@ ul#left_nav :color white :width 700px :padding 10px - :top 75.5px + :top 275.5px :left 217.5px a.close :float right