diff options
author | Stephen Dolan <mu@netsoc.tcd.ie> | 2012-09-18 17:51:53 +0100 |
---|---|---|
committer | Stephen Dolan <mu@netsoc.tcd.ie> | 2012-09-18 17:51:53 +0100 |
commit | cf134909fd20021f4f7628f1eb7c1ad11c4a4e62 (patch) | |
tree | 8308212a1dbede042dc744206e84d925fcbffe1f /docs/Rakefile | |
parent | a4eea165bbab6d13f89b59707e835d58b7014a66 (diff) |
Documentation. Copious.
Diffstat (limited to 'docs/Rakefile')
-rw-r--r-- | docs/Rakefile | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/docs/Rakefile b/docs/Rakefile new file mode 100644 index 00000000..b4e1d6d1 --- /dev/null +++ b/docs/Rakefile @@ -0,0 +1,54 @@ +require 'bonsai' +require 'liquid' +require 'maruku' +require 'json' + +module ExtraFilters + def markdownify(input) + Maruku.new(input).to_html + end + + def sanitize(input) + input.gsub(/[^a-zA-Z0-9_]/,"") + end + + def json(input) + input.to_json + end + + def unique(input) + @n = (@n || 0) + 1 + input + @n.to_s + end +end + +Liquid::Template.register_filter(ExtraFilters) + + +task :serve do + begin + Bonsai.log "Press Control+C to quit" + + require 'rack' + require 'sinatra' + require 'watch' + require 'launchy' + + Bonsai.root_dir = Dir.pwd + + server = fork { + app = Rack::Builder.app { + use Bonsai::StaticPassThrough, :root => Bonsai.root_dir + "/output", :urls => ["/"] + run Bonsai::DevelopmentServer + } + Rack::Handler.default.run(app, :Port => 5000) do + Launchy.open("http://localhost:5000/") + end + } + Watch.new("{content,templates,public}/**/*") { Bonsai::Exporter.process! } + rescue Interrupt + Process.kill("QUIT", server) + Process.wait(server) + exit + end +end |