Wiki source code of Extensions Wiki
Version 56.2 by Denis Gervalle on 2015/10/28 13:55
Hide last authors
author | version | line-number | content |
---|---|---|---|
50.1 | 1 | {{velocity}} | |
54.1 | 2 | ## This pages serves 3 purposes: | |
3 | ## - Used by the Extension Manager UI to display the extension page for an extension based on the Maven <url> element which are set to http://extension.xwiki.org/?id=${groupId}:${artifactId}:::... | ||
4 | ## - Used by the Javadoc to display external link, which based on the Maven <url> are set to http://extension.xwiki.org/?id=${groupId}:${artifactId}:::?id=groupid:artifactid:version:::.../apidocs/....html?is-external=true. Also support old Javadoc (pre-6.2) to display external link, which does not have version in URL. | ||
5 | ## - Displays the list of extensions (when there's no "id" request parameter) using Extension.WebHome | ||
50.1 | 6 | ## | |
7 | #if ("$!request.id" != "") | ||
52.1 | 8 | ## Remove the part after ":::" (see top level pom.xml source for explanation as to why) | |
54.1 | 9 | #set ($mid = $stringtool.substringBefore($request.id, ":::")) | |
10 | ## Find out if we receive a link to javadoc | ||
11 | #set ($jdoc = $stringtool.substringAfter($request.id, "/apidocs/")) | ||
12 | ## Parse module id | ||
13 | #set ($pmid = $stringtool.split($mid,":",3)) | ||
14 | #set ($gid = $pmid[0]) | ||
15 | #set ($artid = $pmid[1]) | ||
16 | ## Determine the version | ||
17 | #if ($pmid.size() > 2) | ||
18 | #set ($version = $pmid[2]) | ||
19 | #else | ||
20 | ## Version is not in the URL and we are targetting Javadoc, so try to get it from the referer | ||
21 | #if ($jdoc) | ||
22 | #set ($referer = $request.getHeader("Referer")) | ||
23 | #if ($referer) | ||
24 | #set ($jmod = $stringtool.split($stringtool.substringAfterLast($stringtool.substringBefore($referer, "-javadoc"),"/"),".")) | ||
25 | #set ($version = "${stringtool.substringAfterLast($jmod[0],'-')}.${jmod[1]}") | ||
26 | #end | ||
27 | #end | ||
28 | ## No version has been found, use the version of this wiki as a default | ||
29 | #if (!$version) | ||
30 | #set ($version = $xwiki.version) | ||
31 | #end | ||
32 | #end | ||
33 | ## If we are targetting Javadoc, redirect to it through our nexus, else determine the id of the module | ||
55.1 | 34 | #if ($jdoc != "") | |
54.1 | 35 | #set ($gid = $stringtool.replace($gid, ".", "/")) | |
36 | $response.sendRedirect("http://nexus.xwiki.org/nexus/service/local/repositories/releases/archive/${gid}/${artid}/${version}/${artid}-${version}-javadoc.jar/!/${jdoc}") | ||
37 | #else | ||
38 | #set($id = "${gid}:${artid}") | ||
39 | #end | ||
50.1 | 40 | ## Locate the extension by its id | |
51.1 | 41 | ## Special case, if the id is the one of the top level POM, then redirect to the main wiki | |
52.1 | 42 | #if ($id == "org.xwiki.commons:xwiki-commons") | |
54.1 | 43 | $response.sendRedirect($xwiki.getURL("xwiki:Main.WebHome")) | |
50.1 | 44 | #else | |
54.1 | 45 | #set ($xwql = "where doc.object(ExtensionCode.ExtensionClass).id = '$id'") | |
46 | #set ($result = $services.query.xwql($xwql).execute()) | ||
47 | #if ($result.size() > 0) | ||
51.1 | 48 | $response.sendRedirect($xwiki.getURL($result.get(0))) | |
49 | #else | ||
56.2 | 50 | ## Search aliases in older versions | |
51 | #set ($xwql = "where doc.object(ExtensionCode.ExtensionVersionClass).id = '$id'") | ||
52 | #set ($result = $services.query.xwql($xwql).execute()) | ||
53 | #if ($result.size() > 0) | ||
54 | $response.sendRedirect($xwiki.getURL($result.get(0))) | ||
55 | #else | ||
56 | ## Unknown ID, list all extensions | ||
57 | {{include document="Extension.WebHome"/}} | ||
58 | #end | ||
51.1 | 59 | #end | |
50.1 | 60 | #end | |
61 | #else | ||
62 | {{include document="Extension.WebHome"/}} | ||
63 | #end | ||
64 | {{/velocity}} | ||
54.1 | 65 |