find first title within 100 lines
This commit is contained in:
parent
4459a95b40
commit
cf916f6b8b
1 changed files with 12 additions and 3 deletions
15
shaargem.php
15
shaargem.php
|
@ -60,7 +60,7 @@ function shaargem_init($conf)
|
|||
*/
|
||||
function hook_shaargem_render_editlink($data)
|
||||
{
|
||||
$ret=preg_match(",gemini://([\d\w\.\+\-@\:%._\~#=]+)/?,", $data['link']['url'] ,$domain);
|
||||
$ret = preg_match(",gemini://([\d\w\.\+\-@\:%._\~#=]+)/?,", $data['link']['url'] ,$domain);
|
||||
|
||||
error_log("ret:".$ret);
|
||||
if ($ret)
|
||||
|
@ -77,11 +77,20 @@ function hook_shaargem_render_editlink($data)
|
|||
error_log("$errstr ($errno)");
|
||||
} else {
|
||||
fwrite($fp, $data['link']['url']."\r\n");
|
||||
$header = fgets($fp,1024);
|
||||
$header = fgets($fp);
|
||||
error_log("header:".$header);
|
||||
if (strstr($header, "20 text/gemini"))
|
||||
{
|
||||
$data['link']['title'] = substr(fgets($fp,1024),2,-1);
|
||||
$nblines = 1;
|
||||
while($line = fgets($fp)) {
|
||||
$ret = preg_match(",# (.*),",$line,$title);
|
||||
if ($title[0] or $nblines > 100 ) {
|
||||
error_log($nblines);
|
||||
break;
|
||||
}
|
||||
$nblines++;
|
||||
}
|
||||
$data['link']['title'] = $title[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue