about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--README.md3
-rw-r--r--config.yml8
-rw-r--r--go.mod4
-rw-r--r--hosted/tmpl/index.html5
-rw-r--r--hosted/tmpl/past.html31
-rw-r--r--hosted/tmpl/pastTalks.html41
-rw-r--r--src/db.go13
-rw-r--r--src/db/go.mod4
-rw-r--r--src/db/go.sum6
-rw-r--r--src/db/talk.go50
-rw-r--r--src/http.go78
-rw-r--r--uploads/DeepinScreenshot_select-area_20191222184454.pngbin0 -> 13000 bytes
-rw-r--r--uploads/DeepinScreenshot_select-area_20191229210336.pngbin0 -> 98259 bytes
-rw-r--r--uploads/DeepinScreenshot_select-area_20200104201703.pngbin0 -> 273420 bytes
-rw-r--r--uploads/DeepinScreenshot_select-area_20200107180131.pngbin0 -> 143955 bytes
-rw-r--r--uploads/DeepinScreenshot_select-area_20200107180829.pngbin0 -> 231411 bytes
-rw-r--r--uploads/bendisposto.jpegbin0 -> 21546 bytes
-rw-r--r--uploads/black.pngbin0 -> 97 bytes
19 files changed, 247 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 8fc0d80..b01c693 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,5 @@
+<<<<<<< HEAD
+./uploads/*
+=======
 uploads/
+>>>>>>> refs/remotes/origin/master
diff --git a/README.md b/README.md
index 2a757bc..daecce9 100644
--- a/README.md
+++ b/README.md
@@ -2,8 +2,11 @@
 
 Super basic piece of Software for handling talk submissions.
 
+<<<<<<< HEAD
+=======
 ![](./imgs/frontpage.png)
 
+>>>>>>> refs/remotes/origin/master
 ## Usage
 
 Well, It's pretty straitfowards…
diff --git a/config.yml b/config.yml
index ba730a0..1a4f81d 100644
--- a/config.yml
+++ b/config.yml
@@ -1,6 +1,10 @@
 # logging verbosity leve (1-7) 1=panic, 7=trace
 verbose:
+<<<<<<< HEAD
+    level: 7
+=======
     level: 6
+>>>>>>> refs/remotes/origin/master
 
 # Host information (ip to bind to and port to listen on)
 server:
@@ -9,7 +13,11 @@ server:
 
 # The database that should be accessed 
 db:
+<<<<<<< HEAD
+    addr: "localhost:5432"
+=======
     addr: "postgres:5432"
+>>>>>>> refs/remotes/origin/master
     user: "postgres"
     password: "postgres"
     database: "postgres"
diff --git a/go.mod b/go.mod
index 5eef6ae..2ef4b51 100644
--- a/go.mod
+++ b/go.mod
@@ -4,7 +4,11 @@ go 1.13
 
 require (
 	git.darknebu.la/chaosdorf/freitagsfoo/src/db v0.0.0-00010101000000-000000000000
+<<<<<<< HEAD
+	git.darknebu.la/chaosdorf/freitagsfoo/src/structs v0.0.0-20200718235609-fc63adf55849
+=======
 	git.darknebu.la/chaosdorf/freitagsfoo/src/structs v0.0.0-00010101000000-000000000000
+>>>>>>> refs/remotes/origin/master
 	github.com/go-pg/pg/v9 v9.1.6
 	github.com/google/uuid v1.1.1
 	github.com/gorilla/mux v1.7.4
diff --git a/hosted/tmpl/index.html b/hosted/tmpl/index.html
index 124271a..b6b73ef 100644
--- a/hosted/tmpl/index.html
+++ b/hosted/tmpl/index.html
@@ -24,6 +24,11 @@
 
             {{ template "upcomingTalks" . }}
 
+<<<<<<< HEAD
+            {{ template "pastTalks" . }}
+
+=======
+>>>>>>> refs/remotes/origin/master
         </main>
     </body>
 
diff --git a/hosted/tmpl/past.html b/hosted/tmpl/past.html
new file mode 100644
index 0000000..233bc55
--- /dev/null
+++ b/hosted/tmpl/past.html
@@ -0,0 +1,31 @@
+{{define "past"}}
+<!DOCTYPE html>
+<html lang="en">
+
+    <head>
+        <meta charset="UTF-8">
+        <meta name="viewport" content="width=device-width, initial-scale=1.0">
+        <meta http-equiv="X-UA-Compatible" content="ie=edge">
+        {{ template "stylesheets" . }}
+        <title>Freitagsfoo</title>
+    </head>
+
+    <body>
+        <main role="main">
+
+            <div class="container-fluid bg-success text-white p-5">
+                <div class="container">
+                    <h1 class="display-3">
+                        <a href="/" class="text-decoration-none text-white">Freitagsfoo!</a>
+                    </h1>
+                    <p><a class="btn btn-primary btn-lg" href="/propose" role="button">Propose a talk &raquo;</a></p>
+                </div>
+            </div>
+
+            {{ template "pastTalks" . }}
+
+        </main>
+    </body>
+
+</html>
+{{end}}
\ No newline at end of file
diff --git a/hosted/tmpl/pastTalks.html b/hosted/tmpl/pastTalks.html
new file mode 100644
index 0000000..cf2f0f1
--- /dev/null
+++ b/hosted/tmpl/pastTalks.html
@@ -0,0 +1,41 @@
+{{ define "pastTalks" }}
+            <div class="container mt-5">
+                <h2>Past talks: {{ .pastCount }}</h2>
+                <hr>
+                <div class="row">
+                    <div class="row row-cols-1 row-cols-md-3">
+                        {{ range $i, $talk := .pastTalks }}
+                        <div class="col mb-3">
+                            <div class="card h-100">
+                                <div class="card-header">
+                                    <h5 class="card-title">{{ $talk.Title }}</h5>
+                                </div>
+                                <div class="card-body">
+                                    <p class="card-text">{{ $talk.Description }}</p>
+                                    <a href="/talk/{{ $talk.UUID }}" class="btn btn-primary">Details</a>
+                                </div>
+                                <div class="card-footer text-muted">
+                                    <div class="row">
+                                        <div class="col text-left">
+                                            {{ $talk.FormattedDate }}
+                                        </div>
+                                        <div class="col text-right">
+                                            {{ $talk.Nickname }}
+                                        </div>
+                                    </div>
+                                </div>
+                            </div>
+                        </div>
+                        {{ end }}
+                    </div>
+
+                    {{ if .All }}
+                    {{ else }}
+                    <div class="text-right mt-3">
+                        <a href="/past" class="link-secondary">view all</a>
+                    </div>
+                    {{ end }}
+                </div>
+                <hr>
+            </div>
+{{ end }}
\ No newline at end of file
diff --git a/src/db.go b/src/db.go
index 713d8e6..1ec0941 100644
--- a/src/db.go
+++ b/src/db.go
@@ -61,18 +61,31 @@ func createSomeTalks(pgdb *pg.DB) {
 		"Bombur",
 	}
 	for i := 0; i < 10; i++ {
+<<<<<<< HEAD
+
+		date := time.Now().Add(-3 * 7 * 24 * time.Hour).Add(time.Duration(i) * 7 * 24 * time.Hour)
+=======
 		date := time.Now().Add(time.Duration(i) * 7 * 24 * time.Hour)
+>>>>>>> refs/remotes/origin/master
 
 		layout := "2006-01-02"
 		formattedDate := date.Format(layout)
 
 		talk := &structs.Talk{
 			UUID:          uuid.New(),
+<<<<<<< HEAD
+			Title:         fmt.Sprintf("Wie baut man eigentlich Raketen ohne Brennstoff? nr. %d", i),
+			Description:   fmt.Sprintf("Sunt rerum illo corrupti. Similique qui rem debitis. Accusamus et rerum sint et amet eos nemo. Et enim omnis et. Tempora et corrupti aut ea et vel. \n Dolor est quae sed molestiae nisi esse aliquid atque. Voluptas vero et ducimus voluptatem in eaque. Quo illum et delectus vel sed molestias quidem. Consequuntur unde dolores quis sunt exercitationem eos et provident. Animi eaque temporibus alias. %d", i),
+			Slides:        "./uploads/black.png",
+			Nickname:      nicknames[rand.Intn(len(nicknames))],
+			Date:          date,
+=======
 			Title:         fmt.Sprintf("Wie baut man eigentlich Raketen ohne Brennstoff nr. %d", i),
 			Description:   fmt.Sprintf("Sunt rerum illo corrupti. Similique qui rem debitis. Accusamus et rerum sint et amet eos nemo. Et enim omnis et. Tempora et corrupti aut ea et vel. \n Dolor est quae sed molestiae nisi esse aliquid atque. Voluptas vero et ducimus voluptatem in eaque. Quo illum et delectus vel sed molestias quidem. Consequuntur unde dolores quis sunt exercitationem eos et provident. Animi eaque temporibus alias. %d", i),
 			Slides:        "./uploads/black.png",
 			Nickname:      nicknames[rand.Intn(len(nicknames))],
 			Date:          time.Now(),
+>>>>>>> refs/remotes/origin/master
 			FormattedDate: formattedDate,
 			Upcoming:      true,
 		}
diff --git a/src/db/go.mod b/src/db/go.mod
index 4e70ab6..2c20fbf 100644
--- a/src/db/go.mod
+++ b/src/db/go.mod
@@ -3,6 +3,10 @@ module git.darknebu.la/chaosdorf/freitagsfoo/src/db
 go 1.13
 
 require (
+<<<<<<< HEAD
+	git.darknebu.la/chaosdorf/freitagsfoo/src/structs v0.0.0-20200718235609-fc63adf55849
+=======
+>>>>>>> refs/remotes/origin/master
 	github.com/go-pg/pg/v9 v9.1.6
 	github.com/google/uuid v1.1.1
 	github.com/sirupsen/logrus v1.6.0
diff --git a/src/db/go.sum b/src/db/go.sum
index eb7a67e..5efb5a8 100644
--- a/src/db/go.sum
+++ b/src/db/go.sum
@@ -11,6 +11,12 @@ cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqCl
 cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
 cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
 dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
+<<<<<<< HEAD
+git.darknebu.la/chaosdorf/freitagsfoo v0.0.0-20200718235609-fc63adf55849 h1:xI4zrY9O8OoR7ais9O+b+ntKoKi4Ln4mb2iUys/e66k=
+git.darknebu.la/chaosdorf/freitagsfoo/src/structs v0.0.0-20200718235609-fc63adf55849 h1:dkaulG2hAwns3QvFwFQEq2DVhiRsGPKvDmV5VrI3sfQ=
+git.darknebu.la/chaosdorf/freitagsfoo/src/structs v0.0.0-20200718235609-fc63adf55849/go.mod h1:dxRyc1J0ktxxbrlUpd3Uujtx+KgGGidcIpfFBT5ftBc=
+=======
+>>>>>>> refs/remotes/origin/master
 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
 github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
diff --git a/src/db/talk.go b/src/db/talk.go
index c286aa8..34a245a 100644
--- a/src/db/talk.go
+++ b/src/db/talk.go
@@ -2,6 +2,10 @@ package db
 
 import (
 	"fmt"
+<<<<<<< HEAD
+	"time"
+=======
+>>>>>>> refs/remotes/origin/master
 
 	"git.darknebu.la/chaosdorf/freitagsfoo/src/structs"
 	pg "github.com/go-pg/pg/v9"
@@ -21,7 +25,11 @@ func InsertTalk(db *pg.DB, talk *structs.Talk) error {
 // UpcomingTalksLimited returns the next 3 upcoming talks
 func UpcomingTalksLimited(db *pg.DB) ([]structs.Talk, error) {
 	var talks []structs.Talk
+<<<<<<< HEAD
+	err := db.Model(&talks).Order("date ASC").Where("date > ?", time.Now()).Limit(3).Select()
+=======
 	err := db.Model(&talks).Order("id DESC").Limit(3).Select()
+>>>>>>> refs/remotes/origin/master
 	if err != nil {
 		return []structs.Talk{}, fmt.Errorf("could not get the talks from the db: %s", err)
 	}
@@ -32,7 +40,33 @@ func UpcomingTalksLimited(db *pg.DB) ([]structs.Talk, error) {
 // UpcomingTalks returns the next upcoming talks
 func UpcomingTalks(db *pg.DB) ([]structs.Talk, error) {
 	var talks []structs.Talk
+<<<<<<< HEAD
+	err := db.Model(&talks).Order("date ASC").Where("date > ?", time.Now()).Select()
+	if err != nil {
+		return []structs.Talk{}, fmt.Errorf("could not get the talks from the db: %s", err)
+	}
+
+	return talks, nil
+}
+
+// PastTalksLimited returns the past 3 talks
+func PastTalksLimited(db *pg.DB) ([]structs.Talk, error) {
+	var talks []structs.Talk
+	err := db.Model(&talks).Order("date DESC").Where("date < ?", time.Now()).Limit(3).Select()
+	if err != nil {
+		return []structs.Talk{}, fmt.Errorf("could not get the talks from the db: %s", err)
+	}
+
+	return talks, nil
+}
+
+// PastTalks returns the next upcoming talks
+func PastTalks(db *pg.DB) ([]structs.Talk, error) {
+	var talks []structs.Talk
+	err := db.Model(&talks).Order("date DESC").Where("date < ?", time.Now()).Select()
+=======
 	err := db.Model(&talks).Order("id DESC").Select()
+>>>>>>> refs/remotes/origin/master
 	if err != nil {
 		return []structs.Talk{}, fmt.Errorf("could not get the talks from the db: %s", err)
 	}
@@ -42,9 +76,25 @@ func UpcomingTalks(db *pg.DB) ([]structs.Talk, error) {
 
 // CountUpcomingTalks counts the amount of talks upcoming
 func CountUpcomingTalks(db *pg.DB) (int, error) {
+<<<<<<< HEAD
+	var talks []structs.Talk
+	count, err := db.Model(&talks).Where("date > ?", time.Now()).Where("upcoming = ?", true).SelectAndCount()
+	if err != nil {
+		return -1, fmt.Errorf("could not get the talks from the db: %s", err)
+	}
+
+	return count, nil
+}
+
+// CountPastTalks counts the amount of past talks
+func CountPastTalks(db *pg.DB) (int, error) {
+	var talks []structs.Talk
+	count, err := db.Model(&talks).Where("date < ?", time.Now()).SelectAndCount()
+=======
 
 	var talks []structs.Talk
 	count, err := db.Model(&talks).Where("upcoming = ?", true).SelectAndCount()
+>>>>>>> refs/remotes/origin/master
 	if err != nil {
 		return -1, fmt.Errorf("could not get the talks from the db: %s", err)
 	}
diff --git a/src/http.go b/src/http.go
index ddab171..ec01825 100644
--- a/src/http.go
+++ b/src/http.go
@@ -19,6 +19,10 @@ func initHTTPServer() {
 	r := mux.NewRouter()
 	r.HandleFunc("/", indexHandler).Methods("GET")
 	r.HandleFunc("/upcoming", upcomingHandler).Methods("GET")
+<<<<<<< HEAD
+	r.HandleFunc("/past", pastHandler).Methods("GET")
+=======
+>>>>>>> refs/remotes/origin/master
 	r.HandleFunc("/propose", proposeHandler).Methods("GET")
 	r.HandleFunc("/talk/{uuid}", talkHandler).Methods("GET")
 
@@ -59,17 +63,42 @@ func indexHandler(w http.ResponseWriter, r *http.Request) {
 		logrus.Warn(err)
 		return
 	}
+<<<<<<< HEAD
+	// fetch the last three talks
+	lastThreeTalks, err := db.PastTalksLimited(pgdb)
+	if err != nil {
+		logrus.Warn(err)
+		return
+	}
+=======
+>>>>>>> refs/remotes/origin/master
 
 	upcomingCount, err := db.CountUpcomingTalks(pgdb)
 	if err != nil {
 		logrus.Warn(err)
 		return
 	}
+<<<<<<< HEAD
+	pastCount, err := db.CountPastTalks(pgdb)
+	if err != nil {
+		logrus.Warn(err)
+		return
+	}
+=======
+>>>>>>> refs/remotes/origin/master
 
 	content := map[string]interface{}{
 		"upcomingTalks": firstThreeTalks,
 		"upcomingCount": upcomingCount,
+<<<<<<< HEAD
+
+		"pastTalks": lastThreeTalks,
+		"pastCount": pastCount,
+
+		"All": false,
+=======
 		"All":           false,
+>>>>>>> refs/remotes/origin/master
 	}
 
 	// define a template
@@ -92,7 +121,11 @@ func upcomingHandler(w http.ResponseWriter, r *http.Request) {
 	defer db.Disconnect(pgdb)
 
 	// fetch the next talks
+<<<<<<< HEAD
+	upcomingTalks, err := db.UpcomingTalks(pgdb)
+=======
 	firstThreeTalks, err := db.UpcomingTalks(pgdb)
+>>>>>>> refs/remotes/origin/master
 	if err != nil {
 		logrus.Warn(err)
 		return
@@ -105,7 +138,11 @@ func upcomingHandler(w http.ResponseWriter, r *http.Request) {
 	}
 
 	content := map[string]interface{}{
+<<<<<<< HEAD
+		"upcomingTalks": upcomingTalks,
+=======
 		"upcomingTalks": firstThreeTalks,
+>>>>>>> refs/remotes/origin/master
 		"upcomingCount": upcomingCount,
 		"All":           true,
 	}
@@ -125,6 +162,47 @@ func upcomingHandler(w http.ResponseWriter, r *http.Request) {
 	}
 }
 
+<<<<<<< HEAD
+func pastHandler(w http.ResponseWriter, r *http.Request) {
+	pgdb := db.Connect()
+	defer db.Disconnect(pgdb)
+
+	// fetch the next talks
+	pastTalks, err := db.PastTalks(pgdb)
+	if err != nil {
+		logrus.Warn(err)
+		return
+	}
+
+	pastCount, err := db.CountPastTalks(pgdb)
+	if err != nil {
+		logrus.Warn(err)
+		return
+	}
+
+	content := map[string]interface{}{
+		"pastTalks": pastTalks,
+		"pastCount": pastCount,
+		"All":       true,
+	}
+
+	// define a template
+	t := template.New("")
+	t, err = t.ParseGlob("./hosted/tmpl/*.html")
+	if err != nil {
+		logrus.Warn(err)
+		return
+	}
+
+	// execute the template
+	err = t.ExecuteTemplate(w, "past", content)
+	if err != nil {
+		logrus.Warn(err)
+	}
+}
+
+=======
+>>>>>>> refs/remotes/origin/master
 func proposeHandler(w http.ResponseWriter, r *http.Request) {
 
 	// find the date of the next friday
diff --git a/uploads/DeepinScreenshot_select-area_20191222184454.png b/uploads/DeepinScreenshot_select-area_20191222184454.png
new file mode 100644
index 0000000..9b930b8
--- /dev/null
+++ b/uploads/DeepinScreenshot_select-area_20191222184454.png
Binary files differdiff --git a/uploads/DeepinScreenshot_select-area_20191229210336.png b/uploads/DeepinScreenshot_select-area_20191229210336.png
new file mode 100644
index 0000000..5687132
--- /dev/null
+++ b/uploads/DeepinScreenshot_select-area_20191229210336.png
Binary files differdiff --git a/uploads/DeepinScreenshot_select-area_20200104201703.png b/uploads/DeepinScreenshot_select-area_20200104201703.png
new file mode 100644
index 0000000..eece90b
--- /dev/null
+++ b/uploads/DeepinScreenshot_select-area_20200104201703.png
Binary files differdiff --git a/uploads/DeepinScreenshot_select-area_20200107180131.png b/uploads/DeepinScreenshot_select-area_20200107180131.png
new file mode 100644
index 0000000..80ec9a5
--- /dev/null
+++ b/uploads/DeepinScreenshot_select-area_20200107180131.png
Binary files differdiff --git a/uploads/DeepinScreenshot_select-area_20200107180829.png b/uploads/DeepinScreenshot_select-area_20200107180829.png
new file mode 100644
index 0000000..4485db0
--- /dev/null
+++ b/uploads/DeepinScreenshot_select-area_20200107180829.png
Binary files differdiff --git a/uploads/bendisposto.jpeg b/uploads/bendisposto.jpeg
new file mode 100644
index 0000000..756e2f5
--- /dev/null
+++ b/uploads/bendisposto.jpeg
Binary files differdiff --git a/uploads/black.png b/uploads/black.png
new file mode 100644
index 0000000..f61a15b
--- /dev/null
+++ b/uploads/black.png
Binary files differ