Antville Project

migrating to xhtml

i am currently modifying the skins to output true and validated xhtml 1.0 (transitional, that is). because this is quite an extensive task that affects a bunch of skins and macros (returning html code) i'd like to kinldy ask you to wait a little bit with your next check-ins, at least if skins are concerned.

btw. i'd like to modify the functions that render html output in a way that there is a set of global skins defining the html that will be called from the function with a parameter object instead "res.writing" the whole html data from within the function. is that okay with you?

update: i made a first step with the xhtml migration as well with the new way how html macros (ie. macros returning html tags) are rendered (as described inside) and already checked it into cvs. please be aware that this stuff is still in development and i cannot guarantee whether it's buggy or not (and sorry, i won't be able to continue before tuesday).

comment    

 
hns, May 16, 2002 at 3:47:43 PM CEST

You mean "no more hardcoded HTML", right? +1, but just for interest: can you say approximately in how many cases HTML is hardcoded in the current version (and thus how many new skins there'd be)?

Something else: Helma HTML encoder currently writes out <br> for line breaks. You'd need that changed to <br/>, right? (I'm not an expert on XHTML.)

link  

 
tobi, May 16, 2002 at 3:54:32 PM CEST

yes

no more hardcoded html inside .js files. actually, i cannot say how much html is hardcoded. but i expect there to be new skins for at least the most frequently used html tags with many attributes (like img, a, input). i don't want to make promises but i think in the end there will be between 5 and 10 more skins...

and, uhm, yes, the encoder output of the br tag i already changed to <br />. is that ok, too?

link  

 
hns, May 16, 2002 at 4:21:25 PM CEST

That's ok

