diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5bd15ce --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +previews/ +index.html diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..3b8c149 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,32 @@ +cache: + untracked: true + paths: + - node_modules/ + +stages: + - build + - deploy + +build: + stage: build + image: golang:1.12 + script: + - go run main.go + - mkdir dist + - mv index.html dist/ + - mv previews/ dist/ + - mv talks/ dist/ + artifacts: + paths: + - dist + +deploy: + stage: deploy + image: node:12-alpine + script: + - npm i -g netlify-cli + - netlify deploy --site $NETLIFY_SITE_ID --auth $NETLIFY_AUTH_TOKEN --prod + dependencies: + - build + only: + - master diff --git a/.netlify/state.json b/.netlify/state.json new file mode 100644 index 0000000..f3acdac --- /dev/null +++ b/.netlify/state.json @@ -0,0 +1,3 @@ +{ + "siteId": "d76a4d4a-6df9-4f82-8e13-6e71b30fce8f" +} \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..31ef95c --- /dev/null +++ b/go.mod @@ -0,0 +1,8 @@ +module git.rainbownerds.de/felix/slides.fleaz.me + +go 1.13 + +require ( + gopkg.in/gographics/imagick.v2 v2.5.0 + gopkg.in/gographics/imagick.v3 v3.2.0 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..f510095 --- /dev/null +++ b/go.sum @@ -0,0 +1,4 @@ +gopkg.in/gographics/imagick.v2 v2.5.0 h1:3wOeg/IgtagJtveISUaX9A3F/L/5PxaFHkAz5AzgbgA= +gopkg.in/gographics/imagick.v2 v2.5.0/go.mod h1:of4TbGX8yMcpgWkWFjha7FsOFr+NjOJ5O1qtKU27Yj0= +gopkg.in/gographics/imagick.v3 v3.2.0 h1:eUwlkCw2fa20OGu47G39Im8c50S9n/CVkh8PwtOKExA= +gopkg.in/gographics/imagick.v3 v3.2.0/go.mod h1:HbW83cYCl1jftZi3B/VZpVqsuNi4vW7qUrghjxBiT+8= diff --git a/main.go b/main.go new file mode 100644 index 0000000..eb2368c --- /dev/null +++ b/main.go @@ -0,0 +1,68 @@ +package main + +import ( + "fmt" + "html/template" + "os" + "path/filepath" + "regexp" + + "gopkg.in/gographics/imagick.v3/imagick" +) + +type Talk struct { + Title string + Preview string + Path string +} + +func generatePreview(path string) Talk { + r := regexp.MustCompile("talks\\/(.*)\\.pdf") + result := r.FindStringSubmatch(path) + imagePath := fmt.Sprintf("previews/%s.jpg", result[1]) + mw := imagick.NewMagickWand() + defer mw.Destroy() + mw.ReadImage(path) + mw.SetIteratorIndex(0) + mw.SetImageFormat("jpg") + mw.WriteImage(imagePath) + return Talk{Title: result[1], Preview: imagePath, Path: path} +} + +func main() { + + var files []string + + root := "talks/" + err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error { + if info.IsDir() { + return nil + } + files = append(files, path) + return nil + }) + if err != nil { + panic(err) + } + + imagick.Initialize() + defer imagick.Terminate() + var data []Talk + for _, file := range files { + t := generatePreview(file) + data = append(data, t) + } + + tmpl, err := template.ParseFiles("template.html") + if err != nil { + panic(err) + } + + f, err := os.Create("index.html") + if err != nil { + panic(err) + } + defer f.Close() + + tmpl.Execute(f, data) +} diff --git a/netlify.toml b/netlify.toml new file mode 100644 index 0000000..cefc5c0 --- /dev/null +++ b/netlify.toml @@ -0,0 +1,2 @@ +[build] + publish = "dist" diff --git a/talks/2016-12-13-rspamd.pdf b/talks/2016-12-13-rspamd.pdf new file mode 100644 index 0000000..acef49f Binary files /dev/null and b/talks/2016-12-13-rspamd.pdf differ diff --git a/talks/2017-06-06-BorgBackup.pdf b/talks/2017-06-06-BorgBackup.pdf new file mode 100644 index 0000000..6cf0746 Binary files /dev/null and b/talks/2017-06-06-BorgBackup.pdf differ diff --git a/template.html b/template.html new file mode 100644 index 0000000..d2333b6 --- /dev/null +++ b/template.html @@ -0,0 +1,5 @@ +{{ range . }} +

{{ .Title }}

+ +Download +{{ end }}