Difference between revisions of "Template:StreamLinkTable"

From Hackerspace ACKspace
Jump to: navigation, search
(created stream link table magic)
 
m (corrected uri buildup (position of underscores are now more 'generic'))
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
<noinclude>
 
<noinclude>
 +
__TOC__
 +
=== synopsis ===
 +
This is the "{{PAGENAME}}" template.
  
TODO: write descent info
+
It will generate a table with various links derived from the <code>stages</code>, <code>languages</code>, <code>formats</code> and <code>types</code>.
  
{{{stages|Tent-1;s1,Tent-2;s2,BER stage;s3}}}
+
It should be called in the following format (all parameters are '''optional'''):
{{{language|Native;_native_,Translated;_translated_}}}
 
todo: {{{languageCount|2}}}
 
{{{types|HD;hd,SD;sd,Slides;slides}}}
 
{{{typeCount|3}}}
 
{{{formats|WebM;.webm,HLS;.m3u8}}}
 
{{{baseURL|http://cdn.c3voc.de/}}}
 
  
 +
<nowiki>{{</nowiki>{{PAGENAME}}
 +
|baseURL=
 +
|stages=
 +
|languages=
 +
|languageCount=
 +
|formats=
 +
|types=
 +
|typeCount=
 +
}}
 +
 +
=== parameters ===
 +
The parameters all default to something useful for [[CCC]] and each has a specific syntax:
 +
baseURL
 +
* <code>baseURL</code>: first common part of the link, defaults to '''<nowiki>https://cdn.c3voc.de/</nowiki>'''
 +
* <code>stages</code>: comma separated (''',''') list of ''<code>Stage Label;urlPart</code>'' (note the semicolon ''';'''), defaults to 3 &times; '''Stage ''n'';s''n'''''
 +
* <code>languages</code>: comma separated (''',''') list of ''<code>Language Label;urlPart</code>'' (note the semicolon ''';'''), defaults to '''Native;_native,Translated;_translated'''
 +
* <code>languageCount</code>: number used for setting the correct table header span, set to reflect the amount of languages, defaults to '''2'''
 +
* <code>formats</code>: comma separated (''',''') list of ''<code>Format Label;urlPart</code>'' (note the semicolon ''';'''), defaults to '''WebM;.webm,HLS;.m3u8'''
 +
* <code>types</code>: comma separated (''',''') list of ''<code>Type Label;urlPart</code>'' (note the semicolon ''';'''), defaults to '''HD;_hd,SD;_sd,Slides;_slides'''
 +
* <code>typeCount</code>: number used for setting the correct table header span, set to reflect the amount of types, defaults to '''3'''
 +
 +
The links are generated as followed (always using the item part ''after'' the semicolon:
 +
<code>baseURL</code>+<code>stage</code>(outer row)+<code>language</code>(inner row)+<code>type</code>(inner column)+<code>format</code>(outer column), for example ''Stage 3 Native Slides as HLS'' will have the link: <code>https://cdn.c3voc.de/s3_native_slides.m3u8</code>
 +
 +
=== css ===
 +
Note that for the best results, this table needs extra CSS in [[MediaWiki:Common.css]]:
 +
<pre>
 +
/* CSS span table rowspan only showing the first row header (assuming there are 2 column headers stacked, hence +3) */
 +
table.span tr>th.span2,
 +
table.span tr>th.span3,
 +
table.span tr>th.span4,
 +
table.span tr>th.span5
 +
{
 +
    display: none;
 +
}
 +
 +
table.span tr:nth-of-type(2n+3)>th.span2,
 +
table.span tr:nth-of-type(3n+3)>th.span3,
 +
table.span tr:nth-of-type(4n+3)>th.span4,
 +
table.span tr:nth-of-type(5n+3)>th.span5
 +
{
 +
    display: table-cell;
 +
}
 +
</pre>
 +
 +
If it is not possible to have this CSS added, or you want to repeat every row header, make sure to set <code>languageCount = 1</code> (or the table layout will break without the added CSS).
 +
 +
=== example ===
 +
Edit the page to see how the following tables are generated:
 +
 +
The default is written like this:
 +
<nowiki>{{</nowiki>{{PAGENAME}}<nowiki>}}</nowiki>
 +
looks like this: {{ {{PAGENAME}} }}
 
----
 
----
 +
For a different set of stages, use this:
 +
<nowiki>{{</nowiki>{{PAGENAME}}
 +
|stages=Main stage;stage1,Backup stage;stageb
 +
<nowiki>}}</nowiki>
 +
to generate: {{ {{PAGENAME}}|stages=Main stage;stage1,Backup stage;stageb}}
 +
----
 +
For an extra set of languages, use this:
 +
<nowiki>{{</nowiki>{{PAGENAME}}
 +
|languages=English;_eng,German;_deu,French;_fra,Dutch;_ned
 +
|languageCount=4
 +
<nowiki>}}</nowiki>
 +
to generate: {{ {{PAGENAME}}|languages=English;_eng,German;_deu,French;_fra,Dutch;_ned|languageCount=4}}
 +
 +
 
</noinclude>
 
</noinclude>
<table class="wikitable">
+
<includeonly>
 +
<table class="wikitable span">
 
<tr>
 
<tr>
 
<th colspan="2" rowspan="2"></th>
 
<th colspan="2" rowspan="2"></th>
Line 23: Line 88:
 
|}}
 
|}}
 
</tr>
 
</tr>
{{#arraymap:{{{stages|Tent-1;s1,Tent-2;s2,BER stage;s3}}}|,|stage|
+
{{#arraymap:{{{stages|Stage 1;s1, Stage 2;s2,Stage 3;s3}}}|,|stage|
  
   {{#arraymap:{{{language|Native;_native_,Translated;_translated_}}}|,|language|
+
   {{#arraymap:{{{languages|Native;_native,Translated;_translated}}}|,|languageVar|
 
     <tr>
 
     <tr>
       <th rowspan="1">{{#explode:stage|;|0}}</th>
+
       <th class="span{{{languageCount|2}}}" rowspan="{{{languageCount|2}}}">{{#explode:stage|;|0}}</th>
       <th>{{#explode:language|;|0}}</th>
+
       <th>{{#explode:languageVar|;|0}}</th>
 
         {{#arraymap:{{{formats|WebM;.webm,HLS;.m3u8}}}|,|format|
 
         {{#arraymap:{{{formats|WebM;.webm,HLS;.m3u8}}}|,|format|
           {{#arraymap:{{{types|HD;hd,SD;sd,Slides;slides}}}|,|type|<td>[{{{baseURL|http://cdn.c3voc.de/}}}{{#explode:stage|;|1}}{{#explode:language|;|1}}{{#explode:type|;|1}}{{#explode:format|;|1}} link]</td>|}}
+
           {{#arraymap:{{{types|HD;_hd,SD;_sd,Slides;_slides}}}|,|type|<td>[{{{baseURL|https://cdn.c3voc.de/}}}{{#ifeq:{{#explode:format|;|0}}|HLS|hls/}}{{#explode:stage|;|1}}{{#explode:languageVar|;|1}}{{#explode:type|;|1}}{{#explode:format|;|1}} link]</td>|}}
 
         |}}
 
         |}}
  
Line 38: Line 103:
 
|}}
 
|}}
 
</table>
 
</table>
 +
</includeonly>

Latest revision as of 14:52, 27 December 2019

synopsis

This is the "StreamLinkTable" template.

It will generate a table with various links derived from the stages, languages, formats and types.

It should be called in the following format (all parameters are optional):

{{StreamLinkTable
|baseURL=
|stages=
|languages=
|languageCount=
|formats=
|types=
|typeCount=
}}

parameters

The parameters all default to something useful for CCC and each has a specific syntax: baseURL

  • baseURL: first common part of the link, defaults to https://cdn.c3voc.de/
  • stages: comma separated (,) list of Stage Label;urlPart (note the semicolon ;), defaults to 3 × Stage n;sn
  • languages: comma separated (,) list of Language Label;urlPart (note the semicolon ;), defaults to Native;_native,Translated;_translated
  • languageCount: number used for setting the correct table header span, set to reflect the amount of languages, defaults to 2
  • formats: comma separated (,) list of Format Label;urlPart (note the semicolon ;), defaults to WebM;.webm,HLS;.m3u8
  • types: comma separated (,) list of Type Label;urlPart (note the semicolon ;), defaults to HD;_hd,SD;_sd,Slides;_slides
  • typeCount: number used for setting the correct table header span, set to reflect the amount of types, defaults to 3

The links are generated as followed (always using the item part after the semicolon: baseURL+stage(outer row)+language(inner row)+type(inner column)+format(outer column), for example Stage 3 Native Slides as HLS will have the link: https://cdn.c3voc.de/s3_native_slides.m3u8

css

Note that for the best results, this table needs extra CSS in MediaWiki:Common.css:

/* CSS span table rowspan only showing the first row header (assuming there are 2 column headers stacked, hence +3) */
table.span tr>th.span2,
table.span tr>th.span3,
table.span tr>th.span4,
table.span tr>th.span5
{
    display: none;
}

table.span tr:nth-of-type(2n+3)>th.span2,
table.span tr:nth-of-type(3n+3)>th.span3,
table.span tr:nth-of-type(4n+3)>th.span4,
table.span tr:nth-of-type(5n+3)>th.span5
{
    display: table-cell;
}

If it is not possible to have this CSS added, or you want to repeat every row header, make sure to set languageCount = 1 (or the table layout will break without the added CSS).

example

Edit the page to see how the following tables are generated:

The default is written like this:

{{StreamLinkTable}}

looks like this:

WebMHLS
HDSDSlidesHDSDSlides
Stage 1 Native linklinklinklinklinklink
Stage 1 Translated linklinklinklinklinklink
Stage 2 Native linklinklinklinklinklink
Stage 2 Translated linklinklinklinklinklink
Stage 3 Native linklinklinklinklinklink
Stage 3 Translated linklinklinklinklinklink

For a different set of stages, use this:

{{StreamLinkTable
|stages=Main stage;stage1,Backup stage;stageb
}}

to generate:

WebMHLS
HDSDSlidesHDSDSlides
Main stage Native linklinklinklinklinklink
Main stage Translated linklinklinklinklinklink
Backup stage Native linklinklinklinklinklink
Backup stage Translated linklinklinklinklinklink

For an extra set of languages, use this:

{{StreamLinkTable
|languages=English;_eng,German;_deu,French;_fra,Dutch;_ned
|languageCount=4
}}

to generate:

WebMHLS
HDSDSlidesHDSDSlides
Stage 1 English linklinklinklinklinklink
Stage 1 German linklinklinklinklinklink
Stage 1 French linklinklinklinklinklink
Stage 1 Dutch linklinklinklinklinklink
Stage 2 English linklinklinklinklinklink
Stage 2 German linklinklinklinklinklink
Stage 2 French linklinklinklinklinklink
Stage 2 Dutch linklinklinklinklinklink
Stage 3 English linklinklinklinklinklink
Stage 3 German linklinklinklinklinklink
Stage 3 French linklinklinklinklinklink
Stage 3 Dutch linklinklinklinklinklink