Browse Source

implement link prefix indicators

PHP-GTK3
yggverse 4 months ago
parent
commit
5ea787cb0f
  1. 3
      src/Interface/Model/Gtk/Pango/Markup.php
  2. 29
      src/Model/Gtk/Pango/Markup/Gemtext.php

3
src/Interface/Model/Gtk/Pango/Markup.php

@ -22,6 +22,9 @@ interface Markup @@ -22,6 +22,9 @@ interface Markup
public const TAG_QUOTE = '<i>%s</i>';
public const TAG_TEXT = '<span>%s</span>';
public const LINK_PREFIX_GEMINI = '⇒';
public const LINK_PREFIX_DEFAULT = '⇗';
public const WRAP_BREAK = PHP_EOL;
public const WRAP_WIDTH = 320; // px

29
src/Model/Gtk/Pango/Markup/Gemtext.php

@ -116,14 +116,21 @@ class Gemtext extends \Yggverse\Yoda\Abstract\Model\Gtk\Pango\Markup @@ -116,14 +116,21 @@ class Gemtext extends \Yggverse\Yoda\Abstract\Model\Gtk\Pango\Markup
else
{
$prefix = self::LINK_PREFIX_DEFAULT;
$line[] = self::link(
self::_url(
$entity->getAddress(),
$request
$request,
$prefix
),
$entity->getAddress(),
$entity->getAlt() ? $entity->getAlt()
: $entity->getAddress() // @TODO date
sprintf(
'%s %s',
$prefix,
$entity->getAlt() ? $entity->getAlt()
: $entity->getAddress() // @TODO date
)
);
}
@ -200,7 +207,8 @@ class Gemtext extends \Yggverse\Yoda\Abstract\Model\Gtk\Pango\Markup @@ -200,7 +207,8 @@ class Gemtext extends \Yggverse\Yoda\Abstract\Model\Gtk\Pango\Markup
private static function _url(
string $link,
string $base
string $base,
string &$prefix = self::LINK_PREFIX_DEFAULT
): ?string
{
$address = new Address(
@ -216,6 +224,19 @@ class Gemtext extends \Yggverse\Yoda\Abstract\Model\Gtk\Pango\Markup @@ -216,6 +224,19 @@ class Gemtext extends \Yggverse\Yoda\Abstract\Model\Gtk\Pango\Markup
);
}
switch ($address->getScheme())
{
case 'gemini':
$prefix = self::LINK_PREFIX_GEMINI;
break;
default:
$prefix = self::LINK_PREFIX_DEFAULT;
}
return $address->get();
}
}
Loading…
Cancel
Save