Changes for page Card Navigation

Last modified by Calvin Henderson on 2025/03/11 10:29

From version 18.9
edited by calvin_henderson
on 2024/12/18 13:45
Change comment: There is no comment for this version
To version 21.6
edited by calvin_henderson
on 2024/12/19 14:36
Change comment: There is no comment for this version

Summary

Details

Page properties
Title
... ... @@ -1,1 +1,1 @@
1 -Card View
1 +Card Navigation
XWiki.WikiMacroClass[0]
code
... ... @@ -2,35 +2,43 @@
2 2  #set($wikiRef = $doc.documentReference.getWikiReference().getName())
3 3  #set($docRef = $doc.getFullName())
4 4  #set($entries = $wikimacro.content)
5 -#set ($targetSyntaxId = $wikimacro.context.transformationContext.targetSyntax.type.id)
6 -#if ($targetSyntaxId == 'annotatedhtml' || $targetSyntaxId == 'annotatedxhtml')
7 -[[Icon search>>https://fontawesome.com/v6/search?m=free]]
8 -Icon Name|Title|URL
9 ----------|-----|---
10 -{{wikimacrocontent/}}
11 -#else
5 +#if("$xcontext.action" != "edit")
12 12  
13 13  
14 14  {{html wiki="false"}}
15 - <div style="display: grid;
16 - grid-template-columns: 1fr 1fr 1fr;
17 - gap: 10px;
18 - ">
9 + <div style="display: flex; flex-direction: row; gap: 10px; max-width: 1790px; flex-wrap: wrap;">
19 19   #foreach($entry in $entries.split('\n'))
20 20   #set($card = $entry.split('\|'))
21 - <a href="$card[2]" style="text-decoration:none;">
22 - <div style="
23 - display:grid;
24 - text-align:center;
25 - padding:8px;
26 - border-radius:5px;
27 - border:1px solid rgba(222,222,222,1);
28 - border-bottom: 3px solid rgba(222,222,222,1);
29 - ">
30 - <i class="fa $card[0]" style="font-size:4em;"></i>
31 - <h3>$card[1]</h3>
32 - </div>
33 - </a>
12 + #set($href = $card[2])
13 + #if (!$href.toString().startsWith('http') && !$href.contains('.'))
14 + #set($href = $wikiRef + ":$docRef.$href")
15 + #end
16 + #set($doc = $xwiki.getDocument($card[2]))
17 + #set($canView =
18 + $href.toString().startsWith('http')
19 + || $services.security.authorization.hasAccess('view', $href)
20 + || $services.security.authorization.hasAccess('edit', $href)
21 + || $services.security.authorization.hasAccess('admin', $href)
22 + )
23 + #if ($canView)
24 + <a href="$xwiki.getDocument($href).getURL()" style="text-decoration:none;">
25 + <div style="
26 + display:grid;
27 + text-align:center;
28 + align-items: center;
29 + justify-items: center;
30 + padding:8px;
31 + border-radius:5px;
32 + border:1px solid rgba(222,222,222,1);
33 + border-bottom: 3px solid rgba(222,222,222,1);
34 + min-width: 350px; max-width: 350px;
35 + min-height: 150px; max-height: 150px;
36 + ">
37 + <i class="fa $card[0]" style="font-size:4em;"></i>
38 + <h3 style="margin-top: 0;">$card[1]</h3>
39 + </div>
40 + </a>
41 + #end
34 34   #end
35 35   </div>
36 36  {{/html}}