improve loop #4
2 changed files with 16 additions and 17 deletions
|
@ -5,10 +5,17 @@ social networks (Twitter/𝕏, Threads, Bluesky and Fediverse) addresses clickab
|
||||||
|
|
||||||
## Manual
|
## Manual
|
||||||
|
|
||||||
1. Clone repository in plugin directory.
|
1. Clone repository in `plugins` directory (plugin directory name must be `clickat`)
|
||||||
|
```
|
||||||
|
$ git clone https://forge.tourmentine.com/n/shaarli-plugin-clickat.git path/to/shaarli/plugins/clickat
|
||||||
|
```
|
||||||
2. Activate plugin.
|
2. Activate plugin.
|
||||||
3. Quote users from:
|
3. Quote users from:
|
||||||
- Twitter/𝕏 with their `@nic`,
|
- Twitter/𝕏 with their `@nic`,
|
||||||
- Threads with `@nic@threads.net`,
|
- Threads with `@nic@threads.net`,
|
||||||
- Bluesky with `@nic.bsky.social`,
|
- Bluesky with `@nic.bsky.social`,
|
||||||
- Fediverse with `@nic@instance`.
|
- Fediverse with `@nic@instance`.
|
||||||
|
|
||||||
|
## Caveats
|
||||||
|
|
||||||
|
For now addresses need to be proceded by an empty space.
|
||||||
|
|
24
clickat.php
24
clickat.php
|
@ -11,23 +11,15 @@ use Shaarli\Render\TemplatePage;
|
||||||
|
|
||||||
function hook_clickat_render_linklist($data)
|
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>'
|
||||||
|
);
|
||||||
foreach ($data['links'] as &$value) {
|
foreach ($data['links'] as &$value) {
|
||||||
$value['description'] = preg_replace(
|
foreach($patterns as $nic => $link) {
|
||||||
'/\ @([\w\d]+).bsky.social/',
|
$value['description'] = preg_replace($nic, $link, $value['description']);
|
||||||
' <a href="https://bsky.app/profile/\1.bsky.social">@\1.bsky.social</a>',
|
}
|
||||||
$value['description']
|
|
||||||
);
|
|
||||||
$value['description'] = preg_replace(
|
|
||||||
'/\ @([\w\d]+)@([\w\d_\-\.]+)/',
|
|
||||||
' <a href="https://\2/@\1">@\1</a>',
|
|
||||||
$value['description']
|
|
||||||
);
|
|
||||||
$value['description'] = preg_replace(
|
|
||||||
'/\ @([\w\d]+)/',
|
|
||||||
' <a href="https://twitter.com/\1">@\1</a>',
|
|
||||||
$value['description']
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue