Add QR code, Add MODT customisation
This commit is contained in:
@@ -12,6 +12,8 @@ type ConfigPageData struct {
|
||||
Success bool
|
||||
Error string
|
||||
|
||||
MODT string
|
||||
|
||||
UploadMaxFileSizeMB int64
|
||||
UploadMultiMaxFiles int
|
||||
UploadMaxHours int
|
||||
@@ -33,6 +35,7 @@ func (h *Handler) ConfigPage(c *gin.Context) {
|
||||
maxBytes := cfg.GetInt64Default(config.KeyUploadMaxFileSizeBytes, config.DefaultUploadMaxFileSizeBytes)
|
||||
data := ConfigPageData{
|
||||
Success: c.Query("saved") == "1",
|
||||
MODT: cfg.GetStringDefault(config.KeyModtext, config.DefaultModt),
|
||||
UploadMaxFileSizeMB: maxBytes / (1024 * 1024),
|
||||
UploadMultiMaxFiles: cfg.GetIntDefault(config.KeyUploadMultiMaxFiles, config.DefaultUploadMultiMaxFiles),
|
||||
UploadMaxHours: cfg.GetIntDefault(config.KeyUploadMaxHours, config.DefaultUploadMaxHours),
|
||||
@@ -82,6 +85,12 @@ func (h *Handler) ConfigSave(c *gin.Context) {
|
||||
return n, nil
|
||||
}
|
||||
|
||||
newMODT, err := strconv.Unquote(`"` + c.PostForm("site_modt") + `"`)
|
||||
if err != nil {
|
||||
h.renderConfigError(c, "invalid modtext")
|
||||
return
|
||||
}
|
||||
|
||||
maxMB, err := parseInt64("upload_max_file_size_mb", 1, 1024*1024)
|
||||
if err != nil {
|
||||
h.renderConfigError(c, "invalid max file size")
|
||||
@@ -142,6 +151,8 @@ func (h *Handler) ConfigSave(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
_ = cfg.SetString(config.KeyModtext, newMODT)
|
||||
|
||||
_ = cfg.SetString(config.KeyRateLimitLoginPerMinute, strconv.Itoa(loginPerMin))
|
||||
_ = cfg.SetString(config.KeyRateLimitLoginBurst, strconv.Itoa(loginBurst))
|
||||
_ = cfg.SetString(config.KeyRateLimitApiPerMinute, strconv.Itoa(apiPerMin))
|
||||
|
||||
@@ -2,6 +2,7 @@ package web
|
||||
|
||||
import (
|
||||
"ResendIt/internal/buildinfo"
|
||||
"ResendIt/internal/config"
|
||||
"ResendIt/internal/file"
|
||||
"os"
|
||||
"strconv"
|
||||
@@ -33,6 +34,7 @@ func NewHandler(fileService *file.Service, cfg ConfigService) *Handler {
|
||||
func (h *Handler) Index(c *gin.Context) {
|
||||
c.HTML(200, "index.html", gin.H{
|
||||
"title": "Home",
|
||||
"MODT": h.configService.GetStringDefault(config.KeyModtext, config.DefaultModt),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -50,7 +52,9 @@ func (h *Handler) FileView(c *gin.Context) {
|
||||
|
||||
fileRecord, err := h.fileService.GetFileByViewID(id)
|
||||
if err != nil {
|
||||
c.HTML(404, "error.html", nil)
|
||||
c.HTML(404, "error.html", gin.H{
|
||||
"MODT": h.configService.GetStringDefault(config.KeyModtext, config.DefaultModt),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -58,6 +62,7 @@ func (h *Handler) FileView(c *gin.Context) {
|
||||
deleteKey := fileRecord.DeletionID
|
||||
|
||||
c.HTML(200, "complete.html", gin.H{
|
||||
"MODT": h.configService.GetStringDefault(config.KeyModtext, config.DefaultModt),
|
||||
"Filename": fileRecord.Filename,
|
||||
"DownloadID": downloadKey,
|
||||
"DeleteID": deleteKey,
|
||||
|
||||
Reference in New Issue
Block a user