mirror of
https://codeberg.org/pluja/kycnot.me
synced 2025-01-20 19:31:35 -05:00
Add changelog page
This commit is contained in:
parent
e80f52fc63
commit
7533475b72
@ -60,3 +60,12 @@ type Announcement struct {
|
||||
Warning bool
|
||||
Active bool
|
||||
}
|
||||
|
||||
type Change struct {
|
||||
Created string `json:"created"`
|
||||
Summary string `json:"summary"`
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Updated string `json:"updated"`
|
||||
Expand map[string]Service `json:"expand,omitempty"`
|
||||
}
|
||||
|
@ -58,6 +58,26 @@ func (p *PbClient) GetServices(filters, sort string) ([]Service, error) {
|
||||
return response.Items, nil
|
||||
}
|
||||
|
||||
func (p *PbClient) GetChanges() ([]Change, error) {
|
||||
|
||||
collection := pocketbase.CollectionSet[Change](p.Client, "changes")
|
||||
params := pocketbase.ParamsList{
|
||||
Page: 1,
|
||||
Size: 200,
|
||||
Expand: "service",
|
||||
Fields: "*,expand.service.*",
|
||||
Sort: "-created",
|
||||
}
|
||||
|
||||
response, err := collection.List(params)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("err")
|
||||
return nil, errors.New("database error")
|
||||
}
|
||||
|
||||
return response.Items, nil
|
||||
}
|
||||
|
||||
func (p *PbClient) GetServiceByNameOrUrl(id string) (*Service, error) {
|
||||
collection := pocketbase.CollectionSet[Service](p.Client, "services")
|
||||
params := pocketbase.ParamsList{
|
||||
|
28
src/frontend/templates/changelog.html
Normal file
28
src/frontend/templates/changelog.html
Normal file
@ -0,0 +1,28 @@
|
||||
<section class="container px-4 py-12 mx-auto">
|
||||
<h1 class="mb-10 text-3xl font-bold text-center text-white/80">Changelog</h1>
|
||||
|
||||
<div class="space-y-4">
|
||||
{{ range .Changes }}
|
||||
<div class="overflow-hidden border rounded-md border-white/20">
|
||||
<div class="p-4">
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
<h3 class="text-base font-semibold text-white/80">{{.Title}}</h3>
|
||||
<span class="text-xs text-white/40">{{.Created}}</span>
|
||||
</div>
|
||||
<p class="mb-4 text-sm text-white/70">{{.Summary | safe}}</p>
|
||||
|
||||
{{ if .Expand.service }}
|
||||
<div class="pt-2 mt-1 border-t border-white/10">
|
||||
{{ with .Expand.service }}
|
||||
<span class="text-sm text-white/50">
|
||||
Related service: <a class="underline transition-colors duration-200 text-lime-700 hover:text-blue-300"
|
||||
href="/service/{{.Name}}">{{ .Name }}</a>
|
||||
</span>
|
||||
{{ end }}
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
</section>
|
@ -95,6 +95,7 @@ func (s *Server) RegisterRoutes() {
|
||||
|
||||
// GET
|
||||
s.Router.Get("/", s.handleIndex)
|
||||
s.Router.Get("/changelog", s.handleChangelog)
|
||||
s.Router.Get("/about", s.handleAbout)
|
||||
s.Router.Get("/pending", s.handlePending)
|
||||
s.Router.Get("/service/{name:string}", s.handleService)
|
||||
|
@ -126,6 +126,26 @@ func (s *Server) handleService(c iris.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) handleChangelog(c iris.Context) {
|
||||
changes, err := database.Pb.GetChanges()
|
||||
if err != nil {
|
||||
c.HTML("<h3>%s</h3>", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
log.Printf("%+v", changes)
|
||||
|
||||
c.ViewLayout("main")
|
||||
data := iris.Map{
|
||||
"Title": "Changelog | KYCNOT.ME",
|
||||
"Changes": changes,
|
||||
}
|
||||
if err := c.View("changelog", data); err != nil {
|
||||
c.HTML("<h3>%s</h3>", err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) handleScoreSummary(c iris.Context) {
|
||||
serviceName := strings.ToLower(c.Params().Get("name"))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user