tasks/site.rake
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
require 'rubygems' require 'extlib' require 'pathname' require 'fileutils' require 'nanoc3' require "#{Dir.pwd}/lib/utils.rb" include SiteUtils namespace :site do task :article, :name do |t, args| raise RuntimeError, "Name not specified" unless args[:name] raise RuntimeError, "Article name can only contain letters, numbers and dashes" unless args[:name].match /^[a-zA-Z0-9-]+$/ meta = {} meta[:permalink] = args[:name] meta[:title] = nil meta[:subtitle] = nil meta[:type] = 'article' meta[:intro] = " |\n " meta[:extended_intro] = " |\n " meta[:tags] = nil meta[:date] = Time.now meta[:pdf] = true file = Pathname.new Dir.pwd/"content/articles/#{meta[:permalink]}.glyph" raise "File '#{file}' already exists!" if file.exist? write_item file, meta, "$[document.intro]\n\n" end task :page, :name do |t, args| raise RuntimeError, "Name not specified" unless args[:name] raise RuntimeError, "Page name can only contain letters, numbers and dashes" unless args[:name].match /^[a-zA-Z0-9-]+$/ meta = {} meta[:permalink] = args[:name] meta[:title] = "" meta[:type] = 'page' file = Pathname.new Dir.pwd/"content/#{meta[:permalink]}.textile" raise "File '#{file}' already exists!" if file.exist? write_item file, meta, '' end task :project, :name do |t, args| raise RuntimeError, "Name not specified" unless args[:name] raise RuntimeError, "Project name can only contain letters, numbers and dashes" unless args[:name].match /^[a-zA-Z0-9-]+$/ meta = {} meta[:permalink] = args[:name] meta[:title] = "" meta[:github] = args[:name] meta[:status] = "Active" meta[:version] = "0.1.0" meta[:type] = 'project' meta[:links] = [{"Documentation" => "http://rubydoc.info/gems/#{args[:name]}/#{meta[:version]}/frames"}, {"Download" => "https://rubygems.org/gems/#{args[:name]}"}, {"Source" => "http://github.com/h3rald/#{args[:name]}/tree/master"}, {"Tracking" => "http://github.com/h3rald/#{args[:name]}/issues"}] contents = %{ <%= render 'project_data', :tag => '#{args[:name]}' %> h3. Installation h3. Usage <%= render 'project_updates', :tag => '#{args[:name]}' %> } file = Pathname.new Dir.pwd/"content/#{meta[:permalink]}.textile" raise "File '#{file}' already exists!" if file.exist? write_item file, meta, contents end end |