#5 and caching
All checks were successful
continuous-integration/drone/push Build is passing

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") 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)) user, err := user2.GetUserById(sqlConnection, s.Get("user_id").(int))
if err != nil { if err != nil {
panic(err) panic(err)
@ -169,6 +169,11 @@ func profileUpdate(s session.Session, c flamego.Context) {
if err != nil{ if err != nil{
panic(err) 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) { 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) { func uploadImageForm(t template.Template, data template.Data , s session.Session, c flamego.Context) {
id := c.Request().FormValue("id") id := c.Request().FormValue("id")
if 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 return
} }
data["id"] = id data["id"] = id

View file

@ -8,7 +8,6 @@ import (
"github.com/nfnt/resize" "github.com/nfnt/resize"
"image" "image"
"image/png" "image/png"
"net/http"
"os" "os"
"strconv" "strconv"
) )
@ -57,9 +56,13 @@ func getImage(c flamego.Context) {
send_s3 := buf.Bytes() send_s3 := buf.Bytes()
c.ResponseWriter().WriteHeader(http.StatusOK) //c.ResponseWriter().WriteHeader(http.StatusOK)
c.ResponseWriter().Header().Set("Content-Type", "application/octet-stream")
//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("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) c.ResponseWriter().Write(send_s3)
return return
} }

View file

@ -1,5 +1,38 @@
{{template "top" .}} {{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="container" style="margin-top: 100px;">
<div class="col-12"> <div class="col-12">
<h1>Select Gallery</h1> <h1>Select Gallery</h1>
@ -7,11 +40,12 @@
<div class="row"> <div class="row">
{{ range . }} {{ range . }}
<div class="col-md-2"> <div class="col-md-2">
<div class="card border-secondary mb-3" style="max-width: 20rem;"> <div class="containerImage">
<div class="card-header">{{ .Name }}</div> <a href="/gallery/edit/{{ .Id }}">
<div class="card-body"> <img src="/image?path={{ .MainImage }}&width=250" style="width: 100%"></img>
<p class="card-text"> <a href="/gallery/edit/{{ .Id }}"><img src="/image?path={{ .MainImage }}&width=170" style="max-width: 100%"></img></a></p> <div class="centered" style="background-color: rgba(0,0,0,0.8);color: #fff;">{{ .Name }}</div>
</div> </a>
</div> </div>
</div> </div>

View file

@ -39,7 +39,6 @@
<ul class="dropdown-menu" aria-labelledby="navbarDropdown"> <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="/gallery/new">New Gallery</a></li>
<!--<li><a class="dropdown-item" href="#">New Group</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><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>!--> <li><a class="dropdown-item" href="#">Something else here</a></li>!-->
</ul> </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" .}}