[Q][httpView2] How do I use a HVCascadingStyleSheet instance

goran.krampe at bluefish.se goran.krampe at bluefish.se
Mon Nov 10 22:12:43 UTC 2003


Hannes Hirzel <hannes.hirzel.squeaklist at bluewin.ch> wrote:
> Hello
> 
> I just started using HttpView2 ( http://anakin.bluefish.se/gohu/6 ). The 
>   provided examples are illustrative and work fine.

Goodie. More coming.

> A question: How do I use a HVCascadingStyleSheet instance together with
> a HVHtmlBuilder instance? A little sample script would be great!

I used it in HomepageBuilder like this, first I subclassed HVHtmlBuilder
for my app and overrode #start and #end, start looked a bit like this
(end was trivial):

start
elements add: '<!DOCTYPE html	PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="sw" xml:lang="sw">

<head>
<title>', view title, '</title>
<style type="text/css" media="all">@import "css";</style>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
</head>
<body>'

As you can see it will try to access the url "css" relative to the
normal GET url. So if a request is made to /bla/blu/something then the
browser will also try to get the css as /bla/blu/css.

So each View class needs to implement #css. I did that by having a base
class. And that base class can simply do:

css
	"Return the CSS."

^HVCascadingStyleSheet string:
'/*
 * Darkblue: 33 82 148, hex: #215294
 * Lightblue: 0 181 231, hex: #00b5e7
 * Black:   55 53 54
 */

.ahem {display:	none;}

/*
 * We do not want borders on any images.
 */
img {border: 0px;}'

----

Well, that's it. I will make samples for this too.

regards, Göran

PS. Little busy right now with TFNR, but there is an article on HV2
coming...



More information about the Squeak-dev mailing list