Thursday, 13. June 2002
hns,
June 13, 2002 at 3:59:18 PM CEST
Extensible Stories in Antville Yesterday I checked in a patch to the This great advantage to this is that it is now possible to add custom properties to stories (and, if desired, comments) with almost no effort. The only thing one has to do is to add macros for the custom parts both in the story (or comment) editor skin and in the story (or comment) skins where that part is to be displayed. Antville still requires a The macro used to edit or display story properties is called
while displaying a custom property called "teaser" might look like this:
The content macro takes one extra attribute called
would display the content part called "teaser" if it exists and the content part called "text" if not. If a part is not defined, nothing is displayed. I must say that I'm myself astounded by the flexibilty, simplicity and usefulness of this concept. A lot of things suddenly become very easy. Most of these are beyond what we will likely ever want to do with Antville, but it's still worth to pick out a few: stories in multiple languages, partitioning a story into multiple parts or over multiple pages, versioning ... the list goes on. Here's a quick look into how this is implemented. All in all, it was surprisingly simple because of Stefan's XML Extension. I'm using the native dumping/reading of Hopobjects, so all I have to do is create a transient Hopobject and add the content parts to it as properties. The Hopobject can be transformed into an XML string in one call of XML.writeToString(hopobject), and converted back from XML to Hopobject calling XML.readFromString(xmlstring). Basically, story content is managed via these three simple functions in story/objectFunctions.js: /** * Get a content part by name. */ function getContentPart (name) { var cnt = this.getContent(); return cnt[name]; } /** * Return the content parsed into a HopObject. */ function getContent () { if (!this.content) return new HopObject (); return Xml.readFromString (this.content); } /** * Set the content of this story object. */ function setContent (cnt) { this.content = Xml.writeToString (cnt); var raw = ""; for (var i in cnt) raw += cnt[i]+" "; this.rawcontent = raw; } (The last section in setContent() is used for writing the raw content without XML markup into a separate column for searching. I'm still thinking about other ways to search over story content. Just as a note, it would technically be possible to search for content in specific content parts using something like "%<partname>%searchterm%</partname>%".) The XML that's written to the DB looks something like this: <?xml version="1.0" encoding="UTF-8"?> <!-- printed by helma object publisher --> <!-- created Wed Jun 12 18:52:09 CEST 2002 --> <xmlroot xmlns:hop="http://www.helma.org/docs/gui I hope this gave you a good impression of what this feature is about and how it works. I'm curious to hear what you think.
tobi,
June 13, 2002 at 3:40:17 PM CEST
bug when registering when i enter a number (e.g. "123") into the field "username" at /members/register i get an Error in application 'antville': Syntax error detected near line 1, column 5, after "this" in string: 'this.123' |
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 Youre not logged in ... Login
... home
... topics ... galleries ... Home
... Tags
... Galleries
... about antville ... download ... macros.antville.org ... help.antville.org ... translate antville! ... antville home
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)
clock not that it's particularly
earthshattering but the antclock is running slow by about 15...
by kohlehydrat (7/23/03, 8:25 PM)
How to log skin names
I accessed to console?? Hi, I would like to know...
by winson (7/23/03, 4:12 PM)
|