Sha256: 02cf24d7ea5310a2ddef16c0026acc785992f078e3333dcde0a5bd37ef26bba2

Contents?: true

Size: 1.67 KB

Versions: 5

Compression:

Stored size: 1.67 KB

Contents

#!/usr/bin/env ruby

#
#  Project BivouacSample
#
#  Created using bivouac on Sun Mar 23 20:30:13 +0100 2008.
#  Copyright (c) 2008 __My__. All rights reserved.
#

require 'rubygems'
require 'camping'
require 'camping/session'
require 'mime/types'
require 'bivouac'

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 :BivouacSample

# 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 BivouacSample::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
        @body = open( File.join( PATH, '..', 'public', file ) )
        # @headers['X-Sendfile'] = File.join PATH, '..', 'public', file
      end
    end
  end
end

# Load create
files( '../db' ) { |file| require( file ) }

# Load postamble and configuration
if __FILE__ == $0
  files( '../config' ) { |file| require( file ) }
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bivouac-0.1.5 examples/bivouac_sample/app/bivouac_sample.rb
bivouac-0.2.0 examples/bivouac_sample/app/bivouac_sample.rb
bivouac-0.1.6 examples/bivouac_sample/app/bivouac_sample.rb
bivouac-0.2.1 examples/bivouac_sample/app/bivouac_sample.rb
bivouac-0.2.2 examples/bivouac_sample/app/bivouac_sample.rb