0 Votes

Changes for page SubmitIncidentMacro

Last modified by Ryan C on 2025/06/08 05:22

From version 3.27
edited by Ryan C
on 2025/06/08 05:02
Change comment: There is no comment for this version
To version 3.14
edited by Ryan C
on 2025/06/08 04:37
Change comment: There is no comment for this version

Summary

Details

XWiki.WikiMacroClass[0]
Macro code
... ... @@ -1,19 +1,27 @@
1 1  {{velocity}}
2 2  #set($headline = "$!wikimacro.parameters.headline")
3 3  #set($url = "$!wikimacro.parameters.url")
4 -#set($desc = "$!wikimacro.parameters.description")
5 -#set($image = "$!wikimacro.parameters.image")
4 +#set($description = "$!wikimacro.parameters.description")
5 +#set($imageParam = "$!wikimacro.parameters.image")
6 6  
7 -<table style="width:100%;">
8 - <tr>
9 - <td style="width:200px; vertical-align:top;">
10 - [[image:$image||data-xwiki-image-style="thumbnail-clickable" width="200" style="border:1px solid #ccc;"]]
11 - </td>
12 - <td style="vertical-align:top; padding-left:20px;">
13 - <h3><a href="$url" class="wikiexternallink" target="_blank">$headline</a></h3>
14 - <p><strong>$desc</strong></p>
15 - </td>
16 - </tr>
17 -</table>
18 -{{/velocity}}
7 +## Build incident block with careful escaping
8 +#set($block = '(% style="margin-bottom:20px; width:100%" %)')
9 +#set($block = "$block\n")
19 19  
11 +#if($imageParam && $imageParam != "")
12 + #set($block = "$block|[[image:$imageParam||data-xwiki-image-style=\"thumbnail-clickable\" style=\"border:1px solid #ccc\" width=\"200\"]]| \n")
13 +#else
14 + #set($block = "$block|No image provided.| \n")
15 +#end
16 +
17 +#set($block = "$block\n=== [[$headline>>$url]] ===\n\n")
18 +#set($block = "$block$description\n\n[[Read More>>$url]]")
19 +
20 +## Append to current document
21 +#set($doc = $xwiki.getDocument($doc.fullName))
22 +#set($content = $doc.getContent())
23 +$doc.setContent("$content\n\n$block")
24 +$doc.save()
25 +
26 +<div class="alert alert-success">Incident added successfully to the page.</div>
27 +{{/velocity}}