Progress Continues
We've already had 21687 updates since Dolphin 5.0. Keep up with Dolphin's continuing progress through the Dolphin Blog: February, March, and April 2024 Dolphin Progress Report. |
The Dolphin Emulator Wiki needs your help! Dolphin can play thousands of games, and changes are happening all the time. Help us keep up! Join in and help us make this the best resource for Dolphin. |
Template:VideoGallery/sandbox: Difference between revisions
Jump to navigation
Jump to search
m (Would spew error without 0 in early #expr if the legacy code was purged) |
mNo edit summary |
||
Line 1: | Line 1: | ||
<includeonly>{{#if:{{{1|}}}|{{#vardefine:tl_vg_videocount|{{#vardefineecho:tl_vg_currentvideo|{{#expr:0{{#regex:{{{1|}}}|/(.+)/|+1}}}}}}}}{{#while:|{{#ifexpr:{{#var:tl_vg_currentvideo}}>0|true}}|{{#vardefine:server{{#var:tl_vg_currentvideo}}|{{#regex:videolist | <includeonly>{{#if:{{{1|}}}|<!-- | ||
Parameterless mode begins | |||
-->{{#vardefine:tl_vg_videocount|{{#vardefineecho:tl_vg_currentvideo|{{#expr:0{{#regex:{{{1|}}}|/(.+)/|+1}}}}}}}}<!-- | |||
Counting completed, max video count is duplicated to two variables: tl_vg_videocount and tl_vg_currentvideo, their values will change later. | |||
-->{{#while:|{{#ifexpr:{{#var:tl_vg_currentvideo}}>0|true}}|{{#vardefine:server{{#var:tl_vg_currentvideo}}|{{#regex:videolist | |||
{{{1|}}}|/videolist(\n.*){1,{{#var:tl_vg_currentvideo}}}\n(((?!\s).)+(\/{{!}}=))([\s\S]*)/|$2}}}} | {{{1|}}}|/videolist(\n.*){1,{{#var:tl_vg_currentvideo}}}\n(((?!\s).)+(\/{{!}}=))([\s\S]*)/|$2}}}} | ||
Line 7: | Line 15: | ||
{{#vardefine:caption{{#var:tl_vg_currentvideo}}|{{#regex:videolist | {{#vardefine:caption{{#var:tl_vg_currentvideo}}|{{#regex:videolist | ||
{{{1|}}}|/videolist(\n.*){1,{{#var:tl_vg_currentvideo}}}\n(((?!\s).)+(\/{{!}}=))(.......(?!\s)....{{!}}.......)(.*)([\s\S]*)/|{{#vardefine:tl_vg_currentvideo|{{#expr:{{#var:tl_vg_currentvideo}}-1}}}}$6}}}}}} | {{{1|}}}|/videolist(\n.*){1,{{#var:tl_vg_currentvideo}}}\n(((?!\s).)+(\/{{!}}=))(.......(?!\s)....{{!}}.......)(.*)([\s\S]*)/|{{#vardefine:tl_vg_currentvideo|{{#expr:{{#var:tl_vg_currentvideo}}-1}}}}$6}}}}}}<!-- | ||
{{#vardefine:tl_vg_embedslots|{{#ifexpr:{{#var:tl_vg_videocount}}<3|{{#var:tl_vg_videocount}}|3}}}} | |||
{{#while:|{{#ifexpr:{{#var:tl_vg_embedslots}}>0|true}}|{{#vardefine:tl_vg_featuredvideo|{{#expr:{{Mod|{{#time:U}}+{{#vardefineecho:tl_vg_embedslots|{{#expr:{{#var:tl_vg_embedslots}}-1}}}}+{{#switch:{{#var:tl_vg_embedslots}}|0={{REVISIONSIZE}}|1={{NUMBEROFPAGES:R}}|2={{CurrentRevision}}}}|{{#var:tl_vg_videocount}}}}+1}}}}{{#while:|{{#if:{{#var:video{{#var:tl_vg_featuredvideo}}}}||used}}|{{#vardefine:tl_vg_featuredvideo|{{#expr:{{#var:tl_vg_featuredvideo}}{{#ifexpr:{{#var:tl_vg_featuredvideo}}-1=0|+2|-1}}}}}}}}<div style="float:left; margin: .5em 0 1.3em 1.4em;">{{#ev:{{#regex:{{#var:server{{#var:tl_vg_featuredvideo}}}}|/.*(youtube{{!}}dailymotion).*/|$1}}|{{#var:video{{#var:tl_vg_featuredvideo}}}}|302||<span style="text-overflow: ellipsis; display: inline-block; width: 275px; white-space: nowrap; overflow: hidden; vertical-align: top;" title="{{#var:caption{{#var:tl_vg_featuredvideo}}}}">[{{#var:server{{#var:tl_vg_featuredvideo}}}}{{#var:video{{#var:tl_vg_featuredvideo}}}} {{#tag:nowiki|{{#var:caption{{#var:tl_vg_featuredvideo}}}}}}]</span>|frame}}</div>{{#vardefine:video{{#var:tl_vg_featuredvideo}}|}}}} | Segregating strings to variables completed, variables are with self-explanatory names: server, video, and caption. The ultimate trick of picking value from each variables index-like is by having the increasing (decreasing in this case) number appended to variable names and then use the while-loop with number increasing/decreasing to iterate values from numbered variable names or call a numbered variable name index-like for its value. I'll learn from this for [[Template:Config required]] and some other templates. | ||
--> | |||
{{#vardefine:tl_vg_embedslots|{{#ifexpr:{{#var:tl_vg_videocount}}<3|{{#var:tl_vg_videocount}}|3}}}}<!-- | |||
Max embed slots to a variable: tl_vg_embedslots, value will be subtracted each time a featuring video is selected for embedding. Next part is while-loop with our silly randomizer logic. | |||
--> | |||
{{#while:|{{#ifexpr:{{#var:tl_vg_embedslots}}>0|true}}|{{#vardefine:tl_vg_featuredvideo|{{#expr:{{Mod|{{#time:U}}+{{#vardefineecho:tl_vg_embedslots|{{#expr:{{#var:tl_vg_embedslots}}-1}}}}+{{#switch:{{#var:tl_vg_embedslots}}|0={{REVISIONSIZE}}|1={{NUMBEROFPAGES:R}}|2={{CurrentRevision}}}}|{{#var:tl_vg_videocount}}}}+1}}}}{{#while:|{{#if:{{#var:video{{#var:tl_vg_featuredvideo}}}}||used}}|{{#vardefine:tl_vg_featuredvideo|{{#expr:{{#var:tl_vg_featuredvideo}}{{#ifexpr:{{#var:tl_vg_featuredvideo}}-1=0|+2|-1}}}}}}}}<!-- | |||
The key part where the video is being turned into an embed video. Notice the #ev used here. | |||
--><div style="float:left; margin: .5em 0 1.3em 1.4em;">{{#ev:{{#regex:{{#var:server{{#var:tl_vg_featuredvideo}}}}|/.*(youtube{{!}}dailymotion).*/|$1}}|{{#var:video{{#var:tl_vg_featuredvideo}}}}|302||<span style="text-overflow: ellipsis; display: inline-block; width: 275px; white-space: nowrap; overflow: hidden; vertical-align: top;" title="{{#var:caption{{#var:tl_vg_featuredvideo}}}}">[{{#var:server{{#var:tl_vg_featuredvideo}}}}{{#var:video{{#var:tl_vg_featuredvideo}}}} {{#tag:nowiki|{{#var:caption{{#var:tl_vg_featuredvideo}}}}}}]</span>|frame}}</div><!-- | |||
-->{{#vardefine:video{{#var:tl_vg_featuredvideo}}|}}}}<!-- | |||
While-loop completed. Ready to render the remaining non-featured videos to the page. | |||
--> | |||
<div style="clear:left"></div> | <div style="clear:left"></div> | ||
{{#vardefine:tl_vg_videocount|{{#expr:{{#var:tl_vg_videocount}}+1}}}} | {{#vardefine:tl_vg_videocount|{{#expr:{{#var:tl_vg_videocount}}+1}}}} | ||
{{#while:|{{#ifexpr:{{#var:tl_vg_videocount}}>0|true}}|{{#if:{{#var:video{{#vardefineecho:tl_vg_videocount|{{#expr:{{#var:tl_vg_videocount}}-1}}}}}}|{{#tag:ul|{{#tag:li|[{{#var:server{{#var:tl_vg_videocount}}}}{{#var:video{{#var:tl_vg_videocount}}}}{{#tag:nowiki|{{#var:caption{{#var:tl_vg_videocount}}}}}}]}}}}|}}}} | {{#while:|{{#ifexpr:{{#var:tl_vg_videocount}}>0|true}}|{{#if:{{#var:video{{#vardefineecho:tl_vg_videocount|{{#expr:{{#var:tl_vg_videocount}}-1}}}}}}|{{#tag:ul|{{#tag:li|[{{#var:server{{#var:tl_vg_videocount}}}}{{#var:video{{#var:tl_vg_videocount}}}}{{#tag:nowiki|{{#var:caption{{#var:tl_vg_videocount}}}}}}]}}}}|}}}}<!-- | ||
Parameterless mode ends | |||
-->}}<!-- | |||
Legacy | Legacy | ||
-->{{#vardefine:tl_vg_visible|true}}<div></div>{{#vardefine:tl_vg_videocount|1}}{{#vardefine:tl_vg_currentvideo|1}}{{#while:|{{{vid{{#var:tl_vg_videocount}}|}}}|{{#vardefine:tl_vg_videocount|{{#expr:{{#var:tl_vg_videocount}}+1}}}}}}{{#vardefine:tl_vg_videocount|{{#expr:{{#var:tl_vg_videocount}}-1}}}}{{#ifexpr:{{#var:tl_vg_videocount}}>50|{{#vardefine:tl_vg_videocount|50}}}}{{#ifexpr:{{#var:tl_vg_videocount}}<4|{{#while:|{{#ifexpr:{{#var:tl_vg_currentvideo}}<={{#var:tl_vg_videocount}}|true}}|{{{{{srv{{#var:tl_vg_currentvideo}}|YouTube/sandbox}}}|{{{vid{{#var:tl_vg_currentvideo}}|}}}|{{{cap{{#var:tl_vg_currentvideo}}|}}}}}{{#vardefine:tl_vg_currentvideo|{{#expr:{{#var:tl_vg_currentvideo}}+1}}}}}}<br style="clear:left"/>|{{#vardefine:tl_vg_thumbnail1|{{#expr:{{rand|{{#var:tl_vg_videocount}}|1}}+1}}}}{{#vardefine:tl_vg_thumbnail2|{{#expr:{{rand|{{#var:tl_vg_videocount}}|2}}+1}}}}{{#vardefine:tl_vg_thumbnail3|{{#expr:{{rand|{{#var:tl_vg_videocount}}|3}}+1}}}}{{{{{srv{{#var:tl_vg_thumbnail1}}|YouTube/sandbox}}}|{{{vid{{#var:tl_vg_thumbnail1}}|}}}|{{{cap{{#var:tl_vg_thumbnail1}}|}}}}}{{{{{srv{{#var:tl_vg_thumbnail2}}|YouTube/sandbox}}}|{{{vid{{#var:tl_vg_thumbnail2}}|}}}|{{{cap{{#var:tl_vg_thumbnail2}}|}}}}}{{{{{srv{{#var:tl_vg_thumbnail3}}|YouTube/sandbox}}}|{{{vid{{#var:tl_vg_thumbnail3}}|}}}|{{{cap{{#var:tl_vg_thumbnail3}}|}}}}}<div style="clear:left;"></div>{{#tag:ul|{{#while:|{{#ifexpr:{{#var:tl_vg_currentvideo}}<={{#var:tl_vg_videocount}}|true}}|{{#ifeq:{{#var:tl_vg_thumbnail1}}|{{#var:tl_vg_currentvideo}}||{{#ifeq:{{#var:tl_vg_thumbnail2}}|{{#var:tl_vg_currentvideo}}||{{#ifeq:{{#var:tl_vg_thumbnail3}}|{{#var:tl_vg_currentvideo}}||{{#tag:li|{{{{{srv{{#var:tl_vg_currentvideo}}|YouTube/sandbox}}}|{{{vid{{#var:tl_vg_currentvideo}}|}}}|{{#tag:nowiki|{{{cap{{#var:tl_vg_currentvideo}}|}}}}}|link}}}}}}}}}}{{#vardefine:tl_vg_currentvideo|{{#expr:{{#var:tl_vg_currentvideo}}+1}}}}}}}}}}</includeonly><noinclude>{{documentation|Template:VideoGallery/sandbox/doc}}</noinclude> | -->{{#vardefine:tl_vg_visible|true}}<div></div>{{#vardefine:tl_vg_videocount|1}}{{#vardefine:tl_vg_currentvideo|1}}{{#while:|{{{vid{{#var:tl_vg_videocount}}|}}}|{{#vardefine:tl_vg_videocount|{{#expr:{{#var:tl_vg_videocount}}+1}}}}}}{{#vardefine:tl_vg_videocount|{{#expr:{{#var:tl_vg_videocount}}-1}}}}{{#ifexpr:{{#var:tl_vg_videocount}}>50|{{#vardefine:tl_vg_videocount|50}}}}{{#ifexpr:{{#var:tl_vg_videocount}}<4|{{#while:|{{#ifexpr:{{#var:tl_vg_currentvideo}}<={{#var:tl_vg_videocount}}|true}}|{{{{{srv{{#var:tl_vg_currentvideo}}|YouTube/sandbox}}}|{{{vid{{#var:tl_vg_currentvideo}}|}}}|{{{cap{{#var:tl_vg_currentvideo}}|}}}}}{{#vardefine:tl_vg_currentvideo|{{#expr:{{#var:tl_vg_currentvideo}}+1}}}}}}<br style="clear:left"/>|{{#vardefine:tl_vg_thumbnail1|{{#expr:{{rand|{{#var:tl_vg_videocount}}|1}}+1}}}}{{#vardefine:tl_vg_thumbnail2|{{#expr:{{rand|{{#var:tl_vg_videocount}}|2}}+1}}}}{{#vardefine:tl_vg_thumbnail3|{{#expr:{{rand|{{#var:tl_vg_videocount}}|3}}+1}}}}{{{{{srv{{#var:tl_vg_thumbnail1}}|YouTube/sandbox}}}|{{{vid{{#var:tl_vg_thumbnail1}}|}}}|{{{cap{{#var:tl_vg_thumbnail1}}|}}}}}{{{{{srv{{#var:tl_vg_thumbnail2}}|YouTube/sandbox}}}|{{{vid{{#var:tl_vg_thumbnail2}}|}}}|{{{cap{{#var:tl_vg_thumbnail2}}|}}}}}{{{{{srv{{#var:tl_vg_thumbnail3}}|YouTube/sandbox}}}|{{{vid{{#var:tl_vg_thumbnail3}}|}}}|{{{cap{{#var:tl_vg_thumbnail3}}|}}}}}<div style="clear:left;"></div>{{#tag:ul|{{#while:|{{#ifexpr:{{#var:tl_vg_currentvideo}}<={{#var:tl_vg_videocount}}|true}}|{{#ifeq:{{#var:tl_vg_thumbnail1}}|{{#var:tl_vg_currentvideo}}||{{#ifeq:{{#var:tl_vg_thumbnail2}}|{{#var:tl_vg_currentvideo}}||{{#ifeq:{{#var:tl_vg_thumbnail3}}|{{#var:tl_vg_currentvideo}}||{{#tag:li|{{{{{srv{{#var:tl_vg_currentvideo}}|YouTube/sandbox}}}|{{{vid{{#var:tl_vg_currentvideo}}|}}}|{{#tag:nowiki|{{{cap{{#var:tl_vg_currentvideo}}|}}}}}|link}}}}}}}}}}{{#vardefine:tl_vg_currentvideo|{{#expr:{{#var:tl_vg_currentvideo}}+1}}}}}}}}}}</includeonly><noinclude>{{documentation|Template:VideoGallery/sandbox/doc}}</noinclude> |
Revision as of 03:27, 4 February 2022
[edit] [ ] Template documentation
{{VideoGallery|{{#vardefineecho:videogallery| https://www.youtube.com/watch?v=wjzv0KtDXOA Xenoblade JP 1 (Dolphin Emulator @ 720p) https://www.youtube.com/watch?v=tJtCp8rPXWg Xenoblade PAL 1 [Dolphin Emulator @ 1080p] https://www.dailymotion.com/video/x1k9hnl Cocoto Platform Jumper HD on Dolphin Emulator (Widescreen Hack) part1 https://www.youtube.com/watch?v=_VLNa9PKT0Y Xenoblade PAL 2 (Dolphin Emulator @ 720p) https://www.youtube.com/watch?v=dp3QnvFn_Hc Xenoblade PAL 3 (Dolphin Emulator @ 720p) }}}}
Compare below and #Legacy compatibility! True randomization is our key feature. Requires JavaScript which I have provided a working sample in the talk page. Without JavaScript this will just display as hyperlinked list in reverse order. Another benefit is reducing editing required. Just copy/paste the video link and write caption!
Legacy compatibility
Videos like below still use the old template parameters, they will work fine.
{{VideoGallery/sandbox |vid1=wjzv0KtDXOA|cap1=Xenoblade JP 1 (Dolphin Emulator @ 720p) |vid2=tJtCp8rPXWg|cap2=Xenoblade PAL 1 [Dolphin Emulator @ 1080p] |srv3=dailymotion|vid3=x1k9hnl|cap3=Cocoto Platform Jumper HD on Dolphin Emulator (Widescreen Hack) part1 |vid4=_VLNa9PKT0Y|cap4=Xenoblade PAL 2 (Dolphin Emulator @ 720p) |vid5=dp3QnvFn_Hc|cap5=Xenoblade PAL 3 (Dolphin Emulator @ 720p) }}
Other rationale
- Requires
{{#vardefineecho:videogallery|}}
to avoid issues with equal sign ("=") in template. If {{Problems}} is doing it then why not this? - Parameterless to prevent parameter typo or tampering. This has happened before. Can't remember where is our old discussion at, there was a delusional anonymous tampering the parameter number in attempt of having his video first on the list - in assumption of only the first three videos will embed on the page. This won't be the case when parameters weren't there. They can paste their url anywhere in the list, doesn't matter. Also with JS they wouldn't be thinking about the edit save grinding.
- Quality categories added: checks if the video url is accepted for embedding and checks for the missing caption.
The above documentation is transcluded from Template:VideoGallery/sandbox/doc. (edit | history) Editors can experiment in this template's sandbox (edit) and testcases (create) pages. Subpages of this template. |