#!/usr/bin/env ruby # # Project <%= @conf.appname %> # # Created using bivouac on <%= Time.now %>. # Copyright (c) <%= Time.now.year %> __My__. All rights reserved. # # DO NOT EDIT THIS FILE OR YOU REALLY KNOW WHAT YOU ARE DOING # USE script/generate helper my_helper # require 'rubygems' require 'camping' require 'mime/types' require 'bivouac' <% if @conf.session == :db %> require 'camping/session' module <%= @conf.appname %> include Camping::Session end <% else %> require 'cookies_sessions' module <%= @conf.appname %> include Camping::CookieSessions @@state_secret = "You want a really really long string of rubbish nobody could ever ever guess! Don't tell anyone! Not even your girlfriend or dog!" end <% end %> include Bivouac # Load libs LIB = filePath( __FILE__, '..', 'lib' ) $:.unshift( LIB ) # Load plugins Dir.glob( filePath( __FILE__, '../plugins/**/init.rb' ) ).each { |p| require p } # Indent the code -- See http://code.whytheluckystiff.net/markaby/wiki/TipsAndTrickery Markaby::Builder.set(:indent, 2) Camping.goes :<%= @conf.appname %> # Load helpers from app/helpers files( 'helpers' ) { |file| require( file ) } # Load models from app/models files( 'models' ) { |file| require( file ) } # Load database schema from db/migrate files( '../db/migrate' ) { |file| require( file ) } # Load views from app/views files( 'views' ) { |file| require( file ) } # Load controllers from app/controllers files( 'controllers', :except => [File.basename(__FILE__)] ) { |file| require( file ) } module <%= @conf.appname %>::Controllers class Public < R '/public/(.+)' PATH = filePath( __FILE__ ) def get file if file.include? '..' @status = '403' return '403 - Invalid path' else type = (MIME::Types.type_for(file)[0] || '/text/plain').to_s @headers['Content-Type'] = type begin @body = open( File.join( PATH, '..', 'public', file ) ).read rescue Errno::ENOENT => e @path = File.join '/public', file @status = '404' @headers['Content-Type'] = "text/html" render :not_found end end end end end # Load create files( '../db' ) { |file| require( file ) } # Load postamble and configuration if __FILE__ == $0 files( '../config' ) { |file| require( file ) } end