mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
simplify link indicators
This commit is contained in:
parent
5ea787cb0f
commit
4ec647e4f6
2 changed files with 11 additions and 19 deletions
|
|
@ -22,8 +22,8 @@ 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 LINK_PREFIX_INTERNAL = '⇒';
|
||||
public const LINK_PREFIX_EXTERNAL = '⇗';
|
||||
|
||||
public const WRAP_BREAK = PHP_EOL;
|
||||
public const WRAP_WIDTH = 320; // px
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ class Gemtext extends \Yggverse\Yoda\Abstract\Model\Gtk\Pango\Markup
|
|||
|
||||
else
|
||||
{
|
||||
$prefix = self::LINK_PREFIX_DEFAULT;
|
||||
$prefix = self::LINK_PREFIX_EXTERNAL;
|
||||
|
||||
$line[] = self::link(
|
||||
self::_url(
|
||||
|
|
@ -208,34 +208,26 @@ class Gemtext extends \Yggverse\Yoda\Abstract\Model\Gtk\Pango\Markup
|
|||
private static function _url(
|
||||
string $link,
|
||||
string $base,
|
||||
string &$prefix = self::LINK_PREFIX_DEFAULT
|
||||
string &$prefix = self::LINK_PREFIX_EXTERNAL
|
||||
): ?string
|
||||
{
|
||||
$address = new Address(
|
||||
$link
|
||||
);
|
||||
|
||||
$request = new Address(
|
||||
$base
|
||||
);
|
||||
|
||||
if ($address->isRelative())
|
||||
{
|
||||
$address->toAbsolute(
|
||||
new Address(
|
||||
$base
|
||||
)
|
||||
$request
|
||||
);
|
||||
}
|
||||
|
||||
switch ($address->getScheme())
|
||||
{
|
||||
case 'gemini':
|
||||
|
||||
$prefix = self::LINK_PREFIX_GEMINI;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
$prefix = self::LINK_PREFIX_DEFAULT;
|
||||
}
|
||||
$prefix = $address->getScheme() == $request->getScheme() ? self::LINK_PREFIX_INTERNAL
|
||||
: self::LINK_PREFIX_EXTERNAL;
|
||||
|
||||
return $address->get();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue