Compare commits

..

No commits in common. "6cbe2c4430815b6f3b8bacb33ee2fa2882e4af5e" and "ce194b23c8d01407b63ca0a4b0bad35e78c38286" have entirely different histories.

9 changed files with 47 additions and 33 deletions

17
.gitignore vendored
View file

@ -1,2 +1,15 @@
/data
/covers
/target
/classes
/checkouts
pom.xml
pom.xml.asc
*.jar
*.class
/.lein-*
/.nrepl-port
/.project
/public/book.html
/public/comic.html
/public/comic-covers/
/public/book-covers/

2
AUTHOR.mkd Normal file
View file

@ -0,0 +1,2 @@
* Aaron Fischer <mail@aaron-fischer.net>
* Michael Reutter <michael@reutter.info>

View file

@ -1,7 +1,7 @@
FROM golang:alpine AS build
COPY . /app
WORKDIR /app
RUN GOOS=linux go build -o bdm src/bdm.go
RUN GOOS=linux go build -o bdm cmd/buchdesmonats/main.go
FROM alpine

18
LICENSE.mkd Normal file
View file

@ -0,0 +1,18 @@
Copyright (C) 2014-2015 Aaron Fischer <mail@aaron-fischer.net>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

6
Makefile Normal file
View file

@ -0,0 +1,6 @@
build:
mkdir -p bin
go build -o bin/buchdesmonats cmd/buchdesmonats/main.go
run:
go run cmd/buchdesmonats/main.go

View file

@ -1,11 +0,0 @@
# Book of the month
## Deploy
$ docker-compose build
$ docker-compose up -d
## Authors
* Aaron Fischer <mail@aaron-fischer.net>
* Michael Reutter <michael@reutter.info>

View file

@ -57,14 +57,14 @@ func getItems(filename string) []Item {
resp, err := http.Get(url)
if err != nil {
log.Fatal(filename + " is missing")
panic(filename + " is missing")
}
defer resp.Body.Close()
content, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal("Can not download the file. Network problem?")
panic("Can not download the file. Network problem?")
}
re := regexp.MustCompile(`[0-9]{13}`)
@ -98,14 +98,13 @@ func main() {
fileServer := http.FileServer(http.Dir("./static"))
http.Handle("/static/", http.StripPrefix("/static", fileServer))
// Cover images
// Images
imageServer := http.FileServer(http.Dir("./covers/"))
http.Handle("/covers/", http.StripPrefix("/covers", imageServer))
// Update "Hook" /update?filename=COMIC.mkd
http.HandleFunc("/update", func(w http.ResponseWriter, r *http.Request) {
filename := r.URL.Query().Get("filename")
log.Printf("Update hook triggered for %v", filename)
// Get all items from the git repo
items := getItems(filename)
@ -120,6 +119,7 @@ func main() {
}
})
// Spawn webserver /comic
http.HandleFunc("/book", func(w http.ResponseWriter, r *http.Request) {
log.Print("/book")
getHTML("BOOK.mkd", w)
@ -129,8 +129,6 @@ func main() {
getHTML("COMIC.mkd", w)
})
// Spawn the webserver (blocking)
log.Print("Spawn webserver on port :9783 and waiting for requests ...")
err := http.ListenAndServe(":9783", nil)
if err != nil {
panic(err)

View file

@ -1,12 +0,0 @@
version: "3"
services:
webservice:
build: .
image: bdm:latest
restart: always
volumes:
- ./data:/app/covers
ports:
- 127.0.0.1:9783:9783

2
go.mod
View file

@ -1,3 +1,3 @@
module okoyono.de/buchdesmonats
go 1.16
go 1.15