aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--controllers/404.go26
-rw-r--r--router/routes.go8
-rw-r--r--static/css/main.css8
-rw-r--r--templates/404.django7
-rw-r--r--templates/home.django2
5 files changed, 39 insertions, 12 deletions
diff --git a/controllers/404.go b/controllers/404.go
new file mode 100644
index 0000000..670f230
--- /dev/null
+++ b/controllers/404.go
@@ -0,0 +1,26 @@
+package controllers
+
+import (
+ "imageboard/utils/shortcuts"
+ "strings"
+
+ "github.com/gofiber/fiber/v2"
+)
+
+func NotFoundController(ctx *fiber.Ctx) error {
+ ctx.Locals("Title", "Page Not Found")
+
+ path := ctx.Path()
+
+ if strings.HasSuffix(path, ".json") {
+ return ctx.Status(fiber.StatusNotFound).JSON(fiber.Map{
+ "error": "Not Found",
+ })
+ }
+
+ if len(path) > 1 && strings.Contains(path[1:], ".") && !strings.HasSuffix(path, ".html") {
+ return ctx.SendStatus(fiber.StatusNotFound)
+ }
+
+ return shortcuts.Render(ctx, "404", nil)
+}
diff --git a/router/routes.go b/router/routes.go
index 8422f99..a7acbde 100644
--- a/router/routes.go
+++ b/router/routes.go
@@ -18,11 +18,5 @@ func Initialize(router *fiber.App) {
// router.Get("/login", controllers.LoginController)
// router.Get("/preferences", controllers.PreferencesController)
- router.Use(func(c *fiber.Ctx) error {
- return c.Status(fiber.StatusNotFound).JSON(fiber.Map{
- "error": "Not Found",
- "message": "The requested resource could not be found.",
- "status": fiber.StatusNotFound,
- })
- })
+ router.Use(controllers.NotFoundController)
}
diff --git a/static/css/main.css b/static/css/main.css
index ccc31bc..3d52c8c 100644
--- a/static/css/main.css
+++ b/static/css/main.css
@@ -18,10 +18,10 @@ body {
color: #ccccff;
margin: 0;
padding: 0;
- overflow-x: hidden;
min-height: 100vh;
display: flex;
flex-direction: column;
+ min-width: 1200px;
}
a {
@@ -137,7 +137,7 @@ main {
padding: 10px;
}
-.home-main {
+.centered-main {
display: flex;
flex-direction: column;
justify-content: center;
@@ -146,13 +146,13 @@ main {
min-height: 580px;
}
-.home-main h1 {
+.centered-main h1 {
color: #ffccff;
font-size: 16px;
margin: 8px 0px;
}
-.home-main p {
+.centered-main p {
color: #99ffcc;
}
diff --git a/templates/404.django b/templates/404.django
new file mode 100644
index 0000000..acf599f
--- /dev/null
+++ b/templates/404.django
@@ -0,0 +1,7 @@
+{% extends 'layouts/main.django' %}
+{% block content %}
+ <div class="centered-main">
+ <h1>404 - Page Not Found</h1>
+ <p>The page you are looking for does not exist.</p>
+ </div>
+{% endblock %}
diff --git a/templates/home.django b/templates/home.django
index 0314015..148dbce 100644
--- a/templates/home.django
+++ b/templates/home.django
@@ -1,6 +1,6 @@
{% extends 'layouts/main.django' %}
{% block content %}
- <div class="home-main">
+ <div class="centered-main">
<img src="/static/images/opwevhieia8ikwltpfgf.webp" alt="Main Image" class="main-img" />
<h1>Welcome to {{ Appname }}!</h1>
<p>~ 個人的な画像ボード ~</p>