Re: My Portal with XSLT
Christophe Fergeau <[email protected]>
| Newsgroups | gmane.comp.web.galeon.devel |
|---|---|
| Message-ID | <[email protected]> |
Did you compare rendering of large bookmark files ? I'm wondering how big the perf impact will be. Otherwise I think using an xslt stylesheet for that is the right thing to do (and that's something I should have done 2 years ago when I remembered xslt :p) Christophe Le sam 01/03/2003 à 14:53, Tommi Komulainen a écrit : > > Hi all, > > I've been playing around with XSLT attempting to generate the My Portal > page with it, instead of doing silly things like hardcoding the portal > structure in code. IMHO, XSLT is just the right tool for the job. If > you look at what XSLT does, you should be convinced too ;) > > Please find attached a stylesheet I've got almost finished. The page > the stylesheet generates should be identical (within reason) to the new > My Portal in 1.3.2. See the attached XHTML file for yourself, it's > generated from the default-bookmarks.xbel (you should have galeon > installed in /usr/local or the CSS and icons can't be found and the page > will look rather dull) > > You can still customize basically every aspect of My Portal by modifying > the XSLT stylesheet, but I bet it'll be much easier than editing the > code. XSLT will also enable you to generate the My Portal page without > running galeon. > > You can use the following command to try the stylesheet on your own > bookmarks and see if anything breaks: > > xsltproc myportal.xsl bookmarks.xbel >myportal.html > > (add '--stringparam prefix /opt/gnome' if you've installed galeon in > /opt/gnome instead of the default /usr/local) > > > Now, what's really going to rock your socks off is that if you add > > <?xml-stylesheet href="myportal.xsl" type="text/xsl"?> > > in the beginning of the bookmarks.xbel file, you can simply open the > bookmarks file itself in the browser and see My Portal. Well, almost, > smart bookmarks text entries seem to disappear somewhere, but anyway... > > > What do you think? Could this be used as new My Portal? > > > -- > Tommi Komulainen [email protected] > GPG 1024D/68388EE6 6FD6 DD79 EB38 BF6F 3533 09C0 04A8 9871 6838 8EE6 > ---- > > > <?xml version="1.0"?> > <!-- myportal.xsl - XSL stylesheet for converting (Galeon) XBEL bookmarks file > - into Galeon My Portal. > - > - Copyright (C) 2003 Tommi Komulainen <[email protected]> > - Available under the terms of the GNU General Public License version 2. > --> > <xsl:stylesheet version="1.0" > xmlns="http://www.w3.org/1999/xhtml" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns:str="http://exslt.org/strings" > exclude-result-prefixes="str" > extension-element-prefixes="str"> > > <xsl:output method="xml" indent="yes" encoding="utf-8" > media-type="text/html" > omit-xml-declaration="no" > doctype-public="-//W3C//DTD XHTML Transitional 1.0//EN" > doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" > /> > > <!-- default installation prefix, can be overridden with for example > - xsltproc -\-stringparam prefix /opt/gnome --> > <xsl:param name="prefix" select="'/usr/local'" /> > > <!-- other helpful variables, don't touch --> > <xsl:variable name="datadir" select="concat('file:',$prefix,'/share/galeon')"/> > <xsl:variable name="galeon">http://galeon.sourceforge.net/</xsl:variable> > > <!-- My Portal --> > <xsl:template match="/"> > > <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> > <head> > <link rel="stylesheet" type="text/css" href="{concat($datadir,'/myportal.css')}"/> > <title>My Portal</title> > </head> > > <body> > <!-- header --> > <div class="top_bar"> > <table cellpadding="2" cellspacing="0" width="100%" border="0"> > <tbody> > <tr> > <td><img alt="" src="{concat($datadir,'/galeon.png')}" />myportal:</td> > </tr> > </tbody> > </table> > </div> > > <div class="top2"> > <a href="http://galeon.sourceforge.net/"> > <img class="logo" alt="Galeon logo" src="{concat($datadir,'/logo.png')}" /> > </a> > </div> > <p><br /></p> > > <!-- add all bookmarks here --> > <xsl:apply-templates select="xbel"/> > <!-- or we could also use this to show only particular folder --> > <!-- <xsl:apply-templates select="//folder[title = $path]"/> --> > > <!-- footer --> > <div class="bottom_bar"><center><b>Galeon</b> : <i>the web, only the web</i></center></div> > </body></html> > </xsl:template> > <!-- /My Portal --> > > <!-- xbel --> > <xsl:template match="xbel"> > <blockquote> > <a class="heading"><strong>Bookmarks</strong></a> > <xsl:apply-templates select="folder|bookmark|separator|alias"/> > </blockquote> > </xsl:template> > <!-- /xbel --> > > <!-- folder --> > <xsl:template match="folder"> > <blockquote> > <a class="heading"> > <strong> > <xsl:value-of select="title"/> > </strong> > </a> > <br /> > <xsl:apply-templates select="folder|bookmark|separator|alias"/> > </blockquote> > </xsl:template> > <!-- /folder --> > > <!-- separator --> > <xsl:template match="separator"> > <br /> > </xsl:template> > <!-- /separator --> > > <!-- alias --> > <xsl:template match="alias"> > <xsl:variable name="ref"><xsl:value-of select="@ref"/></xsl:variable> > <!-- get the bookmark or folder the alias is referring to > - > - TODO currently this is limited to just bookmarks, because I just > - can't figure out how to avoid infinite recursion that happens > - with folders... --> > <!-- <xsl:apply-templates select="//*[@id = $ref]"/> --> > <i> > <xsl:apply-templates select="//bookmark[@id = $ref]"/> > </i> > </xsl:template> > <!-- /alias --> > > <!-- bookmark --> > <xsl:template match="bookmark"> > <a href="{@href}"> > <xsl:value-of select="title"/> > </a> > </xsl:template> > <!-- /bookmark --> > > <!-- smart bookmark --> > <xsl:template match="bookmark[info/metadata[@owner = $galeon]/smarturl]"> > > <xsl:variable name="smarturl" > select="info/metadata[@owner = $galeon]/smarturl" /> > <xsl:variable name="pixmap" > select="info/metadata[@owner = $galeon]/pixmap" /> > > <!-- submit url is the part before the query string > - XXX why are we using GET? --> > <form method="get" action="{substring-before($smarturl, '?')}"> > > <xsl:variable name="query" select="substring-after($smarturl, '?')" /> > > <!-- parameters are separated by ampersands '&' --> > <xsl:for-each select="str:tokenize($query, '&')"> > > <!-- param := name [ '=' value ] --> > <xsl:variable name="name" select="substring-before(., '=')"/> > <xsl:variable name="value" select="substring-after(., '=')"/> > > <xsl:choose> > <!-- parameter with variable value --> > <xsl:when test="$value = '%s'"> > <input type="text" name="{$name}" value="" size="30" /> > </xsl:when> > > <!-- parameter without a value (I think) --> > <xsl:when test="$name = $value"> > <input type="hidden" name="{$name}" />> > </xsl:when> > > <!-- parameter with fixed value --> > <xsl:otherwise> > <input type="hidden" name="{$name}" value="{$value}" /> > </xsl:otherwise> > </xsl:choose> > </xsl:for-each> > > <!-- use image for submit if we have one, ordinary button otherwise --> > <xsl:choose> > <xsl:when test="$pixmap"> > <input type="image" value="{title}" src="{$pixmap}" /> > </xsl:when> > > <xsl:otherwise> > <input type="submit" value="{title}" /> > </xsl:otherwise> > </xsl:choose> > </form> > </xsl:template> > <!-- /smart bookmark --> > > </xsl:stylesheet> > <!-- vim: set sts=2 sw=2: --> > ---- > myportal: Galeon logo Bookmarks New bookmarks GNU / Linux Free Software Foundation (FSF) Gnome Gnome.org Footnotes - Gnome News Portal GNOME Hispano Gnome User's Support Forum Gnome Support.org Galeon: the web, only the web Development The GNOME Developer Site Gnome Mailing Lists Gnome Bugzilla Api Documentation News Desktop Linux OSNews Pclinuxonline Slashdot Internet The World Wide Web Consortium Galeon: the web, only the web Toolbar Bookmarklets More Bookmarklets Old versions of this page More Info About... Zoom on First Image... Page Color... Scroll Page (very slow) Scroll Page (slow) Scroll Page (fast) Scroll Page (very fast) Scroll Page... (variable) Page Freshness? Go To Selected URL Duplicate Page Set In-Page Bookmark Go To In-Page Bookmark Read Cookie for Site AutoFill Anonymous Translate to English Sample Smart Bookmarks Galeon : the web, only the web
signature.asc
(application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.0 (GNU/Linux) iD8DBQA+YMZO+13jZzlzSs4RAjjeAJ97SLWB0hZ5WKHvlCN+yOzd9lbPfgCfZMyu nHjxcaRzhWWTGdDMcsUU6OE= =OHDb -----END PGP SIGNATURE-----