ci2 #7

Merged
n merged 3 commits from ci2 into main 2024-09-14 21:15:53 +02:00
2 changed files with 10 additions and 5 deletions
Showing only changes of commit 10b1ee4a12 - Show all commits

5
.php-cs-fixer.php Normal file
View file

@ -0,0 +1,5 @@
<?php
return (new PhpCsFixer\Config())
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
;

View file

@ -61,8 +61,8 @@ function shaargem_init($conf)
function hook_shaargem_render_editlink($data) function hook_shaargem_render_editlink($data)
{ {
// fetch title only for gemini:// iris // fetch title only for gemini:// iris
if(isset($data['link']['url'])) { if (isset($data['link']['url'])) {
if(strstr($data['link']['url'], "gemini://")) { if (strstr($data['link']['url'], "gemini://")) {
if ($data['link']['title'] == '') { if ($data['link']['title'] == '') {
$data['link']['title'] = fetch_iri_title($data['link']['url']); $data['link']['title'] = fetch_iri_title($data['link']['url']);
} }
@ -84,8 +84,8 @@ function hook_shaargem_render_editlink($data)
function hook_shaargem_save_link($data) function hook_shaargem_save_link($data)
{ {
// ugly hack to get scheme // ugly hack to get scheme
if(isset($_POST['lf_url'])) { if (isset($_POST['lf_url'])) {
if(strstr($_POST['lf_url'], "gemini://")) { if (strstr($_POST['lf_url'], "gemini://")) {
$new_url = str_replace("http://", "gemini://", $data['url']); $new_url = str_replace("http://", "gemini://", $data['url']);
$data['url'] = $new_url; $data['url'] = $new_url;
} }
@ -161,7 +161,7 @@ function fetch_iri_title($iri)
// status 2x ok // status 2x ok
elseif ($status[0] == 2) { elseif ($status[0] == 2) {
$nblines = 1; $nblines = 1;
while($line = fgets($fp)) { while ($line = fgets($fp)) {
$ret = preg_match(",# (.*),", $line, $title); $ret = preg_match(",# (.*),", $line, $title);
if ($title[0] or $nblines > 100) { if ($title[0] or $nblines > 100) {
break; break;