Sha256: 373cd108de4f26b2ed857d00dfc68c20979665a08d9d088cc3a5c27866d7d420

Contents?: true

Size: 932 Bytes

Versions: 2

Compression:

Stored size: 932 Bytes

Contents

namespace :tumblog do

  # iterate over all the files in the "templates/tumblog" folder and create a
  # rake task corresponding to each file found
  FileList["#{Webby.site.template_dir}/tumblog/*"].each do |template|
    next unless test(?f, template)
    name = template.pathmap('%n')

    desc "Create a new tumblog #{name}"
    task name do |t|
      page  = Webby.site.args.page
      title = Webby.site.args.title
      dir   = Webby.site.args.dir

      # if no directory was given use the default tumblog directory (underneath
      # the content directory)
      dir = Webby.site.tumblog_dir if dir.empty?
      dir = File.join(dir, Time.now.strftime('%Y%m'))

      page = File.join(dir, File.basename(page))
      page = Webby::Builder.create(page, :from => template,
                 :locals => {:title => title, :directory => dir})
      Webby.exec_editor(page)
    end
  end  # each

end  # namespace :tumblog

# EOF

Version data entries

2 entries across 1 versions & 1 rubygems

Version Path
mikker-webby-0.9.4 examples/tumblog/tasks/tumblog.rake
mikker-webby-0.9.4 spec/data/site/tasks/tumblog.rake