reset the notifications helper to master's version and monkey patch header
This commit is contained in:
parent
8f5358e68f
commit
46c83a7c7d
3 changed files with 37 additions and 16 deletions
|
|
@ -24,6 +24,8 @@ class VannaController < Vanna::Base
|
|||
before_filter :set_locale
|
||||
before_filter :set_git_header if (AppConfig[:git_update] && AppConfig[:git_revision])
|
||||
before_filter :which_action_and_user
|
||||
before_filter :all_aspects
|
||||
before_filter :object_aspect_ids
|
||||
prepend_before_filter :clear_gc_stats
|
||||
before_filter :set_grammatical_gender
|
||||
|
||||
|
|
@ -53,6 +55,18 @@ class VannaController < Vanna::Base
|
|||
end
|
||||
end
|
||||
|
||||
def object_aspect_ids
|
||||
if user_signed_in?
|
||||
@object_aspect_ids ||= []
|
||||
end
|
||||
end
|
||||
|
||||
def all_aspects
|
||||
if user_signed_in?
|
||||
@all_aspects ||= current_user.aspects
|
||||
end
|
||||
end
|
||||
|
||||
def set_git_header
|
||||
headers['X-Git-Update'] = AppConfig[:git_update]
|
||||
headers['X-Git-Revision'] = AppConfig[:git_revision]
|
||||
|
|
|
|||
|
|
@ -1,25 +1,30 @@
|
|||
|
||||
module NotificationsHelper
|
||||
def object_link(translation_key, post)
|
||||
if translation_key == "notifications.mentioned"
|
||||
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
|
||||
if post
|
||||
"#{translation(translation_key)} #{link_to t('notifications.post'), object_path(post)}".html_safe
|
||||
translation(target_type, :actors => actors, :count => actors_count, :post_link => link_to(t('notifications.post'), object_path(post)).html_safe)
|
||||
else
|
||||
"#{translation(translation_key)} #{t('notifications.deleted')} #{t('notifications.post')}"
|
||||
t('notifications.mentioned_deleted', :actors => actors, :count => actors_count).html_safe
|
||||
end
|
||||
elsif translation_key == "notifications.comment_on_post"
|
||||
elsif note.instance_of?(Notifications::CommentOnPost)
|
||||
post = Post.where(:id => note.target_id).first
|
||||
if post
|
||||
"#{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
|
||||
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)
|
||||
else
|
||||
t('notifications.also_commented_deleted', :actors => actors, :count => actors_count).html_safe
|
||||
end
|
||||
elsif translation_key == "notifications.liked"
|
||||
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
|
||||
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)
|
||||
|
|
@ -48,6 +53,7 @@ module NotificationsHelper
|
|||
number_of_actors = actors.count
|
||||
sentence_translations = {:two_words_connector => " #{t('notifications.index.and')} ", :last_word_connector => ", #{t('notifications.index.and')} " }
|
||||
actor_links = actors.collect{ |person| link_to("#{h(person.name.titlecase.strip)}", person_path(person))}
|
||||
|
||||
if number_of_actors < 4
|
||||
message = actor_links.to_sentence(sentence_translations)
|
||||
else
|
||||
|
|
@ -79,3 +85,4 @@ module NotificationsHelper
|
|||
i18n[0].match(/\d/) ? i18n[1] : i18n[0]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -51,8 +51,8 @@
|
|||
%li{:class => ('selected' if @aspect == :all)}
|
||||
= link_to t('all_aspects'), aspects_path, :class => 'home_selector'
|
||||
|
||||
- for aspect in all_aspects
|
||||
%li{:data=>{:guid=>aspect.id}, :class => ("selected" if object_aspect_ids.include?(aspect.id))}
|
||||
- for aspect in (@all_aspects || all_aspects)
|
||||
%li{:data=>{:guid=>aspect.id}, :class => ("selected" if (@object_aspect_ids || object_aspect_ids).include?(aspect.id))}
|
||||
= link_for_aspect(aspect, :class => 'aspect_selector name', :title => t('contacts', :count => aspect.contacts.size))
|
||||
|
||||
%li
|
||||
|
|
|
|||
Loading…
Reference in a new issue