Sha256: ded01da06de0bdede96249040ea2343bbcfc6430ef11c13a81099b6917be42a2
Contents?: true
Size: 1.62 KB
Versions: 1
Compression:
Stored size: 1.62 KB
Contents
$:.unshift( "../lib" ) require 'capcode' require 'capcode/render/markaby' require 'capcode/render/haml' Capcode::Helpers.haml_path = "./haml" require 'capcode/render/json' require 'capcode/render/erb' Capcode::Helpers.erb_path = "./erb" module Capcode module Helpers def bold( &b ) "<b>"+yield+"</b>" end end end module Capcode class HTTPError def r404(f) "Pas glop !!! #{f} est inconnu !!!" end end class Hello < Route '/hello/(.*)' def get( you ) @you = you @you = "you" if you.nil? session = { :user => @you } # "Hello " + bold { you } + " it's '#{Time.now} !" render( :markaby => :m_hello ) end end class Redir < Route '/r' def get redirect( Hello, "Greg" ) end end class Glop < Route '/glop/(.*)', '/glop/code/([^\/]*)/(.*)' def get( r, v ) "Glop receive #{r}, type #{r.class} and #{v}, type #{v.class} from #{URL(Glop)}" end end class Js < Route '/toto' def get render( :json => { :some => 'json', :stuff => ['here'] } ) end end class Env < Route '/env' def get x = env.map do |k,v| "#{k} => #{v}" end.join( "<br />\n" ) x end end end module Capcode::Views def layout html do head do title "Use a layout ;)" end body do yield end end end def m_hello p do text "Hello " b @you text " it's '#{Time.now} !" end end end #Capcode.map( "/file" ) do # Rack::File.new( "." ) #end Capcode.run( :port => 3001, :host => "localhost", :root => "." )
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
Capcode-0.6.1 | examples/sample.rb |