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;
padding: 10px;
background: lightgrey;
padding-top: 56px;
padding-bottom: 56px;
}
/* Header/Blog Title */
+28 -5
View File
@@ -89,6 +89,27 @@ func (handler *MediaLoFiHandler) ListPage(c *gin.Context) {
session := sessions.Default(c)
user := session.Get(globals.UserKey)
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())
if err != nil {
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))
c.HTML(http.StatusOK, "lofi", gin.H{
"title": "Kontor MediaFiles",
"version": "0.4.0",
"message": "MediaFiles...",
"lofis": lofis,
"user": user,
"title": "Kontor MediaFiles",
"version": "0.4.0",
"message": "MediaFiles...",
"lofis": lofis,
"user": user,
"isReview": review,
"isDownload": download,
})
}
+1 -1
View File
@@ -1,5 +1,5 @@
{{ 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">
<span class="text-muted">{{ .version }}</span>
</div>
+1 -1
View File
@@ -1,7 +1,7 @@
{{ define "navbar" }}
<!-- 1. Kopfzeile & Navigation -->
<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">
<a class="navbar-brand" href="#">Kontor</a>
<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">
{{ template "head" . }}
<body class="d-flex flex-column h-100">
<body>
{{ template "navbar" . }}
<!-- 2. Hauptbereich -->
<main class="flex-shrink-0">
<div class="container my-4">
<div class="row">
<div class="col-md-8">
<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>
<main>
<div class="row">
<div class="col-md-8">
<h1>Media Lofi</h1>
<p>Hier steht der wesentliche Inhalt der Seite.</p>
</div>
<div class="row">
<form class="form-inline" action="/media/lofis">
<input type="text" placeholder="Search" name="query">
<label>
<input type="checkbox" name="review" {{ if .Review }}checked{{ end }}>Review
</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 class="col-md-4">
<aside class="bg-light p-3">
<h3>Seitenbereich</h3>
<p>Optionale Sidebar oder Zusatzinformationen.</p>
</aside>
</div>
<div class="row">
<table class="table table-hover">
<thead>
<tr>
<th scope="col">Title</th>
<th scope="col">Weblink</th>
<th scope="col">Review</th>
<th colspan="2">Actions</th>
</tr>
</thead>
<tbody>
{{ range .lofis }}
<tr>
<th scope="row"><a href="/web/media-lofis/{{.ID}}/edit">{{.Title}}</a></th>
{{ if .WebLink }}
<td><a href="{{.WebLink}}">{{.WebLink}}</a></td>
{{ else }}
<td>WebLink not set</td>
{{ end }}
<td>
{{ if .Review }}
<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>
</div>
<div class="row">
<form class="form-inline" action="/web/media-lofis">
<input type="text" placeholder="Search" name="query">
<label>
<input type="checkbox" name="review" {{if .isReview}}checked{{end}}>Review
</label>
<label>
<input type="checkbox" name="should_download" {{if .isDownload}}checked{{end}}>Download
</label>
<button type="submit">Search</button>
<div class="pill-nav"><a href="/web/media-lofis/add">Add Lofi</a></div>
</form>
</div>
<div class="row">
<table class="table table-hover">
<thead><tr>
<th scope="col">Title</th>
<th scope="col">Weblink</th>
<th scope="col">Review</th>
<th colspan="2">Actions</th>
</tr></thead>
<tbody>
{{ range .lofis }}
<tr>
<th scope="row"><a href="/web/media-lofis/{{.ID}}/edit">{{.Title}}</a></th>
{{ if .WebLink }}
<td><a href="{{.WebLink}}">{{.WebLink}}</a></td>
{{ else }}
<td>WebLink not set</td>
{{ end }}
</tbody>
</table>
</div>
<td>
{{ if .Review }}
<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>
</main>
{{ template "footer" . }}
+59 -69
View File
@@ -5,76 +5,66 @@
<body>
{{ template "navbar" . }}
<div class="row">
<form class="form-inline" action="/web/files">
<input type="text" placeholder="Search" name="query">
<label>
<input type="checkbox" name="review" {{ if .Review }}checked{{ end }}>Review
</label>
<label>
<input type="checkbox" name="download" {{ if .ShouldDownload }}checked{{ end }}>Download
</label>
<button type="submit">Search</button>
<div class="pill-nav"><a href="/web/files/add">Add MediaFile</a></div>
</form>
</div>
<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>
<main>
<div class="row">
<form class="form-inline" action="/web/files">
<input type="text" placeholder="Search" name="query">
<label>
<input type="checkbox" name="review" {{ if .Review }}checked{{ end }}>Review
</label>
<label>
<input type="checkbox" name="download" {{ if .ShouldDownload }}checked{{ end }}>Download
</label>
<button type="submit">Search</button>
<div class="pill-nav"><a href="/web/files/add">Add MediaFile</a></div>
</form>
</div>
</div>
{{ template "footer" . }}
<div class="container">
{{ template "navbar" . }}
</div>
<div class="container">
<h1>{{ .message }}</h1>
<h1>{{ .message }}</h1>
<h1>{{ .message }}</h1>
<h1>{{ .message }}</h1>
</div>
<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>
</main>
{{ template "footer" . }}
</body>
</html>