diff --git a/pfaltgall b/pfaltgall index 4adb755..f4d2dc3 100755 --- a/pfaltgall +++ b/pfaltgall @@ -19,7 +19,7 @@ // todo: add a "last updated on" header $SCRIPTNAME='pfaltgall'; -$SCRIPTVERSION='0.3'; +$SCRIPTVERSION='0.3.1'; $SCRIPTURL='https://git.lattuga.net/Jones/pfaltgall'; require 'lib/ckratelimit.php'; @@ -31,6 +31,7 @@ $outfp=null; $conf=[ 'host'=>null, 'token'=>null, + 'lang'=>null ]; $help= @@ -42,19 +43,21 @@ $help= This is {$SCRIPTNAME} v{$SCRIPTVERSION}, a CLI PHP script that can generate an html file with a gallery from your Pixelfed profile. The html gallery file will load -images dynamically, display each one using almost all the available screen -space and let you jump right from the start to any point in the timeline. -It will also show each post’s text content, its date, and provide each image -with its description (alt-text), if present. - See my example gallery here: https://rame.altervista.org/foto-pixelfed +images dynamically from your Pixelfed instance or its CDN, display each one +using almost all the available screen space and let you jump right from the +start to any point in the timeline. + It will also show each post’s text content, its date, and provide each image +with its description (alt-text), if it’s present on Pixelfed. + Here is example gallery: https://rame.altervista.org/foto-pixelfed In order to create the html gallery file, you just need to login to your -Pixelfed account and get an app token (Settings -> Applications -> Create new -token), then create a configuration file for {$SCRIPTNAME} like this (don’t write -the «---» lines): +Pixelfed account from the official web frontend and get an app token +(Settings -> Applications -> Create new token), then create a configuration +file for {$SCRIPTNAME} like this (don’t write the «---» lines): --- host=your_instance_host token=your_token +lang=your_html_page_language_code --- For example: @@ -62,13 +65,16 @@ token=your_token --- host=pixelfed.social token=as7f8a7s0d89f7as97df09a8s7d90f81jkl2h34lkj12h3jkl4 +lang=it --- Then run {$SCRIPTNAME} with the path of the configuration file you have created and the path of an output file as arguments (if the output file exists, it -will be overwritten), e.g.: «{$SCRIPTNAME} goofy@pixelfed.social.conf index.html». - This will create an html file that will be ready to be put where you want -(you’ll also be able to see it locally, obviously). +will be overwritten), e.g.: «{$SCRIPTNAME} pixelfed.social.conf index.html». + This will create an «index.html» file that will be ready to be put where you +want (you’ll also be able to see it locally, obviously). There is a sample +bash script that you can adapt to run {$SCRIPTNAME} and automatically upload +it where you want. [[[ OPTIONS ]]] @@ -122,6 +128,8 @@ if (!array_key_exists('host',$fconf)) $errors[]="no «host» defined"; if (!array_key_exists('token',$fconf)) $errors[]="no «token» defined"; +if (!array_key_exists('lang',$fconf)) + $errors[]="no «lang» defined"; if (count($errors)>0) { eecho("Error: {$SCRIPTNAME} has found errors in «{$configfp}» configuration file:\n"); foreach ($errors as $val) @@ -143,9 +151,9 @@ if (!$acc['ok']) { ckrl($acc['headers']); $acc=$acc['content']; -$imgurls=[]; +$imgsurls=[]; $imgs=''; -$thumburls=[]; +$thumbsurls=[]; $thumbs=''; $i=0; $ic=0; @@ -183,9 +191,9 @@ do { foreach ($status['media_attachments'] as $attachment) { if (isset($attachment['url'])) { $thumburl=$attachment['preview_url']; - $thumburls[]=$thumburl; + $thumbsurls[]=$thumburl; $imgurl=$attachment['url']; - $imgurls[]=$imgurl; + $imgsurls[]=$imgurl; $ia++; if (isset($attachment['description']) && preg_match('#^\s+$#',$attachment['description'])!==1) $altdesc=' alt="'.htmlspecialchars(trim($attachment['description']),ENT_QUOTES|ENT_HTML5).'"'; @@ -197,8 +205,8 @@ do { $icnt=''; /* $imgs.="
{$desc}{$icnt}{$date}
\n"; $thumbs.="
";*/ - $imgs.="
{$desc}{$icnt}{$date}
\n"; - $thumbs.="
"; + $imgs.="
{$desc}{$icnt}{$date}
\n"; + $thumbs.="
"; $ic++; } } @@ -223,7 +231,7 @@ if ($acc['display_name']!='') { } $html=' - + '.$title.' @@ -465,9 +473,8 @@ hr {