Items sharing progress
This commit is contained in:
parent
007cb94891
commit
2c9b2d4eb7
4 changed files with 54 additions and 2 deletions
24
assets/templates/guest.tmpl
Normal file
24
assets/templates/guest.tmpl
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
{{define "guest"}}
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" >
|
||||||
|
<title>BrainMinder</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<link rel="manifest" href="/static/manifest.json">
|
||||||
|
<link rel="stylesheet" href="/static/bootstrap-icons/font/bootstrap-icons.min.css" />
|
||||||
|
<link rel="stylesheet" href="/static/css/main.css" />
|
||||||
|
<link rel="icon" type="image/x-icon" href="/static/img/brainminder-icon.svg">
|
||||||
|
|
||||||
|
{{block "page:meta" . }}
|
||||||
|
{{
|
||||||
|
end
|
||||||
|
}}
|
||||||
|
</head>
|
||||||
|
<body class="guest">
|
||||||
|
Title
|
||||||
|
<div id="full-main-container">
|
||||||
|
<div id="page-content">{{template "page:content" .}}</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
{{ end }}
|
3
assets/templates/items/sharing_elapsed.tmpl
Normal file
3
assets/templates/items/sharing_elapsed.tmpl
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{{define "page:content"}}
|
||||||
|
Sharing elapsed
|
||||||
|
{{end}}
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"brainminder.speedtech.it/internal/request"
|
"brainminder.speedtech.it/internal/request"
|
||||||
"brainminder.speedtech.it/internal/response"
|
"brainminder.speedtech.it/internal/response"
|
||||||
|
@ -1139,7 +1140,29 @@ func (app *application) itemShared(w http.ResponseWriter, r *http.Request) {
|
||||||
app.serverError(w, r, err)
|
app.serverError(w, r, err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//Check dates
|
itemValidTimeRange := true
|
||||||
|
currentDateTime := time.Now()
|
||||||
|
if strings.TrimSpace(itemShare.StartDatetime) != "" {
|
||||||
|
startDateTime, _ := time.Parse(time.RFC3339, itemShare.StartDatetime+":00Z")
|
||||||
|
if currentDateTime.Before(startDateTime) {
|
||||||
|
itemValidTimeRange = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if strings.TrimSpace(itemShare.EndDatetime) != "" {
|
||||||
|
endDateTime, _ := time.Parse(time.RFC3339, itemShare.EndDatetime+":00Z")
|
||||||
|
if currentDateTime.After(endDateTime) {
|
||||||
|
itemValidTimeRange = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !itemValidTimeRange {
|
||||||
|
err := response.GuestPage(w, http.StatusOK, data, []string{"items/sharing_elapsed.tmpl"})
|
||||||
|
if err != nil {
|
||||||
|
app.serverError(w, r, err)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
//Does it need a password ?
|
//Does it need a password ?
|
||||||
switch r.Method {
|
switch r.Method {
|
||||||
case http.MethodGet:
|
case http.MethodGet:
|
||||||
|
@ -1149,6 +1172,8 @@ func (app *application) itemShared(w http.ResponseWriter, r *http.Request) {
|
||||||
app.serverError(w, r, err)
|
app.serverError(w, r, err)
|
||||||
}
|
}
|
||||||
case http.MethodPost:
|
case http.MethodPost:
|
||||||
|
//Check session token
|
||||||
|
//Check permission_edit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ func Fragment(pagePaths []string, templateName string, data any) (*bytes.Buffer,
|
||||||
}
|
}
|
||||||
|
|
||||||
func GuestPage(w http.ResponseWriter, status int, data any, pagePaths []string, templateNames ...string) error {
|
func GuestPage(w http.ResponseWriter, status int, data any, pagePaths []string, templateNames ...string) error {
|
||||||
templateName := "full"
|
templateName := "guest"
|
||||||
|
|
||||||
if len(templateNames) > 0 {
|
if len(templateNames) > 0 {
|
||||||
templateName = templateNames[0]
|
templateName = templateNames[0]
|
||||||
|
|
Loading…
Add table
Reference in a new issue