parse query parameter
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 7s

This commit is contained in:
Thomas Peetz
2026-10-22 17:24:13 +02:00
parent cdd0276020
commit b3b143cd3f
6 changed files with 145 additions and 135 deletions
+2
View File
@@ -6,6 +6,8 @@ body {
font-family: Arial; font-family: Arial;
padding: 10px; padding: 10px;
background: lightgrey; background: lightgrey;
padding-top: 56px;
padding-bottom: 56px;
} }
/* Header/Blog Title */ /* Header/Blog Title */
+28 -5
View File
@@ -89,6 +89,27 @@ func (handler *MediaLoFiHandler) ListPage(c *gin.Context) {
session := sessions.Default(c) session := sessions.Default(c)
user := session.Get(globals.UserKey) user := session.Get(globals.UserKey)
logger := slog.Get(c) logger := slog.Get(c)
var (
review bool
download bool
)
paramReview, existsReview := c.GetQuery("review")
if existsReview {
if paramReview == "on" {
review = true
} else {
review = false
}
}
paramDownload, existsDownload := c.GetQuery("should_download")
if existsDownload {
if paramDownload == "on" {
download = true
} else {
download = false
}
}
lofis, err := handler.Service.List(c.Request.Context()) lofis, err := handler.Service.List(c.Request.Context())
if err != nil { if err != nil {
logger.Info("MediaLoFiHandler#ListPage", "error", err.Error()) logger.Info("MediaLoFiHandler#ListPage", "error", err.Error())
@@ -97,11 +118,13 @@ func (handler *MediaLoFiHandler) ListPage(c *gin.Context) {
} }
logger.Info("MediaLoFiHandler#ListPage", "lofis count", len(lofis)) logger.Info("MediaLoFiHandler#ListPage", "lofis count", len(lofis))
c.HTML(http.StatusOK, "lofi", gin.H{ c.HTML(http.StatusOK, "lofi", gin.H{
"title": "Kontor MediaFiles", "title": "Kontor MediaFiles",
"version": "0.4.0", "version": "0.4.0",
"message": "MediaFiles...", "message": "MediaFiles...",
"lofis": lofis, "lofis": lofis,
"user": user, "user": user,
"isReview": review,
"isDownload": download,
}) })
} }
+1 -1
View File
@@ -1,5 +1,5 @@
{{ define "footer" }} {{ define "footer" }}
<footer class="mt-auto py-3 bg-light fixed-bottom"> <footer class="mt-auto py-3 bg-light fixed-bottom mt-auto">
<div class="container text-center"> <div class="container text-center">
<span class="text-muted">{{ .version }}</span> <span class="text-muted">{{ .version }}</span>
</div> </div>
+1 -1
View File
@@ -1,7 +1,7 @@
{{ define "navbar" }} {{ define "navbar" }}
<!-- 1. Kopfzeile & Navigation --> <!-- 1. Kopfzeile & Navigation -->
<header> <header>
<nav class="navbar navbar-expand-lg navbar-dark" style="background-color:darkgrey;"> <nav class="navbar navbar-expand-lg navbar-dark fixed-top" style="background-color:darkgrey;">
<div class="container-fluid"> <div class="container-fluid">
<a class="navbar-brand" href="#">Kontor</a> <a class="navbar-brand" href="#">Kontor</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
+54 -59
View File
@@ -3,69 +3,64 @@
<html lang="de"> <html lang="de">
{{ template "head" . }} {{ template "head" . }}
<body class="d-flex flex-column h-100"> <body>
{{ template "navbar" . }} {{ template "navbar" . }}
<!-- 2. Hauptbereich --> <main>
<main class="flex-shrink-0"> <div class="row">
<div class="container my-4"> <div class="col-md-8">
<div class="row"> <h1>Media Lofi</h1>
<div class="col-md-8"> <p>Hier steht der wesentliche Inhalt der Seite.</p>
<h1>Media Lofi</h1>
<p>Hier steht der wesentliche Inhalt der Seite.</p>
</div>
<div class="col-md-4">
<aside class="bg-light p-3">
<h3>Seitenbereich</h3>
<p>Optionale Sidebar oder Zusatzinformationen.</p>
</aside>
</div>
</div> </div>
<div class="row"> <div class="col-md-4">
<form class="form-inline" action="/media/lofis"> <aside class="bg-light p-3">
<input type="text" placeholder="Search" name="query"> <h3>Seitenbereich</h3>
<label> <p>Optionale Sidebar oder Zusatzinformationen.</p>
<input type="checkbox" name="review" {{ if .Review }}checked{{ end }}>Review </aside>
</label>
<label>
<input type="checkbox" name="should_download" {{ if .ShouldDownload }}checked{{ end }}>Download
</label>
<button type="submit">Search</button>
<div class="pill-nav"><a href="/media/lofis/add">Add Lofi</a></div>
</form>
</div> </div>
<div class="row"> </div>
<table class="table table-hover"> <div class="row">
<thead> <form class="form-inline" action="/web/media-lofis">
<tr> <input type="text" placeholder="Search" name="query">
<th scope="col">Title</th> <label>
<th scope="col">Weblink</th> <input type="checkbox" name="review" {{if .isReview}}checked{{end}}>Review
<th scope="col">Review</th> </label>
<th colspan="2">Actions</th> <label>
</tr> <input type="checkbox" name="should_download" {{if .isDownload}}checked{{end}}>Download
</thead> </label>
<tbody> <button type="submit">Search</button>
{{ range .lofis }} <div class="pill-nav"><a href="/web/media-lofis/add">Add Lofi</a></div>
<tr> </form>
<th scope="row"><a href="/web/media-lofis/{{.ID}}/edit">{{.Title}}</a></th> </div>
{{ if .WebLink }} <div class="row">
<td><a href="{{.WebLink}}">{{.WebLink}}</a></td> <table class="table table-hover">
{{ else }} <thead><tr>
<td>WebLink not set</td> <th scope="col">Title</th>
{{ end }} <th scope="col">Weblink</th>
<td> <th scope="col">Review</th>
{{ if .Review }} <th colspan="2">Actions</th>
<a href="/web/media-lofis/{{.ID}}/change-review"><img src="/public/icons/tick.png" alt="true" width="24" height="24"></a> </tr></thead>
{{ else }} <tbody>
<a href="/web/media-lofis/{{.ID}}/change-review"><img src="/public/icons/cross.png" alt="true" width="24" height="24"></a> {{ range .lofis }}
{{ end }} <tr>
</td> <th scope="row"><a href="/web/media-lofis/{{.ID}}/edit">{{.Title}}</a></th>
<td><a href="/web/media-lofis/{{.ID}}/edit" class="btn btn-outline-primary btn-sm active" role="button" aria-pressed="true">Edit</a></td> {{ if .WebLink }}
<td><a href="/web/media-lofis/{{.ID}}/delete" class="btn btn-outline-danger btn-sm active" role="button" aria-pressed="true">Delete</a></td> <td><a href="{{.WebLink}}">{{.WebLink}}</a></td>
</tr> {{ else }}
<td>WebLink not set</td>
{{ end }} {{ end }}
</tbody> <td>
</table> {{ if .Review }}
</div> <a href="/web/media-lofis/{{.ID}}/change-review"><img src="/public/icons/tick.png" alt="true" width="24" height="24"></a>
{{ else }}
<a href="/web/media-lofis/{{.ID}}/change-review"><img src="/public/icons/cross.png" alt="true" width="24" height="24"></a>
{{ end }}
</td>
<td><a href="/web/media-lofis/{{.ID}}/edit" class="btn btn-outline-primary btn-sm active" role="button" aria-pressed="true">Edit</a></td>
<td><a href="/web/media-lofis/{{.ID}}/delete" class="btn btn-outline-danger btn-sm active" role="button" aria-pressed="true">Delete</a></td>
</tr>
{{ end }}
</tbody>
</table>
</div> </div>
</main> </main>
{{ template "footer" . }} {{ template "footer" . }}
+59 -69
View File
@@ -5,76 +5,66 @@
<body> <body>
{{ template "navbar" . }} {{ template "navbar" . }}
<div class="row"> <main>
<form class="form-inline" action="/web/files"> <div class="row">
<input type="text" placeholder="Search" name="query"> <form class="form-inline" action="/web/files">
<label> <input type="text" placeholder="Search" name="query">
<input type="checkbox" name="review" {{ if .Review }}checked{{ end }}>Review <label>
</label> <input type="checkbox" name="review" {{ if .Review }}checked{{ end }}>Review
<label> </label>
<input type="checkbox" name="download" {{ if .ShouldDownload }}checked{{ end }}>Download <label>
</label> <input type="checkbox" name="download" {{ if .ShouldDownload }}checked{{ end }}>Download
<button type="submit">Search</button> </label>
<div class="pill-nav"><a href="/web/files/add">Add MediaFile</a></div> <button type="submit">Search</button>
</form> <div class="pill-nav"><a href="/web/files/add">Add MediaFile</a></div>
</div> </form>
<div class="row">
<div class="maincolumn">
<table class="table table-hover">
<thead>
<tr>
<th scope="col">Title</th>
<th scope="col">Weblink</th>
<th scope="col">Review</th>
<th scope="col">Download</th>
<th colspan="2">Actions</th>
</tr>
</thead>
<tbody>
{{ range .mediafiles }}
<tr>
<th scope="row"><a href="/web/files/{{.ID}}">{{.Title}}</a></th>
{{ if .WebLink }}
<td><a href="{{.WebLink}}">{{.WebLink}}</a></td>
{{ else }}
<td>no link</td>
{{ end }}
<td>
{{ if .Review }}
<img src="/public/icons/tick.png" alt="true" width="24" height="24">
{{ else }}
<img src="/public/icons/cross.png" alt="true" width="24" height="24">
{{ end }}
</td>
<td>
{{ if .ShouldDownload }}
<img src="/public/icons/tick.png" alt="true" width="24" height="24">
{{ else }}
<img src="/public/icons/cross.png" alt="true" width="24" height="24">
{{ end }}
</td>
<td><a href="/web/files/edit/{{.ID}}" class="btn btn-outline-primary btn-sm active" role="button"
aria-pressed="true">Edit</a></td>
<td><a href="/web/files/delete/{{.ID}}" class="btn btn-outline-danger btn-sm active"
role="button" aria-pressed="true">Delete</a></td>
</tr>
{{ end }}
</tbody>
</table>
</div> </div>
</div> <div class="row">
{{ template "footer" . }} <div class="maincolumn">
<table class="table table-hover">
<thead>
<div class="container"> <tr>
{{ template "navbar" . }} <th scope="col">Title</th>
</div> <th scope="col">Weblink</th>
<div class="container"> <th scope="col">Review</th>
<h1>{{ .message }}</h1> <th scope="col">Download</th>
<h1>{{ .message }}</h1> <th colspan="2">Actions</th>
<h1>{{ .message }}</h1> </tr>
<h1>{{ .message }}</h1> </thead>
</div> <tbody>
{{ range .mediafiles }}
<tr>
<th scope="row"><a href="/web/files/{{.ID}}">{{.Title}}</a></th>
{{ if .WebLink }}
<td><a href="{{.WebLink}}">{{.WebLink}}</a></td>
{{ else }}
<td>no link</td>
{{ end }}
<td>
{{ if .Review }}
<img src="/public/icons/tick.png" alt="true" width="24" height="24">
{{ else }}
<img src="/public/icons/cross.png" alt="true" width="24" height="24">
{{ end }}
</td>
<td>
{{ if .ShouldDownload }}
<img src="/public/icons/tick.png" alt="true" width="24" height="24">
{{ else }}
<img src="/public/icons/cross.png" alt="true" width="24" height="24">
{{ end }}
</td>
<td><a href="/web/files/edit/{{.ID}}" class="btn btn-outline-primary btn-sm active" role="button"
aria-pressed="true">Edit</a></td>
<td><a href="/web/files/delete/{{.ID}}" class="btn btn-outline-danger btn-sm active"
role="button" aria-pressed="true">Delete</a></td>
</tr>
{{ end }}
</tbody>
</table>
</div>
</div>
</main>
{{ template "footer" . }} {{ template "footer" . }}
</body> </body>
</html> </html>