0 Votes

Changes for page Incidents list

Last modified by Ryan C on 2025/07/14 15:42

From version 11.1
edited by Ryan C
on 2025/07/14 15:12
Change comment: There is no comment for this version
To version 12.1
edited by Ryan C
on 2025/07/14 15:41
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -1,4 +1,6 @@
1 1  {{groovy}}
2 +print """{{html clean="false"}}"""
3 +
2 2  def results = xwiki.search("""
3 3   select doc.fullName, doc.title
4 4   from XWikiDocument doc, BaseObject obj
... ... @@ -11,35 +11,29 @@
11 11  results.each { row ->
12 12   def docName = row[0]
13 13   def fallbackTitle = row[1]
16 +
14 14   try {
15 15   def doc = xwiki.getDocument(docName)
16 16   def obj = doc.getObject('Main Categories.Anti White Incidents.Code.MoviesClass')
20 +
17 17   if (obj) {
18 - def rawHeadline = obj.getProperty('shortText1')?.value
19 - def headline = (rawHeadline instanceof String) ? rawHeadline.trim() : docName
22 + def headline = obj.getProperty('shortText1')?.value?.toString()?.trim() ?: fallbackTitle
23 + def rawUrl = obj.getProperty('longText2')?.value?.toString()?.trim()
24 + def finalUrl = rawUrl ? (rawUrl.startsWith('http') ? rawUrl : "https://${rawUrl}") : null
20 20  
21 - def rawUrl = obj.getProperty('longText2')?.value
22 - def finalUrl = null
23 -
24 - if (rawUrl) {
25 - def urlString = rawUrl.toString().trim()
26 - if (urlString.startsWith('http://') || urlString.startsWith('https://')) {
27 - finalUrl = urlString
28 - }
29 - }
26 + def labelEscaped = headline.replaceAll(/[\[\]\|]/, '').replaceAll(/\>\>/, '>>\u200B').replaceAll('"', '"')
30 30  
31 - def labelEscaped = headline.replace('[', '').replace(']', '')
32 -
33 33   if (finalUrl) {
34 - // Try different XWiki external link syntaxes
35 - println "* [[$labelEscaped>>$finalUrl]]"
36 - // Alternative: try without the url: prefix but with full URL
29 + println "<li><a href='${finalUrl}'>${labelEscaped}</a></li>"
37 37   } else {
38 - println "* [[${labelEscaped}>>doc:${docName}]]"
31 + println "<li><a href='/bin/view/${docName}'>${labelEscaped}</a></li>"
39 39   }
40 40   }
41 41   } catch (Exception e) {
42 - println "## Error with ${docName}: ${e.message}"
35 + println "<li>Error with ${docName}: ${e.message}</li>"
43 43   }
44 44  }
38 +
39 +print """{{/html}}"""
45 45  {{/groovy}}
41 +

XWiki AI Chat