How do I get the nice __SINATRA__ images to show?

611 views
Skip to first unread message

Mike

unread,
Apr 7, 2011, 7:04:45 AM4/7/11
to sinatrarb
Hi,

Of only trivial importance, but on my dev server I 'show exceptions'
for obvious reasons. I don't get the 404 or 500 png images on the
exception page. They are in the gem library, but of course my web
server is serving up static content from my application root, and not
looking in the gem folders.

I could fix this by moving the images, or setting an alias for
__SINATRA__ in the web server, but how is this supposed to work?
Should there be an intercept inside Sinatra itself (I can see code in
base.rb, but the apache log shows a 404 when trying to GET 500.png)?
They appear nicely if I run via Webrick on my local machine (Windows)
but then there's no real web server involved.

I'm on Sinatra 1.2, running under Passenger and Apache. Classic app
run via config.ru

Thanks.

Oh ... and thinks lots for Sinatra. I really dislike clunky bloated s/
ware (a la Rails) so having something light yet flexible and
extendible is great :-)

Mike.

Evgeni Dzhelyov

unread,
Apr 7, 2011, 7:17:56 AM4/7/11
to sina...@googlegroups.com
Hi,

These images are served by Sinatra itself, via this route:
get '/__sinatra__/:image.png' do

So request to http://example.com/__sinatra__/500.png should display the images,
you could try to investigate this route further.

> --
> You received this message because you are subscribed to the Google Groups "sinatrarb" group.
> To post to this group, send email to sina...@googlegroups.com.
> To unsubscribe from this group, send email to sinatrarb+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/sinatrarb?hl=en.
>
>

Evgeni Dzhelyov

unread,
Apr 7, 2011, 7:19:42 AM4/7/11
to sina...@googlegroups.com
One more thing your environment should be set to :development to have
this route enabled

Mike

unread,
Apr 7, 2011, 8:43:51 AM4/7/11
to sinatrarb
Hi,

Yes - thanks for the suggestions. I get a 404 if I go directly for
the image.

I do set :environment :development.

I think it's because of my 'before' filter which seems to catch
everything. I think I need it to say "before, but not if this is
static content" ! I could put in a regex, but not sure how to break
out of a before filter nicely.

Mike.

On Apr 7, 12:19 pm, Evgeni Dzhelyov <evgeni.dzhel...@gmail.com> wrote:
> One more thing your environment should be set to :development to have
> this route enabled
>
> On Thu, Apr 7, 2011 at 2:17 PM, Evgeni Dzhelyov
>
> <evgeni.dzhel...@gmail.com> wrote:
> > Hi,
>
> > These images are served by Sinatra itself, via this route:
> >      get '/__sinatra__/:image.png' do
>
> > So request tohttp://example.com/__sinatra__/500.pngshould display the images,
> > you could try to investigate this route further.
>

Konstantin Haase

unread,
Apr 8, 2011, 2:45:33 AM4/8/11
to sina...@googlegroups.com
Are you serving Sinatra under / or under some nested path? There is a known bug (at least known to me) with serving those images from nested paths. This will be fixed in the 1.2.2, which is about to be release. I'm at the Scottish Ruby Conference, so it might take until I get home. By the way, if any of you guys is at the conference and wants to talk about Sinatra or anything else, just drop me a line.

Konstantin

Mike

unread,
Apr 8, 2011, 3:49:15 AM4/8/11
to sinatrarb
Hi Konstantin,

Scottish Ruby Conference ... sounds fun. What is 'Scottish
Ruby'? ;-)

No. Am serving Sinatra at the root. I'm pressed for time for the next
few days, but when I get chance I'll put some debug stuff into base.rb
and figure out why it's missing the route in there. I'm sure it must
be linked to the 'before' filter I have. I'll compare with why the
Windows one seems to be working, although that was with an earlier
iteration and I need to reload the database to make any of that work
(actually I guess I dont as I'll get plenty of 500s with no database).

Mike.

On Apr 8, 7:45 am, Konstantin Haase <k.ha...@finn.de> wrote:
> Are you serving Sinatra under / or under some nested path? There is a known bug (at least known to me) with serving those images from nested paths. This will be fixed in the 1.2.2, which is about to be release. I'm at the Scottish Ruby Conference, so it might take until I get home. By the way, if any of you guys is at the conference and wants to talk about Sinatra or anything else, just drop me a line.
>
> Konstantin
>
> On Apr 7, 2011, at 13:43 , Mike wrote:
>
> > Hi,
>
> > Yes - thanks for the suggestions.   I get a 404 if I go directly for
> > the image.
>
> > I do set :environment  :development.
>
> > I think it's because of my 'before' filter which seems to catch
> > everything.  I think I need it to say "before, but not if this is
> > static content" !   I could put in a regex, but not sure how to break
> > out of a before filter nicely.
>
> > Mike.
>
> > On Apr 7, 12:19 pm, Evgeni Dzhelyov <evgeni.dzhel...@gmail.com> wrote:
> >> One more thing your environment should be set to :development to have
> >> this route enabled
>
> >> On Thu, Apr 7, 2011 at 2:17 PM, Evgeni Dzhelyov
>
> >> <evgeni.dzhel...@gmail.com> wrote:
> >>> Hi,
>
> >>> These images are served by Sinatra itself, via this route:
> >>>      get '/__sinatra__/:image.png' do
>
> >>> So request tohttp://example.com/__sinatra__/500.pngshoulddisplay the images,
Reply all
Reply to author
Forward
0 new messages