cleanup/namespacing
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,2 +1,2 @@
|
|||||||
dist/
|
_dist/
|
||||||
|
|
||||||
|
|||||||
30
Makefile
30
Makefile
@@ -4,22 +4,28 @@ ifeq (, $(GO))
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
PAGES := $(sort $(wildcard pages/*.html)) pages.yaml
|
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
|
.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
|
$(OUT_DIR)/index.stamp: $(PAGES) $(TEMPLATES) cmd/build/main.go
|
||||||
@$(GO) run ./cmd/build
|
@$(GO) run ./cmd/build --pages $(PAGES_DIR) --out $(OUT_DIR) --templates $(TEMPLATES_DIR) --order pages.yaml
|
||||||
@mkdir -p dist
|
@mkdir -p $(OUT_DIR)
|
||||||
@date +%s > dist/index.stamp
|
@date +%s > $(OUT_DIR)/index.stamp
|
||||||
|
|
||||||
serve: build
|
serve: build
|
||||||
xdg-open "http://localhost:8000" || true
|
@echo "Serving $(OUT_DIR) as document root..."
|
||||||
python -m http.server
|
@xdg-open "http://localhost:8000/index.html" || true
|
||||||
|
@cd $(OUT_DIR) && python -m http.server
|
||||||
|
|
||||||
PDF := dist/output.pdf
|
PDF := $(OUT_DIR)/output.pdf
|
||||||
PDF_2UP := dist/output-2up.pdf
|
PDF_2UP := $(OUT_DIR)/output-2up.pdf
|
||||||
|
|
||||||
.PHONY: deps
|
.PHONY: deps
|
||||||
deps:
|
deps:
|
||||||
@@ -28,13 +34,13 @@ deps:
|
|||||||
.PHONY: pdf
|
.PHONY: pdf
|
||||||
pdf: build deps
|
pdf: build deps
|
||||||
@echo "Generating PDF with headless Chrome..."
|
@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
|
.PHONY: pdf-2up
|
||||||
pdf-2up: build deps
|
pdf-2up: build deps
|
||||||
@echo "Generating 2-up PDF with headless Chrome..."
|
@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:
|
clean:
|
||||||
rm -rf dist index.html
|
rm -rf $(OUT_DIR) index.html
|
||||||
|
|
||||||
|
|||||||
@@ -43,12 +43,16 @@ func main() {
|
|||||||
width float64
|
width float64
|
||||||
height float64
|
height float64
|
||||||
)
|
)
|
||||||
flag.StringVar(&input, "in", "dist/print.html", "input HTML file path")
|
flag.StringVar(&input, "in", "", "input HTML file path (required)")
|
||||||
flag.StringVar(&output, "out", "dist/output.pdf", "output PDF path")
|
flag.StringVar(&output, "out", "", "output PDF path (required)")
|
||||||
flag.Float64Var(&width, "w", config.PageWidthIn, "page width in inches")
|
flag.Float64Var(&width, "w", config.PageWidthIn, "page width in inches")
|
||||||
flag.Float64Var(&height, "h", config.PageHeightIn, "page height in inches")
|
flag.Float64Var(&height, "h", config.PageHeightIn, "page height in inches")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if input == "" || output == "" {
|
||||||
|
log.Fatal("--in and --out are required")
|
||||||
|
}
|
||||||
|
|
||||||
absInput, _ := filepath.Abs(input)
|
absInput, _ := filepath.Abs(input)
|
||||||
url := "file://" + absInput
|
url := "file://" + absInput
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,13 @@ html, body {
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.page-base {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Use border-box sizing everywhere to keep dimensions predictable */
|
/* Use border-box sizing everywhere to keep dimensions predictable */
|
||||||
html { box-sizing: border-box; }
|
html { box-sizing: border-box; }
|
||||||
*, *::before, *::after { box-sizing: inherit; }
|
*, *::before, *::after { box-sizing: inherit; }
|
||||||
|
|||||||
34
index.html
34
index.html
@@ -1,34 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
||||||
<title>All Pages</title>
|
|
||||||
<link rel="stylesheet" href="/css/style.css" />
|
|
||||||
<style>
|
|
||||||
html, body { margin: 0; padding: 0; height: 100%; }
|
|
||||||
body { background: #eeeeee; }
|
|
||||||
.main { display: flex; flex-direction: column; align-items: center; gap: 1rem; padding: 1rem; box-sizing: border-box; }
|
|
||||||
.thumb { display: flex; flex-direction: column; align-items: center; }
|
|
||||||
.label { font: 12px/1.2 -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif; color: #555; margin: 0.25rem 0; }
|
|
||||||
.thumb iframe { width: 5.5in; height: 8.5in; border: 0; background: white; box-shadow: 0 0 0 1px rgba(0,0,0,0.08), 0 8px 24px rgba(0,0,0,0.18); }
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="main">
|
|
||||||
|
|
||||||
<div class="thumb">
|
|
||||||
<div class="label">cover.html</div>
|
|
||||||
<iframe src="/dist/cover.html" loading="lazy"></iframe>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="thumb">
|
|
||||||
<div class="label">bouba.html</div>
|
|
||||||
<iframe src="/dist/bouba.html" loading="lazy"></iframe>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
<style>
|
<style>
|
||||||
#page {
|
#bouba-page {
|
||||||
background-color: red;
|
background-color: red;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<div id="bouba-page" class="page-base">
|
||||||
<h1>bouba</h1>
|
<h1>bouba</h1>
|
||||||
|
|
||||||
This is a test kiki.
|
This is a test kiki.
|
||||||
|
</div>
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
<style>
|
<style>
|
||||||
#page {
|
#cover-page {
|
||||||
background-color: green;
|
background-color: green;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<div id="cover-page" class="page-base">
|
||||||
<h1>Smart Bar</h1>
|
<h1>Smart Bar</h1>
|
||||||
welcome to smart bar
|
welcome to smart bar
|
||||||
|
</div>
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<title>{{ .Title }}</title>
|
<title>{{ .Title }}</title>
|
||||||
<link rel="stylesheet" href="../css/style.css" />
|
<link rel="stylesheet" href="css/style.css" />
|
||||||
</head>
|
</head>
|
||||||
<body {{ .PageSizeAttr }}>
|
<body {{ .PageSizeAttr }}>
|
||||||
<div id="page">{{ .Content }}</div>
|
<div id="page">{{ .Content }}</div>
|
||||||
|
|||||||
@@ -4,22 +4,22 @@
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<title>All Pages</title>
|
<title>All Pages</title>
|
||||||
<link rel="stylesheet" href="/css/style.css" />
|
<link rel="stylesheet" href="css/style.css" />
|
||||||
<style>
|
<style>
|
||||||
html, body { margin: 0; padding: 0; height: 100%; }
|
html, body { margin: 0; padding: 0; height: 100%; }
|
||||||
body { background: #eeeeee; }
|
body { background: #eeeeee; }
|
||||||
.main { display: flex; flex-direction: column; align-items: center; gap: 1rem; padding: 1rem; box-sizing: border-box; }
|
.main { display: flex; flex-direction: column; align-items: center; gap: 1rem; padding: 1rem; box-sizing: border-box; }
|
||||||
.thumb { display: flex; flex-direction: column; align-items: center; }
|
.thumb { display: flex; flex-direction: column; align-items: center; }
|
||||||
.label { font: 12px/1.2 -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif; color: #555; margin: 0.25rem 0; }
|
.label { font: 12px/1.2 ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif; color: #555; margin: 0.25rem 0; }
|
||||||
.thumb iframe { width: 5.5in; height: 8.5in; border: 0; background: white; box-shadow: 0 0 0 1px rgba(0,0,0,0.08), 0 8px 24px rgba(0,0,0,0.18); }
|
.thumb iframe { width: var(--page-w, 5.5in); height: var(--page-h, 8.5in); border: 0; background: white; box-shadow: 0 0 0 1px rgba(0,0,0,0.08), 0 8px 24px rgba(0,0,0,0.18); }
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body style="--page-w: 5.5in; --page-h: 8.5in;">
|
||||||
<div class="main">
|
<div class="main">
|
||||||
{{ range .Pages }}
|
{{ range .Pages }}
|
||||||
<div class="thumb">
|
<div class="thumb">
|
||||||
<div class="label">{{ .Name }}</div>
|
<div class="label">{{ .Name }}</div>
|
||||||
<iframe src="/{{ .Href }}" loading="lazy"></iframe>
|
<iframe src="{{ .Href }}" loading="lazy"></iframe>
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<title>Print</title>
|
<title>Print</title>
|
||||||
<link rel="stylesheet" href="../css/style.css" />
|
<link rel="stylesheet" href="css/style.css" />
|
||||||
<style>
|
<style>
|
||||||
/* Ensure a clean print with no gaps between pages */
|
/* Ensure a clean print with no gaps between pages */
|
||||||
@media screen { body { background: #eeeeee; } }
|
@media screen { body { background: #eeeeee; } }
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<title>Print 2-Up</title>
|
<title>Print 2-Up</title>
|
||||||
<link rel="stylesheet" href="../css/style.css" />
|
<link rel="stylesheet" href="css/style.css" />
|
||||||
<style>
|
<style>
|
||||||
/* Letter page with two half-letter pages laid out horizontally */
|
/* Letter page with two half-letter pages laid out horizontally */
|
||||||
/* Do NOT constrain the whole document to a single sheet */
|
/* Do NOT constrain the whole document to a single sheet */
|
||||||
|
|||||||
Reference in New Issue
Block a user