aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Magorsch <arzano@gentoo.org>2020-06-19 15:51:41 +0200
committerMax Magorsch <arzano@gentoo.org>2020-06-19 15:51:41 +0200
commit21181c518cf41828917d36005b726f9452fde657 (patch)
tree38fab1b3c86a41383e48be6b2686d92efd86db62 /pkg/app/list/browse.go
downloadarchives-21181c518cf41828917d36005b726f9452fde657.tar.gz
archives-21181c518cf41828917d36005b726f9452fde657.tar.bz2
archives-21181c518cf41828917d36005b726f9452fde657.zip
Initial version
Signed-off-by: Max Magorsch <arzano@gentoo.org>
Diffstat (limited to 'pkg/app/list/browse.go')
-rw-r--r--pkg/app/list/browse.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/pkg/app/list/browse.go b/pkg/app/list/browse.go
new file mode 100644
index 0000000..7d046e6
--- /dev/null
+++ b/pkg/app/list/browse.go
@@ -0,0 +1,40 @@
+package list
+
+import (
+ "archives/pkg/config"
+ "archives/pkg/models"
+ "net/http"
+)
+
+func Browse(w http.ResponseWriter, r *http.Request) {
+
+ // Count number of messages in the current mailing lists
+ var currentMailingLists []models.MailingList
+ for _, listName := range config.CurrentMailingLists() {
+ messageCount, _ := countMessages(listName)
+ currentMailingLists = append(currentMailingLists, models.MailingList{
+ Name: listName,
+ MessageCount: messageCount,
+ })
+ }
+
+ // Count number of messages in the frozen archives
+ var frozenArchives []models.MailingList
+ for _, listName := range config.FrozenArchives() {
+ messageCount, _ := countMessages(listName)
+ frozenArchives = append(frozenArchives, models.MailingList{
+ Name: listName,
+ MessageCount: messageCount,
+ })
+ }
+
+ browseData := struct {
+ CurrentMailingLists []models.MailingList
+ FrozenArchives []models.MailingList
+ }{
+ CurrentMailingLists: currentMailingLists,
+ FrozenArchives: frozenArchives,
+ }
+
+ renderBrowseTemplate(w, browseData)
+}