2020-10-14 00:12:16 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2020-10-14 12:47:42 +02:00
|
|
|
* ClickAt
|
2020-10-14 00:12:16 +02:00
|
|
|
*
|
2024-02-03 22:55:13 +01:00
|
|
|
* This plugin makes microblogging social networks (Twitter/X, Threads, Bluesky and Fediverse) addresses clickable.
|
2020-10-14 00:12:16 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
use Shaarli\Config\ConfigManager;
|
|
|
|
use Shaarli\Plugin\PluginManager;
|
|
|
|
use Shaarli\Render\TemplatePage;
|
|
|
|
|
|
|
|
function hook_clickat_render_linklist($data)
|
|
|
|
{
|
2024-01-27 17:43:56 +01:00
|
|
|
$patterns = array(
|
2024-02-25 18:36:26 +01:00
|
|
|
'/([^\S]+)@([\w]+).bsky.social/' => '\1<a href="https://bsky.app/profile/\2.bsky.social">@\2.bsky.social</a>',
|
|
|
|
'/([^\S]+)@([\w]+)@([\w_\-\.]+)/' => '\1<a href="https://\3/@\2">@\2</a>',
|
|
|
|
'/([^\S]+)@([\w]+)/' => '\1<a href="https://twitter.com/\2">@\2</a>'
|
2024-02-11 21:50:03 +01:00
|
|
|
);
|
|
|
|
foreach ($data['links'] as &$value) {
|
2024-02-25 18:36:26 +01:00
|
|
|
if (strpos($value['description'], '@') !== false) {
|
2024-02-11 21:50:03 +01:00
|
|
|
foreach($patterns as $nic => $link) {
|
2024-01-28 17:23:23 +01:00
|
|
|
$value['description'] = preg_replace($nic, $link, $value['description']);
|
2024-02-11 21:50:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-14 00:12:16 +02:00
|
|
|
return $data;
|
|
|
|
}
|