gctools-outilsgc / gcpedia

A wiki based on MediaWiki
Other
14 stars 14 forks source link

Create script to update embed video #194

Closed Steph4104 closed 3 days ago

Steph4104 commented 9 months ago

The video extension is no longer support. 2 new extension will replace this.

We need to create a script that will find page that currently use the old extension and replacing it with the right extension.

vid commented 8 months ago

Waiting on completion of #192, #216

vid commented 6 months ago

Wrote a report for file types, it can be used for gcwiki for now until we have script access to gcpedia. Of the gcwiki files, wmv, flv and mpg should be transformed.

pdf: 3450, pptx: 777, docx: 1070, png: 4586, xlsx: 179, jpg: 2296, ppt: 64, odt: 1, svg: 40, zip: 52, odp: 1, gif: 33, wmv: 12, jpeg: 18, doc: 33, rtf: 1, vsd: 3, xlsm: 29, oft: 14, xls: 2, txt: 4, flv: 2, mpg: 1

vid commented 2 weeks ago

Many of the video formats are no longer supported, however they are linked so the user can download and play them.

For embedded Youtube videos, we can use the built in ReplaceText extension, and the IFramePage extension (already in use on gcwiki). A template can be used for more flexibility.

These are the regexes, broken out since it's quite complex otherwise;

php replaceAll.php --regex '<video\b[^>]*?id="([^"]*?)"[^>]*?type="([^"]*?)"[^>]*?desc="([^"]*?)"[^>]*?\/?>' '{{Video|id=$1|type=$2|desc=$3}}' # Capture id, type, and desc

php replaceAll.php --regex '<video\b[^>]*?type="([^"]*?)"[^>]*?id="([^"]*?)"[^>]*?desc="([^"]*?)"[^>]*?\/?>' '{{Video|id=$2|type=$1|desc=$3}}' # Capture type, id, and desc

php replaceAll.php --regex '<video\b[^>]*?desc="([^"]*?)"[^>]*?type="([^"]*?)"[^>]*?id="([^"]*?)"[^>]*?\/?>' '{{Video|id=$3|type=$2|desc=$1}}' # Capture desc, type, and id

php replaceAll.php --regex '<video\b[^>]*?desc="([^"]*?)"[^>]*?id="([^"]*?)"[^>]*?type="([^"]*?)"[^>]*?\/?>' '{{Video|id=$2|type=$3|desc=$1}}' # Capture desc, id, and type

php replaceAll.php --regex '<video\b[^>]*?id="([^"]*?)"[^>]*?type="([^"]*?)"[^>]*?\/?>' '{{Video|id=$1|type=$2|desc=}}' # Capture id and type, no desc

php replaceAll.php --regex '<video\b[^>]*?type="([^"]*?)"[^>]*?id="([^"]*?)"[^>]*?\/?>' '{{Video|id=$2|type=$1|desc=}}' # Capture type and id, no desc

Here's Template:Video (though we should probably do some formatting for the optional description)

{{Special:IframePage/{{{type}}}|path={{{id}}}}}
''{{{desc}}}''

The mediawiki settings will need the following:

$wgIframePageSrc = [
    'YouTube' => 'https://www.youtube.com/embed/'
];
$wgIframePageAllowPath = true;

This can also be used for other sites that need embedding.