Class: PostingPresenter

Inherits:
BasePresenter show all
Defined in:
app/presenters/posting_presenter.rb

Instance Attribute Summary

Attributes inherited from BasePresenter

object

Instance Method Summary (collapse)

Methods inherited from BasePresenter

#initialize

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



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?
    ( :p, :class => 'posting_comment_links') do
      ( :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.).count) > 0))
          rc += (" (" + ( :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 edit_buttons
   :div, :class => 'side-tab', :id => "side-tab-posting_#{posting.id.to_s}" do
     :div, :class => 'comment-links', :id => "posting_#{posting.id.to_s}", 
                      :onmouseover=> "cancelSideTabTimeouts()", 
                      :onmouseout => "hideWithDelay('posting_#{posting.id.to_s}',500)" do
       :span, :class=>"item_link_buttons", 
                         :style=>"display: inline", 
                         :onmouseover=>"cancelSideTabTimeouts()" do
        [
          ui_button('read', "", blog_posting_path(posting.blog,posting), :id => "read-link"),
          (can?(:edit, posting) ? ui_button( 'edit', "", edit_blog_posting_path(posting.blog,posting),:id=>'edit-link') : nil),
          (can?(:manage, posting) ? ui_button( '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
    ui_button '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 tags
  ( :div, :class => 'tags') do
    posting.tags_array.map { |tag|
      link_to( tag, tags_path(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 tags_and_limited_information
  ( :div, :class => 'tags') do
    txt = posting.tags_array.map { |tag|
      link_to( tag, tags_path(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
   :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
   :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