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
| #!/usr/bin/env ruby | |
| require 'net/http' | |
| require 'uri' | |
| require 'rubygems' | |
| require 'json' | |
| require 'pp' | |
| if !ARGV[0] | |
| puts "Usage: iphone.rb STATE" |
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
| 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 | |
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
| Merb::Router.prepare do | |
| resources :donors do | |
| resources :pledges do | |
| resources :donations | |
| end | |
| end | |
| resources :campaigns do | |
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
| 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" |
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
| Merb::Router.prepare do | |
| namespace :admin do | |
| match("/dashboard").to(:controller => "dashboard") | |
| resources :users do | |
| resources :comments | |
| end | |
| end | |
| resources :users do |
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
| <?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 |
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
| 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 / |
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
| { | |
| :href => uri(article), | |
| :title => article.title, | |
| # ... | |
| } | |
| ## compiles into | |
| def ... | |
| json = { |
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 self.update_logger | |
| Merb::Config[:log_stream] = File.open(Merb::Config[:log_file], "w+") if Merb::Config[:log_file] | |
| 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
| #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 | |
OlderNewer