Browse Source

add song pdf for songbook.md

automate 2.0-rc2
mxmehl 7 months ago
parent
commit
7843fd2e47
Signed by: mxmehl GPG Key ID: 2704E4AB371E2E92
  1. 28
      scripts/create-index.py
  2. 2
      templates/songbook.md

28
scripts/create-index.py

@ -13,6 +13,28 @@ parser.add_argument("-t", "--type", dest="type",
help="Define whether to build A-Z or A-Y")
args = parser.parse_args()
# HELPER FUNCTIONS
def md_line(songtype, songname, filename):
download = {}
# only add inindented text for category items
if songtype == "category":
indent = ""
song_dl = ""
# indent text and add download info for songs
else:
indent = " "
# Always add PDF download to options
song_dl = " ("
download['PDF'] = f"/songbook/{filename}.pdf"
for dltype, url in download.items():
song_dl += f"[{dltype}]({url})"
song_dl += ")"
f.write(f"{indent}1. {songname}{song_dl}\n")
# Prepare PDF file
pdf = FPDF(format = "A5")
pdf.add_page()
pdf.set_margin(10)
@ -48,11 +70,13 @@ 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")
md_line("category", song_name, file_name)
else:
pdf.set_font('courier', size=8)
pdf.cell(txt=f" {song_no}. {song_name}", ln=1)
f.write(f" 1. {song_name}\n")
md_line("song", song_name, file_name)
pdf.cell(txt="**Akkorde**", ln=1, markdown=True)

2
templates/songbook.md

@ -9,7 +9,7 @@ scripts_head:
---
Unser Stamm hat ein eigenes Songbook, das stetig erweitert wird. Du kannst es
[hier als PDF](/dl/Songbook.pdf) herunterladen.
[hier als PDF](/songbook/Songbook.pdf) herunterladen.
Unten sind auch alle Songs einzeln aufgelistet. Du kannst Dir die einzelnen
Seiten downloaden.

Loading…
Cancel
Save