Class: Tumblargh::Renderer::Blocks::Posts
- Inherits:
-
Base
- Object
- Tumblargh::Renderer::Base
- Base
- Tumblargh::Renderer::Blocks::Posts
- Defined in:
- lib/tumblargh/renderer/blocks/posts.rb
Overview
Posts Loop
block:Posts is executed once for each post. Some post related tags can exist outside of a ‘type` block, such as Title or Permalink, so they should be defined here
Instance Attribute Summary
Attributes inherited from Tumblargh::Renderer::Base
Instance Method Summary collapse
- #permalink ⇒ Object
- #permalink? ⇒ Boolean
- #post_notes_url ⇒ Object
- #reblog_url ⇒ Object
- #render ⇒ Object
-
#tags_as_classes ⇒ Object
An HTML class-attribute friendly list of the post’s tags.
Methods inherited from Base
Methods inherited from Tumblargh::Renderer::Base
#context_post, contextual_tag, #escape_html, #escape_url, #initialize, #method_missing, #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
#permalink ⇒ Object
16 17 18 19 |
# File 'lib/tumblargh/renderer/blocks/posts.rb', line 16 def permalink url = context.post_url url.gsub(/^http:\/\/[^\/]+/, '') end |
#permalink? ⇒ Boolean
21 22 23 |
# File 'lib/tumblargh/renderer/blocks/posts.rb', line 21 def permalink? context.permalink? end |
#post_notes_url ⇒ Object
25 26 27 28 |
# File 'lib/tumblargh/renderer/blocks/posts.rb', line 25 def post_notes_url # http://bikiniatoll.tumblr.com/notes/1377511430/vqS0xw8sm "/notes/#{context.id}/" end |
#reblog_url ⇒ Object
30 31 32 |
# File 'lib/tumblargh/renderer/blocks/posts.rb', line 30 def reblog_url "/reblog/#{context.reblog_key}" end |
#render ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/tumblargh/renderer/blocks/posts.rb', line 50 def render if context.is_a? Resource::Post super else posts = permalink? ? [context.posts.first] : context.posts posts.map do |post| post.context = self self.class.new(node, post).render end.flatten.join('') end end |
#tags_as_classes ⇒ Object
An HTML class-attribute friendly list of the post’s tags. Example: “humor office new_york_city”
By default, an HTML friendly version of the source domain of imported posts will be included. This may not behave as expected with feeds like Del.icio.us that send their content URLs as their permalinks. Example: “twitter_com”, “digg_com”, etc.
The class-attribute “reblog” will be included automatically if the post was reblogged from another post.
44 45 46 47 48 |
# File 'lib/tumblargh/renderer/blocks/posts.rb', line 44 def context..map do |tag| tag.name.titlecase.gsub(/\s+/, '').underscore.downcase end.join " " end |