Skip to content

Instantly share code, notes, and snippets.

@vincentmilliken
Created February 2, 2013 13:42
Show Gist options
  • Save vincentmilliken/4697435 to your computer and use it in GitHub Desktop.
Save vincentmilliken/4697435 to your computer and use it in GitHub Desktop.
Updated App files.
require 'rubygems'
require 'sinatra'
require 'dm-core'
require 'data_mapper'
require 'bundler'
Dir['vendor/*'].each do |lib|
$:.unshift(File.join(File.dirname(__FILE__), lib, 'lib'))
end
# DataMapper::setup(:default, "sqlite3://#{Dir.pwd}/recall.db")
# DataMapper.setup(:default, ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/recall.db")
DataMapper.setup(:default, ENV["DATABASE_URL"] || "sqlite://#{Dir.pwd}/recall.db")
# DataMapper.setup(:default, ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/recall.db")
# DataMapper.setup(:default, ENV['DATABASE_URL'] || 'postgres://localhost/recall.db')
class Note
include DataMapper::Resource
property :id, Serial
property :content, Text, :required => true
property :complete, Boolean, :required => true, :default => 0
property :created_at, DateTime
property :updated_at, DateTime
end
DataMapper.finalize
DataMapper.auto_upgrade!
get '/' do
@notes = Note.all :order => :id.desc
@title = 'All Codes'
erb :home
end
post '/' do
n = Note.new
n.content = params[:code]
n.created_at = Time.now
n.updated_at = Time.now
n.save
redirect '/'
end
get '/:id' do
@note = Note.get params[:id]
@title = "Edit Cdoe ##{params[:id]}"
erb :edit
end
put '/:id' do
n = Note.get params[:id]
n.content = params[:code]
n.complete = params[:complete] ? 1 : 0
n.updated_at = Time.now
n.save
redirect '/'
end
get '/:id/delete' do
@note = Note.get params[:id]
@title = "Confirm deletion of note ##{params[:id]}"
erb :delete
end
delete '/:id' do
n = Note.get params[:id]
n.destroy
redirect '/'
end
get '/:id/complete' do
n = Note.get params[:id]
n.complete = n.complete ? 0 : 1 # flip it
n.updated_at = Time.now
n.save
redirect '/'
end
require 'rubygems'
require 'sinatra'
require 'bundler'
Bundler.require
require './app.rb'
run Sinatra::Application
source :rubygems
source "http://rubygems.org"
gem 'bundler'
gem 'sinatra'
gem 'compass'
gem 'haml'
gem 'sass'
gem 'rake'
gem 'data_mapper'
gem 'dm-core'
gem 'dm-postgres-adapter', :group => :production
gem 'dm-sqlite-adapter', :group => :development
gem 'dm-timestamps'
gem 'dm-validations'
gem 'dm-aggregates'
gem 'dm-migrations'
gem 'haml'
GEM
remote: http://rubygems.org/
remote: http://rubygems.org/
specs:
addressable (2.2.8)
bcrypt-ruby (3.0.1)
chunky_png (1.2.7)
compass (0.12.2)
chunky_png (~> 1.2)
fssm (>= 0.2.7)
sass (~> 3.1)
data_mapper (1.2.0)
dm-aggregates (~> 1.2.0)
dm-constraints (~> 1.2.0)
dm-core (~> 1.2.0)
dm-migrations (~> 1.2.0)
dm-serializer (~> 1.2.0)
dm-timestamps (~> 1.2.0)
dm-transactions (~> 1.2.0)
dm-types (~> 1.2.0)
dm-validations (~> 1.2.0)
data_objects (0.10.12)
addressable (~> 2.1)
dm-aggregates (1.2.0)
dm-core (~> 1.2.0)
dm-constraints (1.2.0)
dm-core (~> 1.2.0)
dm-core (1.2.0)
addressable (~> 2.2.6)
dm-do-adapter (1.2.0)
data_objects (~> 0.10.6)
dm-core (~> 1.2.0)
dm-migrations (1.2.0)
dm-core (~> 1.2.0)
dm-postgres-adapter (1.2.0)
dm-do-adapter (~> 1.2.0)
do_postgres (~> 0.10.6)
dm-serializer (1.2.2)
dm-core (~> 1.2.0)
fastercsv (~> 1.5)
json (~> 1.6)
json_pure (~> 1.6)
multi_json (~> 1.0)
dm-sqlite-adapter (1.2.0)
dm-do-adapter (~> 1.2.0)
do_sqlite3 (~> 0.10.6)
dm-timestamps (1.2.0)
dm-core (~> 1.2.0)
dm-transactions (1.2.0)
dm-core (~> 1.2.0)
dm-types (1.2.2)
bcrypt-ruby (~> 3.0)
dm-core (~> 1.2.0)
fastercsv (~> 1.5)
json (~> 1.6)
multi_json (~> 1.0)
stringex (~> 1.4)
uuidtools (~> 2.1)
dm-validations (1.2.0)
dm-core (~> 1.2.0)
do_postgres (0.10.12)
data_objects (= 0.10.12)
do_sqlite3 (0.10.12)
data_objects (= 0.10.12)
fastercsv (1.5.5)
fssm (0.2.10)
haml (3.1.7)
json (1.7.6)
json_pure (1.7.6)
multi_json (1.5.0)
rack (1.5.1)
rack-protection (1.3.2)
rack
rake (10.0.3)
sass (3.2.5)
sinatra (1.3.4)
rack (~> 1.4)
rack-protection (~> 1.3)
tilt (~> 1.3, >= 1.3.3)
stringex (1.5.1)
tilt (1.3.3)
uuidtools (2.1.3)
PLATFORMS
ruby
DEPENDENCIES
bundler
compass
data_mapper
dm-aggregates
dm-core
dm-migrations
dm-postgres-adapter
dm-sqlite-adapter
dm-timestamps
dm-validations
haml
rake
sass
sinatra
2013-02-02T13:40:01+00:00 heroku[api]: Deploy b2ed55d by [email protected]
2013-02-02T13:40:01+00:00 heroku[api]: Release v18 created by [email protected]
2013-02-02T13:40:02+00:00 heroku[slugc]: Slug compilation finished
2013-02-02T13:40:01+00:00 heroku[web.1]: State changed from crashed to starting
2013-02-02T13:40:05+00:00 heroku[web.1]: State changed from starting to crashed
2013-02-02T13:40:11+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=codebracket.herokuapp.com fwd=86.169.204.153 dyno= queue= wait= connect= service= status=503 bytes=
2013-02-02T13:40:15+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=codebracket.herokuapp.com fwd=86.169.204.153 dyno= queue= wait= connect= service= status=503 bytes=
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment