Moritz Schmidt %!s(int64=9) %!d(string=hai) anos
pai
achega
391f92233f
Modificáronse 1 ficheiros con 18 adicións e 4 borrados
  1. 18 4
      templatehelpers.go

+ 18 - 4
templatehelpers.go

@@ -2,6 +2,7 @@ package templatehelpers
 
 import (
   "github.com/kataras/iris"
+  "strings"
 )
 
 type PageUserParams struct{
@@ -15,12 +16,25 @@ type PageUserParams struct{
 
   // TODO error handler
 
- func ShowError(notification string, ctx *iris.Context, location string) { // TODO: check if backend exploiteable, TODO: implement forwarding form values ?
-   ctx.Render(location + "_box.html", PageUserParams{"1", notification, location, "", "0", []string{}})
+ func ShowError(options []string, ctx *iris.Context) { // TODO: check if backend exploiteable, TODO: implement forwarding form values ?
+   location := strings.TrimLeft(ctx.RequestPath(false), "/")
+   if len(options) > 1 {
+     if options[1] != "" {
+       location = options[1]
+     }
+   }
+
+   ctx.Render(location + "_box.html", PageUserParams{"1", options[0], location, "", "0", []string{}}) // TODO: Dynamic params
    return
  }
 
- func ShowNotification(notification string, ctx *iris.Context, location string) { // TODO: check if backend exploiteable, TODO: implement forwarding form values ?
-   ctx.Render(location + "_box.html", PageUserParams{"2", notification, location, "", "0", []string{}})
+ func ShowNotification(options []string, ctx *iris.Context) { // TODO: check if backend exploiteable, TODO: implement forwarding form values ?
+   location := strings.TrimLeft(ctx.RequestPath(false), "/")
+   if len(options) > 1 {
+     if options[1] != "" {
+       location = options[1]
+     }
+   }
+   ctx.Render(location + "_box.html", PageUserParams{"2", options[0], location, "", "0", []string{}}) // TODO: Dynamic params
    return
  }