Sha256: 21ed2ec46031f86efa6c3cd544560e80affd028b02169ce102308235962c45a7

Contents?: true

Size: 1.76 KB

Versions: 20

Compression:

Stored size: 1.76 KB

Contents

#!/usr/bin/env ruby

#
#  Project Blog
#
#  Created using bivouac on Wed Aug 01 09:38:28 +0200 2007.
#  Copyright (c) 2007 __My__. All rights reserved.
#

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

include Bivouac

Camping.goes :Blog

# 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 Blog::Controllers
  class Public < R '/public/(.+)' 
    PATH = File.expand_path(File.dirname(__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
        @headers['X-Sendfile'] = File.join PATH, '..', 'public', file
      end
    end
  end
end

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

# WEBrick postamble
if __FILE__ == $0
  require 'webrick/httpserver'
  require 'camping/webrick'

  Blog::Models::Base.establish_connection :adapter => 'sqlite3', :database => File.dirname(__FILE__) + "/../db/Blog.db"
  Blog::Models::Base.logger = Logger.new(File.dirname(__FILE__) + "/../log/Blog.log")
  Blog.create if Blog.respond_to? :create
  s = WEBrick::HTTPServer.new :BindAddress => "0.0.0.0", :Port => 3301
  s.mount "/", WEBrick::CampingHandler, Blog

  # This lets Ctrl+C shut down your server
  trap(:INT) do
    s.shutdown
  end

  s.start
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
bivouac-0.0.5 examples/blog_goh/app/blog.rb
bivouac-0.0.6 examples/blog_goh/app/blog.rb
bivouac-0.0.7 examples/blog_goh/app/blog.rb
bivouac-0.0.4 examples/blog_goh/app/blog.rb
bivouac-0.0.8 examples/blog_goh/app/blog.rb
bivouac-0.0.9 examples/blog_goh/app/blog.rb
bivouac-0.1.1 examples/blog_goh/app/blog.rb
bivouac-0.1.0 examples/blog_goh/app/blog.rb
bivouac-0.1.2 examples/blog_goh/app/blog.rb
bivouac-0.1.3 examples/blog_goh/app/blog.rb
bivouac-0.1.4 examples/blog_goh/app/blog.rb
bivouac-0.1.5 examples/blog_goh/app/blog.rb
bivouac-0.1.6 examples/blog_goh/app/blog.rb
bivouac-0.2.0 examples/blog_goh/app/blog.rb
bivouac-0.2.3 examples/blog_goh/app/blog.rb
bivouac-0.2.1 examples/blog_goh/app/blog.rb
bivouac-0.2.2 examples/blog_goh/app/blog.rb
bivouac-0.2.4 examples/blog_goh/app/blog.rb
bivouac-0.3.0 examples/blog_goh/app/blog.rb
bivouac-0.2.5 examples/blog_goh/app/blog.rb