Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Only use post content in the RSS description field. #86

Merged
merged 2 commits into from

2 participants

@kablamo

This patch improves the RSS feed. Previously the description field was
populated with the entire web page including the header, footer, javascript,
css, etc. Now the description field is only populated with html rendered from
a post.

I tested this with Google Reader and the resulting output is much nicer.

@kablamo kablamo Only use post content in the RSS description field.
This patch improves the RSS feed.  Previously the description field was
populated with the entire web page including the header, footer, javascript,
css, etc.  Now the description field is only populated with html rendered from
a post.
9cd6df9
lib/ruhoh/page.rb
@@ -28,6 +28,11 @@ def render
@templater.render(self.expand_layouts, self.payload)
end
+ def render_rss
+ self.ensure_id
+ @templater.render(self.expand_layouts, self.payload)
@plusjade Owner

if we want to only output the body we don't need to expand_layouts at all:

@templater.render('{{{content}}}', self.payload)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
lib/ruhoh/page.rb
@@ -28,6 +28,11 @@ def render
@templater.render(self.expand_layouts, self.payload)
end
+ def render_rss
@plusjade Owner

can we change this to a more general purpose name: render_content

@plusjade Owner

Note my updates above. Since @page already has a @page.content method (outputs raw file content body), the render method should be named render_content

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@plusjade
Owner

@kablamo I like this a lot! Very concise and useful addition. Can you consider my in-line comment suggestions and pending those updates I'll merge this right in. Thanks for your help!

@plusjade plusjade merged commit 9dd7c14 into ruhoh:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 26, 2012
  1. @kablamo

    Only use post content in the RSS description field.

    kablamo authored
    This patch improves the RSS feed.  Previously the description field was
    populated with the entire web page including the header, footer, javascript,
    css, etc.  Now the description field is only populated with html rendered from
    a post.
Commits on Aug 27, 2012
  1. @kablamo
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 3 deletions.
  1. +2 −2 lib/ruhoh/compilers/rss.rb
  2. +6 −1 lib/ruhoh/page.rb
View
4 lib/ruhoh/compilers/rss.rb
@@ -26,7 +26,7 @@ def self.run(target, page)
xml.title_ post['title']
xml.link "#{Ruhoh::DB.site['config']['production_url']}#{post['url']}"
xml.pubDate_ post['date']
- xml.description_ (post['description'] ? post['description'] : page.render)
+ xml.description_ (post['description'] ? post['description'] : page.render_content)
}
end
}
@@ -36,4 +36,4 @@ def self.run(target, page)
end
end #Rss
end #Compiler
-end #Ruhoh
+end #Ruhoh
View
7 lib/ruhoh/page.rb
@@ -28,6 +28,11 @@ def render
@templater.render(self.expand_layouts, self.payload)
end
+ def render_content
+ self.ensure_id
+ @templater.render('{{{content}}}', self.payload)
+ end
+
def process_layouts
self.ensure_id
if @data['layout']
@@ -103,4 +108,4 @@ def ensure_id
end
end #Page
-end #Ruhoh
+end #Ruhoh
Something went wrong with that request. Please try again.