From af8092e7d459c51d35ab220a3e5a78c752a90353 Mon Sep 17 00:00:00 2001 From: Boris Date: Sat, 25 Sep 2021 14:53:41 +0200 Subject: [PATCH 1/3] [ENH] Add lazy loading of images --- www/boris/inc/header.php | 1 + www/boris/lib/lazyImg.min.js | 1 + 2 files changed, 2 insertions(+) create mode 100644 www/boris/lib/lazyImg.min.js diff --git a/www/boris/inc/header.php b/www/boris/inc/header.php index 4131c23..23f5d3c 100644 --- a/www/boris/inc/header.php +++ b/www/boris/inc/header.php @@ -10,6 +10,7 @@ $bodyClasses .= $home ? 'home' : ''; Astroport "<?php echo STATION_NAME; ?>" + diff --git a/www/boris/lib/lazyImg.min.js b/www/boris/lib/lazyImg.min.js new file mode 100644 index 0000000..6b03698 --- /dev/null +++ b/www/boris/lib/lazyImg.min.js @@ -0,0 +1 @@ +var lazyImg={};!function(){lazyImg.image="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEA",lazyImg.custom_offset=100,lazyImg.view_elements=[],lazyImg.viewportHeight=lazyImg.viewportWidth=0,lazyImg.body=lazyImg.docEl=null,lazyImg.initVar=function(){lazyImg.viewportHeight=window.innerHeight,lazyImg.viewportWidth=window.innerWidth,lazyImg.body=document.body,lazyImg.docEl=document.documentElement},lazyImg.setConfig=function(a,b){lazyImg.image=a||lazyImg.image,lazyImg.custom_offset=b||lazyImg.custom_offset},lazyImg.reveal=function(){for(var a=window.scrollTop||lazyImg.docEl.scrollTop||lazyImg.body.scrollTop,b=window.scrollLeft||lazyImg.docEl.scrollLeft||lazyImg.body.scrollLeft,c=lazyImg.docEl.clientTop||lazyImg.body.clientTop||0,d=lazyImg.docEl.clientLeft||lazyImg.body.clientLeft||0,e=0;ea-lazyImg.custom_offset&&hb-lazyImg.custom_offset&&j Date: Sat, 25 Sep 2021 15:08:10 +0200 Subject: [PATCH 2/3] [ENH] Change tag filtering behavior --- www/boris/youtube.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/www/boris/youtube.php b/www/boris/youtube.php index 387a89e..d6124c6 100644 --- a/www/boris/youtube.php +++ b/www/boris/youtube.php @@ -193,7 +193,7 @@ echo ' '; -if (!empty($tagFilter)) { +// if (!empty($tagFilter)) { echo ' '; -} +// } +/* echo ' +'; +*/ + +echo ' '; @@ -324,6 +328,8 @@ foreach ($videosList as $video) { $tagQueryArray = array_diff($tagFilter, $tagArray); } + $tagQueryArray = $tagArray; + $classes = $selectedTag ? ' selected' : 'selectable'; if (!empty($tagQueryArray)) { From 624de324ca5e327dc094fb3bad30460154ec012e Mon Sep 17 00:00:00 2001 From: Boris Date: Sat, 25 Sep 2021 15:30:19 +0200 Subject: [PATCH 3/3] [FIX] Fix slowness of webUI --- www/boris/youtube.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/www/boris/youtube.php b/www/boris/youtube.php index d6124c6..7ab0375 100644 --- a/www/boris/youtube.php +++ b/www/boris/youtube.php @@ -2,6 +2,12 @@ require_once('conf.php'); require_once('functions.php'); +$i = 0; +$div = 9; +$r = rand(0, ($div - 1)); +$j = 0; +$maxElt = 16; + // require('php-ipfs-api/vendor/autoload.php'); // use Cloutier\PhpIpfsApi\IPFS; // $ipfs = new IPFS("astroport", "8181", IPFS_API_PORT); @@ -12,6 +18,7 @@ require_once('functions.php'); $uriParams = []; $videosList = array(); +$videosListURIs = array(); $search = isset($_GET['search']) ? urldecode($_GET['search']) : ""; exec("/bin/bash -c './get_astrxbian_index.sh \"*\" \"". $search . "\"'", $videos); exec("/bin/bash -c './get_PIN.sh'", $pinnedVideos); @@ -23,10 +30,6 @@ exec("/bin/bash -c './get_PIN.sh'", $pinnedVideos); // echo shell_exec('whoami'); // Pour savoir quel utilisateur système exécute les scripts PHP // echo '
'; var_dump($videos); echo '
'; exit; -$i = 0; -$div = 9; -$r = rand(0, ($div - 1)); -$j = 0; $tagsMenu = array(); $narrowingTags = array(); $show = isset($_GET['show']) ? $_GET['show'] : 'pinned'; @@ -49,7 +52,7 @@ foreach ($videos as $v) { list($contentType, $videoID, $year, $filename, $saison, $tagsStr, $ipnsHash, $definition, $videoURI) = explode(";", $v); - if (in_array_column($videoURI, 'uri', $videosList)) { + if (in_array($videoURI, $videosListURIs)) { continue; } @@ -76,7 +79,6 @@ foreach ($videos as $v) { if ($keepVideo) { $narrowingTags = array_merge($narrowingTags, $videoTags); - /* ++$i; if ($i % $div != $r) { @@ -84,11 +86,12 @@ foreach ($videos as $v) { } ++$j; - if ($j > 9) { + if ($j > $maxElt) { break; } */ + $duration = NULL; $thumbURL = ''; $videoTitle = NULL; @@ -96,6 +99,7 @@ foreach ($videos as $v) { if (($contentType == 'youtube') and ($videoSource == 'www.youtube.com')) { $thumbURL = sprintf(YOUTUBE_THUMB, $videoID); + // $thumbURL = ''; // $json = getVideoJson($ipnsHash); @@ -115,6 +119,8 @@ foreach ($videos as $v) { $thumbURL = 'styles/'. THEME .'/font-awesome/film.white.90x90.png'; } + $videosListURIs[] = $videoURI; + $videosList[] = [ 'duration' => $duration, 'thumbURL' => $thumbURL,