0 Votes

Wiki source code of VelocityConsole

Last modified by Ryan C on 2025/09/09 09:09

Hide last authors
Ryan C 3.1 1 {{velocity}}
Ryan C 6.1 2 #set($hql = "select doc.fullName, lower(att.filename), att.filename from XWikiDocument as doc, XWikiAttachment as att where doc.id = att.docId and (lower(att.filename) like :e1 or lower(att.filename) like :e2 or lower(att.filename) like :e3 or lower(att.filename) like :e4 or lower(att.filename) like :e5 or lower(att.filename) like :e6 or lower(att.filename) like :e7)")
Ryan C 3.1 3
Ryan C 5.1 4 #set($q = $services.query.hql($hql))
5 #set($q = $q.bindValue('e1','%.mp4'))
6 #set($q = $q.bindValue('e2','%.avi'))
7 #set($q = $q.bindValue('e3','%.mov'))
8 #set($q = $q.bindValue('e4','%.wmv'))
9 #set($q = $q.bindValue('e5','%.flv'))
10 #set($q = $q.bindValue('e6','%.webm'))
11 #set($q = $q.bindValue('e7','%.mkv'))
Ryan C 3.1 12 #set($rows = $q.execute())
13
Ryan C 5.1 14 #if($rows && $rows.size() > 0)
Ryan C 6.1 15 #set($today = $datetool.get('yyyy-MM-dd'))
16 #set($index = $mathtool.abs($today.hashCode()) % $rows.size())
17 #set($row = $rows.get($index))
18
Ryan C 5.1 19 #set($docName = $row.get(0))
Ryan C 6.1 20 #set($lname = $row.get(1))
21 #set($fname = $row.get(2))
Ryan C 3.1 22
Ryan C 6.1 23 #set($doc = $xwiki.getDocument($docName))
24 #set($title = $doc.getDisplayTitle())
Ryan C 5.1 25 #set($pageURL = $xwiki.getURL($docName))
Ryan C 6.1 26 #set($attURL = $doc.getAttachmentURL($fname))
27 #set($dlURL = $xwiki.getURL($docName, 'download', "filename=$escapetool.url($fname)"))
Ryan C 3.1 28
Ryan C 5.1 29 #set($videoType = 'video/mp4')
30 #if($lname.endsWith('.webm'))
31 #set($videoType = 'video/webm')
32 #elseif($lname.endsWith('.avi'))
33 #set($videoType = 'video/x-msvideo')
34 #elseif($lname.endsWith('.mov'))
35 #set($videoType = 'video/quicktime')
Ryan C 3.1 36 #end
37
Ryan C 6.1 38 ## Render actual HTML
39 {{html wiki="false" clean="false"}}
Ryan C 3.1 40 <div class="daily-video-container" style="margin:20px 0;padding:20px;border:1px solid #ddd;border-radius:8px;background-color:#f9f9f9;">
41 <h3 style="margin-top:0;color:#333;">Today's Featured Video</h3>
42 <div class="video-info" style="margin-bottom:15px;">
Ryan C 6.1 43 <strong>From:</strong> <a href="${pageURL}">${title}</a><br/>
44 <strong>File:</strong> ${escapetool.xml($fname)}<br/>
Ryan C 3.1 45 <small style="color:#666;">Video changes daily</small>
46 </div>
47 <video width="100%" height="auto" controls preload="metadata" style="max-width:600px;border-radius:4px;">
Ryan C 6.1 48 <source src="${attURL}" type="${videoType}"/>
49 <p>Your browser doesn't support HTML5 video. <a href="${dlURL}">Download the video</a> instead.</p>
Ryan C 3.1 50 </video>
51 <div style="margin-top:10px;text-align:center;">
Ryan C 6.1 52 <small style="color:#888;">Found ${rows.size()} total videos • <a href="${dlURL}" download="${escapetool.xml($fname)}">Download</a></small>
Ryan C 3.1 53 </div>
54 </div>
Ryan C 6.1 55 {{/html}}
Ryan C 3.1 56 #else
Ryan C 6.1 57 {{html wiki="false" clean="false"}}
Ryan C 3.1 58 <div style="margin:20px 0;padding:20px;border:1px solid #ffa500;border-radius:8px;background-color:#fff3cd;color:#856404;">
59 <h3 style="margin-top:0;">No Videos Found</h3>
60 <p>No video files were found in your XWiki site. Upload videos to any page to see them featured here.</p>
61 </div>
Ryan C 6.1 62 {{/html}}
Ryan C 3.1 63 #end
Ryan C 6.1 64 {{/velocity}}
Ryan C 3.1 65