aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Magorsch <arzano@gentoo.org>2020-10-01 01:46:57 +0200
committerMax Magorsch <arzano@gentoo.org>2020-10-01 01:47:20 +0200
commit5864ed1bdc049f537f11f6ce2024dcffb4bd6173 (patch)
tree37be5375269477622a9249c810b3f900c6cbf113
parentStore the status of each update in the database (diff)
downloadsoko-5864ed1bdc049f537f11f6ce2024dcffb4bd6173.tar.gz
soko-5864ed1bdc049f537f11f6ce2024dcffb4bd6173.tar.bz2
soko-5864ed1bdc049f537f11f6ce2024dcffb4bd6173.zip
Add a page to display the status of each update
Signed-off-by: Max Magorsch <arzano@gentoo.org>
-rw-r--r--pkg/app/handler/about/status.go35
-rw-r--r--pkg/app/serve.go1
-rw-r--r--web/templates/about/status.tmpl47
3 files changed, 83 insertions, 0 deletions
diff --git a/pkg/app/handler/about/status.go b/pkg/app/handler/about/status.go
new file mode 100644
index 0000000..1a6b05c
--- /dev/null
+++ b/pkg/app/handler/about/status.go
@@ -0,0 +1,35 @@
+package about
+
+import (
+ "html/template"
+ "net/http"
+ "soko/pkg/app/utils"
+ "soko/pkg/database"
+ "soko/pkg/models"
+ "time"
+)
+
+// Index shows the landing page of the about pages
+func Status(w http.ResponseWriter, r *http.Request) {
+ templates := template.Must(
+ template.Must(
+ template.New("status").
+ Funcs(template.FuncMap{
+ "timeSince" : time.Since,
+ }).
+ ParseGlob("web/templates/layout/*.tmpl")).
+ ParseGlob("web/templates/about/status.tmpl"))
+
+ var applicationData []*models.Application
+ database.DBCon.Model(&applicationData).Select()
+
+ templates.ExecuteTemplate(w, "status.tmpl", struct {
+ Header models.Header
+ Application models.Application
+ Applications []*models.Application
+ }{
+ Header: models.Header{Title: "About – ", Tab: "about"},
+ Application: utils.GetApplicationData(),
+ Applications: applicationData,
+ })
+}
diff --git a/pkg/app/serve.go b/pkg/app/serve.go
index 2649012..8bdd8e8 100644
--- a/pkg/app/serve.go
+++ b/pkg/app/serve.go
@@ -46,6 +46,7 @@ func Serve() {
setRoute("/about/help", about.Help)
setRoute("/about/feedback", about.Feedback)
setRoute("/about/feeds", about.Feeds)
+ setRoute("/about/status", about.Status)
setRoute("/maintainers", maintainer.Browse)
setRoute("/maintainers/", maintainer.Browse)
diff --git a/web/templates/about/status.tmpl b/web/templates/about/status.tmpl
new file mode 100644
index 0000000..1ab8a8f
--- /dev/null
+++ b/web/templates/about/status.tmpl
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html lang="en">
+{{template "head" .Header}}
+<body>
+{{template "header" .Header}}
+
+
+<div class="container mb-5">
+ <div class="row">
+ <div class="col-12 text-center">
+
+ <h1 class="px-3 pt-5 pb-1" style="font-size: 3em;">About packages.gentoo.org</h1>
+ <span style="font-size: 90%;" class="text-muted">Feel free to <a href="/about/feedback">get in touch</a> if you have any questions that are not answered on this page.<br/>
+ And welcome to the new packages.gentoo.org!</span>
+
+ </div>
+
+ <div class="col-8 offset-md-2 mt-5 pt-4">
+
+ <table class="table">
+ <thead>
+ <tr>
+ <th scope="col">Type</th>
+ <th scope="col">Last Update</th>
+ <th scope="col">Difference</th>
+ </tr>
+ </thead>
+ <tbody>
+ {{range .Applications}}
+ <tr>
+ <th scope="row" class="text-capitalize">{{.Id}}</th>
+ <td>{{.LastUpdate.Format "2 Jan 2006 15:04:05"}} UTC</td>
+ <td>{{timeSince .LastUpdate}}</td>
+ </tr>
+ {{end}}
+ </tbody>
+ </table>
+
+ </div>
+</div>
+</div>
+
+
+{{template "footer" .Application }}
+
+</body>
+</html>