Tim Connor | 6 Jul 19:00 2007
Picon

Re: FastCGI without ScriptAlias

Nagy Bence <lists <at> ...> writes:

> 
> Hi,
> 
> I made some experiments with the sample blog application, my index.fcgi 
> file contains the following:
> 
> require 'camping/fastcgi'
> Camping::Models::Base.establish_connection(
> 	:adapter => 'sqlite3',
> 	:database => 'database/camping.db'
> )
> Camping::FastCGI.serve('blog.rb')
> 
> Without ScriptAlias the application works fine, but only if I give the 
> url with "index.fcgi/" at the end 
> (http://localhost/~gimb/camping/index.fcgi/). Loading 
> http://localhost/~gimb/camping/ or 
> http://localhost/~gimb/camping/index.fcgi (no slash at the end) gives an 
> error:
> 
> ./lib/camping/fastcgi.rb:180:in `camp_do': undefined local variable or 
> method `exc' for #<Camping::FastCGI:0xb78443e4> (NameError)
>          from ./lib/camping/fastcgi.rb:79:in `start'
>          from /usr/lib/ruby/1.8/fcgi.rb:117:in `session'
>          from /usr/lib/ruby/1.8/fcgi.rb:104:in `each_request'
>          from /usr/lib/ruby/1.8/fcgi.rb:36:in `each'
>          from ./lib/camping/fastcgi.rb:78:in `start'
>          from ./lib/camping/fastcgi.rb:90:in `start'
(Continue reading)

carmen | 7 Jul 07:30 2007

[patch] no crumbs

in the spirit of minimal-impact 'leave no trace' principles, this patch adds a missing feature, the
ability to remove cookies.

usage:

 <at> cookies.redbean = nil

a side note, the trunk seems to be broken when using Markaby. i've tested this out using ngrep and firefox and
opera w/ controllers that just return strings in any case..
Index: lib/camping.rb
===================================================================
--- lib/camping.rb	(revision 194)
+++ lib/camping.rb	(working copy)
 <at>  <at>  -25,7 +25,7  <at>  <at> 
 "post" and e.CONTENT_TYPE == "application/x-www-form-urlencoded"
 q.u C.qsp( <at> in.read)end; <at> cookies, <at> input= <at> k.dup,q.dup end;def service*a
  <at> body=send( <at> method,*a)if respond_to? <at> method; <at> headers["Set-Cookie"]= <at> cookies.map{
-|k,v|"#{k}=#{C.escape(v)}; path=#{self/'/'}"if v!= <at> k[k]}-[nil];self end;def to_s
+|k,v|"#{k}=#{C.escape(v)};#{"max-age=0;"if !v}path=#{self/'/'}"if v!= <at> k[k]}-[nil];self
end;def to_s
 a=[]; <at> headers.map{|k,v|[*v].map{|x|a<<"#{k}: #{x}"}};"Status: #{ <at> status}#{Z+a*Z+
 Z*2+ <at> body}"end;end;X=module Controllers; <at> r=[];class<<self;def r; <at> r;end;def R*u
 r= <at> r;Class.new{meta_def(:urls){u};meta_def(:inherited){|x|r<<x}}end;def M;def M
Index: lib/camping-unabridged.rb
===================================================================
--- lib/camping-unabridged.rb	(revision 194)
+++ lib/camping-unabridged.rb	(working copy)
 <at>  <at>  -438,7 +438,7  <at>  <at> 
(Continue reading)

carmen | 7 Jul 07:58 2007

[patch] trunk markaby fix

