From ea73be68313292262b341a5273b01a979441f4ec Mon Sep 17 00:00:00 2001 From: Viktor Lofgren Date: Fri, 29 Dec 2023 15:55:46 +0100 Subject: [PATCH] (search) Remove the ugly placeholder screenshots from the site info view. --- .../marginalia/search/svc/SearchSiteInfoService.java | 12 +++++++++++- .../templates/search/site-info/site-info-summary.hdb | 7 +++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/code/services-application/search-service/src/main/java/nu/marginalia/search/svc/SearchSiteInfoService.java b/code/services-application/search-service/src/main/java/nu/marginalia/search/svc/SearchSiteInfoService.java index 97aa69bd..a6e9e381 100644 --- a/code/services-application/search-service/src/main/java/nu/marginalia/search/svc/SearchSiteInfoService.java +++ b/code/services-application/search-service/src/main/java/nu/marginalia/search/svc/SearchSiteInfoService.java @@ -9,6 +9,7 @@ import nu.marginalia.feedlot.model.FeedItems; import nu.marginalia.model.EdgeDomain; import nu.marginalia.renderer.MustacheRenderer; import nu.marginalia.renderer.RendererFactory; +import nu.marginalia.screenshot.ScreenshotService; import nu.marginalia.search.SearchOperator; import nu.marginalia.assistant.client.model.DomainInformation; import nu.marginalia.feedlot.FeedlotClient; @@ -33,6 +34,7 @@ public class SearchSiteInfoService { private final DbDomainQueries domainQueries; private final MustacheRenderer renderer; private final FeedlotClient feedlotClient; + private final ScreenshotService screenshotService; @Inject public SearchSiteInfoService(SearchOperator searchOperator, @@ -40,7 +42,8 @@ public class SearchSiteInfoService { RendererFactory rendererFactory, SearchFlagSiteService flagSiteService, DbDomainQueries domainQueries, - FeedlotClient feedlotClient) throws IOException + FeedlotClient feedlotClient, + ScreenshotService screenshotService) throws IOException { this.searchOperator = searchOperator; this.assistantClient = assistantClient; @@ -50,6 +53,7 @@ public class SearchSiteInfoService { this.renderer = rendererFactory.renderer("search/site-info/site-info"); this.feedlotClient = feedlotClient; + this.screenshotService = screenshotService; } public Object handle(Request request, Response response) throws SQLException { @@ -130,6 +134,8 @@ public class SearchSiteInfoService { final List linkingDomains; String url = "https://" + domainName + "/";; + boolean hasScreenshot = screenshotService.hasScreenshot(domainId); + var feedItemsFuture = feedlotClient.getFeedItems(domainName); if (domainId < 0 || !assistantClient.isAccepting()) { domainInfo = createDummySiteInfo(domainName); @@ -161,6 +167,7 @@ public class SearchSiteInfoService { return new SiteInfoWithContext(domainName, domainId, url, + hasScreenshot, domainInfo, similarSet, linkingDomains, @@ -217,6 +224,7 @@ public class SearchSiteInfoService { String domain, long domainId, String siteUrl, + boolean hasScreenshot, DomainInformation domainInformation, List similar, List linking, @@ -226,6 +234,7 @@ public class SearchSiteInfoService { public SiteInfoWithContext(String domain, long domainId, String siteUrl, + boolean hasScreenshot, DomainInformation domainInformation, List similar, List linking, @@ -238,6 +247,7 @@ public class SearchSiteInfoService { domain, domainId, siteUrl, + hasScreenshot, domainInformation, similar, linking, diff --git a/code/services-application/search-service/src/main/resources/templates/search/site-info/site-info-summary.hdb b/code/services-application/search-service/src/main/resources/templates/search/site-info/site-info-summary.hdb index fba7adad..d913a0a6 100644 --- a/code/services-application/search-service/src/main/resources/templates/search/site-info/site-info-summary.hdb +++ b/code/services-application/search-service/src/main/resources/templates/search/site-info/site-info-summary.hdb @@ -8,9 +8,16 @@

🌎 {{domain}}

+ {{#if hasScreenshot}} Screenshot of {{domain}} + {{/if}} + + {{#unless hasScreenshot}} +

Screenshot not yet available.

+ {{/unless}} + {{#with domainInformation}} {{> search/site-info/site-info-feed}} {{> search/site-info/site-info-index}}