Wiki source code of VelocityConsole
Hide last authors
author | version | line-number | content |
---|---|---|---|
![]() |
3.1 | 1 | {{velocity}} |
![]() |
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)") |
![]() |
3.1 | 3 | |
![]() |
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')) | ||
![]() |
3.1 | 12 | #set($rows = $q.execute()) |
13 | |||
![]() |
5.1 | 14 | #if($rows && $rows.size() > 0) |
![]() |
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 | |||
![]() |
5.1 | 19 | #set($docName = $row.get(0)) |
![]() |
6.1 | 20 | #set($lname = $row.get(1)) |
21 | #set($fname = $row.get(2)) | ||
![]() |
3.1 | 22 | |
![]() |
6.1 | 23 | #set($doc = $xwiki.getDocument($docName)) |
24 | #set($title = $doc.getDisplayTitle()) | ||
![]() |
5.1 | 25 | #set($pageURL = $xwiki.getURL($docName)) |
![]() |
6.1 | 26 | #set($attURL = $doc.getAttachmentURL($fname)) |
27 | #set($dlURL = $xwiki.getURL($docName, 'download', "filename=$escapetool.url($fname)")) | ||
![]() |
3.1 | 28 | |
![]() |
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') | ||
![]() |
3.1 | 36 | #end |
37 | |||
![]() |
6.1 | 38 | ## Render actual HTML |
39 | {{html wiki="false" clean="false"}} | ||
![]() |
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;"> | ||
![]() |
6.1 | 43 | <strong>From:</strong> <a href="${pageURL}">${title}</a><br/> |
44 | <strong>File:</strong> ${escapetool.xml($fname)}<br/> | ||
![]() |
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;"> | ||
![]() |
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> | ||
![]() |
3.1 | 50 | </video> |
51 | <div style="margin-top:10px;text-align:center;"> | ||
![]() |
6.1 | 52 | <small style="color:#888;">Found ${rows.size()} total videos • <a href="${dlURL}" download="${escapetool.xml($fname)}">Download</a></small> |
![]() |
3.1 | 53 | </div> |
54 | </div> | ||
![]() |
6.1 | 55 | {{/html}} |
![]() |
3.1 | 56 | #else |
![]() |
6.1 | 57 | {{html wiki="false" clean="false"}} |
![]() |
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> | ||
![]() |
6.1 | 62 | {{/html}} |
![]() |
3.1 | 63 | #end |
![]() |
6.1 | 64 | {{/velocity}} |
![]() |
3.1 | 65 |