This commit is contained in:
parent
1989307a67
commit
745ac3077d
2 changed files with 4 additions and 8 deletions
|
@ -15,7 +15,3 @@ $ git clone https://forge.tourmentine.com/n/shaarli-plugin-clickat.git path/to/s
|
|||
- Threads with `@nic@threads.net`,
|
||||
- Bluesky with `@nic.bsky.social`,
|
||||
- Fediverse with `@nic@instance`.
|
||||
|
||||
## Caveats
|
||||
|
||||
For now addresses need to be proceded by an empty space.
|
||||
|
|
|
@ -12,12 +12,12 @@ use Shaarli\Render\TemplatePage;
|
|||
function hook_clickat_render_linklist($data)
|
||||
{
|
||||
$patterns = array(
|
||||
'/\ @([\w\d]+).bsky.social/' => ' <a href="https://bsky.app/profile/\1.bsky.social">@\1.bsky.social</a>',
|
||||
'/\ @([\w\d]+)@([\w\d_\-\.]+)/' => ' <a href="https://\2/@\1">@\1</a>',
|
||||
'/\ @([\w\d]+)/' => ' <a href="https://twitter.com/\1">@\1</a>'
|
||||
'/([^\S]+)@([\w]+).bsky.social/' => ' <a href="https://bsky.app/profile/\2.bsky.social">@\2.bsky.social</a>',
|
||||
'/([^\S]+)@([\w]+)@([\w_\-\.]+)/' => ' <a href="https://\3/@\2">@\2</a>',
|
||||
'/([^\S]+)@([\w]+)/' => ' <a href="https://twitter.com/\2">@\2</a>'
|
||||
);
|
||||
foreach ($data['links'] as &$value) {
|
||||
if (strpos($value['description'], ' @') !== false) {
|
||||
if (strpos($value['description'], '@') !== false) {
|
||||
foreach($patterns as $nic => $link) {
|
||||
$value['description'] = preg_replace($nic, $link, $value['description']);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue