Changes for page api

Last modified by Ophion Admin on 2026/10/06 19:32

From version 1.2
edited by Ophion Admin
on 2026/10/06 15:57
Change comment: Updated application icon
To version 2.1
edited by Ophion Admin
on 2026/10/06 15:59
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -1,4 +1,64 @@
1 1  {{velocity}}
2 +#set ($appSpace = 'api')
3 +#set ($appClass = 'api.Code.apiClass')
4 +#set ($templateRef = 'api.Code.apiTemplate')
5 +## Lowercase letters and digits, single hyphens only between the parts
6 +#set ($namePattern = '[a-z0-9]+(-[a-z0-9]+)*')
7 +## Collect all AWM apps: data class name -> app title
8 +#set ($apps = {})
9 +#set ($xwql = "select doc.fullName from Document doc, doc.object(AppWithinMinutes.LiveTableClass) as app order by doc.fullName")
10 +#foreach ($homeName in $services.query.xwql($xwql).execute())
11 + #set ($home = $xwiki.getDocument($homeName))
12 + #if ($home)
13 + #set ($cls = "$!home.getObject('AppWithinMinutes.LiveTableClass').getValue('class')")
14 + ## Skip empty entries and the API app itself
15 + #if ($cls != '' && $cls != $appClass)
16 + #set ($discard = $apps.put($cls, $home.plainTitle))
17 + #end
18 + #end
19 +#end
20 +#set ($errorMsg = '')
21 +#if ("$!request.createEntry" == '1')
22 + #set ($name = "$!request.name")
23 + #set ($sourceClass = "$!request.sourceClass")
24 + #if (!$name.matches($namePattern))
25 + #set ($errorMsg = 'Only lowercase letters, digits and hyphens are allowed.')
26 + #elseif (!$apps.containsKey($sourceClass))
27 + #set ($errorMsg = 'Invalid source application.')
28 + #else
29 + #set ($ref = $services.model.createDocumentReference('', [$appSpace, $name], 'WebHome'))
30 + #if ($xwiki.exists($ref))
31 + #set ($errorMsg = "An API named '${name}' already exists.")
32 + #else
33 + ## The last parameter prefills the sourceClass field of the new entry
34 + #set ($qs = $escapetool.url({'template': $templateRef, 'parent': "${appSpace}.WebHome", 'title': $name, "${appClass}_0_sourceClass": $sourceClass}))
35 + $response.sendRedirect($xwiki.getURL($ref, 'edit', $qs))
36 + #end
37 + #end
38 +#end
39 +#if ($errorMsg != '')
40 + {{error}}$errorMsg{{/error}}
41 +#end
42 +{{html clean="false"}}
43 +<style>
44 + /* Hide the default AWM "Add new entry" button */
45 + ul.actions a.action.add, a.action.add { display: none !important; }
46 +</style>
47 +<form action="$doc.getURL()" method="get" class="form-inline">
48 + <input type="hidden" name="createEntry" value="1"/>
49 + <select name="sourceClass" class="form-control">
50 + #foreach ($app in $apps.entrySet())
51 + <option value="$escapetool.xml($app.key)">$escapetool.xml($app.value)</option>
52 + #end
53 + </select>
54 + <input type="text" name="name" class="form-control" required="required"
55 + pattern="$namePattern" title="Lowercase letters, digits and hyphens only"/>
56 + <input type="submit" class="btn btn-primary" value="Create API"/>
57 +</form>
58 +{{/html}}
59 +{{/velocity}}
60 +
61 +{{velocity}}
2 2  #set ($columnsProperties = {
3 3   'doc.title': {"link":"view"},
4 4   'doc.location': {"html":true},