aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/response.rs13
-rw-r--r--src/url.rs10
2 files changed, 23 insertions, 0 deletions
diff --git a/src/response.rs b/src/response.rs
index 486ea3e..288a07f 100644
--- a/src/response.rs
+++ b/src/response.rs
@@ -28,6 +28,7 @@ pub async fn default(
) -> Result<HttpResponse, Error> {
let mut is_proxy = false;
let mut is_raw = false;
+ let mut is_nocss = false;
// Try to construct a Gemini URL
let url = match make_url(
&format!("{}{}", req.path(), {
@@ -41,6 +42,7 @@ pub async fn default(
false,
&mut is_proxy,
&mut is_raw,
+ &mut is_nocss,
) {
Ok(url) => url,
Err(e) => {
@@ -65,6 +67,7 @@ pub async fn default(
true,
&mut is_proxy,
&mut is_raw,
+ &mut is_nocss,
) {
Ok(url) => url,
Err(e) => {
@@ -123,6 +126,16 @@ pub async fn default(
);
}
+ if is_nocss {
+ html_context.push_str(&gemini_html.1);
+
+ return Ok(
+ HttpResponse::Ok()
+ .content_type(format!("text/html; charset={}", meta.mime()))
+ .body(html_context),
+ );
+ }
+
// Try to add an external stylesheet from the `CSS_EXTERNAL` environment
// variable.
if let Ok(css) = var("CSS_EXTERNAL") {
diff --git a/src/url.rs b/src/url.rs
index 8c6dd9c..5100d44 100644
--- a/src/url.rs
+++ b/src/url.rs
@@ -23,6 +23,7 @@ pub fn make(
fallback: bool,
is_proxy: &mut bool,
is_raw: &mut bool,
+ is_nocss: &mut bool,
) -> Result<Url, gmi::url::UrlParseError> {
Ok(
match Url::try_from(&*if path.starts_with("/proxy") {
@@ -50,6 +51,15 @@ pub fn make(
path.replace("/raw/", ""),
if fallback { "/" } else { "" }
)
+ } else if path.starts_with("/nocss") {
+ *is_proxy = true;
+ *is_nocss = true;
+
+ format!(
+ "gemini://{}{}",
+ path.replace("/nocss/", ""),
+ if fallback { "/" } else { "" }
+ )
} else {
// Try to set `ROOT` as `ROOT` environment variable, or use
// `"gemini://fuwn.me"` as default.