Skip to content

Commit

Permalink
Implement the new download area.
Browse files Browse the repository at this point in the history
Use the new Configuration Parameters feature of Servlex.
  • Loading branch information
fgeorges committed Dec 28, 2013
1 parent 34c750e commit 76aaa18
Show file tree
Hide file tree
Showing 5 changed files with 214 additions and 12 deletions.
130 changes: 126 additions & 4 deletions expath-website/src/servlets.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,130 @@

<xsl:param name="menus" as="element(menu)+" select="doc('sitemap.xml')/sitemap/menu"/>

<xsl:param name="config-file" select="'../../../expath-website/config.xml'"/>
<!--
Display the download area page, from the files repository.
-->
<xsl:function name="app:download-area-servlet">
<!-- the http request -->
<xsl:param name="request" as="element(web:request)"/>
<!-- the list of files -->
<xsl:variable name="list" select="
doc(resolve-uri('files.xml', web:config-param('web-files-dir')))/files"/>
<web:response status="200" message="Ok">
<web:body content-type="text/html" method="xhtml"/>
</web:response>
<xsl:variable name="doc" as="element(webpage)">
<webpage menu="main" xmlns="">
<title>EXPath - Download</title>
<section>
<title>Download</title>
<para>Here are the latest version of the available components. For
earlier versions, please check individual download areas.</para>
<divider/>
<xsl:apply-templates select="$list/area"/>
</section>
</webpage>
</xsl:variable>
<xsl:apply-templates select="$doc">
<xsl:with-param name="page-name" select="'download'"/>
</xsl:apply-templates>
</xsl:function>

<xsl:template match="area[@dir]">
<primary xmlns="">
<title>
<xsl:value-of select="name"/>
</title>
<para>
<xsl:text>See the dedicated download </xsl:text>
<link href="files/{ @dir }">
<xsl:text>area</xsl:text>
</link>
<xsl:text> for all versions.</xsl:text>
</para>
<list>
<xsl:for-each select="component">
<item>
<xsl:value-of select="name"/>
<xsl:text>: </xsl:text>
<link href="file/{ ../@dir }/{ file/@href }">
<xsl:value-of select="file/@href"/>
</link>
</item>
</xsl:for-each>
</list>
</primary>
</xsl:template>

<!--
Display a specific download area page, from the files repository.
-->
<xsl:function name="app:download-page-servlet">
<!-- the http request -->
<xsl:param name="request" as="element(web:request)"/>
<!-- the name of the specific area -->
<xsl:variable name="area-name" as="xs:string" select="
$request/web:path/web:match[@name eq 'area']"/>
<!-- the list of files -->
<xsl:variable name="area" select="
doc(resolve-uri(concat($area-name, '/__files.xml'), web:config-param('web-files-dir')))/area"/>
<web:response status="200" message="Ok">
<web:body content-type="text/html" method="xhtml"/>
</web:response>
<xsl:variable name="doc" as="element(webpage)">
<webpage menu="download" xmlns="" root="..">
<title>EXPath - Download</title>
<section>
<title>
<xsl:text>Download: </xsl:text>
<xsl:value-of select="$area/name"/>
</title>
<xsl:apply-templates select="$area/component"/>
</section>
</webpage>
</xsl:variable>
<xsl:apply-templates select="$doc">
<xsl:with-param name="page-name" select="'download'"/>
</xsl:apply-templates>
</xsl:function>

<xsl:template match="component">
<primary xmlns="">
<title>
<xsl:value-of select="name"/>
</title>
<list>
<xsl:for-each select="file">
<item>
<link href="../file/{ ../../@dir }/{ @href }">
<xsl:value-of select="@href"/>
</link>
</item>
</xsl:for-each>
</list>
</primary>
</xsl:template>

<!--
Return a file straight from the web-files repository.
-->
<xsl:function name="app:download-file-servlet">
<!-- the http request -->
<xsl:param name="request" as="element(web:request)"/>
<!-- the url param 'resource' -->
<xsl:variable name="area" select="$request/web:path/web:match[@name eq 'area']"/>
<xsl:variable name="file" select="$request/web:path/web:match[@name eq 'file']"/>
<!-- the resolved file for the resource -->
<xsl:variable name="href" select="
resolve-uri(
concat($area, '/', $file),
web:config-param('web-files-dir'))"/>
<!-- TODO: Is there a way to test the file exists? -->
<!-- TODO: Find a way to set the proper content-type... In __files.xml, maybe? -->
<web:response status="200" message="Ok">
<web:body content-type="application/octet-stream" src="{ $href }"/>
</web:response>
</xsl:function>

<!--
Display a page from the page repository, which must be a 'webpage' XML document.
Expand Down Expand Up @@ -93,7 +216,7 @@
<xsl:sequence select="
resolve-uri(
concat($page, '.xml'),
doc($config-file)/config/web-content-dir)"/>
web:config-param('web-content-dir'))"/>
</xsl:function>

