[Seaside] Fill background with image?

Marcus Pedersén marcus.pedersen at comhem.se
Mon Dec 5 21:55:04 CET 2005


----- Original Message ----- 
From: "Esteban A. Maringolo" <emaringolo at gmail.com>
To: "The Squeak Enterprise Aubergines Server - general discussion."
<seaside at lists.squeakfoundation.org>
Sent: Sunday, December 04, 2005 10:32 PM
Subject: Re: [Seaside] Fill background with image?


2005/12/4, Marcus Pedersén <marcus.pedersen at comhem.se>:
> Thanks that was what I was after! Yes, the background of my webpage.
> I tried:
> style
>        ^ 'body { background-image: url(C:\....\...\background.jpg) } '
> and:
> style
>        ^ 'body { background-image: url(C:\....\...\background.gif) } '
> and:
> style
>        ^ 'body { background-image: anImageForm } '
>
> but neither of them worked.
> What am I doing wrong or isn't it working?
> Many thanks in advance!

To use an image obtained from a Form (a Squeak one), you have to
generate a valid URL for that form. Sadly, the style of the component
is obtained before that the render begins, and with no context
available, so a quick&dirty solution would be:


renderContentOn: html
  "Renders receiver on an html generator."
html attributeAt: 'type' put: 'text/css'.
html tag: 'style' do: [
  html text: (
      'body { background-image: url('
       , (self context urlForDocument: aForm)
       , '); }'
   )
].
" rest of your code."

This will generate a separate document handler (and an url for this)
each time the component is rendered, so you can cache the generated
url and use them instead of generating them each time. If not, the web
browser won't cache the generate image, downloading the background
each time.

Another solution, more elegant, would be to have a separate, static
file serving resource, and then point your styles url's to that
resource. i.e. have a "http://youhost/pics/" which is a resource that
directly maps to a directory in the web server.

Then you can apply the background style using:

style
  "Answer a string containing the CSS style for the receiver."

  ^'body { background-image: url(''/pics/yourPicture.png'') }'


I don't know how you can set a separate resource server on Squeak, in
VW with WebToolkit you can do it, and with Swazoo (VW, Squeak, and
Dolphin) can be done using a FileResource.


--
Esteban A. Maringolo
eMaringolo at gmail.com

Hi!
I must get something severly wrong!!
The suggestions above does not work for me!
Something I don't get is where my webserver root is.
If I start squeak in say c:\Program\squeak\ and want to make the url for my
image in c:\Program\squeak\images\Background.gif how do I do that?
Is my root at c:\Program\squeak\ and am I able to point at a file in a
subfolder relatively to the root?
Sorry for stupid questions but apparently I don't get it!!
A second question: If I just want to change the colour of my background how
do I do that?
Many thanks in advance!
Marcus
_______________________________________________
Seaside mailing list
Seaside at lists.squeakfoundation.org
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside




More information about the Seaside mailing list