Changeset 110
- Timestamp:
- 06/08/2006 14:21:32 (2 years ago)
- Location:
- trunk
- Files:
-
- 4 modified
-
examples/blog/blog.rb (modified) (1 diff)
-
examples/campsh/campsh.rb (modified) (1 diff)
-
lib/camping-unabridged.rb (modified) (2 diffs)
-
lib/camping.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/examples/blog/blog.rb
r83 r110 272 272 273 273 if __FILE__ == $0 274 require 'mongrel/camping' 274 begin 275 require 'mongrel/camping' 276 rescue LoadError => e 277 abort "** Try running `camping #$0' instead." 278 end 275 279 276 280 Blog::Models::Base.establish_connection :adapter => 'sqlite3', :database => 'blog.db' -
trunk/examples/campsh/campsh.rb
r103 r110 621 621 622 622 if __FILE__ == $0 623 CampSh::Models::Base.establish_connection :adapter => 'sqlite3', :database => 'campsh.db' 623 begin 624 require 'mongrel/camping' 625 rescue LoadError => e 626 abort "** Try running `camping #$0' instead." 627 end 628 629 CampSh::Models::Base.establish_connection :adapter => 'sqlite3', :database => 'blog.db' 624 630 CampSh::Models::Base.logger = Logger.new('camping.log') 631 CampSh::Models::Base.threaded_connections=false 625 632 CampSh.create 626 puts CampSh.run 633 634 server = Mongrel::Camping::start("0.0.0.0",3002,"/",CampSh) 635 puts "** CampSh example is running at http://localhost:3002/" 636 server.run.join 627 637 end -
trunk/lib/camping-unabridged.rb
r108 r110 87 87 # For more tips, see http://code.whytheluckystiff.net/camping/wiki/GiveUsTheCreateMethod. 88 88 module Camping 89 # Stores an +Array+ of all Camping applications modules. Modules are added 90 # automatically by +Camping.goes+. 91 # 92 # Camping.goes :Blog 93 # Camping.goes :Tepee 94 # Camping::Apps # => [Blog, Tepee] 95 # 96 Apps = [] 89 97 C = self 90 98 F = __FILE__ … … 548 556 def goes(m) 549 557 eval(S.gsub(/Camping/,m.to_s),TOPLEVEL_BINDING) 558 Apps << const_get(m) 550 559 end 551 560 -
trunk/lib/camping.rb
r108 r110 1 1 %w[active_record markaby metaid tempfile uri].each{|l|require l} 2 module Camping; C=self;F=__FILE__;S=IO.read(F).gsub(/_+FILE_+/,F.dump)2 module Camping;Apps=[];C=self;F=__FILE__;S=IO.read(F).gsub(/_+FILE_+/,F.dump) 3 3 module Helpers;def R c,*args;p=/\(.+?\)/;args.inject(c.urls.find{|x|x.scan(p). 4 4 size==args.size}.dup){|str,a|str.sub(p,C.escape((a.__send__(a.class.primary_key … … 34 34 k.meta_def(:urls){["/#{c.downcase}"]}if !(k<R);d||([k,$~[1..-1]]if k.urls.find{ 35 35 |x|path=~/^#{x}\/?$/})}||[NotFound,[path]] end end end;class<<self;def goes m 36 eval(S.gsub(/Camping/,m.to_s),TOPLEVEL_BINDING) end;def escape s;s.to_s.gsub(36 eval(S.gsub(/Camping/,m.to_s),TOPLEVEL_BINDING);Apps<<const_get(m);end;def escape s;s.to_s.gsub( 37 37 /([^ a-zA-Z0-9_.-]+)/n){'%'+$1.unpack('H2'*$1.size).join('%').upcase}.tr ' ','+' 38 38 end;def un s;s.tr('+', ' ').gsub(/((?:%[0-9a-fA-F]{2})+)/n){[$1.delete('%'
