X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=plugins%2Farchiveorg%2Farchiveorg.php;h=a7b595e163424fa3ce3e1b2a181e3bdc4f9d1575;hb=7f5250421be4832b9679d8140bc4a71c8005dfa3;hp=7d172584c45ee9d87aa6169d2cdc186bc82c9059;hpb=1b4ea59f93386594a6e6f35e581244b65c2db57f;p=github%2Fshaarli%2FShaarli.git diff --git a/plugins/archiveorg/archiveorg.php b/plugins/archiveorg/archiveorg.php index 7d172584..a7b595e1 100644 --- a/plugins/archiveorg/archiveorg.php +++ b/plugins/archiveorg/archiveorg.php @@ -5,6 +5,8 @@ * Add an icon in the link list for archive.org. */ +use Shaarli\Plugin\PluginManager; + /** * Add archive.org icon to link_plugin when rendering linklist. * @@ -15,11 +17,27 @@ function hook_archiveorg_render_linklist($data) { $archive_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/archiveorg/archiveorg.html'); + $rootPath = preg_replace('#/index\.php$#', '', $data['_BASE_PATH_'] ?? ''); + $path = $rootPath . '/' . PluginManager::$PLUGINS_PATH; foreach ($data['links'] as &$value) { - $archive = sprintf($archive_html, $value['url']); + $isNote = startsWith($value['real_url'], '/shaare/'); + if ($value['private'] && $isNote) { + continue; + } + $url = $isNote ? rtrim(index_url($_SERVER), '/') . $value['real_url'] : $value['real_url']; + $archive = sprintf($archive_html, $url, $path, t('View on archive.org')); $value['link_plugin'][] = $archive; } return $data; } + +/** + * This function is never called, but contains translation calls for GNU gettext extraction. + */ +function archiveorg_dummy_translation() +{ + // meta + t('For each link, add an Archive.org icon.'); +}