Browse Source

build markdown index and package as tgz

automate
mxmehl 6 months ago
parent
commit
08eba6f3ec
Signed by: mxmehl GPG Key ID: 2704E4AB371E2E92
  1. 11
      Makefile
  2. 5
      README.md
  3. 13
      scripts/create-index.py
  4. 0
      templates/Songtemplate.ott
  5. 15
      templates/songbook.md

11
Makefile

@ -16,10 +16,7 @@ prepare:
@[ -d $(BUILDDIR) ] || mkdir -p $(BUILDDIR)
.PHONY: build
build: prepare $(TARGETS_SONGS) $(TARGETS_EXTRA) index-az bundle-az ## build Songbook A-Z
.PHONY: build-ay
build-ay: prepare $(TARGETS_SONGS) $(TARGETS_EXTRA) index-ay bundle-ay ## build Songbook A-Y
build: prepare $(TARGETS_SONGS) $(TARGETS_EXTRA) index-az bundle-ay bundle-az archive ## build Songbook A-Y, A-Z, songbook.md and archive
build/Songs/%.pdf : src/Songs/%.odt
@soffice --headless "-env:UserInstallation=file:///tmp/LibreOffice_Conversion" --convert-to pdf:writer_pdf_Export --outdir build/Songs/ "$<"
@ -33,10 +30,14 @@ index-az:
@python3 scripts/create-index.py
bundle-ay:
@pdfunite build/Extra/Cover+Intro.pdf build/Extra/Index.pdf build/Songs/[A-Y]* build/Extra/Akkorde.pdf build/Songbook_A-Y.pdf
@pdfunite build/Extra/Cover+Intro.pdf build/Extra/Index_A-Y.pdf build/Songs/[A-Y]* build/Extra/Akkorde.pdf build/Songbook_A-Y.pdf
bundle-az:
@pdfunite build/Extra/Cover+Intro.pdf build/Extra/Index.pdf build/Songs/* build/Extra/Akkorde.pdf build/Songbook.pdf
archive:
@[ -e build/Songbook.tar.gz ] && rm -r build/Songbook.tar.gz || true
@cd build/ && tar czf Songbook.tar.gz *
.PHONY: clean
clean: ## remove all build artifacts
@[ -d $(BUILDDIR) ] && rm -r $(BUILDDIR) || true

5
README.md

@ -18,7 +18,7 @@ in one PDF document in `build/`.
### 1. Fill in song template
Open the template `src/Songtemplate.ott` and fill in all fields. Check list:
Open the template `templates/Songtemplate.ott` and fill in all fields. Check list:
* Ideally, the song fits on one page to keep the songbook compact.
* The font size and family should not be altered.
@ -62,8 +62,7 @@ The `Dockerfile` should install all required dependencies. All you need is
1. Run `docker run --rm -v "$pwd":/data mxmehl/songbook`. This will pull the
precompiled image, mount your current directory in `/data` of the container,
and build the songbook. You can append `make build-ay` to only create the
censored version.
and build the songbook.
## Versioning

13
scripts/create-index.py

@ -1,10 +1,11 @@
"""Create an index of Songbook files"""
"""Create an index of Songbook files, both as PDF and Markdown"""
import argparse
import glob
import os
import re
from fpdf import FPDF
from shutil import copyfile
parser = argparse.ArgumentParser(description='Create songbook index')
parser.add_argument("-t", "--type", dest="type",
@ -21,11 +22,17 @@ pdf.set_font('courier', size=16, style="BU")
pdf.cell(0, 6, 'Songbook-Index', ln=1, align='C')
pdf.ln(4)
# Prepare and open songbook.md
copyfile("templates/songbook.md", "build/songbook.md")
f = open("build/songbook.md", "a")
# Print index of Songs
if args.type == "az":
SELECTION = "[A-Z]"
OUTPUT = "Index.pdf"
else:
SELECTION = "[A-Y]"
OUTPUT = "Index_A-Y.pdf"
for file_name in sorted(glob.iglob(f'build/Songs/{SELECTION}*.pdf')):
# converts file name to e.g. D03_Hotel_California
@ -41,10 +48,12 @@ for file_name in sorted(glob.iglob(f'build/Songs/{SELECTION}*.pdf')):
if song_no == 0:
pdf.set_font('courier', size=8, style="B")
pdf.cell(txt=f"{song_cat}. {song_name}", ln=1)
f.write(f"1. {song_name}\n")
else:
pdf.set_font('courier', size=8)
pdf.cell(txt=f" {song_no}. {song_name}", ln=1)
f.write(f" 1. {song_name}\n")
pdf.cell(txt="**Akkorde**", ln=1, markdown=True)
pdf.output("build/Extra/Index.pdf")
pdf.output(f"build/Extra/{OUTPUT}")

0
src/Songtemplate.ott → templates/Songtemplate.ott

15
templates/songbook.md

@ -0,0 +1,15 @@
---
title: "Songbook"
page: true
menu:
main:
weight: 5
scripts_head:
- '<link rel="stylesheet" href="/css/songbook.css">'
---
Unser Stamm hat ein eigenes Songbook, das stetig erweitert wird. Du kannst es
[hier als PDF](/dl/Songbook.pdf) herunterladen.
Unten sind auch alle Songs einzeln aufgelistet. Du kannst Dir die einzelnen
Seiten downloaden.
Loading…
Cancel
Save