Skip to content

Pass data properly to paella #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class provider implements \core_privacy\local\metadata\null_provider {
*
* @return string
*/
public static function get_reason() : string {
public static function get_reason(): string {
return 'privacy:metadata';
}
}
4 changes: 2 additions & 2 deletions lang/en/filter_opencast.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
$string['filtername'] = 'Opencast';
$string['pluginname'] = 'Opencast Filter';
$string['privacy:metadata'] = 'The Opencast filter plugin does not store any personal data.';
$string['setting_episodeurl'] = 'URL templates for filtering';
$string['setting_episodeurl_desc'] = 'URLs matching this template are replaced with the Opencast player. You must use the placeholder [EPISODEID] to indicate where the episode ID is contained in the URL e.g. http://stable.opencast.de/play/[EPISODEID]. If you want to filter for multiple URLs, enter each URL in a new line.';
$string['setting_configurl'] = 'URL to Paella config.json';
$string['setting_configurl_desc'] = 'URL of the config.json used by Paella Player. Can either be a absolute URL or a URL relative to the wwwroot.';
$string['setting_episodeurl'] = 'URL templates for filtering';
$string['setting_episodeurl_desc'] = 'URLs matching this template are replaced with the Opencast player. You must use the placeholder [EPISODEID] to indicate where the episode ID is contained in the URL e.g. http://stable.opencast.de/play/[EPISODEID]. If you want to filter for multiple URLs, enter each URL in a new line.';
4 changes: 2 additions & 2 deletions templates/player.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"playerid": "ocplayer_0",
"configurl": "/filter/opencast/config.json",
"modplayerpath": "/mod/opencast/player.html",
"data": "{"metadata":{"title": "Test video", "etc": "..."}"
"data": "{\"metadata\":{\"title\": \"Test video\", \"etc\": \"...\"}"
}
}}

Expand All @@ -51,7 +51,7 @@ function init_{{playerid}}() {
iframeWindow.MoodlePaellaPlayer.initPaella(
'{{{configurl}}}',
'{{{themeurl}}}',
JSON.parse('{{{data}}}')
{{{data}}}
);
}
}
Expand Down
18 changes: 9 additions & 9 deletions tests/replacement_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @group filter_opencast
*/
class replacement_test extends \advanced_testcase {
final class replacement_test extends \advanced_testcase {

public function setUp(): void {
$this->resetAfterTest();
Expand All @@ -52,53 +52,53 @@ public function setUp(): void {
* @param string $input input for filter
* @param string $output expected filter output.
*/
public function test_replacement($input, $output) {
public function test_replacement($input, $output): void {
$filter = new testable_filter(\context_system::instance(), []);
$this->assertEquals($output, $filter->filter($input));
}

/**
* Provides test cases.
*/
public function replacement_provider() {
public static function replacement_provider(): array {
return [
[
' <p> hello </p> <video src="http://localhost:8080/play/f78ac136-8252-4b8e-bfea-4786c6993f03"> hello </video>',
' <p> hello </p> <oc-video episode="f78ac136-8252-4b8e-bfea-4786c6993f03"/>'
' <p> hello </p> <oc-video episode="f78ac136-8252-4b8e-bfea-4786c6993f03"/>',
],
[
'<video src="https://somethingother.com"></video><video>
<source
src="https://stable.opencast.de/play/370e5bef-1d59-4440-858a-4df62e767dfc">
</video>',
'<video src="https://somethingother.com"></video><oc-video episode="370e5bef-1d59-4440-858a-4df62e767dfc"/>'
'<video src="https://somethingother.com"></video><oc-video episode="370e5bef-1d59-4440-858a-4df62e767dfc"/>',
],
[
'<video
autoplay loopdiloop
src="http://localhost:8080/play/f9e7b289-c8be-462f-80bf-d1f493c6ed55"></video>',
'<oc-video episode="f9e7b289-c8be-462f-80bf-d1f493c6ed55"/>'
'<oc-video episode="f9e7b289-c8be-462f-80bf-d1f493c6ed55"/>',
],
[
'begin <video>
<source src="https://somethingother.de/play/4380f73a-47a6-41c6-b854-ec0fa9d0261b">
<source
src="https://stable.opencast.de/play/2e0ca3bb-df8e-4913-9380-c925efaf5ac2">
</video> end',
'begin <oc-video episode="2e0ca3bb-df8e-4913-9380-c925efaf5ac2"/> end'
'begin <oc-video episode="2e0ca3bb-df8e-4913-9380-c925efaf5ac2"/> end',
],
[
'and a link <a href="https://www.google.com">link</a>
<a href="http://localhost:8080/play/09b9d154-c849-429d-adea-3df4f76429b6">look, a video!</a>',
'and a link <a href="https://www.google.com">link</a>
<oc-video episode="09b9d154-c849-429d-adea-3df4f76429b6"/>'
<oc-video episode="09b9d154-c849-429d-adea-3df4f76429b6"/>',
],
[
'and now two <a
href="http://localhost:8080/play/64b085e9-0142-4a10-a08e-3dbce055e740">look, a video!</a>
<video src="http://localhost:8080/play/329885fe-d18e-4c6b-a896-dbc66463a6b2"></video>.',
'and now two <oc-video episode="64b085e9-0142-4a10-a08e-3dbce055e740"/>
<oc-video episode="329885fe-d18e-4c6b-a896-dbc66463a6b2"/>.'
<oc-video episode="329885fe-d18e-4c6b-a896-dbc66463a6b2"/>.',
],
];
}
Expand Down
Loading