# Wiki source code of VelocityMacros

Last modified by Jean Franco on 2022/06/19 21:15
Export
Office Formats
Export as PDF Export as ODT Export as RTF
Other Formats
Export as HTML

Hide last authors

author | version | line-number | content
--- | --- | --- | ---
| 1.1 | 1 | {{velocity output="false"}}
|  | 2 | #set ($discard = $xwiki.ssx.use('Help.Code.VelocityMacros'))
|  | 3 | #set ($discard = $xwiki.jsx.use('Help.Code.VelocityMacros'))
|  | 4 | #set ($docextras = [])
|  | 5 |
|  | 6 | #macro (helpActionCard $data)
|  | 7 | <div class="well">
|  | 8 | <h2>$escapetool.xml($data.title)</h2>
|  | 9 | <div class="row">
|  | 10 | <div class="col-xs-12 col-md-7">
|  | 11 | <p>$data.description</p>
|  | 12 | <p class="noitems">$data.tip</p>
|  | 13 | #foreach ($action in $data.actions)
|  | 14 | #set ($actionType = $action.type)
|  | 15 | #if ("$!actionType" == '')
|  | 16 | #set ($actionType = 'default')
|  | 17 | #end
|  | 18 | <a href="$action.url" class="btn btn-$actionType">
|  | 19 | $escapetool.xml($action.label)
|  | 20 | </a>
|  | 21 | #end
|  | 22 | </div>
|  | 23 | <div class="col-xs-12 col-md-5">
|  | 24 | #helpVideoPopup($data.title $data.thumbnail)
|  | 25 | </div>
|  | 26 | </div>
|  | 27 | </div>
|  | 28 | #end
|  | 29 |
|  | 30 | #macro (helpVideoPopup $title $fileNamePrefix)
|  | 31 | #set ($id = $stringtool.substringBeforeLast($fileNamePrefix, '.'))
|  | 32 | <a href="#" data-toggle="modal" data-target="#${id}Modal">
|  | 33 | <video class="thumbnail" autoplay loop muted>
|  | 34 | #helpVideoSources($fileNamePrefix)
|  | 35 | </video>
|  | 36 | </a>
|  | 37 | <div class="modal fade video-modal" id="${id}Modal" tabindex="-1" role="dialog" aria-labelledby="${id}ModalLabel">
|  | 38 | <div class="modal-dialog modal-lg" role="document">
|  | 39 | <div class="modal-content">
|  | 40 | <div class="modal-header">
|  | 41 | <button type="button" class="close" data-dismiss="modal" aria-label="Close">
|  | 42 | <span aria-hidden="true">&times;</span>
|  | 43 | </button>
|  | 44 | <span class="modal-title" id="${id}ModalLabel">$!escapetool.xml($title)</span>
|  | 45 | </div>
|  | 46 | <div class="modal-body">
|  | 47 | <video controls autoplay>
|  | 48 | #helpVideoSources($fileNamePrefix)
|  | 49 | </video>
|  | 50 | </div>
|  | 51 | <div class="modal-footer">
|  | 52 | <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|  | 53 | </div>
|  | 54 | </div>
|  | 55 | </div>
|  | 56 | </div>
|  | 57 | #end
|  | 58 |
|  | 59 | #macro (helpVideoSources $fileNamePrefix)
|  | 60 | #set ($attachments = [])
|  | 61 | #set ($attachment = $doc.getAttachment($fileNamePrefix))
|  | 62 | #if ($attachment)
|  | 63 | #set ($discard = $attachments.add($attachment))
|  | 64 | #else
|  | 65 | #foreach ($attachment in $doc.attachmentList)
|  | 66 | #if ($stringtool.startsWith($attachment.filename, $fileName))
|  | 67 | #set ($discard = $attachments.add($attachment))
|  | 68 | #end
|  | 69 | #end
|  | 70 | #end
|  | 71 | #foreach ($attachment in $attachments)
|  | 72 | <source src="$doc.getAttachmentURL($attachment.filename)" type="$escapetool.xml($attachment.mimeType)" />
|  | 73 | #end
|  | 74 | #end
|  | 75 |
|  | 76 | #macro (helpExampleCard $data)
|  | 77 | #set ($documentationURL = $NULL)
|  | 78 | #if ($data.documentation)
|  | 79 | #set ($externalDocumentation = $data.documentation.contains('://'))
|  | 80 | #if ($externalDocumentation)
|  | 81 | #set ($documentationURL = $data.documentation)
|  | 82 | #else
|  | 83 | #set ($documentationURL = $xwiki.getURL($data.documentation))
|  | 84 | #end
|  | 85 | #end
|  | 86 | #set ($examplesURL = $NULL)
|  | 87 | #if ($data.examples)
|  | 88 | #if ($data.examples.startsWith('/'))
|  | 89 | ## Relative internal URL
|  | 90 | #set ($examplesURL = $data.examples)
|  | 91 | #else
|  | 92 | ## Page reference
|  | 93 | #set ($examplesURL = $xwiki.getURL($data.examples))
|  | 94 | #end
|  | 95 | #set ($url = $examplesURL)
|  | 96 | #else
|  | 97 | #set ($url = $documentationURL)
|  | 98 | #end
|  | 99 | <div class="well">
|  | 100 | <div>
|  | 101 | <a href="$!url">
|  | 102 | #if ($data.icon)
|  | 103 | <span class="icon $data.icon"></span>
|  | 104 | #end
|  | 105 | $escapetool.xml($data.title)
|  | 106 | </a>
|  | 107 | </div>
|  | 108 | #if ($data.description)
|  | 109 | <p class="noitems">
|  | 110 | $data.description
|  | 111 | </p>
|  | 112 | #end
|  | 113 | #if (($data.examples && $data.documentation) || !$data.thumbnail)
|  | 114 | <ul class="noitems">
|  | 115 | #if ($data.examples)
|  | 116 | <li>
|  | 117 | <a href="$examplesURL">$services.localization.render('help.example.label')</a>
|  | 118 | </li>
|  | 119 | #end
|  | 120 | #if ($data.documentation)
|  | 121 | <li>
|  | 122 | <a href="$documentationURL"#if ($externalDocumentation) class="wikiexternallink"#end>
|  | 123 | $services.localization.render('help.more.label')
|  | 124 | </a>
|  | 125 | </li>
|  | 126 | #end
|  | 127 | </ul>
|  | 128 | #end
|  | 129 | #if ($data.thumbnail)
|  | 130 | <a href="$!url">
|  | 131 | #set ($attachmentReference = $services.model.resolveAttachment($data.thumbnail))
|  | 132 | <img src="$xwiki.getURL($attachmentReference)" class="thumbnail"
|  | 133 | alt="$escapetool.xml($attachmentReference.name)" />
|  | 134 | </a>
|  | 135 | #end
|  | 136 | </div>
|  | 137 | #end
|  | 138 | {{/velocity}}

# Applications

# Tips

Did you know that you can improve XWiki? Take 5 minutes to fill this survey and help this open source project!

Maila Networks
XWiki Debian 14.4.1