0 Votes

Changes for page Incidents list

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

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

Summary

Details

Page properties
Content
... ... @@ -1,6 +1,4 @@
1 1  {{groovy}}
2 -print """{{html clean="false"}}"""
3 -
4 4  def results = xwiki.search("""
5 5   select doc.fullName, doc.title
6 6   from XWikiDocument doc, BaseObject obj
... ... @@ -20,22 +20,23 @@
20 20  
21 21   if (obj) {
22 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
21 + def url = obj.getProperty('longText2')?.value?.toString()?.trim()
25 25  
26 - def labelEscaped = headline.replaceAll(/[\[\]\|]/, '').replaceAll(/\>\>/, '>>\u200B').replaceAll('"', '"')
23 + // Skip empty or malformed links
24 + def isValidUrl = url && (url.startsWith('http://') || url.startsWith('https://'))
27 27  
28 - if (finalUrl) {
29 - println "<li><a href='${finalUrl}'>${labelEscaped}</a></li>"
26 + // Clean label to avoid wiki syntax breakage
27 + def labelEscaped = headline.replaceAll(/[\[\]\|]/, '').replaceAll(/\>\>/, '>>\u200B')
28 +
29 + if (isValidUrl) {
30 + println "* [[$labelEscaped>>$url]]"
30 30   } else {
31 - println "<li><a href='/bin/view/${docName}'>${labelEscaped}</a></li>"
32 + println "* [[${labelEscaped}>>doc:${docName}]]"
32 32   }
33 33   }
34 34   } catch (Exception e) {
35 - println "<li>Error with ${docName}: ${e.message}</li>"
36 + println "## Error with ${docName}: ${e.message}"
36 36   }
37 37  }
38 -
39 -print """{{/html}}"""
40 40  {{/groovy}}
41 41  

XWiki AI Chat