mirror of
https://github.com/Kugelschieber/marvinblum.git
synced 2026-01-18 14:50:27 +00:00
Small refactoring and improved legal page and more whitespace.
This commit is contained in:
2
go.mod
2
go.mod
@@ -8,7 +8,7 @@ require (
|
||||
github.com/cenkalti/backoff/v4 v4.0.2 // indirect
|
||||
github.com/emvi/api-go v0.0.0-20191210194347-0a945446f6a8
|
||||
github.com/emvi/logbuch v1.1.1
|
||||
github.com/emvi/pirsch v0.0.0-20200623193552-b3a3d4a6434d
|
||||
github.com/emvi/pirsch v0.0.0-20200624123353-86381b017755
|
||||
github.com/gorilla/mux v1.7.4
|
||||
github.com/gosimple/slug v1.9.0
|
||||
github.com/jmoiron/sqlx v1.2.0 // indirect
|
||||
|
||||
2
go.sum
2
go.sum
@@ -87,6 +87,8 @@ github.com/emvi/pirsch v0.0.0-20200623192632-5c5fcd1d78cc h1:G05tiq3JKZwjnPSObRB
|
||||
github.com/emvi/pirsch v0.0.0-20200623192632-5c5fcd1d78cc/go.mod h1:+YmBbltJ3feZz9L/QQyqwywltYvQKBfzrGD51TPKl5g=
|
||||
github.com/emvi/pirsch v0.0.0-20200623193552-b3a3d4a6434d h1:+HRIYgA9AaXlGFQfhXpUShXxJ1knG2stwNIai1M6mzs=
|
||||
github.com/emvi/pirsch v0.0.0-20200623193552-b3a3d4a6434d/go.mod h1:+YmBbltJ3feZz9L/QQyqwywltYvQKBfzrGD51TPKl5g=
|
||||
github.com/emvi/pirsch v0.0.0-20200624123353-86381b017755 h1:TdiDC7+IfV6giMtFNvbYKFlSPJJZewr9jfh3KGcr8QQ=
|
||||
github.com/emvi/pirsch v0.0.0-20200624123353-86381b017755/go.mod h1:+YmBbltJ3feZz9L/QQyqwywltYvQKBfzrGD51TPKl5g=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/exoscale/egoscale v0.18.1/go.mod h1:Z7OOdzzTOz1Q1PjQXumlz9Wn/CddH0zSYdCF3rnBKXE=
|
||||
|
||||
62
main.go
62
main.go
@@ -1,10 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"github.com/Kugelschieber/marvinblum.de/blog"
|
||||
"github.com/Kugelschieber/marvinblum.de/tpl"
|
||||
"github.com/Kugelschieber/marvinblum.de/tracking"
|
||||
"github.com/NYTimes/gziphandler"
|
||||
"github.com/caddyserver/certmagic"
|
||||
emvi "github.com/emvi/api-go"
|
||||
@@ -16,17 +15,15 @@ import (
|
||||
"html/template"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
staticDir = "static"
|
||||
staticDirPrefix = "/static/"
|
||||
logTimeFormat = "2006-01-02_15:04:05"
|
||||
envPrefix = "MB_"
|
||||
connectionString = `host=%s port=%s user=%s password=%s dbname=%s sslmode=%s sslcert=%s sslkey=%s sslrootcert=%s connectTimeout=%s timezone=%s`
|
||||
staticDir = "static"
|
||||
staticDirPrefix = "/static/"
|
||||
logTimeFormat = "2006-01-02_15:04:05"
|
||||
envPrefix = "MB_"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -58,53 +55,6 @@ func logEnvConfig() {
|
||||
}
|
||||
}
|
||||
|
||||
func setupTracker() {
|
||||
logbuch.Info("Connecting to database...")
|
||||
host := os.Getenv("MB_DB_HOST")
|
||||
port := os.Getenv("MB_DB_PORT")
|
||||
user := os.Getenv("MB_DB_USER")
|
||||
password := os.Getenv("MB_DB_PASSWORD")
|
||||
schema := os.Getenv("MB_DB_SCHEMA")
|
||||
sslMode := os.Getenv("MB_DB_SSLMODE")
|
||||
sslCert := os.Getenv("MB_DB_SSLCERT")
|
||||
sslKey := os.Getenv("MB_DB_SSLKEY")
|
||||
sslRootCert := os.Getenv("MB_DB_SSLROOTCERT")
|
||||
zone, offset := time.Now().Zone()
|
||||
timezone := zone + strconv.Itoa(-offset/3600)
|
||||
logbuch.Info("Setting time zone", logbuch.Fields{"timezone": timezone})
|
||||
connectionStr := fmt.Sprintf(connectionString, host, port, user, password, schema, sslMode, sslCert, sslKey, sslRootCert, "30", timezone)
|
||||
db, err := sql.Open("postgres", connectionStr)
|
||||
|
||||
if err != nil {
|
||||
logbuch.Fatal("Error connecting to database", logbuch.Fields{"err": err})
|
||||
}
|
||||
|
||||
if err := db.Ping(); err != nil {
|
||||
logbuch.Fatal("Error pinging database", logbuch.Fields{"err": err})
|
||||
}
|
||||
|
||||
store := pirsch.NewPostgresStore(db)
|
||||
tracker = pirsch.NewTracker(store, nil)
|
||||
processor := pirsch.NewProcessor(store)
|
||||
processTrackingData(processor)
|
||||
pirsch.RunAtMidnight(func() {
|
||||
processTrackingData(processor)
|
||||
})
|
||||
}
|
||||
|
||||
func processTrackingData(processor *pirsch.Processor) {
|
||||
logbuch.Info("Processing tracking data...")
|
||||
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
logbuch.Error("Error processing tracking data", logbuch.Fields{"err": err})
|
||||
}
|
||||
}()
|
||||
|
||||
processor.Process()
|
||||
logbuch.Info("Done processing tracking data")
|
||||
}
|
||||
|
||||
func serveAbout() http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
tracker.Hit(r)
|
||||
@@ -217,7 +167,7 @@ func start(handler http.Handler) {
|
||||
func main() {
|
||||
configureLog()
|
||||
logEnvConfig()
|
||||
setupTracker()
|
||||
tracker = tracking.NewTracker()
|
||||
tplCache = tpl.NewCache()
|
||||
blogInstance = blog.NewBlog(tplCache)
|
||||
router := setupRouter()
|
||||
|
||||
@@ -11,14 +11,14 @@
|
||||
{{template "menu.html"}}
|
||||
|
||||
<section>
|
||||
<h2>who am I?</h2>
|
||||
<h2>Who Am I?</h2>
|
||||
<p>
|
||||
I'm a full stack software engineer from Germany, open source and Linux enthusiast and co-founder of <a href="https://emvi.com/" target="_blank">Emvi</a>.
|
||||
In love with Go, but fluent in a lot of programming languages.
|
||||
</p>
|
||||
</section>
|
||||
<section>
|
||||
<h2>latest blog posts</h2>
|
||||
<h2>Latest Blog Posts</h2>
|
||||
{{range $article := .Articles}}
|
||||
<p>
|
||||
<a href="/blog/{{slug $article.LatestArticleContent.Title}}-{{$article.Id}}">{{$article.LatestArticleContent.Title}}</a>
|
||||
@@ -32,11 +32,14 @@
|
||||
</p>
|
||||
</section>
|
||||
<section>
|
||||
<h2>projects</h2>
|
||||
<h2>Projects</h2>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://emvi.com/" target="_blank">Emvi</a> a note taking, collaboration and knowledge management tool for personal use and teams of any size
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/emvi/pirsch" target="_blank">pirsch</a> a server side, no-cookie and privacy focused tracking library for Golang
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/emvi/logbuch" target="_blank">logbuch</a> a simple Golang logging library
|
||||
</li>
|
||||
@@ -52,7 +55,7 @@
|
||||
</ul>
|
||||
</section>
|
||||
<section>
|
||||
<h2>skills</h2>
|
||||
<h2>Skills</h2>
|
||||
<ul>
|
||||
<li>Go (Golang)</li>
|
||||
<li>JavaScript (Vue, Node)</li>
|
||||
@@ -66,7 +69,7 @@
|
||||
</ul>
|
||||
</section>
|
||||
<section>
|
||||
<h2>work</h2>
|
||||
<h2>Work</h2>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://emvi.com/" target="_blank">Emvi</a> co-founder of a note taking, collaboration and knowledge management SaaS startup
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
|
||||
<section>
|
||||
<h1>Blog</h1>
|
||||
{{range $year, $articles := .Articles}}
|
||||
</section>
|
||||
{{range $year, $articles := .Articles}}
|
||||
<section>
|
||||
<h2>{{$year}}</h2>
|
||||
|
||||
{{range $article := $articles}}
|
||||
@@ -12,9 +14,11 @@
|
||||
<small>{{format $article.Published "2. January 2006"}}</small>
|
||||
</p>
|
||||
{{end}}
|
||||
{{else}}
|
||||
</section>
|
||||
{{else}}
|
||||
<section>
|
||||
<p>There are no blog posts yet...</p>
|
||||
{{end}}
|
||||
</section>
|
||||
</section>
|
||||
{{end}}
|
||||
|
||||
{{template "end.html"}}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<hr />
|
||||
<section>
|
||||
<p>
|
||||
Like to see more? Read my blog articles on <a href="https://emvi.com/blog" target="_blank">Emvi</a>, my project page on <a href="https://github.com/Kugelschieber" target="_blank">GitHub</a> or send me a <a href="mailto:marvin@marvinblum.de">mail</a>.
|
||||
Would you like to see more? Read my blog articles on <a href="https://emvi.com/blog" target="_blank">Emvi</a>, my project page on <a href="https://github.com/Kugelschieber" target="_blank">GitHub</a> or send me a <a href="mailto:marvin@marvinblum.de">mail</a>.
|
||||
</p>
|
||||
<p>
|
||||
This page uses <a href="https://concrete.style/" target="_blank">concrete</a> for styling. Check it out!
|
||||
</p>
|
||||
<p>
|
||||
<a href="/legal">Legal</a>
|
||||
This page does not use Cookies. <a href="/legal">Legal</a>
|
||||
</p>
|
||||
</section>
|
||||
</body>
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
{{template "head.html"}}
|
||||
{{template "menu.html"}}
|
||||
|
||||
<section>
|
||||
<h1>Legal</h1>
|
||||
</section>
|
||||
<section>
|
||||
<h2>According to §5 TMG</h2>
|
||||
<p>
|
||||
@@ -10,5 +13,11 @@
|
||||
<a href="mailto:marvin@marvinblum.de">marvin@marvinblum.de</a>
|
||||
</p>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Cookie Policy</h2>
|
||||
<p>
|
||||
This page does not use cookies.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
{{template "end.html"}}
|
||||
|
||||
66
tracking/tracking.go
Normal file
66
tracking/tracking.go
Normal file
@@ -0,0 +1,66 @@
|
||||
package tracking
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"github.com/emvi/logbuch"
|
||||
"github.com/emvi/pirsch"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
connectionString = `host=%s port=%s user=%s password=%s dbname=%s sslmode=%s sslcert=%s sslkey=%s sslrootcert=%s connectTimeout=%s timezone=%s`
|
||||
)
|
||||
|
||||
func NewTracker() *pirsch.Tracker {
|
||||
logbuch.Info("Connecting to database...")
|
||||
host := os.Getenv("MB_DB_HOST")
|
||||
port := os.Getenv("MB_DB_PORT")
|
||||
user := os.Getenv("MB_DB_USER")
|
||||
password := os.Getenv("MB_DB_PASSWORD")
|
||||
schema := os.Getenv("MB_DB_SCHEMA")
|
||||
sslMode := os.Getenv("MB_DB_SSLMODE")
|
||||
sslCert := os.Getenv("MB_DB_SSLCERT")
|
||||
sslKey := os.Getenv("MB_DB_SSLKEY")
|
||||
sslRootCert := os.Getenv("MB_DB_SSLROOTCERT")
|
||||
zone, offset := time.Now().Zone()
|
||||
timezone := zone + strconv.Itoa(-offset/3600)
|
||||
logbuch.Info("Setting time zone", logbuch.Fields{"timezone": timezone})
|
||||
connectionStr := fmt.Sprintf(connectionString, host, port, user, password, schema, sslMode, sslCert, sslKey, sslRootCert, "30", timezone)
|
||||
db, err := sql.Open("postgres", connectionStr)
|
||||
|
||||
if err != nil {
|
||||
logbuch.Fatal("Error connecting to database", logbuch.Fields{"err": err})
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := db.Ping(); err != nil {
|
||||
logbuch.Fatal("Error pinging database", logbuch.Fields{"err": err})
|
||||
return nil
|
||||
}
|
||||
|
||||
store := pirsch.NewPostgresStore(db)
|
||||
tracker := pirsch.NewTracker(store, nil)
|
||||
processor := pirsch.NewProcessor(store)
|
||||
processTrackingData(processor)
|
||||
pirsch.RunAtMidnight(func() {
|
||||
processTrackingData(processor)
|
||||
})
|
||||
|
||||
return tracker
|
||||
}
|
||||
|
||||
func processTrackingData(processor *pirsch.Processor) {
|
||||
logbuch.Info("Processing tracking data...")
|
||||
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
logbuch.Error("Error processing tracking data", logbuch.Fields{"err": err})
|
||||
}
|
||||
}()
|
||||
|
||||
processor.Process()
|
||||
logbuch.Info("Done processing tracking data")
|
||||
}
|
||||
Reference in New Issue
Block a user