Skip to content

Commit 76aaa18

Browse files
committed
Implement the new download area.
Use the new Configuration Parameters feature of Servlex.
1 parent 34c750e commit 76aaa18

File tree

5 files changed

+214
-12
lines changed

5 files changed

+214
-12
lines changed

expath-website/src/servlets.xsl

+126-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,130 @@
1515

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

18-
<xsl:param name="config-file" select="'../../../expath-website/config.xml'"/>
18+
<!--
19+
Display the download area page, from the files repository.
20+
-->
21+
<xsl:function name="app:download-area-servlet">
22+
<!-- the http request -->
23+
<xsl:param name="request" as="element(web:request)"/>
24+
<!-- the list of files -->
25+
<xsl:variable name="list" select="
26+
doc(resolve-uri('files.xml', web:config-param('web-files-dir')))/files"/>
27+
<web:response status="200" message="Ok">
28+
<web:body content-type="text/html" method="xhtml"/>
29+
</web:response>
30+
<xsl:variable name="doc" as="element(webpage)">
31+
<webpage menu="main" xmlns="">
32+
<title>EXPath - Download</title>
33+
<section>
34+
<title>Download</title>
35+
<para>Here are the latest version of the available components. For
36+
earlier versions, please check individual download areas.</para>
37+
<divider/>
38+
<xsl:apply-templates select="$list/area"/>
39+
</section>
40+
</webpage>
41+
</xsl:variable>
42+
<xsl:apply-templates select="$doc">
43+
<xsl:with-param name="page-name" select="'download'"/>
44+
</xsl:apply-templates>
45+
</xsl:function>
46+
47+
<xsl:template match="area[@dir]">
48+
<primary xmlns="">
49+
<title>
50+
<xsl:value-of select="name"/>
51+
</title>
52+
<para>
53+
<xsl:text>See the dedicated download </xsl:text>
54+
<link href="files/{ @dir }">
55+
<xsl:text>area</xsl:text>
56+
</link>
57+
<xsl:text> for all versions.</xsl:text>
58+
</para>
59+
<list>
60+
<xsl:for-each select="component">
61+
<item>
62+
<xsl:value-of select="name"/>
63+
<xsl:text>: </xsl:text>
64+
<link href="file/{ ../@dir }/{ file/@href }">
65+
<xsl:value-of select="file/@href"/>
66+
</link>
67+
</item>
68+
</xsl:for-each>
69+
</list>
70+
</primary>
71+
</xsl:template>
72+
73+
<!--
74+
Display a specific download area page, from the files repository.
75+
-->
76+
<xsl:function name="app:download-page-servlet">
77+
<!-- the http request -->
78+
<xsl:param name="request" as="element(web:request)"/>
79+
<!-- the name of the specific area -->
80+
<xsl:variable name="area-name" as="xs:string" select="
81+
$request/web:path/web:match[@name eq 'area']"/>
82+
<!-- the list of files -->
83+
<xsl:variable name="area" select="
84+
doc(resolve-uri(concat($area-name, '/__files.xml'), web:config-param('web-files-dir')))/area"/>
85+
<web:response status="200" message="Ok">
86+
<web:body content-type="text/html" method="xhtml"/>
87+
</web:response>
88+
<xsl:variable name="doc" as="element(webpage)">
89+
<webpage menu="download" xmlns="" root="..">
90+
<title>EXPath - Download</title>
91+
<section>
92+
<title>
93+
<xsl:text>Download: </xsl:text>
94+
<xsl:value-of select="$area/name"/>
95+
</title>
96+
<xsl:apply-templates select="$area/component"/>
97+
</section>
98+
</webpage>
99+
</xsl:variable>
100+
<xsl:apply-templates select="$doc">
101+
<xsl:with-param name="page-name" select="'download'"/>
102+
</xsl:apply-templates>
103+
</xsl:function>
104+
105+
<xsl:template match="component">
106+
<primary xmlns="">
107+
<title>
108+
<xsl:value-of select="name"/>
109+
</title>
110+
<list>
111+
<xsl:for-each select="file">
112+
<item>
113+
<link href="../file/{ ../../@dir }/{ @href }">
114+
<xsl:value-of select="@href"/>
115+
</link>
116+
</item>
117+
</xsl:for-each>
118+
</list>
119+
</primary>
120+
</xsl:template>
121+
122+
<!--
123+
Return a file straight from the web-files repository.
124+
-->
125+
<xsl:function name="app:download-file-servlet">
126+
<!-- the http request -->
127+
<xsl:param name="request" as="element(web:request)"/>
128+
<!-- the url param 'resource' -->
129+
<xsl:variable name="area" select="$request/web:path/web:match[@name eq 'area']"/>
130+
<xsl:variable name="file" select="$request/web:path/web:match[@name eq 'file']"/>
131+
<!-- the resolved file for the resource -->
132+
<xsl:variable name="href" select="
133+
resolve-uri(
134+
concat($area, '/', $file),
135+
web:config-param('web-files-dir'))"/>
136+
<!-- TODO: Is there a way to test the file exists? -->
137+
<!-- TODO: Find a way to set the proper content-type... In __files.xml, maybe? -->
138+
<web:response status="200" message="Ok">
139+
<web:body content-type="application/octet-stream" src="{ $href }"/>
140+
</web:response>
141+
</xsl:function>
19142

