#5 and caching
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Kekskurse 2022-01-17 12:25:22 +01:00
parent c106da7c2a
commit 8161c384d7
Signed by: kekskurse
GPG Key ID: 728ACCB59341E7E4
6 changed files with 62 additions and 33 deletions

View File

@ -153,7 +153,7 @@ func profile(t template.Template, data template.Data, s session.Session, c flame
t.HTML(http.StatusOK, "settings_profile")
}
func profileUpdate(s session.Session, c flamego.Context) {
func profileUpdate(t template.Template, data template.Data, s session.Session, c flamego.Context) {
user, err := user2.GetUserById(sqlConnection, s.Get("user_id").(int))
if err != nil {
panic(err)
@ -169,6 +169,11 @@ func profileUpdate(s session.Session, c flamego.Context) {
if err != nil{
panic(err)
}
data["msg"] = "Profil updated"
data["link"] = "/settings/profile"
t.HTML(200, "message")
}
func profileImage(t template.Template, data template.Data, s session.Session, c flamego.Context) {

View File

@ -29,29 +29,6 @@ type File struct {
func uploadImageForm(t template.Template, data template.Data , s session.Session, c flamego.Context) {
id := c.Request().FormValue("id")
if id == "" {
galleries := []Gallery{}
err := sqlConnection.Select(&galleries, "SELECT * FROM gallery WHERE owner_id = ? ORDER BY id DESC", s.Get("user_id"))
if err != nil {
panic(err)
}
data["galleries"] = galleries
var list [][]Gallery
var tmp []Gallery
for _, g := range galleries {
if len(tmp) == 6 {
list = append(list, tmp)
tmp = []Gallery{}
}
tmp = append(tmp, g)
}
list = append(list, tmp)
data["list"] = list
t.HTML(http.StatusOK, "file_gallery")
return
}
data["id"] = id

View File

@ -8,7 +8,6 @@ import (
"github.com/nfnt/resize"
"image"
"image/png"
"net/http"
"os"
"strconv"
)
@ -57,9 +56,13 @@ func getImage(c flamego.Context) {
send_s3 := buf.Bytes()
c.ResponseWriter().WriteHeader(http.StatusOK)
c.ResponseWriter().Header().Set("Content-Type", "application/octet-stream")
//c.ResponseWriter().WriteHeader(http.StatusOK)
//c.ResponseWriter().Header().Set("Content-Type", "application/octet-stream")
c.ResponseWriter().Header().Set("Content-Length", fmt.Sprintf("%v", len(send_s3)))
c.ResponseWriter().Header().Set("Cache-Control", "max-age=31536000")
c.ResponseWriter().Header().Set("X-Foo", "BAR")
c.ResponseWriter().WriteHeader(200)
c.ResponseWriter().Write(send_s3)
return
}

View File

@ -1,5 +1,38 @@
{{template "top" .}}
<style type="text/css">
@media all and (min-width: 900px){
.row {
padding-top: calc(var(--bs-gutter-x) * .2);
padding-bottom: calc(var(--bs-gutter-x) * .2);
}
.col-md-2 {
padding-right: calc(var(--bs-gutter-x) * .2);
padding-left: calc(var(--bs-gutter-x) * .2);
}
}
@media all and (max-width: 900px){
.row {
padding-top: calc(var(--bs-gutter-x) * .1);
padding-bottom: calc(var(--bs-gutter-x) * .1);
}
.col-md-2 {
padding-right: calc(var(--bs-gutter-x) * .1);
padding-left: calc(var(--bs-gutter-x) * .1);
}
}
.containerImage {
position: relative;
text-align: center;
color: white;
}
.centered {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>
<div class="container" style="margin-top: 100px;">
<div class="col-12">
<h1>Select Gallery</h1>
@ -7,11 +40,12 @@
<div class="row">
{{ range . }}
<div class="col-md-2">
<div class="card border-secondary mb-3" style="max-width: 20rem;">
<div class="card-header">{{ .Name }}</div>
<div class="card-body">
<p class="card-text"> <a href="/gallery/edit/{{ .Id }}"><img src="/image?path={{ .MainImage }}&width=170" style="max-width: 100%"></img></a></p>
</div>
<div class="containerImage">
<a href="/gallery/edit/{{ .Id }}">
<img src="/image?path={{ .MainImage }}&width=250" style="width: 100%"></img>
<div class="centered" style="background-color: rgba(0,0,0,0.8);color: #fff;">{{ .Name }}</div>
</a>
</div>
</div>

View File

@ -39,7 +39,6 @@
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
<li><a class="dropdown-item" href="/gallery/new">New Gallery</a></li>
<!--<li><a class="dropdown-item" href="#">New Group</a></li>!-->
<li><a class="dropdown-item" href="/file/upload">Upload Images</a></li>
<!--<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>!-->
</ul>

11
templates/message.tmpl Normal file
View File

@ -0,0 +1,11 @@
{{template "top" .}}
<div class="container" style="margin-top: 100px;">
<div class="col-12">
<h1>Nachricht</h1>
{{ .msg }}<br>
<a href="{{ .link }}">{{ if .linktext}}{{ .linktext }}{{ else }}Zurück{{ end }}</a>
</div>
</div>
{{template "bottom" .}}