Skip to content

web search done right

academic optic

Mikkel Denker516d350e33fc
diff --git a/core/src/api/optics.rs b/core/src/api/optics.rs
index a562730a..27c0ace9 100644
--- a/core/src/api/optics.rs
+++ b/core/src/api/optics.rs
@@ -18,7 +18,7 @@ use super::HtmlTemplate;
use askama::Template;
use axum::response::IntoResponse;
-pub const DEFAULT_OPTICS: [OpticLink; 6] = [
+pub const DEFAULT_OPTICS: [OpticLink; 7] = [
OpticLink {
name: "Copycats removal",
url:
@@ -50,6 +50,11 @@ pub const DEFAULT_OPTICS: [OpticLink; 6] = [
url: "https://raw.githubusercontent.com/StractOrg/sample-optics/main/devdocs.optic",
description: "Only return results from some of the developer documentation sites listed on devdocs.io. This is a non-exhaustive list.",
},
+ OpticLink {
+ name: "Academic",
+ url: "https://raw.githubusercontent.com/StractOrg/sample-optics/main/academic.optic",
+ description: "Search exclusively in academic sites (.edu, .ac.uk, arxiv.org etc.). This is a non-exhaustive list.",
+ },
];
#[derive(Debug, Clone)]
diff --git a/frontend/src/pages/search.astro b/frontend/src/pages/search.astro
index b0c56397..38f9bb52 100644
--- a/frontend/src/pages/search.astro
+++ b/frontend/src/pages/search.astro
@@ -287,6 +287,8 @@ import type { AstroCookies } from "astro/dist/core/cookies";
var rankingModalHeight = modal.clientHeight;
+ var prevButtonClickIdx = -1;
+
rankingAdjustButtons.forEach((btn) => {
btn.addEventListener("click", (event) => {
event.stopPropagation();
@@ -305,8 +307,15 @@ import type { AstroCookies } from "astro/dist/core/cookies";
"px";
setTimeout(() => {
- modal.classList.remove("modal-closed");
- modal.classList.add("modal-open");
+ if (prevButtonClickIdx == elem.dataset.idx && modal.classList.contains("modal-open")) {
+ modal.classList.add("modal-closed");
+ modal.classList.remove("modal-open");
+ } else {
+ modal.classList.remove("modal-closed");
+ modal.classList.add("modal-open");
+ }
+
+ prevButtonClickIdx = elem.dataset.idx;
}, 0);
});
});
diff --git a/optics/src/ast.rs b/optics/src/ast.rs
index eec04684..31d4a587 100644
--- a/optics/src/ast.rs
+++ b/optics/src/ast.rs
@@ -318,4 +318,9 @@ mod tests {
fn devdocs_parse() {
assert!(parse(include_str!("../testcases/devdocs.optic")).is_ok());
}
+
+ #[test]
+ fn academic_parse() {
+ assert!(parse(include_str!("../testcases/academic.optic")).is_ok());
+ }
}
diff --git a/optics/testcases b/optics/testcases
index ec468504..ca19b09f 160000
--- a/optics/testcases
+++ b/optics/testcases
@@ -1 +1 @@
-Subproject commit ec468504519f8044b62f7847467f65870fcfdd0e
+Subproject commit ca19b09fb5e0ab8ecea839d9d12c3728d5e4549f