diff --git a/ext/reverse_search_links/icons/ascii2d.ico b/ext/reverse_search_links/icons/ascii2d.ico new file mode 100644 index 000000000..29e6fd120 Binary files /dev/null and b/ext/reverse_search_links/icons/ascii2d.ico differ diff --git a/ext/reverse_search_links/icons/saucenao.ico b/ext/reverse_search_links/icons/saucenao.ico new file mode 100644 index 000000000..128dde644 Binary files /dev/null and b/ext/reverse_search_links/icons/saucenao.ico differ diff --git a/ext/reverse_search_links/icons/tineye.ico b/ext/reverse_search_links/icons/tineye.ico new file mode 100644 index 000000000..184b8793e Binary files /dev/null and b/ext/reverse_search_links/icons/tineye.ico differ diff --git a/ext/reverse_search_links/icons/trace.moe.ico b/ext/reverse_search_links/icons/trace.moe.ico new file mode 100644 index 000000000..ff23d4f12 Binary files /dev/null and b/ext/reverse_search_links/icons/trace.moe.ico differ diff --git a/ext/reverse_search_links/icons/yandex.ico b/ext/reverse_search_links/icons/yandex.ico new file mode 100644 index 000000000..984e71c07 Binary files /dev/null and b/ext/reverse_search_links/icons/yandex.ico differ diff --git a/ext/reverse_search_links/info.php b/ext/reverse_search_links/info.php new file mode 100644 index 000000000..15f6164b7 --- /dev/null +++ b/ext/reverse_search_links/info.php @@ -0,0 +1,18 @@ + 'joe@thisisjoes.site']; + public string $license = self::LICENSE_GPLV2; + public string $description = "Provides reverse search links for images."; + public ?string $documentation = "Click on an icon in the 'Reverse Image Search' block to search for the image using the corresponding service. This may be useful to find the original source or author of an image.
+ Options for which services to show and the position and priority of the block are available for admins on the config page."; +} diff --git a/ext/reverse_search_links/main.php b/ext/reverse_search_links/main.php new file mode 100644 index 000000000..07a961b6d --- /dev/null +++ b/ext/reverse_search_links/main.php @@ -0,0 +1,67 @@ +image->get_mime(), $supported_types)) { + $this->theme->reverse_search_block($page, $event->image); + } + } + + + /** + * Supported reverse search services + */ + protected array $SERVICES = [ + 'SauceNAO', + 'TinEye', + 'trace.moe', + 'ascii2d', + 'Yandex' + ]; + + private function get_options(): array + { + global $config; + + $output = []; + $services = $this->SERVICES; + foreach ($services as $service) { + $output[$service] = $service; + } + + return $output; + } + + /** + * Set default config values + */ + public function onInitExt(InitExtEvent $event) + { + global $config; + $config->set_default_array( + ReverseSearchLinksConfig::ENABLED_SERVICES, + ['SauceNAO', 'TinEye', 'trace.moe', 'ascii2d', 'Yandex'] + ); + } +} diff --git a/ext/reverse_search_links/style.css b/ext/reverse_search_links/style.css new file mode 100644 index 000000000..36cab20aa --- /dev/null +++ b/ext/reverse_search_links/style.css @@ -0,0 +1,3 @@ +.reverse_image_link { + padding: 0 5px; +} diff --git a/ext/reverse_search_links/theme.php b/ext/reverse_search_links/theme.php new file mode 100644 index 000000000..ffe79d46e --- /dev/null +++ b/ext/reverse_search_links/theme.php @@ -0,0 +1,34 @@ + 'https://saucenao.com/search.php?url=' . url_escape(make_http($image->get_thumb_link())), + 'TinEye' => 'https://www.tineye.com/search/?url=' . url_escape(make_http($image->get_thumb_link())), + 'trace.moe' => 'https://trace.moe/?auto&url=' . url_escape(make_http($image->get_thumb_link())), + 'ascii2d' => 'https://ascii2d.net/search/url/' . url_escape(make_http($image->get_thumb_link())), + 'Yandex' => 'https://yandex.com/images/search?rpt=imageview&url=' . url_escape(make_http($image->get_thumb_link())) + ]; + + // only generate links for enabled reverse search services + $enabled_services = $config->get_array(ReverseSearchLinksConfig::ENABLED_SERVICES); + + $html = ""; + foreach($links as $name => $link) { + if (in_array($name, $enabled_services)) { + $icon_link = make_link("/ext/reverse_search_links/icons/" . strtolower($name) . ".ico"); + $html .= "$name icon"; + } + } + + $page->add_block(new Block("Reverse Image Search", $html, "main", 20)); + } +}