Wiki source code of Import-Test-App-01
Version 2.1 by Ophion Admin on 2026/10/06 14:23
Hide last authors
| author | version | line-number | content |
|---|---|---|---|
| |
1.1 | 1 | {{velocity}} |
| |
2.1 | 2 | #set ($appSpace = 'Import-Test-App-01') |
| 3 | #set ($templateRef = 'Import-Test-App-01.Code.Import-Test-App-01Template') | ||
| 4 | ## Allowed values for the first part of the page name | ||
| 5 | #set ($prefixes = ['doc', 'faq', 'howto']) | ||
| 6 | #set ($errorMsg = '') | ||
| 7 | #if ("$!request.createEntry" == '1') | ||
| 8 | #set ($prefix = "$!request.prefix") | ||
| 9 | #set ($suffix = "$!request.suffix") | ||
| 10 | #if (!$prefixes.contains($prefix)) | ||
| 11 | #set ($errorMsg = 'Invalid prefix.') | ||
| 12 | #elseif (!$suffix.matches('[a-z0-9_-]+')) | ||
| 13 | #set ($errorMsg = 'Only lowercase letters, digits, hyphen and underscore are allowed.') | ||
| 14 | #else | ||
| 15 | #set ($name = "${prefix}-${suffix}") | ||
| 16 | ## Nested page: Import-Test-App-01.<name>.WebHome | ||
| 17 | #set ($ref = $services.model.createDocumentReference('', [$appSpace, $name], 'WebHome')) | ||
| 18 | #if ($xwiki.exists($ref)) | ||
| 19 | #set ($errorMsg = "Page '${name}' already exists.") | ||
| 20 | #else | ||
| 21 | #set ($qs = $escapetool.url({'template': $templateRef, 'parent': "${appSpace}.WebHome", 'title': $name})) | ||
| 22 | $response.sendRedirect($xwiki.getURL($ref, 'edit', $qs)) | ||
| 23 | #end | ||
| 24 | #end | ||
| 25 | #end | ||
| 26 | #if ($errorMsg != '') | ||
| 27 | {{error}}$errorMsg{{/error}} | ||
| 28 | #end | ||
| 29 | {{html clean="false"}} | ||
| 30 | <form action="$doc.getURL()" method="get" class="form-inline"> | ||
| 31 | <input type="hidden" name="createEntry" value="1"/> | ||
| 32 | <select name="prefix" class="form-control"> | ||
| 33 | #foreach ($p in $prefixes) | ||
| 34 | <option value="$p">$p</option> | ||
| 35 | #end | ||
| 36 | </select> | ||
| 37 | - | ||
| 38 | <input type="text" name="suffix" class="form-control" required="required" | ||
| 39 | pattern="[a-z0-9_-]+" title="Lowercase letters, digits, - and _ only"/> | ||
| 40 | <input type="submit" class="btn btn-primary" value="Create entry"/> | ||
| 41 | </form> | ||
| 42 | {{/html}} | ||
| 43 | {{/velocity}} | ||
| 44 | {{velocity}} | ||
| |
1.1 | 45 | #set ($columnsProperties = { |
| 46 | 'doc.title': {"link":"view"}, | ||
| 47 | 'doc.location': {"html":true}, | ||
| 48 | 'doc.date': {}, | ||
| 49 | 'doc.author': {"link":"author"}, | ||
| 50 | '_actions': {"sortable":false,"filterable":false,"html":true,"actions":["edit","delete"]} | ||
| 51 | }) | ||
| 52 | #set ($options = { | ||
| 53 | 'className': 'Import-Test-App-01.Code.Import-Test-App-01Class', | ||
| 54 | 'translationPrefix': 'import-test-app-01.livetable.', | ||
| 55 | 'tagCloud': true, | ||
| 56 | 'rowCount': 15, | ||
| 57 | 'maxPages': 10, | ||
| 58 | 'selectedColumn': 'doc.title', | ||
| 59 | 'defaultOrder': 'asc' | ||
| 60 | }) | ||
| 61 | #set ($columns = ['doc.title', 'doc.location', 'doc.date', 'doc.author', '_actions']) | ||
| 62 | #livetable('import-test-app-01' $columns $columnsProperties $options) | ||
| 63 | {{/velocity}} |