Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
David Ricciardi committed Jul 31, 2010
1 parent e600a1f commit 707ba6e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 12 deletions.
9 changes: 9 additions & 0 deletions bin/sinatra-s3
Expand Up @@ -7,6 +7,14 @@ if ARGV.any? { |arg| %w(--version -v).any? { |flag| arg == flag } }
exit 0
end

if ARGV.any? { |arg| %w(--help -h).any? { |flag| arg == flag } }
puts "sinatra-s3 [options] install_dir\n\n"
puts " --version -v Get version string"
puts " --help -h this"
puts " --include-wiki installs sinatra-s3 with wiki support"
exit 0
end

$APP_PATH = ARGV.last

def check_install(file,data)
Expand Down Expand Up @@ -42,6 +50,7 @@ def verify_overwrite(file)
end

FileUtils.mkdir_p($APP_PATH)
FileUtils.mkdir_p(File.join($APP_PATH, "public"))
config_ru = "require 'rubygems'\nrequire 'sinatra-s3'"
if ARGV.any? { |arg| %w(--include-wiki --wiki).any? { |flag| arg == flag } }
check_install("wiki.rb", File.read(File.join(S3::ROOT_DIR,"examples","wiki.rb")))
Expand Down
2 changes: 1 addition & 1 deletion lib/sinatra-s3/admin.rb
Expand Up @@ -22,7 +22,7 @@ class Admin < Sinatra::Base
end

get %r{^/control/s/(.*)} do
open(File.join(PUBLIC_PATH, params[:captures].first))
open(File.join(ROOT_DIR, 'public', params[:captures].first))
end

get '/control/login' do
Expand Down
6 changes: 1 addition & 5 deletions lib/sinatra-s3/base.rb
@@ -1,14 +1,10 @@
module S3

def self.config
@config ||= YAML.load_file("s3.yml")[S3::Application.environment] rescue { :db => { :adapter => 'sqlite3', :database => "db/s3.db" } }
end

class Application < Sinatra::Base

enable :static
disable :raise_errors, :show_exceptions
set :environment, :production
set :environment, S3_ENV
set :public, PUBLIC_PATH

helpers do
Expand Down
13 changes: 10 additions & 3 deletions lib/sinatra-s3/s3.rb
@@ -1,6 +1,7 @@
require 'rubygems'
require 'activerecord'
require 'active_record'

require 'fileutils'
require 'sinatra/base'
require 'openssl'
require 'digest/sha1'
Expand Down Expand Up @@ -29,13 +30,19 @@
end

module S3
S3_ENV = :production

def self.config
@config ||= YAML.load_file("s3.yml")[S3_ENV] rescue { :db => { :adapter => 'sqlite3', :database => "db/s3.db" } }
end

VERSION = "0.99"
DEFAULT_PASSWORD = 'pass@word1'

BUFSIZE = (4 * 1024)
ROOT_DIR = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
PUBLIC_PATH = File.join(ROOT_DIR, 'public')
STORAGE_PATH = File.expand_path('storage') unless defined?(STORAGE_PATH)
PUBLIC_PATH = File.expand_path(S3.config[:public_path] || File.join(ROOT_DIR, 'public'))
STORAGE_PATH = File.expand_path(S3.config[:storage_path] || 'storage') unless defined?(STORAGE_PATH)
RESOURCE_TYPES = %w[acl versioning torrent]
CANNED_ACLS = {
'private' => 0600,
Expand Down
9 changes: 6 additions & 3 deletions s3.yml.example
@@ -1,17 +1,20 @@
:development:
:storage: storage
:public_path: public
:storage_path: storage
:db:
:database: db/development.db
:adapter: sqlite3

:test:
:storage: test/storage
:public_path: public
:storage_path: test/storage
:db:
:database: db/test.db
:adapter: sqlite3

:production:
:storage: storage
:public_path: public
:storage_path: storage
:db:
:database: db/production.db
:adapter: sqlite3

0 comments on commit 707ba6e

Please sign in to comment.