Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TclHttpd: How to use CSS with it?

28 views
Skip to first unread message

Robert Hicks

unread,
Jul 18, 2006, 12:17:31 PM7/18/06
to
I am looking at the source and all and I have gotten TclHttpd to use a
CSS file by doing:

html::headTag {link href="css/main.css" rel="stylesheet"
type="text/css" /}

The issue seems to be that everything is generated (pretty much). I can
hard code everything in that CSS file but I would really like to create
classes of things.

How do you wrap the current html commands where something like this:

set html [mypage::header $title]

gets wrapped into a class="whatever" string? So that <h2> becomes <h2
class="whatever">?

I was thinking along Tk lines and it would be cool to be able to do
this:

set html [mypage::header $title -class $banner] # -class could also be
-id

and it would spit out the correct html.

Any guidance or thoughts on this?

:Robert

Gerald W. Lester

unread,
Jul 18, 2006, 12:48:45 PM7/18/06
to

Lots of questions before any thoughts!

1) Are you talking about just files on disk?
2) Are you talking about tml files on disk?
3) If you are doing the generation in tcl code, what package are you using
to generate your html?

The answers to the above questions will allow an intelligent answer to your
question.

--
+--------------------------------+---------------------------------------+
| Gerald W. Lester |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+

newtop...@yahoo.com

unread,
Jul 18, 2006, 1:08:54 PM7/18/06
to
Robert Hicks wrote:
> I am looking at the source and all and I have gotten TclHttpd to use a
> CSS file by doing:
>
> html::headTag {link href="css/main.css" rel="stylesheet"
> type="text/css" /}
>
> The issue seems to be that everything is generated (pretty much). I can
> hard code everything in that CSS file but I would really like to create
> classes of things.
> ...

>
> and it would spit out the correct html.
>
> Any guidance or thoughts on this?

I did something similar and ended up generating my own html code so I
am not using the html package. I simply add the CSS class info to the
strings, and everything works just fine. (i.e., class="mystyle.css")

It seems to me that most html lib routines take what you give them
literally. So, you should be ok if you just append "class=..."
declarations when you make these calls. In your example above, this
would be:

set html [mypage::header "$title class=\"mystyle.css\""]

Robert Hicks

unread,
Jul 18, 2006, 1:09:49 PM7/18/06
to

Gerald W. Lester wrote:
> Robert Hicks wrote:
<snip>

> Lots of questions before any thoughts!
>
> 1) Are you talking about just files on disk?
> 2) Are you talking about tml files on disk?
> 3) If you are doing the generation in tcl code, what package are you using
> to generate your html?
>
> The answers to the above questions will allow an intelligent answer to your
> question.
>

Well I am currently just looking at the TclHttpd stuff itself.

1) I am not sure what you mean by this but if it was just files then I
assume I could do whatever I wanted in the html.

2) Tml: Yes, this one throws me for a loop. Probably because #1 I am
not all that good at Tcl (though trying).

3). Packages: It looks like the html, and ncgi packages are being used.

Here is an example:

proc ::learn::header { title } {
Doc_Dynamic


set html [mypage::header $title]

return $html
}

That is set in a .tml file and in the index.tml file you have:

[mypage::header "TclHttpd Home Page"]

That wraps the "TclHttpd Home Page" in an <h2> tag (although I cannot
find out where this happens. If I want to change it and use CSS I have
to hard code the h2 element to something but that changes all the h2
elements. I would rather have an easy way to wrap that into CSS.

Granted...I am just trying to figure out TclHttpd and where it gets all
the files it uses to create even the default home page, so I may be
missing something.

My ignorance in all things Tcl is probably showing. : )

Robert

Robert Hicks

unread,
Jul 18, 2006, 1:22:25 PM7/18/06
to

I see what I have been missing...the custom folder. Looking in that I
see how things are being defined now so that makes more sense to me
now.

Robert

Michael Schlenker

unread,
Jul 18, 2006, 1:41:44 PM7/18/06
to
Robert Hicks schrieb:

> Gerald W. Lester wrote:
>> Robert Hicks wrote:
> <snip>
>> Lots of questions before any thoughts!
>>
>> 1) Are you talking about just files on disk?
>> 2) Are you talking about tml files on disk?
>> 3) If you are doing the generation in tcl code, what package are you using
>> to generate your html?
>>
>> The answers to the above questions will allow an intelligent answer to your
>> question.
>>
>
> Well I am currently just looking at the TclHttpd stuff itself.
>
> 1) I am not sure what you mean by this but if it was just files then I
> assume I could do whatever I wanted in the html.
>
> 2) Tml: Yes, this one throws me for a loop. Probably because #1 I am
> not all that good at Tcl (though trying).
>
> 3). Packages: It looks like the html, and ncgi packages are being used.
>
The html package in tcllib is currently missing any real support for css.

If you want to add it, just go on write a patch. If the changes are
larger a 2.x release of the html package would be ok.

There is also a javascript module in Tcllib, which is quasi obsolete and
could need an infusion with new life aka an ajax module or something
similar.

Michael

Gerald W. Lester

unread,
Jul 18, 2006, 1:58:23 PM7/18/06
to
Robert Hicks wrote:
> Gerald W. Lester wrote:
>> Robert Hicks wrote:
> <snip>
>> Lots of questions before any thoughts!
>>
>> 1) Are you talking about just files on disk?
>> 2) Are you talking about tml files on disk?
>> 3) If you are doing the generation in tcl code, what package are you using
>> to generate your html?
>>
>> The answers to the above questions will allow an intelligent answer to your
>> question.
>>
>
> Well I am currently just looking at the TclHttpd stuff itself.

CSS are something the browser processes not the server. TclHttpd supports
serving them up. Just put them out there and use them in your HTML code.

> 1) I am not sure what you mean by this but if it was just files then I
> assume I could do whatever I wanted in the html.
>
> 2) Tml: Yes, this one throws me for a loop. Probably because #1 I am
> not all that good at Tcl (though trying).
>
> 3). Packages: It looks like the html, and ncgi packages are being used.
>
> Here is an example:
>
> proc ::learn::header { title } {
> Doc_Dynamic
> set html [mypage::header $title]
> return $html
> }

Looks like custom code in the custom directory to me.

The html package in tcllib supports adding class et al, for example:

::html::h1 {This is a class=test header!} {class=test}

produces:

<h1 class=test>This is a class=test header!</h1>

Hope this clears things up a little.

Robert Hicks

unread,
Jul 18, 2006, 2:01:40 PM7/18/06
to

Michael Schlenker wrote:
<snip>

> The html package in tcllib is currently missing any real support for css.
>
> If you want to add it, just go on write a patch. If the changes are
> larger a 2.x release of the html package would be ok.
>
> There is also a javascript module in Tcllib, which is quasi obsolete and
> could need an infusion with new life aka an ajax module or something
> similar.
>
> Michael

I never even knew there was a javascript module. heh

Ajax...yikes. Wouldn't I have to choose one of the current Ajaxian
things like prototype.js and then write wrappers for it? I am not very
good at javascript but maybe I don't need to be to wrap it.

Hmmm...that is something to think about anyway. I have made feature
request to the html package (like adding doctypes).

Robert

Robert Hicks

unread,
Jul 18, 2006, 2:03:58 PM7/18/06
to
Yup...I just found the custom code.

Thanks Gerald.

Robert

Michael Schlenker

unread,
Jul 18, 2006, 2:55:51 PM7/18/06
to
Robert Hicks schrieb:
Some of those are actually done in a minimalistic version in current cvs...

Michael

0 new messages