render_editlink: don't overwrite title if already set

This commit is contained in:
n 2021-03-06 17:44:34 +01:00
parent 899276cd13
commit e799199016
Signed by: n
GPG key ID: E96086FC951DAE30

View file

@ -62,9 +62,10 @@ 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 (!isset($data['link']['title'])) {
$data['link']['title'] = fetch_iri_title($data['link']['url']); $data['link']['title'] = fetch_iri_title($data['link']['url']);
}
} }
} }
return $data; return $data;
@ -144,7 +145,7 @@ function fetch_iri_title($iri)
$fp = stream_socket_client("tls://".$domain[1].":1965", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $stream_context); $fp = stream_socket_client("tls://".$domain[1].":1965", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $stream_context);
if (!$fp) { if (!$fp) {
error_log("$errstr ($errno)"); error_log("[shaargem] $errstr ($errno)");
} else { } else {
fwrite($fp, $iri."\r\n"); fwrite($fp, $iri."\r\n");
$header = fgets($fp); $header = fgets($fp);