Class: Tumblargh::Renderer::Blocks::PostNotes

Inherits:
Base show all
Defined in:
lib/tumblargh/renderer/blocks/notes.rb

Overview

Rendered on permalink pages if this post has notes.

Instance Attribute Summary

Attributes inherited from Tumblargh::Renderer::Base

#context, #node, #options

Instance Method Summary collapse

Methods inherited from Base

#render

Methods inherited from Tumblargh::Renderer::Base

#context_post, contextual_tag, #escape_html, #escape_url, #initialize, #method_missing, #render, #strip_html

Constructor Details

This class inherits a constructor from Tumblargh::Renderer::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Tumblargh::Renderer::Base

Instance Method Details

#note_countObject



11
12
13
# File 'lib/tumblargh/renderer/blocks/notes.rb', line 11

def note_count
  context_post.note_count || 0
end

#post_notesObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/tumblargh/renderer/blocks/notes.rb', line 15

def post_notes
  buf = ['<ol class="notes">']

  # TODO: Support notes with_commentary
  buf << context_post.notes.map do |note|
    classes = "note without_commentary #{note.type}"
    action = case note.type
    when 'like'
      'liked this'
    when 'reblog'
      'reblogged this from somewhere?'
    end

    <<-eos
    <li class='#{classes}'>
      <a href="#{note.blog_url}" title="" rel="nofollow">
        <img src="http://assets.tumblr.com/images/default_avatar_16.gif" class="avatar" alt="">
      </a>
      
      <span class="action">
        <a href="#{note.blog_url}" title="" rel="nofollow">#{note.blog_name}</a> 
        #{action}
      </span>

      <div class="clear"></div>
    </li>
    eos
  end.join("\n")

  buf << '</ol>'

  buf.join ''
end

#should_render?Boolean

Returns:



7
8
9
# File 'lib/tumblargh/renderer/blocks/notes.rb', line 7

def should_render?
  context.permalink? && note_count > 0
end