From d11718c89cbac6753a7ae494ee79653c4bf99e03 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 6 May 2021 22:27:49 +0300 Subject: [PATCH 1/4] fix combined/three panel transition to expandable mode --- js/Article.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/js/Article.js b/js/Article.js index be06e8f73..a3a75ba21 100644 --- a/js/Article.js +++ b/js/Article.js @@ -282,9 +282,13 @@ const Article = { console.log("packing", row.id); row.setAttribute("data-is-packed", "1"); - row.querySelector(".content-inner").innerHTML = `
- ${__("Loading, please wait...")} -
` + const content_inner = row.querySelector(".content-inner"); + + // missing in unexpanded mode + if (content_inner) + content_inner.innerHTML = `
+ ${__("Loading, please wait...")} +
` } }, view: function (id, no_expand) { From 86300a0ca85f3133f7a5f0d1bc9ad5d99a8b680d Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 7 May 2021 07:37:27 +0300 Subject: [PATCH 2/4] add urlhelper to extract youtube video id from url --- classes/urlhelper.php | 22 ++++++++++++++++++++++ plugins/af_youtube_embed/init.php | 12 +++++------- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/classes/urlhelper.php b/classes/urlhelper.php index 46d80a0e6..edfb2ad73 100644 --- a/classes/urlhelper.php +++ b/classes/urlhelper.php @@ -487,4 +487,26 @@ class UrlHelper { } } + public static function url_to_youtube_vid($url) { + $url = str_replace("youtube.com", "youtube-nocookie.com", $url); + + $regexps = [ + "/\/\/www\.youtube-nocookie\.com\/v\/([\w-]+)/", + "/\/\/www\.youtube-nocookie\.com\/embed\/([\w-]+)/", + "/\/\/www\.youtube-nocookie\.com\/watch?v=([\w-]+)/", + "/\/\/youtu.be\/([\w-]+)/", + ]; + + foreach ($regexps as $re) { + $matches = []; + + if (preg_match($re, $url, $matches)) { + return $matches[1]; + } + } + + return false; + } + + } diff --git a/plugins/af_youtube_embed/init.php b/plugins/af_youtube_embed/init.php index 95ab0b9d5..72d25a826 100644 --- a/plugins/af_youtube_embed/init.php +++ b/plugins/af_youtube_embed/init.php @@ -16,18 +16,16 @@ class Af_Youtube_Embed extends Plugin { } function hook_iframe_whitelisted($src) { - return in_array($src, ["www.youtube.com", "youtube.com", "youtu.be"]); + return in_array($src, ["www.youtube.com", "youtube.com", + "www.youtube-nocookie.com", "youtube-nocookie.com", + "youtu.be"]); } function hook_render_enclosure($entry, $hide_images) { - $matches = array(); + $url = $entry["content_url"]; - if (preg_match("/\/\/www\.youtube\.com\/v\/([\w-]+)/", $entry["content_url"], $matches) || - preg_match("/\/\/www\.youtube\.com\/watch?v=([\w-]+)/", $entry["content_url"], $matches) || - preg_match("/\/\/youtu.be\/([\w-]+)/", $entry["content_url"], $matches)) { - - $vid_id = $matches[1]; + if ($vid_id = UrlHelper::url_to_youtube_vid($url)) { return "