Changes for page api

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

From version 3.1
edited by Ophion Admin
on 2026/10/06 16:01
Change comment: There is no comment for this version
To version 1.1
edited by Ophion Admin
on 2026/10/06 15:57
Change comment: Update LiveTable

Summary

Details

Page properties
Content
... ... @@ -1,67 +1,6 @@
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}}
62 62  #set ($columnsProperties = {
63 63   'doc.title': {"link":"view"},
64 - 'sourceClass': {},
65 65   'doc.location': {"html":true},
66 66   'doc.date': {},
67 67   'doc.author': {"link":"author"},
... ... @@ -76,6 +76,6 @@
76 76   'selectedColumn': 'doc.title',
77 77   'defaultOrder': 'asc'
78 78  })
79 -#set ($columns = ['doc.title', 'sourceClass', 'doc.location', 'doc.date', 'doc.author', '_actions'])
18 +#set ($columns = ['doc.title', 'doc.location', 'doc.date', 'doc.author', '_actions'])
80 80  #livetable('api' $columns $columnsProperties $options)
81 81  {{/velocity}}
XWiki.UIExtensionClass[0]
Extension ID
... ... @@ -1,1 +1,0 @@
1 -platform.panels.apiApplication
Extension Parameters
... ... @@ -1,3 +1,0 @@
1 -label=api
2 -target=api.WebHome
3 -icon=icon:application