Skip to content

Instantly share code, notes, and snippets.

helpers do
include Rack::Utils
alias_method :h, :escape_html
end
@rtomayko
rtomayko / gist:13682
Created September 29, 2008 21:40 — forked from entp/gist:13681
<!-- for some reason this isn't receiving my style! -->
<pre class="tl-body viewsource"><%= foo.bar %></pre>
<!-- duh -->
Let's make a list of Sinatra-based apps!
Apps:
- http://github.com/cschneid/irclogger "Sinatra based irclogger.com"
- http://github.com/rtomayko/wink "minimalist blogging engine"
- http://github.com/foca/integrity "The easy and fun Continuous Integration server"
- http://github.com/sr/git-wiki "git-powered wiki"
- http://github.com/entp/seinfeld "Seinfeld-inspired productivity calendar to track your public github commits."
- http://github.com/karmi/marley "Marley, the blog engine without <textareas>."
- http://github.com/ichverstehe/gaze "Serve up your Markdown files with this tiny Sinatra app!"
require 'sinatra'
require 'sinatra/test/rspec'
require File.join(File.dirname(__FILE__), '../../server.rb')
Dir.chdir('../../')
describe 'Game logic' do
it 'should be able to play in 0,0' do
get '/new'
require 'rubygems'
require 'sinatra/base'
class App < Sinatra::Base
enable :static
set :app_file, __FILE__
get '/' do
'See <a href="/thing.txt">this text file</a>.'
end
def run(app, &blk)
app = app.new(&blk) if blk && app.respond_to?(:new)
@ins << app
end
@rtomayko
rtomayko / gist:53726
Created January 28, 2009 00:17 — forked from sr/gist:53511
require 'sinatra'
enable :sessions
before do
if session['rand'].nil?
session['rand'] = rand(1000)
end
if session['object'].nil?
@rtomayko
rtomayko / base.rb
Created January 30, 2009 01:56 — forked from bmizerany/base.rb
class Foo < Sinatra::Base
host_name "sinatrarb.com"
user_agent /Mosaic/
provides :xml
get '/' do
"Welcome!"
end
get '/' do
"You are not to be welcomed!"
# BAD:
foo.bar = 25
foo.biz = 'Hello World'
foo.bazzle = 42
# GOOD:
foo.bar = 25
foo.biz = 'Hello World'
foo.bazzle = 42