Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
require 'net/http'
require 'uri'
require 'rubygems'
require 'json'
require 'pp'
if !ARGV[0]
puts "Usage: iphone.rb STATE"
Router.prepare do |r|
# generating this requires :domain, :controller, and :action
r.match("/:domain/complicated/url").to(:controller => "what", :action => "index")
# generating this requires :controller and :index
r.match("/:controller/:index").to
end
Merb::Router.prepare do
resources :donors do
resources :pledges do
resources :donations
end
end
resources :campaigns do
@wycats
wycats / gist:8093
Created August 30, 2008 06:18 — forked from carllerche/gist:8091
it "should only use the second namespace" do
Merb::Router.prepare do |r|
r.namespace(:foo) do |f|
end
r.namespace(:bar) do |b|
b.match("/login").to(:controller => "home").name(:login)
end
end
url(:bar_login).should == "/bar/login"
@wycats
wycats / router.rb
Created September 13, 2008 19:48 — forked from carllerche/router.rb
Merb::Router.prepare do
namespace :admin do
match("/dashboard").to(:controller => "dashboard")
resources :users do
resources :comments
end
end
resources :users do
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Ditty - A non-linear web notebook</title>
<script src='jquery.js' type='text/javascript'></script>
<script type='text/javascript'>
//<![CDATA[
$(document).ready(function() {
// let tiddlers be closed
@wycats
wycats / gist:12061
Created September 22, 2008 17:25 — forked from piclez/gist:12058
Merb::Router.prepare do |r|
add_slice(:MerbAuth, :path => "", :default_routes => false)
# This is the default route for /:controller/:action/:id
# This is fine for most cases. If you're heavily using resource-based
# routes, you may want to comment/remove this line to prevent
# clients from calling your create or destroy actions with a GET
#r.default_routes
# Change this for your home page to be available at /
{
:href => uri(article),
:title => article.title,
# ...
}
## compiles into
def ...
json = {
def self.update_logger
Merb::Config[:log_stream] = File.open(Merb::Config[:log_file], "w+") if Merb::Config[:log_file]
end
#load required files
require 'rubygems'
gem 'merb-core', '>= 0'
require 'merb-core'
require 'rack/handler/grizzly'
require 'rack/adapter/merb'
require 'jruby/rack/grizzly_helper'
Merb::Rack::Adapter.register %w{grizzly}, :GrizzlyMerb