so i guess the parser changed or something..
Index: camping.rb
===================================================================
--- camping.rb	(revision 194)
+++ camping.rb	(working copy)
 <at>  <at>  -7,7 +7,7  <at>  <at> 
 c=self/c;c="//"+ <at> env.HTTP_HOST+c if c[/^\//];URI(c)end;def/p;p[/^\//]? <at> root+p :
 p end;def errors_for o;ul.errors{o.errors.each_full{|x|li x}}if o.errors.any?end
 end;module Base;include Helpers;attr_accessor:input,:cookies,:env,:headers,:body,
-:status,:root;def method_missing*a,&b;a.shift if a[0]==:render;m=Mab.new {},self
+:status,:root;def method_missing*a,&b;a.shift if a[0]==:render;m=Mab.new({},self)
 s=m.capture{send(*a,&b)};s=m.capture{send(:layout){s}} if /^_/!~a[0].to_s and m.
 respond_to?:layout;s end;def r s,b,h={}; <at> status=s; <at> headers.merge!h; <at> body=b end
 def redirect*a;r 302,'','Location'=>URL(*a)end;Z="\r\n";def to_a;[ <at> status, <at> body,
_______________________________________________
Camping-list mailing list
Camping-list@...
http://rubyforge.org/mailman/listinfo/camping-list
Tim Connor | 7 Jul 22:49 2007
Picon

logging errors

Looking over the ServerError code there is no built in way to tell
camping to log its errors is there?  I suppose the answer it to
instantiate a logger, inherit ServerError, call super and pass the
return into the logger?

If we using fcgi on production, does the ServerError get called, or
only the server_error in fcgi.rb?  Mainly I'm wondering if there is
just one place I can handle things (my theoretical overloaded
ServerError method), or if I need to get in there and muck with e code
of fastcgi.rb also.

BTW, I've got things (camping fcgi on dreamhost with mysql) mostly
running, aside this last bit, and I'll blog some of the tricky bits,
and see if there is anything on fcgi that should be updated on the
wiki after I push it live.

Thanks,
Tim
Ernest Prabhakar | 11 Jul 23:26 2007
Picon

Extending Markaby for SVG

Hi all,

I love the elegance of Markaby for HTML generation. I'd like to do something similar for SVG, e.g.:

svg11 do
  title "Slide Title"
  rect({:x=>2,:y=>2,:width=>508,:height=>318,:fill=>"aqua"})
  g({:style=>"fill:blue; stroke:black", :transform=>"translate(17,-38)"}) do
circle({:cx=>70, :cy=>100, :r=>50})
rect(:x=>"150", :y=>"50", :rx=>"20", :ry=>"20", :width=>"135", :height=>"100")
line(:x1=>325, :y1=>150, :x2=>375, :y2=>50)
polyline(:points=>"50, 250 75, 350 100, 250 125, 350 150, 250 175, 350")
polygon(:points=>"250, 250, 297, 284, 279, 340, 220, 340, 202, 284")
ellipse({:cx=>400, :cy=>300, :rx=>72, :ry=>50})
  end
end

I've hacked a custom subclass of Builder (SVGBuilder) that can handle this, but that's probably the wrong approach -- since most users will want to embed SVG inside HTML.

Any Markaby experts here who can help me figure out the best way to integrate SVG support into Markaby?

Thanks,
-- Dr. Ernie

_______________________________________________
Camping-list mailing list
Camping-list@...
http://rubyforge.org/mailman/listinfo/camping-list
Timur Mehrvarz | 11 Jul 23:31 2007
Picon

Re: Extending Markaby for SVG

Hello. I'm interested in this as well.

Timur

On 11.07.2007, at 23:26, Ernest Prabhakar wrote:

> Hi all,
>
> I love the elegance of Markaby for HTML generation. I'd like to do  
> something similar for SVG, e.g.:
>
> svg11 do
>   title "Slide Title"
>   rect({:x=>2,:y=>2,:width=>508,:height=>318,:fill=>"aqua"})
>   g({:style=>"fill:blue; stroke:black", :transform=>"translate 
> (17,-38)"}) do
> 	circle({:cx=>70, :cy=>100, :r=>50})
> 	rect 
> (:x=>"150", :y=>"50", :rx=>"20", :ry=>"20", :width=>"135", :height=>"1 
> 00")
> 	line(:x1=>325, :y1=>150, :x2=>375, :y2=>50)
> 	polyline(:points=>"50, 250 75, 350 100, 250 125, 350 150, 250 175,  
> 350")
> 	polygon(:points=>"250, 250, 297, 284, 279, 340, 220, 340, 202, 284")
> 	ellipse({:cx=>400, :cy=>300, :rx=>72, :ry=>50})
>   end
> end
>
> I've hacked a custom subclass of Builder (SVGBuilder) that can  
> handle this, but that's probably the wrong approach -- since most  
> users will want to embed SVG inside HTML.
>
> Any Markaby experts here who can help me figure out the best way to  
> integrate SVG support into Markaby?
>
> Thanks,
> -- Dr. Ernie
> http://ihack.us/
>
> _______________________________________________
> Camping-list mailing list
> Camping-list@...
> http://rubyforge.org/mailman/listinfo/camping-list
Tim Fletcher | 12 Jul 00:34 2007
Picon

Re: Extending Markaby for SVG

> I've hacked a custom subclass of Builder (SVGBuilder) that can handle this,
> but that's probably the wrong approach -- since most users will want to
> embed SVG inside HTML.
>
> Any Markaby experts here who can help me figure out the best way to
> integrate SVG support into Markaby?

My opinion would be to keep it seperate so that in can be used
elsewhere, but provide a hook into Markaby. So something along the
lines of this (completely untested):

    module Markaby
      class Builder
        def svg(options = {}, &block)
          concat SVGBuilder.new(&block)
        end
      end
    end

The developer could either have to explicitly require the hook, or, if
you make the assumption that Markaby is loaded before the SVG code
then you can just test for it's presence i.e. if defined?(Markaby) and
load it based on that.

Hope that makes sense - getting late here :)
Geoffrey Grosenbach | 12 Jul 01:10 2007

Re: Extending Markaby for SVG

On 7/11/07, Tim Fletcher <twoggle@...> wrote:
> > Any Markaby experts here who can help me figure out the best way to
> > integrate SVG support into Markaby?

I worked on a project started by Scott Barron to do something similar
for CSS. I'm using SASS now, but here it is for reference:

http://topfunky.net/svn/plugins/styleaby/

--

-- 
Geoffrey Grosenbach
boss@...
........................
Blog | http://nubyonrails.com
Podcast | http://podcast.rubyonrails.com
Screencast | http://peepcode.com
Ernest Prabhakar | 13 Jul 00:23 2007
Picon

Re: Extending Markaby for SVG - done!

Hi Tim,

On Jul 11, 2007, at 3:34 PM, Tim Fletcher wrote:
>    My opinion would be to keep it seperate so that in can be  
> usedelsewhere, but provide a hook into Markaby. So something along the
> lines of this (completely untested):

Thanks!  That's exactly what I needed.  The whole implementation is  
now at:

http://pastie.caboo.se/78442

This uses an Markaby::SVG11 tagset, which is at:

http://pastie.caboo.se/78441

The only ugly bit is that Markaby defines "text" as the output  
command, which conflicts with the SVG tag named "text." I remember  
_why saying he was going to rename that method to "out" or something.  
Is that still planned?

To use it, simply make sure that builder_svg is loaded, and do  
something like:

> html do
> 	head {title "Testing HTML+SVG"}
> 	body do
> 		p "Below is a wonderful example of"
> 		a "SVG", :href => "http://www.w3.org/2000/svg"
> 		svg do
> 			title "Slide Title"
> 			rect({:x=>2,:y=>2,:width=>508,:height=>318,:fill=>"aqua"})
> 		end
> 	end
> end

I have a test suite, if anyone is interested. I haven't done anything  
fancy yet, but it seems to all work.

Is this something I should submit as a patch to Markaby itself?

Best,
-- Ernie P.
	
Sérgio | 23 Jul 00:47 2007
Picon

500 error while trying to run Camping on Dreamhost

I've tried setting up an Hello World app with Rails (no database), on a Dreamhost account. I used the configuration I found here http://www.mail-archive.com/camping-list-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org/msg00114.html with the proper paths. But I keep getting Internal Server Errors (500). On the error.log I found this

[Sun Jul 22 15:32:07 2007] [error] [client 82.154.48.138] FastCGI: comm with (dynamic) server "/home/xxx/little/dispatch.fcgi" aborted: (first read) idle timeout (60 sec), referer: http://little.xxx.com/
[Sun Jul 22 15:32:07 2007] [error] [client 82.154.48.138] FastCGI: incomplete headers (0 bytes) received from server "/home/xxx/little/dispatch.fcgi", referer: http://little.xxx.com/

It seems that is a somewhat common error, that can have several causes. Could anyone who already has their application running on Dreamhost or other shared hosting service, please give a few pointer on how to deploy a Camping application or just try to guess what could be causing the error above.

I was really hoping I could use Camping on some projects. Thanks in advance.

_______________________________________________
Camping-list mailing list
Camping-list@...
http://rubyforge.org/mailman/listinfo/camping-list

Gmane