(search) Hackery to get a more balanced view

This commit is contained in:
Viktor Lofgren 2023-12-04 22:50:39 +01:00
parent 8a1934008c
commit f36cfe34ab
4 changed files with 41 additions and 13 deletions

View File

@ -197,6 +197,16 @@ public class SearchSiteInfoService {
linking);
}
public String getLayout() {
// My CSS is too weak to handle this in CSS alone, so I guess we're doing layout in Java...
if (similar.size() < 25) {
return "lopsided";
}
else {
return "balanced";
}
}
public String query() { return "site:" + domain; }
private static String domainInfoState(DomainInformation info) {

View File

@ -114,7 +114,7 @@ public class SimilarDomainsService {
LEFT JOIN EC_DOMAIN_LINK STOD ON STOD.SOURCE_DOMAIN_ID = NEIGHBOR.ID AND STOD.DEST_DOMAIN_ID = EC_DOMAIN_NEIGHBORS_2.DOMAIN_ID
LEFT JOIN EC_DOMAIN_LINK DTOS ON DTOS.DEST_DOMAIN_ID = NEIGHBOR.ID AND DTOS.SOURCE_DOMAIN_ID = EC_DOMAIN_NEIGHBORS_2.DOMAIN_ID
WHERE DOMAIN_ID = ?
ORDER BY RELATEDNESS DESC
ORDER BY RELATEDNESS DESC, RANK ASC
LIMIT ?
""";
String q2 = """
@ -134,7 +134,7 @@ public class SimilarDomainsService {
LEFT JOIN EC_DOMAIN_LINK STOD ON STOD.SOURCE_DOMAIN_ID = NEIGHBOR.ID AND STOD.DEST_DOMAIN_ID = EC_DOMAIN_NEIGHBORS_2.NEIGHBOR_ID
LEFT JOIN EC_DOMAIN_LINK DTOS ON DTOS.DEST_DOMAIN_ID = NEIGHBOR.ID AND DTOS.SOURCE_DOMAIN_ID = EC_DOMAIN_NEIGHBORS_2.NEIGHBOR_ID
WHERE NEIGHBOR_ID = ?
ORDER BY RELATEDNESS DESC
ORDER BY RELATEDNESS DESC, RANK ASC
LIMIT ?
""";
@ -166,7 +166,7 @@ public class SimilarDomainsService {
LEFT JOIN EC_DOMAIN_LINK DTOS ON DTOS.DEST_DOMAIN_ID = STOD.SOURCE_DOMAIN_ID AND DTOS.SOURCE_DOMAIN_ID = STOD.DEST_DOMAIN_ID
WHERE STOD.DEST_DOMAIN_ID = ?
GROUP BY NEIGHBOR.ID
ORDER BY RELATEDNESS DESC
ORDER BY RELATEDNESS DESC, RANK ASC
LIMIT ?
""";
String q2 = """
@ -188,7 +188,7 @@ public class SimilarDomainsService {
LEFT JOIN EC_DOMAIN_LINK STOD ON STOD.DEST_DOMAIN_ID = DTOS.SOURCE_DOMAIN_ID AND STOD.SOURCE_DOMAIN_ID = DTOS.DEST_DOMAIN_ID
WHERE DTOS.SOURCE_DOMAIN_ID = ?
GROUP BY NEIGHBOR.ID
ORDER BY RELATEDNESS DESC
ORDER BY RELATEDNESS DESC, RANK ASC
LIMIT ?
""";
@ -225,8 +225,8 @@ public class SimilarDomainsService {
domains.add(new SimilarDomain(
new EdgeDomain(rsp.getString("DOMAIN_NAME")).toRootUrl(),
id,
100 * rsp.getDouble("RELATEDNESS"),
100 * (1. - rsp.getDouble("RANK")),
Math.round(100 * rsp.getDouble("RELATEDNESS")),
Math.round(100 * (1. - rsp.getDouble("RANK"))),
rsp.getBoolean("INDEXED"),
rsp.getBoolean("ACTIVE"),
rsp.getBoolean("HAS_SCREENSHOT"),

View File

@ -372,18 +372,36 @@ footer {
}
}
#similar-info {
#similar-view[data-layout="lopsided"] {
#similar-info {
@extend .dialog;
grid-column: 1;
grid-row: 1 / span 2;
}
#similar-domains {
@extend .dialog;
grid-column: 2;
grid-row: 1;
}
#similar-links {
@extend .dialog;
grid-row: 2;
grid-column: 2;
}
}
#similar-domains {
#similar-view[data-layout="balanced"] {
#similar-info {
@extend .dialog;
}
#similar-domains {
grid-row: span 2;
@extend .dialog;
}
#similar-links {
}
#similar-links {
@extend .dialog;
}
}
@media (max-device-width: 900px) {

View File

@ -53,7 +53,7 @@
</div>
<div id="similar-view">
<div id="similar-view" data-layout="{{layout}}">
<div id="similar-info">
<h2><span title="External Link">&#x1F30E;</span>&nbsp;<a rel="external noopener" href="https://{{domain}}/">{{domain}}</a></h2>