Wiki source code of VelocityConsole
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | {{velocity}} | ||
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)") | ||
3 | |||
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')) | ||
12 | #set($rows = $q.execute()) | ||
13 | |||
14 | #if($rows && $rows.size() > 0) | ||
15 | #set($today = $datetool.get('yyyy-MM-dd')) | ||
16 | #set($index = $mathtool.abs($today.hashCode()) % $rows.size()) | ||
17 | #set($row = $rows.get($index)) | ||
18 | |||
19 | #set($docName = $row.get(0)) | ||
20 | #set($lname = $row.get(1)) | ||
21 | #set($fname = $row.get(2)) | ||
22 | |||
23 | #set($doc = $xwiki.getDocument($docName)) | ||
24 | #set($title = $doc.getDisplayTitle()) | ||
25 | #set($pageURL = $xwiki.getURL($docName)) | ||
26 | #set($attURL = $doc.getAttachmentURL($fname)) | ||
27 | #set($dlURL = $xwiki.getURL($docName, 'download', "filename=$escapetool.url($fname)")) | ||
28 | |||
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') | ||
36 | #end | ||
37 | |||
38 | ## Render actual HTML | ||
39 | {{html wiki="false" clean="false"}} | ||
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;"> | ||
43 | <strong>From:</strong> <a href="${pageURL}">${title}</a><br/> | ||
44 | <strong>File:</strong> ${escapetool.xml($fname)}<br/> | ||
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;"> | ||
48 | <source src="${attURL}" type="${videoType}"/> | ||
49 | <p>Your browser doesn't support HTML5 video. <a href="${dlURL}">Download the video</a> instead.</p> | ||
50 | </video> | ||
51 | <div style="margin-top:10px;text-align:center;"> | ||
52 | <small style="color:#888;">Found ${rows.size()} total videos • <a href="${dlURL}" download="${escapetool.xml($fname)}">Download</a></small> | ||
53 | </div> | ||
54 | </div> | ||
55 | {{/html}} | ||
56 | #else | ||
57 | {{html wiki="false" clean="false"}} | ||
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> | ||
62 | {{/html}} | ||
63 | #end | ||
64 | {{/velocity}} |