aboutsummaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/web.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/modules/web.rs b/src/modules/web.rs
index 2bb2833..df13058 100644
--- a/src/modules/web.rs
+++ b/src/modules/web.rs
@@ -36,6 +36,8 @@ To visit the web version of this exact page, <{ROOT_HTTPS_URL}/web>, you would v
"/web/*url",
"World Wide Web to Gemini Gateway Visitor",
async move |context: RouteContext| {
+ let queries = windmark::utilities::queries_from_url(&context.url);
+
Response::success({
let Ok(url) = url::Url::parse(&format!(
"https://{}",
@@ -47,7 +49,7 @@ To visit the web version of this exact page, <{ROOT_HTTPS_URL}/web>, you would v
)) else {
return error("The URL you provided is invalid.", &context);
};
- let mut contents = vec![];
+ let mut contents = vec![format!("=> {url} {url}")];
let website = if let Ok(website) = reqwest::get(url.clone()).await {
if let Ok(text) = website.text().await {
text
@@ -72,6 +74,18 @@ To visit the web version of this exact page, <{ROOT_HTTPS_URL}/web>, you would v
let parser = dom.parser();
let mut nodes = dom.nodes().iter().peekable();
+ if let Some(id) = queries.get("id") {
+ nodes = if let Some(element) = dom.get_element_by_id(id.as_str()) {
+ if let Some(children) = element.get(parser).unwrap().children() {
+ children.all(parser).iter().peekable()
+ } else {
+ nodes
+ }
+ } else {
+ nodes
+ };
+ }
+
while let Some(element) = nodes.next() {
let mut text = String::new();
@@ -127,7 +141,7 @@ To visit the web version of this exact page, <{ROOT_HTTPS_URL}/web>, you would v
"h3" => {
contents.push(format!("\n### {}\n\n", tag.inner_text(parser)));
}
- "pre" => {
+ "pre" | "code" => {
contents.push(format!("```\n{}```\n", tag.inner_text(parser)));
}
"blockquote" => {