Changes for page XWiki Syntax Guide

Last modified by Ludovic Dubost on 2020/07/30 11:21

From version 6.1
edited by Ludovic Dubost
on 2015/11/28 14:59
Change comment: Install extension [org.xwiki.platform:xwiki-platform-help-ui-7.3]
To version 3.1
edited by Thomas Mortagne
on 2014/09/29 12:41
Change comment: Install extension [org.xwiki.platform:xwiki-platform-help-ui-6.2]

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -xwiki:XWiki.ludovic
1 +xwiki:XWiki.ThomasMortagne
Content
... ... @@ -1,32 +1,8 @@
1 1  {{velocity output="false"}}
2 2  #set($SUPPORTED_SYNTAXES = {})
3 -#set($void = $SUPPORTED_SYNTAXES.put('1.0', 'XWiki Syntax 1.0'))
4 -#set($void = $SUPPORTED_SYNTAXES.put('2.0', 'XWiki Syntax 2.0'))
5 -#set($void = $SUPPORTED_SYNTAXES.put('2.1', 'XWiki Syntax 2.1'))
6 -##
7 -## needed for sections that contain descriptions valid for several syntaxes
8 -## basically it is hack to reuse the 2.0 descriptions for 2.1
9 -#set($SUPPORTED_SYNTAX_ORDER = ['1.0', '2.0', '2.1'])
10 -##
11 -## filter all syntaxes that are not installed/configured
12 -#set($configuredSyntaxIds = $xwiki.getConfiguredSyntaxes())
13 -#set($enabledSyntaxIds = [])
14 -#foreach($syntax in $services.rendering.getAvailableParserSyntaxes())
15 - #if($configuredSyntaxIds.contains($syntax.toIdString()))
16 - #set($discard = $enabledSyntaxIds.add($syntax.toIdString()))
17 - #end
18 -#end
19 -#set($unavailableSyntaxes=[])
20 -#foreach($supportedSyntax in $SUPPORTED_SYNTAX_ORDER)
21 - #set($fullSyntaxId = "xwiki/$supportedSyntax")
22 - #if(!$enabledSyntaxIds.contains($fullSyntaxId))
23 - #set($discard = $unavailableSyntaxes.add($supportedSyntax))
24 - #end
25 -#end
26 -#foreach($unavailableSyntax in $unavailableSyntaxes)
27 - #set($discard = $SUPPORTED_SYNTAX_ORDER.remove($unavailableSyntax))
28 - #set($discard = $SUPPORTED_SYNTAXES.removeKey($unavailableSyntax))
29 -#end
3 +#set($void = $SUPPORTED_SYNTAXES.put(1.0, 'XWiki Syntax 1.0'))
4 +#set($void = $SUPPORTED_SYNTAXES.put(2.0, 'XWiki Syntax 2.0'))
5 +#set($void = $SUPPORTED_SYNTAXES.put(2.1, 'XWiki Syntax 2.1'))
30 30  
31 31  #if ($request.xaction == 'switchContext')
32 32   $response.sendRedirect($request.target)
... ... @@ -38,14 +38,13 @@
38 38   #set ($crtCategoryId = $mathtool.toInteger($crtCategoryId))
39 39  #end
40 40  #set ($crtSectionId = "$!{request.section}")
41 -#set ($crtSyntaxVer = "$!{request.syntax}")
42 -#if (!$SUPPORTED_SYNTAXES.containsKey($crtSyntaxVer))
43 - ## Default to the most current one (if we have any)
44 - #if(!$SUPPORTED_SYNTAX_ORDER.isEmpty())
45 - #set ($crtSyntaxVer = $SUPPORTED_SYNTAX_ORDER.get($mathtool.sub($SUPPORTED_SYNTAX_ORDER.size(),1)))
46 - #end
17 +#set ($crtSyntaxVer = $mathtool.toDouble($request.syntax))
18 +#if ($crtSyntaxVer && $SUPPORTED_SYNTAXES.containsKey($crtSyntaxVer))
19 + #set ($crtSyntaxVer = $mathtool.toDouble($crtSyntaxVer))
20 +
21 +#else
22 + #set ($crtSyntaxVer = 2.1) ## Default to Syntax 2.1
47 47  #end
48 -#set($crtSyntaxPos = $SUPPORTED_SYNTAX_ORDER.indexOf($crtSyntaxVer))
49 49  
50 50  #set ($extraParamList = [])
51 51  #if ($request.language)
... ... @@ -77,7 +77,7 @@
77 77   #set($obj = $sectionDoc.getObject("XWiki.XWikiSyntaxClass"))
78 78  
79 79   ## detect if we entered a new category
80 - #if($catCount < $obj.getProperty("category").value)
55 + #if($catCount < $obj.getProperty("category").value))
81 81   ## Put previous category into map (if existing), and reset children map
82 82   #if($catId)
83 83   #set($cat = { 'id' : $catId, 'name' : $catName, 'children' : $catChildren })
... ... @@ -114,7 +114,7 @@
114 114   #end
115 115  
116 116   ## Add new sections to category children map
117 - #set($child = {'id' : $sectionDoc.getName().substring(11), 'minSyntax' : $obj.getProperty("minSyntaxId").value, 'maxSyntax' : $obj.getProperty("maxSyntaxId").value, 'name' : $sectionTitle})
92 + #set($child = {'id' : $sectionDoc.getName().substring(11), 'minSyntax' : $obj.getProperty("minSyntaxVersion").value, 'maxSyntax' : $obj.getProperty("maxSyntaxVersion").value, 'name' : $sectionTitle})
118 118   $catChildren.add($child)
119 119   #end
120 120  #end
... ... @@ -129,11 +129,10 @@
129 129  #foreach ($category in $syntaxMenu)
130 130   #set ($sectionsToRemove = [])
131 131   #foreach ($section on $category.children)
132 - #set($minSyntaxPos = $SUPPORTED_SYNTAX_ORDER.indexOf($section.minSyntax))
133 - #if ($minSyntaxPos > $crtSyntaxPos)
107 + #if ($section.minSyntax > $crtSyntaxVer)
134 134   #set ($discard = $sectionsToRemove.add($section))
135 135   #if ($section.id == $crtSectionId)
136 - #set ($crtSectionId = '') ## clear section if it doesn't exist (can happen when switching from 2.x to 1.0 syntax)
110 + #set ($crtSectionId = '') ## clear section if it doesn't exist (can happen when switching from 2.0 to 2.1 syntax)
137 137   #end
138 138   #end
139 139   #end
... ... @@ -198,24 +198,15 @@
198 198   *#
199 199  #macro(syntax_displayCategory $sections $translationPrefix $heading)
200 200   #foreach ($section in $sections)
201 - #syntax_displaySection($section $translationPrefix $heading)
202 - #end
203 -#end
204 -
205 -#macro(syntax_displaySection $section $translationPrefix $heading)
206 206   #set ($displayVersion = $crtSyntaxVer)
207 - ## here is the hack to display the description for 2.0 if we have no description for 2.x
208 - ## this likely needs more work if e.g. there is a 3.x which is not compatible with 2.x
209 - #set($maxSyntaxPos = $SUPPORTED_SYNTAX_ORDER.indexOf($section.maxSyntax))
210 - #if ($crtSyntaxPos > $maxSyntaxPos)
176 + #if ($crtSyntaxVer > $section.maxSyntax)
211 211   #set ($displayVersion = $section.maxSyntax)
212 212   #end
213 - #if($heading)
214 214   (% class="sectionheader" %)
215 215   $heading $section.name $heading
216 216  
217 - #end
218 218   {{include reference="XWiki.XWikiSyntax${section.id}" section="H${displayVersion}${section.id}"/}}
183 + #end
219 219  #end
220 220  
221 221  
... ... @@ -260,7 +260,7 @@
260 260   #set ($crtSelection = "$extraParams")
261 261   #end
262 262  {{html}}
263 - <form id="change-context" class="xformInline" action="$doc.getURL()">
228 + <form id="change-context" class="xformInline" action="">
264 264   <div>
265 265   <input type="hidden" name="xaction" value="switchContext" />
266 266   #if ($request.language)
... ... @@ -271,10 +271,12 @@
271 271   #end
272 272   <select id="goto-select" name="target" title="$escapetool.xml($services.localization.render("help.changesyntax"))">
273 273   <optgroup label="$services.localization.render('help.choose_syntax')">
274 - #foreach($syntaxId in $SUPPORTED_SYNTAX_ORDER)
275 - #set ($query = "syntax=${escapetool.url($syntaxId)}&${crtSelection}")
276 - <option value="$escapetool.xml($doc.getURL('view', $query))"#if($crtSyntaxVer == $syntaxId) selected="selected"#end>$escapetool.html($SUPPORTED_SYNTAXES.get($syntaxId))</option>
277 - #end
239 + #set ($query = "syntax=1.0&${crtSelection}")
240 + <option value="$doc.getURL('view', $query)" #if($crtSyntaxVer==1.0)selected="selected"#end>$SUPPORTED_SYNTAXES.get(1.0)</option>
241 + #set ($query = "syntax=2.0&${crtSelection}")
242 + <option value="$doc.getURL('view', $query)" #if($crtSyntaxVer==2.0)selected="selected"#end>$SUPPORTED_SYNTAXES.get(2.0)</option>
243 + #set ($query = "syntax=2.1&${crtSelection}")
244 + <option value="$doc.getURL('view', $query)" #if($crtSyntaxVer==2.1)selected="selected"#end>$SUPPORTED_SYNTAXES.get(2.1)</option>
278 278   </optgroup>
279 279   </select>
280 280   <span class="buttonwrapper"><input type="submit" value="$escapetool.xml($services.localization.render('admin.switchContext'))" class="button" /></span>
... ... @@ -302,7 +302,7 @@
302 302  #syntaxSwitch()
303 303  (((
304 304  #set ($query = "syntax=$escapetool.url(${crtSyntaxVer})${extraParams}")
305 -#if ($crtCategory){{html}}<a href="${doc.getURL('view', ${query})}">$syntaxTitle</a>{{/html}}#{else}(% class="current" %)$syntaxTitle#{end}#if ($crtCategory) » #if ($crtSection){{html}}<a href="${crtCategory.url}">${crtCategory.name}</a>{{/html}}#{else}(% class="current" %)${crtCategory.name}#{end}#if ($crtSection) » (% class="current" %)${crtSection.name}#end#end
272 +#if ($crtCategory){{html}}<a href="${doc.getURL('view', ${query})}">$syntaxTitle</a>{{/html}}#{else}(% class="current" %)$syntaxTitle#{end}#if ($crtCategory) (% class="separator" %)» #if ($crtSection){{html}}<a href="${crtCategory.url}">${crtCategory.name}</a>{{/html}}#{else}(% class="current" %)${crtCategory.name}#{end}#if ($crtSection) (% class="separator" %)» (% class="current" %)${crtSection.name}#end#end
306 306  )))
307 307  == $syntaxTitle: $sectionName ==
308 308  
... ... @@ -317,7 +317,12 @@
317 317   #set ($subHeading = '===')
318 318   #syntax_displayCategory($crtCategory.children 'syntax.' '==')
319 319   #else
320 - #syntax_displaySection($crtSection 'syntax.' false)
287 + #set ($displayVersion = $crtSyntaxVer)
288 + #if ($crtSyntaxVer > $crtSection.maxSyntax)
289 + #set ($displayVersion = $crtSection.maxSyntax)
290 + #end
291 + #set ($subHeading = '==')
292 + {{include reference="XWiki.XWikiSyntax${crtSection.id}" section="H${displayVersion}${crtSection.id}"/}}
321 321   #end
322 322   ))) ## syntax-page-content
323 323  {{/velocity}}