From 28fa0f38b231f447c521e0ec0f018ab17de417f2 Mon Sep 17 00:00:00 2001 From: wuyinjun Date: Tue, 31 May 2016 10:11:41 +0800 Subject: [PATCH 1/2] add error message template --- app/handler/auth.go | 5 ++++- app/handler/init.go | 1 + view/default/error_msg.html | 25 +++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 view/default/error_msg.html diff --git a/app/handler/auth.go b/app/handler/auth.go index e6c67c5..f879e8c 100644 --- a/app/handler/auth.go +++ b/app/handler/auth.go @@ -28,7 +28,10 @@ func AuthSignUpPageHandler(ctx *golf.Context) { if userNum == 0 { ctx.Loader("admin").Render("signup.html", make(map[string]interface{})) } else { - ctx.Abort(404) + ctx.Loader("default").Render("error_msg.html", map[string]interface{}{ + "Reason": "No more Users", + }) + // ctx.Abort(404) return } } diff --git a/app/handler/init.go b/app/handler/init.go index 8ec9676..47c7b0f 100644 --- a/app/handler/init.go +++ b/app/handler/init.go @@ -20,6 +20,7 @@ func Initialize(app *golf.Application) *golf.Application { theme := model.GetSettingValue("theme") app.View.SetTemplateLoader("base", "view") app.View.SetTemplateLoader("admin", filepath.Join("view", "admin")) + app.View.SetTemplateLoader("default", filepath.Join("view", "default")) app.View.SetTemplateLoader("theme", filepath.Join("view", theme)) // static_dir, _ := app.Config.GetString("app/static_dir", "static") app.Static("/upload/", upload_dir) diff --git a/view/default/error_msg.html b/view/default/error_msg.html new file mode 100644 index 0000000..ef04da4 --- /dev/null +++ b/view/default/error_msg.html @@ -0,0 +1,25 @@ +{{ extends "/default.html" }} + +{{ define "content"}} +
+
+
+
+ +
+
+

+ Oops! Error occurred: +

+
+
+

{{ .Reason }}

+

You can return to our homepage by clicking here.

+
+
+
+ +
+
+
+{{end}} From ad062998416daf03aa36cade2612fb8785b61ad8 Mon Sep 17 00:00:00 2001 From: wuyinjun Date: Tue, 31 May 2016 13:06:33 +0800 Subject: [PATCH 2/2] some grammatical changes --- app/handler/auth.go | 2 +- view/default/error_msg.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/handler/auth.go b/app/handler/auth.go index f879e8c..ee49fa1 100644 --- a/app/handler/auth.go +++ b/app/handler/auth.go @@ -29,7 +29,7 @@ func AuthSignUpPageHandler(ctx *golf.Context) { ctx.Loader("admin").Render("signup.html", make(map[string]interface{})) } else { ctx.Loader("default").Render("error_msg.html", map[string]interface{}{ - "Reason": "No more Users", + "Reason": "New user accounts cannot be created for this blog at this time.", }) // ctx.Abort(404) return diff --git a/view/default/error_msg.html b/view/default/error_msg.html index ef04da4..e60af2f 100644 --- a/view/default/error_msg.html +++ b/view/default/error_msg.html @@ -9,7 +9,7 @@

- Oops! Error occurred: + Oops! An error occurred: