Permalink
Browse files

Modify page title notification style.

  • Loading branch information...
1 parent fee16be commit 7977c810e098d7b266f4b1d58dafa20e6924c6d9 huangzg committed Jun 29, 2012
Showing with 10 additions and 7 deletions.
  1. +8 −0 app/helpers/application_helper.rb
  2. +1 −6 app/views/layouts/application.haml
  3. +1 −1 app/views/layouts/settings.haml
@@ -7,6 +7,14 @@ def page_title
end
end
+ def page_title_with_notification
+ if logined? && current_user.notifications.unread.count != 0
+ "(#{current_user.notifications.unread.count}) #{page_title}"
+ else
+ page_title
+ end
+ end
+
def format_text(text, options = {})
sanitize markdown(link_mentions(text.to_s, options[:mention_names]))
end
@@ -3,12 +3,7 @@
%head
%meta{charset: "utf-8"}
%meta{:name => "viewport", :content => "width=device-width, initial-scale=1.0"}
-
- - if logined? && current_user.notifications.unread.count != 0
- %title= page_title + " (#{current_user.notifications.unread.count})"
- - else
- %title= page_title
-
+ %title= page_title_with_notification
- if defined?(@subscribe_url)
%link{:rel => 'alternate', :type => 'application/rss+xml', :href => @subscribe_url}
= stylesheet_link_tag "application"
@@ -3,7 +3,7 @@
%head
%meta{charset: "utf-8"}
%meta{:name => "viewport", :content => "width=device-width, initial-scale=1.0"}
- %title= page_title
+ %title= page_title_with_notification
= stylesheet_link_tag "application"
= javascript_include_tag "application"
= timeago_script_tag

2 comments on commit 7977c81

Contributor

fenprace replied Jun 29, 2012

我代码果然拙了点儿,咋就想不起来吧那一坨代码放 Helper 里呢?

Owner

chloerei replied Jun 29, 2012

一步到位不一定好,我也是想到有两个前台 layout 都要用才抽出 helper。

如果逻辑简单只用在一个地方,用 helper 就是过度设计了。

Please sign in to comment.