0 Votes

Changes for page IncidentGallery

Last modified by Ryan C on 2025/07/17 06:41

From version 1.1
edited by Ryan C
on 2025/07/17 04:45
Change comment: There is no comment for this version
To version 4.8
edited by Ryan C
on 2025/07/17 05:51
Change comment: There is no comment for this version

Summary

Details

Macros.AntiWhiteTagClass.WebHome[0]
XWiki.WikiMacroClass[0]
Cached
... ... @@ -1,0 +1,1 @@
1 +No
Asynchronous rendering
... ... @@ -1,0 +1,1 @@
1 +No
Macro code
... ... @@ -1,0 +1,61 @@
1 +{{groovy}}
2 +def results = []
3 +
4 +def hql = """
5 + select doc.fullName
6 + from XWikiDocument doc, BaseObject obj
7 + where obj.name = doc.fullName
8 + and obj.className = 'Main Categories.Anti White Incidents.Code.MoviesClass'
9 + order by doc.date desc
10 +"""
11 +
12 +def docs = xwiki.search(hql, 100, 0)
13 +
14 +docs.each { docName ->
15 + def doc = xwiki.getDocument(docName)
16 + def obj = doc.getObject("Main Categories.Anti White Incidents.Code.MoviesClass")
17 + if (!obj) return
18 +
19 + def title = obj.getProperty("shortText1")?.value?.toString()?.trim()
20 + def summary = obj.getProperty("shortText2")?.value?.toString()?.trim() ?: obj.getProperty("longText1")?.value?.toString()?.trim()
21 + def externalURL = obj.getProperty("longText2")?.value?.toString()?.trim()
22 +
23 + if (!title || !summary) return
24 +
25 + // ✅ Choose external link if valid, otherwise link to doc
26 + def isValidURL = externalURL && (externalURL.startsWith("http://") || externalURL.startsWith("https://"))
27 + def linkTarget = isValidURL ? externalURL : "doc:${docName}"
28 +
29 + // ✅ Escape brackets in title to avoid wiki breakage
30 + def safeTitle = title.replaceAll(/[\[\]\|]/, '').replaceAll(/\>\>/, '>>\u200B')
31 +
32 + // ✅ Auto-detect first attached image
33 + def imageFile = doc.getAttachmentList()?.find {
34 + it.filename.toLowerCase().matches(".*\\.(png|jpg|jpeg|gif)")
35 + }?.filename
36 +
37 + def imageMarkup = ""
38 + if (imageFile) {
39 + imageMarkup = "[[image:${doc.fullName}@${imageFile}||alt=\"Image\" data-xwiki-image-style=\"thumbnail-clickable\" style=\"border:1px solid #ccc\" width=\"200\"]]"
40 + }
41 +
42 + def block = """
43 +(% style="margin-bottom:20px; width:100%" %)
44 +|${imageMarkup}|
45 +
46 +=== [[${safeTitle}>>${linkTarget}]] ===
47 +
48 +${summary}
49 +[[Read More>>${linkTarget}]]
50 +""".trim()
51 +
52 + results << block
53 +}
54 +
55 +if (results.isEmpty()) {
56 + println "⚠️ Still no incident blocks rendered — ensure at least one page has valid title/summary/attachment."
57 +} else {
58 + println results.join("\n\n")
59 +}
60 +{{/groovy}}
61 +
Macro content type
... ... @@ -1,0 +1,1 @@
1 +Wiki
Macro content availability
... ... @@ -1,0 +1,1 @@
1 +No content
Default categories
... ... @@ -1,0 +1,1 @@
1 +Content
Macro description
... ... @@ -1,0 +1,1 @@
1 +Displays a gallery of anti-White incidents, with optional tag filter
Execution is isolated
... ... @@ -1,0 +1,1 @@
1 +No
Macro id
... ... @@ -1,0 +1,1 @@
1 +incidentGallery
Macro name
... ... @@ -1,0 +1,1 @@
1 +Incident Gallery
Supports inline mode
... ... @@ -1,0 +1,1 @@
1 +Yes
Macro visibility
... ... @@ -1,0 +1,1 @@
1 +Current Wiki
XWiki.WikiMacroParameterClass[0]
Parameter advanced
... ... @@ -1,0 +1,1 @@
1 +Yes
Parameter default value
... ... @@ -1,0 +1,1 @@
1 +Job Discrimination
Parameter deprecated
... ... @@ -1,0 +1,1 @@
1 +No
Parameter description
... ... @@ -1,0 +1,1 @@
1 +tags
Parameter hidden
... ... @@ -1,0 +1,1 @@
1 +No
Parameter mandatory
... ... @@ -1,0 +1,1 @@
1 +No
Parameter name
... ... @@ -1,0 +1,1 @@
1 +tags
Parameter type
... ... @@ -1,0 +1,1 @@
1 +Wiki