but the place where this is probably more important is in helma/util/HtmlEncoder.java. Feel free to change it there too (just search and replace "<br>), otherwise I can do it.

PS: I propose writing empty tags without space between element name and slash. I think that's the more common way to write them.

link  

 
tobi, May 16, 2002 at 5:05:08 PM CEST

nope

"IMPORTANT Compatibility Note: To make your XHTML compatible with today's browsers, you should add an extra space before the "/" symbol like this: <br />, and this: <hr />." (source).

link  

 
hns, May 16, 2002 at 5:08:32 PM CEST

i

see

link  


... comment
 
robert, May 16, 2002 at 3:56:44 PM CEST

wow

many many thanks for your efforts, tobi! and +1 for removing hardcoded html-code in macros/renderFunctions (actually i don't know how often this is the case, i hope it's not that often ...)

link  


... comment
 
kris, May 16, 2002 at 5:28:33 PM CEST

erm, xhtml and community sites

i just read the specs. whatdoes the reality look like? do browser render non-valid xhtml? what happens if some comments contain not well-formed xhtml?

i'm not against making antville xhtml compatible. it's a great thing for those who like clean code. but i wonder if a preference for strict and sloppy doctype would make sense.

link  

 
tobi, May 16, 2002 at 6:01:12 PM CEST

i don't think you'll have to worry

the browsers won't complain if a story or comment contains invalid xhtml and this is mixing up with the default, (hopefully) valid antville markup. i won't use the strict doctype anyway, but the transitional one. and your proposal sounds like a lot of work, honestly (rage, rage, rage!)

link  

 
kris, May 16, 2002 at 6:31:01 PM CEST

no hard work, but not necessary

maybe my comment was too short. i think it is necessary that all antville code is valid in xhtml. what i was referring to is given the admin an easy menu to change the doctype used the template. but this is not an issue if browsers do render invalid xhmtl sufficiently well.

link  


... comment
 
tobi, May 16, 2002 at 6:08:19 PM CEST

proposal / rfc

i came to a solution which to me looks quite nice and obviously reduces the amount of (redundant) code. as an example, here's how an image would be rendered:

hopobject/renderFunctions.js (i think this and some other functions should go global, shouldn't they?)

function renderImage(img, param) {
var attr = new Object();
attr.title = param.title ? param.title : img.alttext;
attr.style = param.style;
attr.id = param.id ? param.id : param.style;
attr.src = getProperty("imgUrl");
attr.src += img.weblog ? img.weblog.alias + "/" : "";
attr.src += img.filename + "." + img.fileext;
attr.width = param.width ? param.width : img.width;
attr.height = param.height ? param.height : img.height;
attr.alt = param.description ? param.description :
img.alttext;
renderMarkupElement("img", null, attr);
return;
}
global/renderFunctions.js
function renderMarkupElement(name, content, attr) {
var param = new Object();
param.tagname = name;
param.content = content;
param.attributes = "";
for (var i in attr) {
if (!attr[i])
continue;
param.attributes += " " + i + "="" + attr[i] + """;
}
renderSkin("htmltag", param);
return;
}
global/htmltag.skin
<<% param.tagname %><% param.attributes
%>><% param.content %></<% param.tagname %>>
this way, any xhtml element could be rendered with only one skin. however, still the attributes are somehow residing in the script and not in the skin, and probably this approach is not as flexible as it should be...

what do you think?

link  

 
hns, May 16, 2002 at 6:21:17 PM CEST

genius!

but we don't even need the skin, I think. Since HTML and XML tags always look the same (and this is infact cast in stone for eternity), we could directly write out the formatted tag in the global renderMarkupElement() function.

Very smart + elegant!

Re: fexibility: This is a perfect solution whenever tags are "pushed" from the code. When they're pulled together from skins, the skin author has to do with what macros are provided anyway, so I'd say this is nothing to worry about here.

link  

 
robert, May 16, 2002 at 7:04:23 PM CEST

yeeha!

this looks fabulous! +1 for directly writing out the tag in renderMarkupElement(), and one question:

in your example you have attr.style = param.style; which i assume will end up as style="[css-definition]". now using an additional parameter "class" is prohibited by Fesi ("EcmaScriptParseException: Keyword ' class' reserved for future extension"), what about "sclass"? (not as nice, i know ...)

link  

 
tobi, May 16, 2002 at 8:11:52 PM CEST

we could do without class

because id will do the same (you just have to define your custom styles as "#cssDefinition", ie. using the hash instead of the period).

and no problem with backwards compatibility, because we can define both, the old "classes" as well as the new "ids" in one stylesheet:.title, #title {...}

thanks for supporting my proposal. i will include the tag in the code and get rid of the htmltag skin.

link  

 
hns, May 16, 2002 at 8:50:29 PM CEST

it sucks

to be forced to go one way or the other because something in the underlying technology interferes. But I think using

param["class"] = "...";

instead of

param.class = "...";

we can smuggle it past the parser.

link  

 
tobi, May 17, 2002 at 11:45:46 AM CEST

cool

if that'll work, i'll happily add it to the code. thanks!

link  


... comment
 
tobi, May 21, 2002 at 9:51:27 AM CEST

feedback?

did somebody try out the new code resp. take a look at it? your comments are appreciated.

link  

 
robert, May 21, 2002 at 3:48:43 PM CEST

sorry, tobi, i didn't have the time 'til now. i'll give it a try tonight.

link  

 
hns, May 21, 2002 at 5:26:44 PM CEST

If your changes are in the main branch then I'm using them already. Didn't see any special behaviour, but all i did was rendering main.hac pages.

link  

 
tobi, May 22, 2002 at 10:06:51 AM CEST

yes and no

the first steps i made (until i wrote the story above) i checked into the main cvs branch. however yesterday, i continued with the work and created a new branch called "devjamtobi". there are just too many lines of code that i had to touch, i was afraid to put it in the main branch. and because this time i already know that there are bugs in my current code, i think this was a good decision, too.

link  


... comment


The Antville Server Fund has been a great success. Thanks to everybody who contributed!
online for 8550 Days
last updated: 1/4/11, 10:22 AM
status
Youre not logged in ... Login
menu
November 2024
SunMonTueWedThuFriSat
12
3456789
10111213141516
17181920212223
24252627282930
July
recent
zfuture's house here is zfuture's
house
by zfuture (7/31/03, 2:59 AM)
i understand your concerns however,
i hardly can think of a solution. certainly, if the...
by tobi (7/29/03, 9:47 AM)
Found several more similar sites
listed This is getting to be quite a concern to...
by cobalt123 (7/27/03, 7:56 PM)
Second Post Alert on Referrer
bug livecatz I put this into "help" and now here:...
by cobalt123 (7/26/03, 7:14 PM)
well it's not easy to
find from here, anyway. think we should include a link,...
by tobi (7/24/03, 11:25 AM)
So finally I found
the helma Bugzilla - stupid me.
by mdornseif (7/24/03, 10:28 AM)
clock not that it's particularly
earthshattering but the antclock is running slow by about 15...
by kohlehydrat (7/23/03, 8:25 PM)
but blogosphere.us isn't can't really
be rated as spam can it?
by kohlehydrat (7/23/03, 8:08 PM)
More referrer spam www.webfrost.com
by Irene (7/23/03, 7:55 PM)
How to log skin names
I accessed to console?? Hi, I would like to know...
by winson (7/23/03, 4:12 PM)

Click here to get an XML version of this weblog.

Made with Antville
powered by
Helma Object Publisher