diff --git a/.gitignore b/.gitignore index 30b9507..b09cfd7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -dist/ +_dist/ diff --git a/Makefile b/Makefile index be84654..b9fc7d8 100644 --- a/Makefile +++ b/Makefile @@ -4,22 +4,28 @@ ifeq (, $(GO)) endif PAGES := $(sort $(wildcard pages/*.html)) pages.yaml +TEMPLATES := $(sort $(wildcard templates/*.gohtml)) + +OUT_DIR := _dist +PAGES_DIR := pages +TEMPLATES_DIR := templates .PHONY: serve build clean -build: dist/index.stamp +build: $(OUT_DIR)/index.stamp -dist/index.stamp: $(PAGES) templates/base.gohtml templates/index.gohtml templates/print.gohtml templates/print_2up.gohtml cmd/build/main.go - @$(GO) run ./cmd/build - @mkdir -p dist - @date +%s > dist/index.stamp +$(OUT_DIR)/index.stamp: $(PAGES) $(TEMPLATES) cmd/build/main.go + @$(GO) run ./cmd/build --pages $(PAGES_DIR) --out $(OUT_DIR) --templates $(TEMPLATES_DIR) --order pages.yaml + @mkdir -p $(OUT_DIR) + @date +%s > $(OUT_DIR)/index.stamp serve: build - xdg-open "http://localhost:8000" || true - python -m http.server + @echo "Serving $(OUT_DIR) as document root..." + @xdg-open "http://localhost:8000/index.html" || true + @cd $(OUT_DIR) && python -m http.server -PDF := dist/output.pdf -PDF_2UP := dist/output-2up.pdf +PDF := $(OUT_DIR)/output.pdf +PDF_2UP := $(OUT_DIR)/output-2up.pdf .PHONY: deps deps: @@ -28,13 +34,13 @@ deps: .PHONY: pdf pdf: build deps @echo "Generating PDF with headless Chrome..." - @$(GO) run ./cmd/pdf --in dist/print.html --out $(PDF) + @$(GO) run ./cmd/pdf --in $(OUT_DIR)/print.html --out $(PDF) .PHONY: pdf-2up pdf-2up: build deps @echo "Generating 2-up PDF with headless Chrome..." - @$(GO) run ./cmd/pdf --in dist/print_2up.html --out $(PDF_2UP) --w 11 --h 8.5 + @$(GO) run ./cmd/pdf --in $(OUT_DIR)/print_2up.html --out $(PDF_2UP) --w 11 --h 8.5 clean: - rm -rf dist index.html + rm -rf $(OUT_DIR) index.html diff --git a/cmd/pdf/main.go b/cmd/pdf/main.go index f7a2ec8..5144051 100644 --- a/cmd/pdf/main.go +++ b/cmd/pdf/main.go @@ -43,12 +43,16 @@ func main() { width float64 height float64 ) - flag.StringVar(&input, "in", "dist/print.html", "input HTML file path") - flag.StringVar(&output, "out", "dist/output.pdf", "output PDF path") + flag.StringVar(&input, "in", "", "input HTML file path (required)") + flag.StringVar(&output, "out", "", "output PDF path (required)") flag.Float64Var(&width, "w", config.PageWidthIn, "page width in inches") flag.Float64Var(&height, "h", config.PageHeightIn, "page height in inches") flag.Parse() + if input == "" || output == "" { + log.Fatal("--in and --out are required") + } + absInput, _ := filepath.Abs(input) url := "file://" + absInput diff --git a/css/style.css b/css/style.css index 7954087..a5c5458 100644 --- a/css/style.css +++ b/css/style.css @@ -13,6 +13,13 @@ html, body { padding: 0; } +.page-base { + width: 100%; + height: 100%; + padding: 0; + margin: 0; +} + /* Use border-box sizing everywhere to keep dimensions predictable */ html { box-sizing: border-box; } *, *::before, *::after { box-sizing: inherit; } diff --git a/index.html b/index.html deleted file mode 100644 index 2116f1f..0000000 --- a/index.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - All Pages - - - - -
- -
-
cover.html
- -
- -
-
bouba.html
- -
- -
- - - - diff --git a/pages/bouba.html b/pages/bouba.html index b49c822..bf95f5e 100644 --- a/pages/bouba.html +++ b/pages/bouba.html @@ -1,9 +1,11 @@ -

bouba

+
+

bouba

-This is a test kiki. \ No newline at end of file + This is a test kiki. +
\ No newline at end of file diff --git a/pages/cover.html b/pages/cover.html index bb62485..260dccd 100644 --- a/pages/cover.html +++ b/pages/cover.html @@ -1,8 +1,10 @@ -

Smart Bar

-welcome to smart bar \ No newline at end of file +
+

Smart Bar

+ welcome to smart bar +
\ No newline at end of file diff --git a/templates/base.gohtml b/templates/base.gohtml index 7fe5ab0..86dfe9b 100644 --- a/templates/base.gohtml +++ b/templates/base.gohtml @@ -4,7 +4,7 @@ {{ .Title }} - +
{{ .Content }}
diff --git a/templates/index.gohtml b/templates/index.gohtml index 8ab4581..941ceb6 100644 --- a/templates/index.gohtml +++ b/templates/index.gohtml @@ -4,22 +4,22 @@ All Pages - + - +
{{ range .Pages }}
{{ .Name }}
- +
{{ end }}
diff --git a/templates/print.gohtml b/templates/print.gohtml index de134e5..b76680b 100644 --- a/templates/print.gohtml +++ b/templates/print.gohtml @@ -4,7 +4,7 @@ Print - +