Compare commits
No commits in common. "4dd9e0547331f50796280dfee2da250cf8df1f8c" and "a5979f2a1788a31106875ebc1afcd617d9e09ae8" have entirely different histories.
4dd9e05473
...
a5979f2a17
@ -5,7 +5,6 @@
|
|||||||
docker_container:
|
docker_container:
|
||||||
name: "bouquins_draft_{{ draft_name }}"
|
name: "bouquins_draft_{{ draft_name }}"
|
||||||
image: "reg.meutel.net/go-bouquins:{{ draft_name }}"
|
image: "reg.meutel.net/go-bouquins:{{ draft_name }}"
|
||||||
pull: yes
|
|
||||||
state: started
|
state: started
|
||||||
recreate: yes
|
recreate: yes
|
||||||
labels:
|
labels:
|
||||||
|
@ -30,7 +30,6 @@ steps:
|
|||||||
settings:
|
settings:
|
||||||
registry: reg.meutel.net
|
registry: reg.meutel.net
|
||||||
repo: reg.meutel.net/go-bouquins
|
repo: reg.meutel.net/go-bouquins
|
||||||
build_args: "version=$DRONE_TAG"
|
|
||||||
username:
|
username:
|
||||||
from_secret: registry_login
|
from_secret: registry_login
|
||||||
password:
|
password:
|
||||||
@ -74,6 +73,6 @@ trigger:
|
|||||||
|
|
||||||
---
|
---
|
||||||
kind: signature
|
kind: signature
|
||||||
hmac: 6d31a8c73df2a63f6f04334ebf20ad9c7e4a992acb15097b1f887433748f0fd7
|
hmac: 402ef53d245969c2df4d6ec14d51d3d9665856c8fa0ec8248755a209fb66ff36
|
||||||
|
|
||||||
...
|
...
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
FROM golang as builder
|
FROM golang as builder
|
||||||
|
|
||||||
ARG version
|
|
||||||
WORKDIR /go/src/meutel.net/meutel/go-bouquins
|
WORKDIR /go/src/meutel.net/meutel/go-bouquins
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN GO111MODULE=on go get .
|
RUN GO111MODULE=on go get .
|
||||||
RUN GO111MODULE=on CGO_ENABLED=1 GOOS=linux go build -ldflags "-X main.version=$version" -a -installsuffix cgo -o app .
|
RUN GO111MODULE=on CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o app .
|
||||||
RUN curl -X POST -s --data-urlencode 'input@assets/css/bouquins.css' https://cssminifier.com/raw > assets/css/bouquins.min.css
|
RUN curl -X POST -s --data-urlencode 'input@assets/css/bouquins.css' https://cssminifier.com/raw > assets/css/bouquins.min.css
|
||||||
|
|
||||||
# deployment image
|
# deployment image
|
||||||
|
@ -15,12 +15,6 @@ Bouquins in Go
|
|||||||
* JS: https://www.danstools.com/javascript-minify/
|
* JS: https://www.danstools.com/javascript-minify/
|
||||||
* CSS: curl -X POST -s --data-urlencode 'input@assets/css/bouquins.css' https://cssminifier.com/raw > assets/css/bouquins.min.css
|
* CSS: curl -X POST -s --data-urlencode 'input@assets/css/bouquins.css' https://cssminifier.com/raw > assets/css/bouquins.min.css
|
||||||
|
|
||||||
## Versionning
|
|
||||||
|
|
||||||
Build with flag to define `main.version`
|
|
||||||
|
|
||||||
go build -ldflags "-X main.version=myVersion"
|
|
||||||
|
|
||||||
## Deployment archive
|
## Deployment archive
|
||||||
|
|
||||||
tar czf ~/tmp/go-bouquins.tar.gz go-bouquins assets/ templates/
|
tar czf ~/tmp/go-bouquins.tar.gz go-bouquins assets/ templates/
|
||||||
|
@ -19,6 +19,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// Version defines application version
|
||||||
|
Version = "master"
|
||||||
|
|
||||||
tplBooks = "book.html"
|
tplBooks = "book.html"
|
||||||
tplAuthors = "author.html"
|
tplAuthors = "author.html"
|
||||||
tplSeries = "series.html"
|
tplSeries = "series.html"
|
||||||
@ -53,11 +56,11 @@ const (
|
|||||||
// URLAbout url of about page
|
// URLAbout url of about page
|
||||||
URLAbout = "/about/"
|
URLAbout = "/about/"
|
||||||
// URLJs url of js assets
|
// URLJs url of js assets
|
||||||
URLJs = "/js/"
|
URLJs = "/" + Version + "/js/"
|
||||||
// URLCss url of css assets
|
// URLCss url of css assets
|
||||||
URLCss = "/css/"
|
URLCss = "/" + Version + "/css/"
|
||||||
// URLFonts url of fonts assets
|
// URLFonts url of fonts assets
|
||||||
URLFonts = "/webfonts/"
|
URLFonts = "/" + Version + "/webfonts/"
|
||||||
// URLCalibre url of calibre resources (covers, ebooks files)
|
// URLCalibre url of calibre resources (covers, ebooks files)
|
||||||
URLCalibre = "/calibre/"
|
URLCalibre = "/calibre/"
|
||||||
)
|
)
|
||||||
@ -183,6 +186,7 @@ type SeriesFull struct {
|
|||||||
type Model struct {
|
type Model struct {
|
||||||
Title string
|
Title string
|
||||||
Page string
|
Page string
|
||||||
|
Version string
|
||||||
Username string
|
Username string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,6 +195,7 @@ func (app *Bouquins) NewModel(title, page string, req *http.Request) *Model {
|
|||||||
return &Model{
|
return &Model{
|
||||||
Title: title,
|
Title: title,
|
||||||
Page: page,
|
Page: page,
|
||||||
|
Version: Version,
|
||||||
Username: app.Username(req),
|
Username: app.Username(req),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -280,21 +285,18 @@ type ReqParams struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TemplatesFunc adds functions to templates
|
// TemplatesFunc adds functions to templates
|
||||||
func TemplatesFunc(prod bool, version string) *template.Template {
|
func TemplatesFunc(prod bool) *template.Template {
|
||||||
return template.New("").Funcs(template.FuncMap{
|
return template.New("").Funcs(template.FuncMap{
|
||||||
"assetUrl": func(name string, ext string) string {
|
"assetUrl": func(name string, ext string) string {
|
||||||
sep := "."
|
sep := "."
|
||||||
if prod {
|
if prod {
|
||||||
sep = ".min."
|
sep = ".min."
|
||||||
}
|
}
|
||||||
return "/" + ext + "/" + name + sep + ext
|
return "/" + Version + "/" + ext + "/" + name + sep + ext
|
||||||
},
|
},
|
||||||
"humanSize": func(sz int64) string {
|
"humanSize": func(sz int64) string {
|
||||||
return datasize.ByteSize(sz).HumanReadable()
|
return datasize.ByteSize(sz).HumanReadable()
|
||||||
},
|
},
|
||||||
"version": func() string {
|
|
||||||
return version
|
|
||||||
},
|
|
||||||
"bookCover": func(book *BookFull) string {
|
"bookCover": func(book *BookFull) string {
|
||||||
fmt.Println(book.Path)
|
fmt.Println(book.Path)
|
||||||
return "/calibre/" + url.PathEscape(book.Path) + "/cover.jpg"
|
return "/calibre/" + url.PathEscape(book.Path) + "/cover.jpg"
|
||||||
|
16
main.go
16
main.go
@ -2,12 +2,11 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"gopkg.in/yaml.v2"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"gopkg.in/yaml.v2"
|
|
||||||
|
|
||||||
"golang.org/x/oauth2"
|
"golang.org/x/oauth2"
|
||||||
|
|
||||||
"github.com/gorilla/sessions"
|
"github.com/gorilla/sessions"
|
||||||
@ -16,10 +15,6 @@ import (
|
|||||||
"meutel.net/meutel/go-bouquins/bouquins"
|
"meutel.net/meutel/go-bouquins/bouquins"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
version string
|
|
||||||
)
|
|
||||||
|
|
||||||
// ReadConfig loads configuration file and initialize default value
|
// ReadConfig loads configuration file and initialize default value
|
||||||
func ReadConfig() (*bouquins.Conf, error) {
|
func ReadConfig() (*bouquins.Conf, error) {
|
||||||
conf := new(bouquins.Conf)
|
conf := new(bouquins.Conf)
|
||||||
@ -58,7 +53,7 @@ func initApp() *bouquins.Bouquins {
|
|||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
tpl, err := bouquins.TemplatesFunc(conf.Prod, version).ParseGlob("templates/*.html")
|
tpl, err := bouquins.TemplatesFunc(conf.Prod).ParseGlob("templates/*.html")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
@ -91,9 +86,9 @@ func initApp() *bouquins.Bouquins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func assets(calibre string) {
|
func assets(calibre string) {
|
||||||
http.Handle(bouquins.URLJs, http.FileServer(http.Dir("assets")))
|
http.Handle(bouquins.URLJs, http.StripPrefix("/"+bouquins.Version, http.FileServer(http.Dir("assets"))))
|
||||||
http.Handle(bouquins.URLCss, http.FileServer(http.Dir("assets")))
|
http.Handle(bouquins.URLCss, http.StripPrefix("/"+bouquins.Version, http.FileServer(http.Dir("assets"))))
|
||||||
http.Handle(bouquins.URLFonts, http.FileServer(http.Dir("assets")))
|
http.Handle(bouquins.URLFonts, http.StripPrefix("/"+bouquins.Version, http.FileServer(http.Dir("assets"))))
|
||||||
}
|
}
|
||||||
|
|
||||||
func handle(f func(res http.ResponseWriter, req *http.Request) error) func(res http.ResponseWriter, req *http.Request) {
|
func handle(f func(res http.ResponseWriter, req *http.Request) error) func(res http.ResponseWriter, req *http.Request) {
|
||||||
@ -125,7 +120,6 @@ func router(app *bouquins.Bouquins) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
log.Println("go-bouquins", version)
|
|
||||||
app := initApp()
|
app := initApp()
|
||||||
defer app.DB.Close()
|
defer app.DB.Close()
|
||||||
defer app.UserDB.Close()
|
defer app.UserDB.Close()
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
{{ template "header.html" . }}
|
{{ template "header.html" . }}
|
||||||
<div class="container" id="about">
|
<div class="container" id="about">
|
||||||
<p>go-bouquins {{ version }}</p>
|
|
||||||
<p><b>bouquins</b> est une interface web pour le gestionnaire de livres numériques <a href="https://calibre-ebook.com/">calibre</a>. Cette version utilise le langage <a href="https://golang.org/">Go</a>, le framework <a href="https://getbootstrap.com/">bootstap</a> et le framework <a href="https://vuejs.org/">Vue.js</a>.</p>
|
<p><b>bouquins</b> est une interface web pour le gestionnaire de livres numériques <a href="https://calibre-ebook.com/">calibre</a>. Cette version utilise le langage <a href="https://golang.org/">Go</a>, le framework <a href="https://getbootstrap.com/">bootstap</a> et le framework <a href="https://vuejs.org/">Vue.js</a>.</p>
|
||||||
<p>Ce logiciel est open-source et distribué sous <a href="https://opensource.org/licenses/BSD-3-Clause">license BSD</a>. Le code source est disponible ici: <a href="https://git.meutel.net/meutel/go-bouquins">https://git.meutel.net/meutel/go-bouquins</a>.
|
<p>Ce logiciel est open-source et distribué sous <a href="https://opensource.org/licenses/BSD-3-Clause">license BSD</a>. Le code source est disponible ici: <a href="https://git.meutel.net/meutel/go-bouquins">https://git.meutel.net/meutel/go-bouquins</a>.
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user