mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
implement link prefix indicators
This commit is contained in:
parent
c58d16e861
commit
5ea787cb0f
2 changed files with 28 additions and 4 deletions
|
|
@ -22,6 +22,9 @@ interface Markup
|
||||||
public const TAG_QUOTE = '<i>%s</i>';
|
public const TAG_QUOTE = '<i>%s</i>';
|
||||||
public const TAG_TEXT = '<span>%s</span>';
|
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_BREAK = PHP_EOL;
|
||||||
public const WRAP_WIDTH = 320; // px
|
public const WRAP_WIDTH = 320; // px
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -116,14 +116,21 @@ class Gemtext extends \Yggverse\Yoda\Abstract\Model\Gtk\Pango\Markup
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$prefix = self::LINK_PREFIX_DEFAULT;
|
||||||
|
|
||||||
$line[] = self::link(
|
$line[] = self::link(
|
||||||
self::_url(
|
self::_url(
|
||||||
$entity->getAddress(),
|
$entity->getAddress(),
|
||||||
$request
|
$request,
|
||||||
|
$prefix
|
||||||
),
|
),
|
||||||
$entity->getAddress(),
|
$entity->getAddress(),
|
||||||
$entity->getAlt() ? $entity->getAlt()
|
sprintf(
|
||||||
: $entity->getAddress() // @TODO date
|
'%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
|
||||||
|
|
||||||
private static function _url(
|
private static function _url(
|
||||||
string $link,
|
string $link,
|
||||||
string $base
|
string $base,
|
||||||
|
string &$prefix = self::LINK_PREFIX_DEFAULT
|
||||||
): ?string
|
): ?string
|
||||||
{
|
{
|
||||||
$address = new Address(
|
$address = new Address(
|
||||||
|
|
@ -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();
|
return $address->get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue