Skip to content
Browse files

Even simpler and more customizable tag-atomizer

  • Loading branch information...
1 parent 78e679c commit 6ae46d566743e86589226ecf7e1fcc48e124f72c @goldmann committed
Showing with 10 additions and 8 deletions.
  1. +1 −1 _ext/pipeline.rb
  2. +9 −7 _ext/tag-atomizer.rb
View
2 _ext/pipeline.rb
@@ -3,7 +3,7 @@
Awestruct::Extensions::Pipeline.new do
extension Awestruct::Extensions::Posts.new('/blog')
extension Awestruct::Extensions::Paginator.new(:posts, '/blog/index', :per_page => 3)
- extension Awestruct::Extensions::Atomizer.new(:posts, '/blog.atom')
+ extension Awestruct::Extensions::Atomizer.new(:posts, '/blog.atom', :feed_title => "Blog posts")
extension Awestruct::Extensions::Indexifier.new
extension Awestruct::Extensions::IntenseDebate.new
View
16 _ext/tag-atomizer.rb
@@ -1,18 +1,20 @@
class TagAtomizer
- def initialize(entries_name, options = {})
- @entries_name = entries_name
+ def initialize(options = {})
@options = {
- :tags => []
+ :output_path => "/#TAG#.atom",
+ :feed_title => "Blog posts for #TAG# tag",
+ :tags => [],
+ :atom_options => {}
}.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)
+ output_path = @options[:output_path].gsub(/#TAG#/, tag.to_s)
+ feed_title = @options[:feed_title].gsub(/#TAG#/, tag.to_s)
+
+ Awestruct::Extensions::Atomizer.new(tag.pages, output_path, @options[:atom_options].merge(:feed_title => feed_title)).execute(site)
end
end
end

0 comments on commit 6ae46d5

Please sign in to comment.
Something went wrong with that request. Please try again.