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
helpers do | |
include Rack::Utils | |
alias_method :h, :escape_html | |
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
<!-- for some reason this isn't receiving my style! --> | |
<pre class="tl-body viewsource"><%= foo.bar %></pre> | |
<!-- duh --> |
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
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!" |
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 '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' |
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/base' | |
class App < Sinatra::Base | |
enable :static | |
set :app_file, __FILE__ | |
get '/' do | |
'See <a href="/thing.txt">this text file</a>.' | |
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
def run(app, &blk) | |
app = app.new(&blk) if blk && app.respond_to?(:new) | |
@ins << app | |
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
✈ | |
♨ | |
⚕ | |
⚛ | |
⚤ | |
⚰ | |
⚧ | |
⚘ |
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 'sinatra' | |
enable :sessions | |
before do | |
if session['rand'].nil? | |
session['rand'] = rand(1000) | |
end | |
if session['object'].nil? |
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
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!" |
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
# BAD: | |
foo.bar = 25 | |
foo.biz = 'Hello World' | |
foo.bazzle = 42 | |
# GOOD: | |
foo.bar = 25 | |
foo.biz = 'Hello World' | |
foo.bazzle = 42 | |
OlderNewer