diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-01-30 16:55:53 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-30 10:55:53 +0200 |
commit | 5e20fd6dbf52ede60ed9ac7944db0d3f6769cf86 (patch) | |
tree | 519259f05f7e7fc4dd1df4da521e000ce469567b /modules/middlewares/flash.go | |
parent | 0e0424c8ecaf6fa3cdd1fcfc154f188014c63dd8 (diff) | |
download | gitea-5e20fd6dbf52ede60ed9ac7944db0d3f6769cf86.tar.gz gitea-5e20fd6dbf52ede60ed9ac7944db0d3f6769cf86.zip |
Move middlewares to web/middleware (#14480)
Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'modules/middlewares/flash.go')
-rw-r--r-- | modules/middlewares/flash.go | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/modules/middlewares/flash.go b/modules/middlewares/flash.go deleted file mode 100644 index 732e1c76ea..0000000000 --- a/modules/middlewares/flash.go +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2020 The Gitea Authors. All rights reserved. -// Use of this source code is governed by a MIT-style -// license that can be found in the LICENSE file. - -package middlewares - -import "net/url" - -// flashes enumerates all the flash types -const ( - SuccessFlash = "SuccessMsg" - ErrorFlash = "ErrorMsg" - WarnFlash = "WarningMsg" - InfoFlash = "InfoMsg" -) - -var ( - // FlashNow FIXME: - FlashNow bool -) - -// Flash represents a one time data transfer between two requests. -type Flash struct { - DataStore - url.Values - ErrorMsg, WarningMsg, InfoMsg, SuccessMsg string -} - -func (f *Flash) set(name, msg string, current ...bool) { - if f.Values == nil { - f.Values = make(map[string][]string) - } - isShow := false - if (len(current) == 0 && FlashNow) || - (len(current) > 0 && current[0]) { - isShow = true - } - - if isShow { - f.GetData()["Flash"] = f - } else { - f.Set(name, msg) - } -} - -// Error sets error message -func (f *Flash) Error(msg string, current ...bool) { - f.ErrorMsg = msg - f.set("error", msg, current...) -} - -// Warning sets warning message -func (f *Flash) Warning(msg string, current ...bool) { - f.WarningMsg = msg - f.set("warning", msg, current...) -} - -// Info sets info message -func (f *Flash) Info(msg string, current ...bool) { - f.InfoMsg = msg - f.set("info", msg, current...) -} - -// Success sets success message -func (f *Flash) Success(msg string, current ...bool) { - f.SuccessMsg = msg - f.set("success", msg, current...) -} |