web search done right
devdocs optic
Mikkel Denker560b8bdcbf99
diff --git a/core/src/api/optics.rs b/core/src/api/optics.rsindex 16f573f4..a562730a 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; 5] = [+pub const DEFAULT_OPTICS: [OpticLink; 6] = [OpticLink {name: "Copycats removal",url:@@ -45,6 +45,11 @@ pub const DEFAULT_OPTICS: [OpticLink; 5] = [url: "https://raw.githubusercontent.com/StractOrg/sample-optics/main/blogroll.optic",description: "Search only in a list of blogs from blogroll.org and some hand-picked blogs from hackernews.",},+ OpticLink {+ name: "Devdocs",+ 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.",+ },];#[derive(Debug, Clone)]diff --git a/optics-lsp/src/lib.rs b/optics-lsp/src/lib.rsindex 97d1a0c6..bb075f4b 100644--- a/optics-lsp/src/lib.rs+++ b/optics-lsp/src/lib.rs@@ -153,7 +153,7 @@ impl OpticsBackend {optics::Token::Rule => Some("A rule specifies how a particular search result should be treated. \It consists of a `Matches` block and an optional `Action`. Any search result that matches the `Matches` block \will have the `Action` applied to it. The action can either `Boost`, `Downrank` or `Discard` a result. An empty `Action` is \- equivalent to a `Boost` of 1.".to_string()),+ equivalent to a `Boost` of 0.".to_string()),optics::Token::RankingPipeline => Some("The final ranking consists of multiple stages in a pipeline. Each stage receives thebest scoring webpages from the stage before it, and uses more accurate yet computationally expensive algorithms to rankdiff --git a/optics/src/ast.rs b/optics/src/ast.rsindex 7b252488..eec04684 100644--- a/optics/src/ast.rs+++ b/optics/src/ast.rs@@ -313,4 +313,9 @@ mod tests {fn blogroll_parse() {assert!(parse(include_str!("../testcases/blogroll.optic")).is_ok());}++ #[test]+ fn devdocs_parse() {+ assert!(parse(include_str!("../testcases/devdocs.optic")).is_ok());+ }}diff --git a/optics/src/lib.rs b/optics/src/lib.rsindex 7fdb954e..b7c0bd66 100644--- a/optics/src/lib.rs+++ b/optics/src/lib.rs@@ -115,7 +115,7 @@ impl TryFrom<RawRule> for Rule {Ok(Rule {matches,- action: raw.action.map(Action::from).unwrap_or(Action::Boost(1)),+ action: raw.action.map(Action::from).unwrap_or(Action::Boost(0)),})}}diff --git a/optics/testcases b/optics/testcasesindex e47e5dc0..ec468504 160000--- a/optics/testcases+++ b/optics/testcases@@ -1 +1 @@-Subproject commit e47e5dc04516eb75cb26a6a066cd75df0e06c5b2+Subproject commit ec468504519f8044b62f7847467f65870fcfdd0e