... |
... |
@@ -1,61 +1,0 @@ |
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 |
|
- |