<!--
Expand Down Expand Up @@ -313,8 +436,7 @@

<xsl:function name="app:get-spec-list" as="element(specs)">
<xsl:param name="param" as="xs:string"/>
<xsl:variable name="dir" as="xs:string" select="
doc($config-file)/config/*[local-name(.) eq $param]"/>
<xsl:variable name="dir" as="xs:string" select="web:config-param($param)"/>
<xsl:sequence select="
doc(resolve-uri('list.xml', $dir))/specs"/>
</xsl:function>
Expand Down
23 changes: 23 additions & 0 deletions expath-website/src/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,20 @@
<item name="resources" href="resources" title="EXPath Resources">Resources</item>
<item name="map" href="map" title="EXPath Website Map">Map</item>
<item name="wiki" href="http://wiki.expath.org/wiki/EXPath" title="EXPath Wiki">Wiki</item>
<item name="download" href="files" title="EXPath Downloads">Download</item>
</menu>

<menu name="download">
<item name="nop" href=".." title="EXPath Home">Home</item>
<item name="news" href="../news" title="EXPath News">News</item>
<item name="faq" href="../faq" title="EXPath FAQ">FAQ</item>
<item name="lists" href="../lists" title="EXPath Mailing Lists">Lists</item>
<item name="modules" href="../modules" title="EXPath Modules">Modules</item>
<item name="specs" href="../specs" title="EXPath Specifications">Specs</item>
<item name="index" href="../resources" title="EXPath Resources">Resources</item>
<item name="map" href="../map" title="EXPath Website Map">Map</item>
<item name="wiki" href="http://wiki.expath.org/wiki/EXPath" title="EXPath Wiki">Wiki</item>
<item name="download" href="../files" title="EXPath Downloads">Download</item>
</menu>

<menu name="oxygen">
Expand All @@ -137,6 +151,7 @@
<item name="index" href="../resources" title="EXPath Resources">Resources</item>
<item name="map" href="../map" title="EXPath Website Map">Map</item>
<item name="wiki" href="http://wiki.expath.org/wiki/EXPath" title="EXPath Wiki">Wiki</item>
<item name="download" href="../files" title="EXPath Downloads">Download</item>
</menu>

<menu name="binary">
Expand All @@ -146,6 +161,7 @@
<item name="samples" href="samples" title="EXPath Binary Samples">Samples</item>
<item name="spec" href="../../spec/binary" title="EXPath Binary Spec">Specification</item>
<item name="wiki" href="http://wiki.expath.org/wiki/Binary" title="EXPath Binary Wiki">Wiki</item>
<item name="download" href="../../files" title="EXPath Downloads">Download</item>
</menu>

<menu name="file">
Expand All @@ -155,6 +171,7 @@
<item name="samples" href="samples" title="EXPath File Samples">Samples</item>
<item name="spec" href="../../spec/file" title="EXPath File Spec">Specification</item>
<item name="wiki" href="http://wiki.expath.org/wiki/File" title="EXPath Wiki">Wiki</item>
<item name="download" href="../../files" title="EXPath Downloads">Download</item>
</menu>

<menu name="geo">
Expand All @@ -164,6 +181,7 @@
<!--item name="samples" href="samples" title="EXPath Geo Samples">Samples</item-->
<item name="spec" href="../../spec/geo" title="EXPath Geo Spec">Specification</item>
<item name="wiki" href="http://wiki.expath.org/wiki/Geo" title="EXPath Wiki">Wiki</item>
<item name="download" href="../../files" title="EXPath Downloads">Download</item>
</menu>

<menu name="hc">
Expand All @@ -173,6 +191,7 @@
<item name="samples" href="samples" title="EXPath HTTP Client Samples">Samples</item>
<item name="spec" href="../../spec/http-client" title="EXPath HTTP Client Spec">Specification</item>
<item name="wiki" href="http://wiki.expath.org/wiki/HttpClient" title="EXPath Wiki">Wiki</item>
<item name="download" href="../../files" title="EXPath Downloads">Download</item>
</menu>

<menu name="pkg">
Expand All @@ -181,6 +200,7 @@
<item name="implems" href="implems" title="EXPath Packaging Implems">Implementations</item>
<item name="spec" href="../../spec/pkg" title="EXPath Packaging Spec">Specification</item>
<item name="wiki" href="http://wiki.expath.org/wiki/Packaging" title="EXPath Wiki">Wiki</item>
<item name="download" href="../../files" title="EXPath Downloads">Download</item>
</menu>

<menu name="webapp">
Expand All @@ -190,13 +210,15 @@
<item name="samples" href="samples" title="EXPath Webapp Samples">Samples</item>
<item name="spec" href="../../spec/webapp" title="EXPath Webapp Spec">Specification</item>
<item name="wiki" href="http://wiki.expath.org/wiki/Webapp" title="EXPath Wiki">Wiki</item>
<item name="download" href="../../files" title="EXPath Downloads">Download</item>
</menu>

<menu name="xproj">
<item name="parent" href="../../modules" title="Modules">[ ../Modules ]</item>
<item name="index" href="." title="XProject Home">XProject</item>
<item name="oxygen" href="oxygen" title="XProject plugin for oXygen">oXygen Plugin</item>
<item name="wiki" href="http://wiki.expath.org/wiki/XProject" title="EXPath Wiki">Wiki</item>
<item name="download" href="../../files" title="EXPath Downloads">Download</item>
</menu>

<menu name="zip">
Expand All @@ -206,6 +228,7 @@
<item name="samples" href="samples" title="EXPath ZIP Samples">Samples</item>
<item name="spec" href="../../spec/zip" title="EXPath ZIP Spec">Specification</item>
<item name="wiki" href="http://wiki.expath.org/wiki/Zip" title="EXPath Wiki">Wiki</item>
<item name="download" href="../../files" title="EXPath Downloads">Download</item>
</menu>

</sitemap>
2 changes: 1 addition & 1 deletion expath-website/src/webpage.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
<xsl:text>EXPath website version </xsl:text>
<xsl:value-of select="$version"/>
<xsl:text> (revision #</xsl:text>
<a href="http://code.google.com/p/expath/source/browse/trunk?r={ $revision }#trunk%2Fwebsite%2Fsrc">
<a href="http://github.com/expath/website/commit/{ $revision }">
<xsl:value-of select="$revision"/>
</a>
<xsl:text>)</xsl:text>
Expand Down
69 changes: 63 additions & 6 deletions expath-website/xproject/expath-web.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
<webapp xmlns="http://expath.org/ns/webapp/descriptor"
<webapp xmlns="http://expath.org/ns/webapp"
xmlns:app="http://expath.org/ns/website"
name="http://expath.org/website"
abbrev="expath"
version="0.5.0pre1">
version="0.5.0pre2">

<!--
TODO: Create a proper error handler!
-->

<title>EXPath website</title>

<config-param id="org-spec-dir">
<name>Legacy specification directory</name>
<desc>The directory in the EXPath.org source repository where to find the specifications (and
containing the file "list.xml"). See https://code.google.com/p/expath/.</desc>
<uri>../../../expath-website/org-specs/</uri>
</config-param>

<config-param id="w3c-spec-dir">
<name>W3C specification directory</name>
<desc>The directory in the W3C EXPath CG source repository where to find the specifications
(and containing the file "list.xml"). See https://github.com/expath/expath-cg/.</desc>
<uri>../../../expath-website/expath-cg/specs/</uri>
</config-param>

<config-param id="web-content-dir">
<name>Web content directory</name>
<desc>The directory in the EXPath Web Content source repository where to find the pages
content. See https://github.com/expath/web-content/.</desc>
<uri>../../../expath-website/web-content/pages/</uri>
</config-param>

<resource pattern="/style/.+.css" media-type="text/css"/>
<resource pattern="/js/.+.js" media-type="text/javascript"/>
<resource pattern="/images/.+.png" media-type="image/png"/>
Expand Down Expand Up @@ -54,10 +79,10 @@
<match group="6" name="xml"/>
</url>
<!--
To resolve the above TODO, add the ability to have several URL elements
for the same SERVLET, binding several URL patterns to the same servlet.
In this case, one with an optional date (but no editor), and one with
a mandatory editor.
To resolve the above TODO, add the ability to have several URL elements
for the same SERVLET, binding several URL patterns to the same servlet.
In this case, one with an optional date (but no editor), and one with
a mandatory editor.
<url pattern="/spec/([-a-z]+)(/20[0-9]{6})?(/diff)?(.xml)?">
<match group="1" name="spec"/>
<match group="2" name="date"/>
Expand All @@ -84,6 +109,38 @@
</url>
</servlet>

<!--
The generated download area.
-->
<servlet name="download">
<xslt uri="http://expath.org/ns/website/servlets.xsl"
function="app:download-area-servlet"/>
<url pattern="/files"/>
</servlet>

<!--
A specific download area page.
-->
<servlet name="area">
<xslt uri="http://expath.org/ns/website/servlets.xsl"
function="app:download-page-servlet"/>
<url pattern="/files/([-a-z0-9]+)">
<match group="1" name="area"/>
</url>
</servlet>

<!--
Downloading a file straight from the web-files repository.
-->
<servlet name="file">
<xslt uri="http://expath.org/ns/website/servlets.xsl"
function="app:download-file-servlet"/>
<url pattern="/file/([-a-z0-9]+)/([^/]+)">
<match group="1" name="area"/>
<match group="2" name="file"/>
</url>
</servlet>

<!--
A simple, plain page.
-->
Expand Down
2 changes: 1 addition & 1 deletion expath-website/xproject/project.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<project xmlns="http://expath.org/ns/project"
name="http://expath.org/website"
abbrev="expath-website"
version="0.5.0pre1">
version="0.5.0pre2">

<title>EXPath website</title>

Expand Down

0 comments on commit 76aaa18

Please sign in to comment.