💾 Archived View for lists.flounder.online › patches › threads › 20210320000714.11299-3-johann@qwertq… captured on 2022-07-16 at 16:25:18. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2022-04-28)
-=-=-=-=-=-=-
From: johann@qwertqwefsday.eu
Date: Sat, 20 Mar 2021 01:07:13 +0100
Message-Id: 20210320000714.11299-3-johann@qwertqwefsday.eu
To: <~aw/patches@lists.sr.ht>
In-Reply-To: 20210320000714.11299-1-johann@qwertqwefsday.eu
Cc: "Johann150" <johann@qwertqwefsday.eu>
--------------------------------------
From: Johann150 <johann@qwertqwefsday.eu>
---
src/main.rs | 14 ++++++++++++++
templates/not-found.html | 8 ++++++++
2 files changed, 22 insertions(+)
create mode 100644 templates/not-found.html
diff --git a/src/main.rs b/src/main.rs
index fe97363..cc4b9af 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -95,6 +95,20 @@ fn args() -> Config {
}
}
+#[derive(Template)]
+#[template(path = "not-found.html")]
+struct NotFound<'a> {
+ what: &'a str,
+}
+
+fn not_found(what: &str) -> tide::Result {
+ use std::convert::TryInto;
+
+ let body: tide::Body = NotFound { what }.try_into().unwrap();
+
+ Ok(tide::Response::builder(404).body(body).build())
+}
+
#[derive(Template)]
#[template(path = "index.html")] // using the template in this path, relative
struct IndexTemplate {
diff --git a/templates/not-found.html b/templates/not-found.html
new file mode 100644
index 0000000..6171e03
--- /dev/null
+++ b/templates/not-found.html
@@ -0,0 +1,8 @@
+{% extends "base.html" %}
+
+{% block content %}
+ <div class="page-title"><h1>Hmm, that didn't work.</h1></div>
+ <div>
+ That thing you were looking for - "{{what}}" - it's not here.
+ </div>
+{% endblock %}
--
2.20.1
From: alex@alexwennerberg.com
Date: Sat, 20 Mar 2021 10:47:02 -0700
Message-Id: CA2D7MNMZT84.35AY7H7GNAAI5@debian-alex
To: "Johann Galle" <johann@qwertqwefsday.eu>, <~aw/patches@lists.sr.ht>
In-Reply-To: 20210320000714.11299-3-johann@qwertqwefsday.eu
--------------------------------------
Could we turn this into a general error page, making "not found" just
one instance of that erorr page? IE just take a generic error message
and use this for e.g. internal server errors as well
On Fri Mar 19, 2021 at 5:07 PM PDT, Johann Galle wrote:
From: Johann150 <johann@qwertqwefsday.eu>
---
src/main.rs | 14 ++++++++++++++
templates/not-found.html | 8 ++++++++
2 files changed, 22 insertions(+)
create mode 100644 templates/not-found.html
diff --git a/src/main.rs b/src/main.rs
index fe97363..cc4b9af 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -95,6 +95,20 @@ fn args() -> Config {
}
}
+#[derive(Template)]
+#[template(path = "not-found.html")]
+struct NotFound<'a> {
+ what: &'a str,
+}
+
+fn not_found(what: &str) -> tide::Result {
+ use std::convert::TryInto;
+
+ let body: tide::Body = NotFound { what }.try_into().unwrap();
+
+ Ok(tide::Response::builder(404).body(body).build())
+}
+
#[derive(Template)]
#[template(path = "index.html")] // using the template in this path,
relative
struct IndexTemplate {
diff --git a/templates/not-found.html b/templates/not-found.html
new file mode 100644
index 0000000..6171e03
--- /dev/null
+++ b/templates/not-found.html
@@ -0,0 +1,8 @@
+{% extends "base.html" %}
+
+{% block content %}
+ <div class="page-title"><h1>Hmm, that didn't work.</h1></div>
+ <div>
+ That thing you were looking for - "{{what}}" - it's not here.
+ </div>
+{% endblock %}
--
2.20.1