Created
April 24, 2009 22:01
-
-
Save kad3nce/101366 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'ostruct' | |
# Ruby Gems | |
require 'haml' | |
require 'json' | |
require 'sinatra' unless defined?(Sinatra) | |
require 'bumble' | |
require 'movie' | |
set :views, "#{File.dirname(__FILE__)}/views" | |
error do | |
e = request.env['sinatra.error'] | |
Kernel.puts e.backtrace.join("\n") | |
'Application error' | |
end | |
helpers do | |
# add your helpers here | |
end | |
get '/' do | |
# @movies = Movie.all(:limit => 1000, :tomatometer.not => [nil, 'n/a', 'not found'], :order => [:tomatometer.desc]) | |
@movies = Movie.all({}, :limit => 1000) | |
# @movies = Movie.all | |
haml :index | |
end | |
get '/movies' do | |
# movies = Movie.all.map { |m| m.attributes } | |
# JSON.generate movies; | |
end | |
get '/movies/:id' do | |
m = Movie.find(params[:id]) | |
end | |
post '/movies' do | |
attributes = JSON.parse(params[:attributes]) | |
movie = Movie.create attributes | |
movie.id | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'sinatra' | |
root_dir = File.dirname(__FILE__) | |
set :environment, :development | |
set :root, root_dir | |
set :app_file, File.join(root_dir, 'app.rb') | |
disable :run | |
require 'app' | |
run Sinatra::Application |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE web-app PUBLIC | |
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" | |
"http://java.sun.com/dtd/web-app_2_3.dtd"> | |
<web-app> | |
<context-param> | |
<param-name>rails.env</param-name> | |
<param-value>production</param-value> | |
</context-param> | |
<context-param> | |
<param-name>public.root</param-name> | |
<param-value>/</param-value> | |
</context-param> | |
<context-param> | |
<param-name>rackup</param-name> | |
<param-value>require 'rubygems' | |
require 'sinatra' | |
root_dir = File.dirname(__FILE__) | |
set :environment, :development | |
set :root, root_dir | |
set :app_file, File.join(root_dir, 'app.rb') | |
disable :run | |
require 'app' | |
run Sinatra::Application</param-value> | |
</context-param> | |
<context-param> | |
<param-name>jruby.min.runtimes</param-name> | |
<param-value>1</param-value> | |
</context-param> | |
<context-param> | |
<param-name>jruby.max.runtimes</param-name> | |
<param-value>1</param-value> | |
</context-param> | |
<context-param> | |
<param-name>jruby.init.serial</param-name> | |
<param-value>true</param-value> | |
</context-param> | |
<filter> | |
<filter-name>RackFilter</filter-name> | |
<filter-class>org.jruby.rack.RackFilter</filter-class> | |
</filter> | |
<filter-mapping> | |
<filter-name>RackFilter</filter-name> | |
<url-pattern>/*</url-pattern> | |
</filter-mapping> | |
<listener> | |
<listener-class>org.jruby.rack.RackServletContextListener</listener-class> | |
</listener> | |
</web-app> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment