aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-03-23 00:04:52 -0700
committerFuwn <[email protected]>2024-03-23 00:04:52 -0700
commite1107f9b80a1c32ad38b60e14c2eafdaa33edc3f (patch)
treeb04e090c553d673b9deb35769d1ad1a3bb65f055
parentfeat(index): add random button (diff)
downloadlocus-e1107f9b80a1c32ad38b60e14c2eafdaa33edc3f.tar.xz
locus-e1107f9b80a1c32ad38b60e14c2eafdaa33edc3f.zip
fix(web): ignore style tag
-rw-r--r--src/modules/web.rs38
1 files changed, 14 insertions, 24 deletions
diff --git a/src/modules/web.rs b/src/modules/web.rs
index 02354cd..2a0bce6 100644
--- a/src/modules/web.rs
+++ b/src/modules/web.rs
@@ -15,9 +15,10 @@
// Copyright (C) 2022-2023 Fuwn <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only
-use windmark::response::Response;
-
-use crate::{response::success, route::track_mount};
+use {
+ crate::{response::success, route::track_mount},
+ windmark::response::Response,
+};
fn error(message: &str, context: &windmark::context::RouteContext) -> Response {
success(
@@ -29,23 +30,18 @@ fn error(message: &str, context: &windmark::context::RouteContext) -> Response {
}
pub fn module(router: &mut windmark::router::Router) {
- track_mount(
- router,
- "/web",
- "World Wide Web to Gemini Gateway",
- |context| {
- success(
- &r"# World Wide Web to Gemini Gateway
+ track_mount(router, "/web", "World Wide Web to Gemini Gateway", |context| {
+ success(
+ &r"# World Wide Web to Gemini Gateway
To use this gateway, simply append the address of your target resource to the end of the current route, minus the protocol.
To visit the web version of this exact page, <https://fuwn.me/web>, you would visit <gemini://fuwn.me/web/fuwn.me/web>.
=> /web/fuwn.me/web Try it!",
- &context,
- )
- },
- );
+ &context,
+ )
+ });
track_mount(
router,
"/web/*url",
@@ -57,16 +53,10 @@ To visit the web version of this exact page, <https://fuwn.me/web>, you would vi
if let Some(url_choice) = context.parameters.get("url") {
url_choice
} else {
- return error(
- "Looks like you didn't provide a URL!",
- &context,
- );
+ return error("Looks like you didn't provide a URL!", &context);
}
)) else {
- return error(
- "The URL you provided is invalid.",
- &context,
- );
+ return error("The URL you provided is invalid.", &context);
};
let mut contents = vec![];
let website = if let Ok(website) = reqwest::get(url.clone()).await {
@@ -149,8 +139,8 @@ To visit the web version of this exact page, <https://fuwn.me/web>, you would vi
"li" => {
contents.push(format!("* {}\n", tag.inner_text(parser)));
}
- "html" | "head" | "script" | "link" | "title" | "body" | "ul" => {
- }
+ "html" | "head" | "script" | "link" | "title" | "body" | "ul"
+ | "style" => {}
_ => {
text = tag.inner_text(parser).to_string();