Wiki source code of Incidents list
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | {{groovy}} | ||
2 | def results = xwiki.search(""" | ||
3 | select doc.fullName, doc.title | ||
4 | from XWikiDocument doc, BaseObject obj | ||
5 | where obj.className = 'Main Categories.Anti White Incidents.Code.MoviesClass' | ||
6 | and obj.name = doc.fullName | ||
7 | and doc.hidden = false | ||
8 | order by doc.creationDate desc | ||
9 | """) | ||
10 | |||
11 | results.each { row -> | ||
12 | def docName = row[0] | ||
13 | def fallbackTitle = row[1] | ||
14 | |||
15 | try { | ||
16 | def doc = xwiki.getDocument(docName) | ||
17 | def obj = doc.getObject('Main Categories.Anti White Incidents.Code.MoviesClass') | ||
18 | |||
19 | if (obj) { | ||
20 | def headline = obj.getProperty('shortText1')?.value?.toString()?.trim() ?: fallbackTitle | ||
21 | def url = obj.getProperty('longText2')?.value?.toString()?.trim() | ||
22 | |||
23 | // Skip empty or malformed links | ||
24 | def isValidUrl = url && (url.startsWith('http://') || url.startsWith('https://')) | ||
25 | |||
26 | // Clean label to avoid wiki syntax breakage | ||
27 | def labelEscaped = headline.replaceAll(/[\[\]\|]/, '').replaceAll(/\>\>/, '>>\u200B') | ||
28 | |||
29 | if (isValidUrl) { | ||
30 | println "* [[$labelEscaped>>$url]]" | ||
31 | } else { | ||
32 | println "* [[${labelEscaped}>>doc:${docName}]]" | ||
33 | } | ||
34 | } | ||
35 | } catch (Exception e) { | ||
36 | println "## Error with ${docName}: ${e.message}" | ||
37 | } | ||
38 | } | ||
39 | {{/groovy}} |