first commit
This commit is contained in:
parent
e9b6e00ca2
commit
fb398afd8b
10 changed files with 124 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
previews/
|
||||||
|
index.html
|
32
.gitlab-ci.yml
Normal file
32
.gitlab-ci.yml
Normal file
|
@ -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
|
3
.netlify/state.json
Normal file
3
.netlify/state.json
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"siteId": "d76a4d4a-6df9-4f82-8e13-6e71b30fce8f"
|
||||||
|
}
|
8
go.mod
Normal file
8
go.mod
Normal file
|
@ -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
|
||||||
|
)
|
4
go.sum
Normal file
4
go.sum
Normal file
|
@ -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=
|
68
main.go
Normal file
68
main.go
Normal file
|
@ -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)
|
||||||
|
}
|
2
netlify.toml
Normal file
2
netlify.toml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[build]
|
||||||
|
publish = "dist"
|
BIN
talks/2016-12-13-rspamd.pdf
Normal file
BIN
talks/2016-12-13-rspamd.pdf
Normal file
Binary file not shown.
BIN
talks/2017-06-06-BorgBackup.pdf
Normal file
BIN
talks/2017-06-06-BorgBackup.pdf
Normal file
Binary file not shown.
5
template.html
Normal file
5
template.html
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{{ range . }}
|
||||||
|
<h1>{{ .Title }}</h1>
|
||||||
|
<img src="{{ .Preview }}" />
|
||||||
|
<a href="{{ .Path }}">Download</a>
|
||||||
|
{{ end }}
|
Loading…
Add table
Reference in a new issue