Skip to content

Commit

Permalink
Allow to create atom feeds for selected tags
Browse files Browse the repository at this point in the history
  • Loading branch information
goldmann committed Apr 18, 2012
1 parent 9ecc319 commit 78e679c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions _ext/pipeline.rb
@@ -1,3 +1,4 @@
require 'tag-atomizer'

Awestruct::Extensions::Pipeline.new do
extension Awestruct::Extensions::Posts.new('/blog')
Expand All @@ -14,6 +15,7 @@
extension Awestruct::Extensions::TagCloud.new(:posts,
'/blog/tags/index.html',
:layout=>'base')
extension TagAtomizer.new(:tags => ['fedora'])

helper Awestruct::Extensions::GoogleAnalytics
end
Expand Down
20 changes: 20 additions & 0 deletions _ext/tag-atomizer.rb
@@ -0,0 +1,20 @@
class TagAtomizer
def initialize(entries_name, options = {})
@entries_name = entries_name
@options = {
:tags => []
}.merge(options)
end

def execute(site)
atoms = {}

site.posts_tags.each do |tag|
if @options[:tags].include?(tag.to_s) or @options[:tags].empty?
site.send( "#{@entries_name}_#{tag.to_s}=", tag.pages )
Awestruct::Extensions::Atomizer.new("#{@entries_name}_#{tag.to_s}".to_sym, "/#{tag.to_s}.atom").execute(site)
end
end
end
end

0 comments on commit 78e679c

Please sign in to comment.