20143
<!--
21144
Display a page from the page repository, which must be a 'webpage' XML document.
@@ -93,7 +216,7 @@
93216
<xsl:sequence select="
94217
resolve-uri(
95218
concat($page, '.xml'),
96-
doc($config-file)/config/web-content-dir)"/>
219+
web:config-param('web-content-dir'))"/>
97220
</xsl:function>
98221

99222
<!--
@@ -313,8 +436,7 @@
313436

314437
<xsl:function name="app:get-spec-list" as="element(specs)">
315438
<xsl:param name="param" as="xs:string"/>
316-
<xsl:variable name="dir" as="xs:string" select="
317-
doc($config-file)/config/*[local-name(.) eq $param]"/>
439+
<xsl:variable name="dir" as="xs:string" select="web:config-param($param)"/>
318440
<xsl:sequence select="
319441
doc(resolve-uri('list.xml', $dir))/specs"/>
320442
</xsl:function>

expath-website/src/sitemap.xml

+23
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,20 @@
125125
<item name="resources" href="resources" title="EXPath Resources">Resources</item>
126126
<item name="map" href="map" title="EXPath Website Map">Map</item>
127127
<item name="wiki" href="http://wiki.expath.org/wiki/EXPath" title="EXPath Wiki">Wiki</item>
128+
<item name="download" href="files" title="EXPath Downloads">Download</item>
129+
</menu>
130+
131+
<menu name="download">
132+
<item name="nop" href=".." title="EXPath Home">Home</item>
133+
<item name="news" href="../news" title="EXPath News">News</item>
134+
<item name="faq" href="../faq" title="EXPath FAQ">FAQ</item>
135+
<item name="lists" href="../lists" title="EXPath Mailing Lists">Lists</item>
136+
<item name="modules" href="../modules" title="EXPath Modules">Modules</item>
137+
<item name="specs" href="../specs" title="EXPath Specifications">Specs</item>
138+
<item name="index" href="../resources" title="EXPath Resources">Resources</item>
139+
<item name="map" href="../map" title="EXPath Website Map">Map</item>
140+
<item name="wiki" href="http://wiki.expath.org/wiki/EXPath" title="EXPath Wiki">Wiki</item>
141+
<item name="download" href="../files" title="EXPath Downloads">Download</item>
128142
</menu>
129143

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

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

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

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

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

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

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

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

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

211234
</sitemap>

expath-website/src/webpage.xsl

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
<xsl:text>EXPath website version </xsl:text>
109109
<xsl:value-of select="$version"/>
110110
<xsl:text> (revision #</xsl:text>
111-
<a href="http://code.google.com/p/expath/source/browse/trunk?r={ $revision }#trunk%2Fwebsite%2Fsrc">
111+
<a href="http://github.com/expath/website/commit/{ $revision }">
112112
<xsl:value-of select="$revision"/>
113113
</a>
114114
<xsl:text>)</xsl:text>

expath-website/xproject/expath-web.xml

+63-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,36 @@
1-
<webapp xmlns="http://expath.org/ns/webapp/descriptor"
1+
<webapp xmlns="http://expath.org/ns/webapp"
22
xmlns:app="http://expath.org/ns/website"
33
name="http://expath.org/website"
44
abbrev="expath"
5-
version="0.5.0pre1">
5+
version="0.5.0pre2">
6+
7+
<!--
8+
TODO: Create a proper error handler!
9+
-->
610

711
<title>EXPath website</title>
812

13+
<config-param id="org-spec-dir">
14+
<name>Legacy specification directory</name>
15+
<desc>The directory in the EXPath.org source repository where to find the specifications (and
16+
containing the file "list.xml"). See https://code.google.com/p/expath/.</desc>
17+
<uri>../../../expath-website/org-specs/</uri>
18+
</config-param>
19+
20+
<config-param id="w3c-spec-dir">
21+
<name>W3C specification directory</name>
22+
<desc>The directory in the W3C EXPath CG source repository where to find the specifications
23+
(and containing the file "list.xml"). See https://github.com/expath/expath-cg/.</desc>
24+
<uri>../../../expath-website/expath-cg/specs/</uri>
25+
</config-param>
26+
27+
<config-param id="web-content-dir">
28+
<name>Web content directory</name>
29+
<desc>The directory in the EXPath Web Content source repository where to find the pages
30+
content. See https://github.com/expath/web-content/.</desc>
31+
<uri>../../../expath-website/web-content/pages/</uri>
32+
</config-param>
33+
934
<resource pattern="/style/.+.css" media-type="text/css"/>
1035
<resource pattern="/js/.+.js" media-type="text/javascript"/>
1136
<resource pattern="/images/.+.png" media-type="image/png"/>
@@ -54,10 +79,10 @@
5479
<match group="6" name="xml"/>
5580
</url>
5681
<!--
57-
To resolve the above TODO, add the ability to have several URL elements
58-
for the same SERVLET, binding several URL patterns to the same servlet.
59-
In this case, one with an optional date (but no editor), and one with
60-
a mandatory editor.
82+
To resolve the above TODO, add the ability to have several URL elements
83+
for the same SERVLET, binding several URL patterns to the same servlet.
84+
In this case, one with an optional date (but no editor), and one with
85+
a mandatory editor.
6186
<url pattern="/spec/([-a-z]+)(/20[0-9]{6})?(/diff)?(.xml)?">
6287
<match group="1" name="spec"/>
6388
<match group="2" name="date"/>
@@ -84,6 +109,38 @@
84109
</url>
85110
</servlet>
86111

112+
<!--
113+
The generated download area.
114+
-->
115+
<servlet name="download">
116+
<xslt uri="http://expath.org/ns/website/servlets.xsl"
117+
function="app:download-area-servlet"/>
118+
<url pattern="/files"/>
119+
</servlet>
120+
121+
<!--
122+
A specific download area page.
123+
-->
124+
<servlet name="area">
125+
<xslt uri="http://expath.org/ns/website/servlets.xsl"
126+
function="app:download-page-servlet"/>
127+
<url pattern="/files/([-a-z0-9]+)">
128+
<match group="1" name="area"/>
129+
</url>
130+
</servlet>
131+
132+
<!--
133+
Downloading a file straight from the web-files repository.
134+
-->
135+
<servlet name="file">
136+
<xslt uri="http://expath.org/ns/website/servlets.xsl"
137+
function="app:download-file-servlet"/>
138+
<url pattern="/file/([-a-z0-9]+)/([^/]+)">
139+
<match group="1" name="area"/>
140+
<match group="2" name="file"/>
141+
</url>
142+
</servlet>
143+
87144
<!--
88145
A simple, plain page.
89146
-->

expath-website/xproject/project.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<project xmlns="http://expath.org/ns/project"
22
name="http://expath.org/website"
33
abbrev="expath-website"
4-
version="0.5.0pre1">
4+
version="0.5.0pre2">
55

66
<title>EXPath website</title>
77

0 commit comments

Comments
 (0)