diff --git a/internal/controller/template_controller.go b/internal/controller/template_controller.go index 7361f0d2..a01307ff 100644 --- a/internal/controller/template_controller.go +++ b/internal/controller/template_controller.go @@ -86,3 +86,10 @@ func (tc *TemplateController) UserInfo(ctx *gin.Context) { "cssPath": tc.cssPath, }) } + +func (tc *TemplateController) Page404(ctx *gin.Context) { + ctx.HTML(http.StatusOK, "404.html", gin.H{ + "scriptPath": tc.scriptPath, + "cssPath": tc.cssPath, + }) +} diff --git a/internal/router/template_router.go b/internal/router/template_router.go index 87c91d20..cd7a6f6b 100644 --- a/internal/router/template_router.go +++ b/internal/router/template_router.go @@ -35,4 +35,5 @@ func (a *TemplateRouter) RegisterTemplateRouter(r *gin.RouterGroup) { r.GET("/tags", a.templateController.TagList) r.GET("/tags/:tag", a.templateController.TagInfo) r.GET("/users/:username", a.templateController.UserInfo) + r.GET("/404", a.templateController.Page404) } diff --git a/ui/template/404.html b/ui/template/404.html index 99cda5ca..b16e4028 100644 --- a/ui/template/404.html +++ b/ui/template/404.html @@ -1,59 +1,9 @@ - - - - - - - - - - - - -
- -
+{{template "header" . }}
(=‘x‘=)
Unfortunately, this page doesn't exist.
-
-
- -
- - +{{template "footer" .}} diff --git a/ui/template/footer.html b/ui/template/footer.html new file mode 100644 index 00000000..724e282d --- /dev/null +++ b/ui/template/footer.html @@ -0,0 +1,17 @@ +{{define "footer"}} + + + + + + + +{{end}} diff --git a/ui/template/header.html b/ui/template/header.html new file mode 100644 index 00000000..1fa2f045 --- /dev/null +++ b/ui/template/header.html @@ -0,0 +1,42 @@ +{{define "header"}} + + + + + + + + + + + + + +
+ +
+{{end}} diff --git a/ui/template/homepage.html b/ui/template/homepage.html index 29607966..9da911d0 100644 --- a/ui/template/homepage.html +++ b/ui/template/homepage.html @@ -1,43 +1,6 @@ - - +{{template "header" . }} - - - - - - - - - -
- -
@@ -85,25 +48,6 @@
-
-
-
-
-

- Built on Answer - - the open-source software that power Q&A communities
Made - with love © 2022 Answer -

-
-
-
- - + +{{template "footer" .}} diff --git a/ui/template/question-detail.html b/ui/template/question-detail.html index 0700fa79..3e30df35 100644 --- a/ui/template/question-detail.html +++ b/ui/template/question-detail.html @@ -1,43 +1,4 @@ - - - - - - - - - - - - - -
- -
+{{template "header" . }}
@@ -530,25 +491,5 @@ ">
-
-
-
-
-

- Built on Answer - - the open-source software that power Q&A communities
Made - with love © 2022 Answer -

-
-
-
- +{{template "footer" .}} - diff --git a/ui/template/question.html b/ui/template/question.html index 757753a9..b29200b1 100644 --- a/ui/template/question.html +++ b/ui/template/question.html @@ -1,44 +1,4 @@ - - - - - - - - - - - - - 111 - -
- -
+{{template "header" . }}
@@ -109,25 +69,4 @@
-
-
-
-
-

- Built on Answer - - the open-source software that power Q&A communities
Made - with love © 2022 Answer -

-
-
-
- - - +{{template "footer" .}} diff --git a/ui/template/tag-detail.html b/ui/template/tag-detail.html index 8b49bbfc..65b473b0 100644 --- a/ui/template/tag-detail.html +++ b/ui/template/tag-detail.html @@ -1,44 +1,4 @@ - - - - - - - - - - - - - - -
- -
+{{template "header" . }}
@@ -172,25 +132,4 @@
-
-
-
-
-

- Built on Answer - - the open-source software that power Q&A communities
Made - with love © 2022 Answer -

-
-
-
- - - +{{template "footer" .}} diff --git a/ui/template/tags.html b/ui/template/tags.html index 72d4dfb6..a1d2c3c6 100644 --- a/ui/template/tags.html +++ b/ui/template/tags.html @@ -1,44 +1,4 @@ - - - - - - - - - - - - - - -
- -
+{{template "header" . }}
+
+
+ 算法 +

212121212121221 +

+
+ 0 + questions +
+
+
+
+ +
    @@ -93,25 +70,8 @@
-
-
- -
- - + + +{{template "footer" .}} +