mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-23 21:18:58 +00:00
Placeholder screenshots when the domain is missing from the database entirely.
This commit is contained in:
parent
5c1a59257c
commit
2a25b5e8a9
@ -87,37 +87,38 @@ public class ScreenshotService {
|
|||||||
|
|
||||||
private Object serveSvgPlaceholder(Response response, int id) {
|
private Object serveSvgPlaceholder(Response response, int id) {
|
||||||
|
|
||||||
var domainName = domainQueries.getDomain(new EdgeId<>(id)).map(Object::toString);
|
var name = domainQueries.getDomain(new EdgeId<>(id)).map(Object::toString)
|
||||||
if (domainName.isEmpty()) {
|
.orElse("[Screenshot Not Yet Captured]");
|
||||||
Spark.halt(404);
|
|
||||||
}
|
|
||||||
|
|
||||||
response.type("image/svg+xml");
|
response.type("image/svg+xml");
|
||||||
return String.format("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
|
|
||||||
"<svg\n" +
|
return """
|
||||||
" xmlns=\"http://www.w3.org/2000/svg\"\n" +
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
" width=\"640px\"\n" +
|
<svg
|
||||||
" height=\"480px\"\n" +
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
" viewBox=\"0 0 640 480\"\n" +
|
width="640px"
|
||||||
" version=\"1.1\">\n" +
|
height="480px"
|
||||||
" <g>\n" +
|
viewBox="0 0 640 480"
|
||||||
" <rect\n" +
|
version="1.1">
|
||||||
" style=\"fill:#808080\"\n" +
|
<g>
|
||||||
" id=\"rect288\"\n" +
|
<rect
|
||||||
" width=\"595.41992\"\n" +
|
style="fill:#808080"
|
||||||
" height=\"430.01825\"\n" +
|
id="rect288"
|
||||||
" x=\"23.034981\"\n" +
|
width="595.41992"
|
||||||
" y=\"27.850344\" />\n" +
|
height="430.01825"
|
||||||
" <text\n" +
|
x="23.034981"
|
||||||
" xml:space=\"preserve\"\n" +
|
y="27.850344" />
|
||||||
" style=\"font-size:100px;fill:#909090;font-family:sans-serif;\"\n" +
|
<text
|
||||||
" x=\"20\"\n" +
|
xml:space="preserve"
|
||||||
" y=\"120\">Placeholder</text>\n" +
|
style="font-size:100px;fill:#909090;font-family:sans-serif;"
|
||||||
" <text\n" +
|
x="20"
|
||||||
" xml:space=\"preserve\"\n" +
|
y="120">Placeholder</text>
|
||||||
" style=\"font-size:32px;fill:#000000;font-family:monospace;\"\n" +
|
<text
|
||||||
" x=\"320\" y=\"240\" dominant-baseline=\"middle\" text-anchor=\"middle\">%s</text>\n" +
|
xml:space="preserve"
|
||||||
" </g>\n" +
|
style="font-size:32px;fill:#000000;font-family:monospace;"
|
||||||
"</svg>\n", domainName.get());
|
x="320" y="240" dominant-baseline="middle" text-anchor="middle">%s</text>
|
||||||
|
</g>
|
||||||
|
</svg>\n
|
||||||
|
""".formatted(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,8 @@ server {
|
|||||||
rewrite ^/explore/(.*)$ /search?query=browse:$1&profile=yolo;
|
rewrite ^/explore/(.*)$ /search?query=browse:$1&profile=yolo;
|
||||||
rewrite ^/links/(.*)$ /search?query=links:$1&profile=corpo;
|
rewrite ^/links/(.*)$ /search?query=links:$1&profile=corpo;
|
||||||
|
|
||||||
|
|
||||||
location /screenshot {
|
location /screenshot {
|
||||||
proxy_pass http://assistant-service:5025/public$uri;
|
proxy_pass http://assistant-service:5025/public/screenshot;
|
||||||
}
|
}
|
||||||
location /site-search {
|
location /site-search {
|
||||||
proxy_pass http://search-service:5023/public/site-search;
|
proxy_pass http://search-service:5023/public/site-search;
|
||||||
|
Loading…
Reference in New Issue
Block a user