Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed compatibility with new Sinatra 1.0 #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.log
blog.db
config/app_config.rb
14 changes: 14 additions & 0 deletions config/app_config.rb.default
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
configure do
Sequel.connect(ENV['DATABASE_URL'] || 'sqlite://blog.db')

require 'ostruct'
Blog = OpenStruct.new(
:title => 'a scanty blog',
:author => 'John Doe',
:url_base => 'http://localhost:4567/',
:admin_password => 'changeme',
:admin_cookie_key => 'scanty_admin',
:admin_cookie_value => '51d6d976913ace58',
:disqus_shortname => nil
)
end
18 changes: 2 additions & 16 deletions main.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
require 'rubygems'
require 'sinatra'

$LOAD_PATH.unshift File.dirname(__FILE__) + '/vendor/sequel'
require 'sequel'
require 'config/app_config.rb'

configure do
Sequel.connect(ENV['DATABASE_URL'] || 'sqlite://blog.db')

require 'ostruct'
Blog = OpenStruct.new(
:title => 'a scanty blog',
:author => 'John Doe',
:url_base => 'http://localhost:4567/',
:admin_password => 'changeme',
:admin_cookie_key => 'scanty_admin',
:admin_cookie_value => '51d6d976913ace58',
:disqus_shortname => nil
)
end

error do
e = request.env['sinatra.error']
Expand Down Expand Up @@ -89,7 +75,7 @@ def auth
end

post '/auth' do
set_cookie(Blog.admin_cookie_key, Blog.admin_cookie_value) if params[:password] == Blog.admin_password
response.set_cookie(Blog.admin_cookie_key, Blog.admin_cookie_value) if params[:password] == Blog.admin_password
redirect '/'
end

Expand Down