X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=plugins%2Farchiveorg%2Farchiveorg.php;h=922b5966fe3340b203b8c98cc6f970555e4b43a5;hb=76fe68d924d424283d0a1784c5f5e7582dda3a00;hp=7d172584c45ee9d87aa6169d2cdc186bc82c9059;hpb=66017e28935c72ad4ed037f022483ee5630e7372;p=github%2Fshaarli%2FShaarli.git diff --git a/plugins/archiveorg/archiveorg.php b/plugins/archiveorg/archiveorg.php index 7d172584..922b5966 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,26 @@ function hook_archiveorg_render_linklist($data) { $archive_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/archiveorg/archiveorg.html'); + $path = ($data['_BASE_PATH_'] ?? '') . '/' . 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.'); +}