This file contains 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 'bundler/setup' | |
require 'sinatra/base' | |
require 'slim' | |
require 'coffee-script' | |
require 'sequel' | |
require 'sqlite3' |
This file contains 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
module Sinatra | |
module Mount | |
def mount(app, route="/#{app.name.downcase}") | |
%w{get post put delete patch options}.each do |method| | |
self.send method.to_sym, "#{route}*" do | |
app.call( | |
env.merge!( | |
'SCRIPT_NAME' => route.split('/').last, | |
'PATH_INFO' => params.delete('splat').join('/') |
This file contains 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 'sequel' | |
require 'sqlite3' | |
require 'nokogiri' | |
DB = Sequel.sqlite | |
DB.instance_eval do | |
create_table :mazes do | |
primary_key :id |
This file contains 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 'rack/cache' | |
require 'sequel' | |
require 'sqlite3' | |
require 'yajl' | |
DB = Sequel.sqlite | |
DB.instance_eval do | |
create_table :tasks do |
This file contains 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/base' | |
require 'slim' | |
require 'sequel' | |
require 'sqlite3' | |
require 'bcrypt' | |
require 'thin' | |
require 'rack/cache' |
This file contains 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
ul | |
- for keyword in keywords | |
li | |
a rel='item' href=url("/#{keyword.id}", false) = keyword.name | |
nav | |
ul | |
- if keywords.next_page | |
li | |
a rel='next' href=url("/?page=#{keywords.next_page}", false) Next Page |
This file contains 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 'sequel' | |
require 'sqlite3' | |
DB = Sequel.sqlite | |
DB.instance_eval do | |
create_table :artists do | |
primary_key :id | |
String :name | |
end |
This file contains 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
module Rack | |
class ConditionalForms | |
IF_MATCH_PARAM_KEY = '_if_match'.freeze | |
IF_UNMODIFIED_SINCE_KEY = '_if_unmodified_since'.freeze | |
def initialize(app) | |
@app = app | |
end | |
This file contains 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 Presenter < BasicObject | |
def initialize(model, scope) | |
@model = model | |
@scope = scope | |
end | |
def method_missing(symbol, *args, &blk) | |
[@model, @scope].each do |obj| | |
return obj.send(symbol, *args, &blk) if obj.respond_to?(symbol) |
This file contains 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
Spine = require('spine') | |
class Page extends Spine.Model | |
@configure 'Page', 'name' | |
@extend Spine.Model.Ajax | |
@fetch: (params) -> | |
index = @last()?.id or 0 | |
return if index is @index |