Class: PostingPresenter
- Inherits:
-
BasePresenter
- Object
- BasePresenter
- PostingPresenter
- Defined in:
- app/presenters/posting_presenter.rb
Instance Attribute Summary
Attributes inherited from BasePresenter
Instance Method Summary (collapse)
- - (Object) comment_links
- - (Object) edit_buttons
- - (Object) read_more
- - (Object) tags
- - (Object) tags_and_limited_information
- - (Object) title
- - (Object) user_and_time
Methods inherited from BasePresenter
Constructor Details
This class inherits a constructor from BasePresenter
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class BasePresenter
Instance Method Details
- (Object) comment_links
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/presenters/posting_presenter.rb', line 36 def comment_links if posting.blog.allow_public_comments || (posting.blog.allow_comments && user_signed_in?) || posting.comments.any? content_tag( :p, :class => 'posting_comment_links') do content_tag( :span, :class=> 'comments_counter') do rc = I18n.translate(:num_of_comments, :count => posting.comments.count) if (user_signed_in? && ((count=posting.comments.since(current_user.last_sign_in_at).count) > 0)) rc += (" (" + content_tag( :span, :class=>'new_comments' ) { I18n.translate(:new_since_last_visit, :count => count) }+")").html_safe end (rc += "<br/>").html_safe end end end end |
- (Object) edit_buttons
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/presenters/posting_presenter.rb', line 4 def content_tag :div, :class => 'side-tab', :id => "side-tab-posting_#{posting.id.to_s}" do content_tag :div, :class => 'comment-links', :id => "posting_#{posting.id.to_s}", :onmouseover=> "cancelSideTabTimeouts()", :onmouseout => "hideWithDelay('posting_#{posting.id.to_s}',500)" do content_tag :span, :class=>"item_link_buttons", :style=>"display: inline", :onmouseover=>"cancelSideTabTimeouts()" do [ ('read', "", blog_posting_path(posting.blog,posting), :id => "read-link"), (can?(:edit, posting) ? ( 'edit', "", edit_blog_posting_path(posting.blog,posting),:id=>'edit-link') : nil), (can?(:manage, posting) ? ( 'destroy', "", blog_posting_path(posting.blog,posting), :confirm => I18n.translate(:are_you_sure), :method => :delete, :id =>'destroy-link') : nil) ].compact.join(sc(:nbsp)).html_safe end end end end |
- (Object) read_more
72 73 74 75 76 |
# File 'app/presenters/posting_presenter.rb', line 72 def read_more if posting.body.paragraphs.count > 1 'read', I18n.translate(:read_more), posting end end |
- (Object) tags
52 53 54 55 56 57 58 |
# File 'app/presenters/posting_presenter.rb', line 52 def content_tag( :div, :class => 'tags') do posting..map { |tag| link_to( tag, (tag)) unless tag.blank? }.compact.join(", ").html_safe end end |
- (Object) tags_and_limited_information
60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/presenters/posting_presenter.rb', line 60 def content_tag( :div, :class => 'tags') do txt = posting..map { |tag| link_to( tag, (tag)) unless tag.blank? }.compact.join(", ").html_safe unless posting.public? txt += I18n.translate(:limited_posting) end txt.html_safe end end |
- (Object) title
22 23 24 25 26 27 |
# File 'app/presenters/posting_presenter.rb', line 22 def title content_tag :h2, :onmouseover=> "showSideTab($('#posting_#{posting.id.to_s}'));", :onmouseout=>"hideWithDelay('posting_#{posting.id.to_s}',2000);" do link_to(posting.title, blog_posting_path(posting.blog,posting)) end end |
- (Object) user_and_time
29 30 31 32 33 34 |
# File 'app/presenters/posting_presenter.rb', line 29 def user_and_time content_tag :address, :class => "#{posting.created_at > current_user_field( :last_sign_in_at,Time::now()-1.hour) ? 'new_posting' : 'old_posting'}" do I18n.translate(:user_wrote_a_comment_at, :user => posting.user.name, :at => distance_of_time_in_words_to_now(posting.created_at)).html_safe end end |