... |
... |
@@ -5,11 +5,107 @@ |
5 |
5 |
|
6 |
6 |
|
7 |
7 |
|
|
8 |
+{{velocity}} |
|
9 |
+## Daily Random Video Display Script for XWiki |
|
10 |
+## This script finds all video attachments and displays one randomly each day |
8 |
8 |
|
|
12 |
+#set($videos = []) |
9 |
9 |
|
|
14 |
+## Query to find all documents with video attachments |
|
15 |
+#set($query = "select doc.fullName from XWikiDocument doc, XWikiAttachment attach where doc.id = attach.docId and (attach.filename like '%.mp4' or attach.filename like '%.avi' or attach.filename like '%.mov' or attach.filename like '%.wmv' or attach.filename like '%.flv' or attach.filename like '%.webm' or attach.filename like '%.mkv')") |
10 |
10 |
|
|
17 |
+#set($results = $services.query.xwql($query).execute()) |
11 |
11 |
|
|
19 |
+## Collect all video attachments |
|
20 |
+#foreach($docName in $results) |
|
21 |
+ #set($doc = $xwiki.getDocument($docName)) |
|
22 |
+ #foreach($attachment in $doc.getAttachmentList()) |
|
23 |
+ #set($filename = $attachment.getFilename().toLowerCase()) |
|
24 |
+ #if($filename.endsWith('.mp4') || $filename.endsWith('.avi') || $filename.endsWith('.mov') || $filename.endsWith('.wmv') || $filename.endsWith('.flv') || $filename.endsWith('.webm') || $filename.endsWith('.mkv')) |
|
25 |
+ #set($videoInfo = { |
|
26 |
+ 'docName': $docName, |
|
27 |
+ 'filename': $attachment.getFilename(), |
|
28 |
+ 'url': $doc.getAttachmentURL($attachment.getFilename()), |
|
29 |
+ 'title': $doc.getDisplayTitle(), |
|
30 |
+ 'size': $attachment.getLongSize() |
|
31 |
+ }) |
|
32 |
+ #set($discard = $videos.add($videoInfo)) |
|
33 |
+ #end |
|
34 |
+ #end |
|
35 |
+#end |
12 |
12 |
|
|
37 |
+## Check if we found any videos |
|
38 |
+#if($videos.size() > 0) |
|
39 |
+ ## Create a seed based on current date to ensure same video shows all day |
|
40 |
+ #set($today = $datetool.get('yyyy-MM-dd')) |
|
41 |
+ #set($seed = $today.hashCode()) |
|
42 |
+ |
|
43 |
+ ## Use the seed to create a consistent random index for today |
|
44 |
+ #set($random = $mathtool.random) |
|
45 |
+ #set($index = $mathtool.abs($seed) % $videos.size()) |
|
46 |
+ |
|
47 |
+ ## Get today's video |
|
48 |
+ #set($todaysVideo = $videos.get($index)) |
|
49 |
+ |
|
50 |
+ ## Display the video |
|
51 |
+ <div class="daily-video-container" style="margin: 20px 0; padding: 20px; border: 1px solid #ddd; border-radius: 8px; background-color: #f9f9f9;"> |
|
52 |
+ <h3 style="margin-top: 0; color: #333;">📺 Today's Featured Video</h3> |
|
53 |
+ <div class="video-info" style="margin-bottom: 15px;"> |
|
54 |
+ <strong>From:</strong> <a href="$xwiki.getURL($todaysVideo.docName)">$todaysVideo.title</a><br/> |
|
55 |
+ <strong>File:</strong> $todaysVideo.filename<br/> |
|
56 |
+ <small style="color: #666;">Video changes daily • Size: $mathtool.roundTo(2, $todaysVideo.size / 1048576) MB</small> |
|
57 |
+ </div> |
|
58 |
+ |
|
59 |
+ ## Determine video type for HTML5 video element |
|
60 |
+ #set($videoType = "video/mp4") |
|
61 |
+ #set($filename = $todaysVideo.filename.toLowerCase()) |
|
62 |
+ #if($filename.endsWith('.webm')) |
|
63 |
+ #set($videoType = "video/webm") |
|
64 |
+ #elseif($filename.endsWith('.avi')) |
|
65 |
+ #set($videoType = "video/x-msvideo") |
|
66 |
+ #elseif($filename.endsWith('.mov')) |
|
67 |
+ #set($videoType = "video/quicktime") |
|
68 |
+ #elseif($filename.endsWith('.wmv')) |
|
69 |
+ #set($videoType = "video/x-ms-wmv") |
|
70 |
+ #elseif($filename.endsWith('.flv')) |
|
71 |
+ #set($videoType = "video/x-flv") |
|
72 |
+ #elseif($filename.endsWith('.mkv')) |
|
73 |
+ #set($videoType = "video/x-matroska") |
|
74 |
+ #end |
|
75 |
+ |
|
76 |
+ ## HTML5 Video Player |
|
77 |
+ <video width="100%" height="auto" controls preload="metadata" style="max-width: 600px; border-radius: 4px;"> |
|
78 |
+ <source src="$todaysVideo.url" type="$videoType"> |
|
79 |
+ <p>Your browser doesn't support HTML5 video. <a href="$todaysVideo.url">Download the video</a> instead.</p> |
|
80 |
+ </video> |
|
81 |
+ |
|
82 |
+ <div style="margin-top: 10px; text-align: center;"> |
|
83 |
+ <small style="color: #888;"> |
|
84 |
+ Found $videos.size() total videos in your wiki • |
|
85 |
+ <a href="$todaysVideo.url" download="$todaysVideo.filename">Download Video</a> |
|
86 |
+ </small> |
|
87 |
+ </div> |
|
88 |
+ </div> |
|
89 |
+#else |
|
90 |
+ <div class="no-videos-message" style="margin: 20px 0; padding: 20px; border: 1px solid #ffa500; border-radius: 8px; background-color: #fff3cd; color: #856404;"> |
|
91 |
+ <h3 style="margin-top: 0;">📺 No Videos Found</h3> |
|
92 |
+ <p>No video files were found in your XWiki site. Upload videos (MP4, AVI, MOV, WMV, FLV, WebM, MKV) to any page to see them featured here!</p> |
|
93 |
+ <small>Supported formats: MP4, AVI, MOV, WMV, FLV, WebM, MKV</small> |
|
94 |
+ </div> |
|
95 |
+#end |
|
96 |
+ |
|
97 |
+## Optional: Add refresh info for admins |
|
98 |
+#if($hasAdmin) |
|
99 |
+<div style="margin-top: 10px; padding: 10px; background-color: #e7f3ff; border-left: 4px solid #2196F3; font-size: 12px;"> |
|
100 |
+ <strong>Admin Info:</strong> Video selection updates at midnight. Current seed: $today ($seed). |
|
101 |
+ To force refresh for testing, change the date format in the script. |
|
102 |
+</div> |
|
103 |
+#end |
|
104 |
+{{/velocity}} |
|
105 |
+ |
|
106 |
+ |
|
107 |
+ |
|
108 |
+ |
13 |
13 |
This is a **Pro-White Wikipedia** project aiming to unite the scattered White lone wolves into an anonymous force of reckoning in today’s culture and information war. |
14 |
14 |
|
15 |
15 |
== What sets this apart from sites like Metapedia? == |