Sha256: a711675609d1635bfc8c789c188e8667e0d7f855f529bf3f0caa3e85afdb5630

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

#!/usr/bin/env ruby


require 'rack'
require 'yaml'
require_relative '../lib/patricia'


config = {
  :css_dir => CLI.options[:css],
  :js_dir => CLI.options[:js],
  :markup_dir => CLI.options[:markup_dir],
  :tooltips => CLI.options[:tooltips],
}
config_file = File.dirname(__FILE__) + '/app_config.yml'
# The thread ensures that the config file is written before the Sinatra app
# starts.
config_writer = Thread.new do
  begin
    File.delete(config_file)
  rescue
    # Ignore.
  end
  File.open(config_file, 'w') do |f|
    f.write(config.to_yaml)
  end
end

# Wait for the config file to be written.
config_writer.join

if CLI.options[:output_dir]
  css_dir = CLI.options[:css]
  js_dir = CLI.options[:js]
  css = Dir[css_dir + '/**/*.css'].collect { |x| x.sub(/#{css_dir}/, '') }
  js = Dir[js_dir + '/**/*.js'].collect { |x| x.sub(/#{js_dir}/, '') }
  patricia = Patricia::Wiki.new(CLI.options[:markup_dir], :output_dir =>
                                CLI.options[:output_dir], :css =>
                                css, :js => js)
  patricia.render
else
  require_relative '../lib/patricia/app'
  app = Rack::Builder.new do
    use PatriciaApp::App
    run Proc.new { |env| [404, {'Content-Type' => 'text/html'}, ['404']] }
  end
  Rack::Handler::WEBrick.run app, :Port => CLI.options[:port] || 4321
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
patricia-0.0.1 bin/patricia