mirror of
https://gitlab.com/parroquia-san-leandro/cancionero-web.git
synced 2025-04-25 14:46:18 +02:00
Whitelabel songbook websites
This commit is contained in:
parent
bc4e7ed51d
commit
103fb07630
9 changed files with 35 additions and 16 deletions
12
Makefile
12
Makefile
|
@ -5,6 +5,10 @@ ALL_LESS := public/main.css public/index.css public/song.css
|
|||
ALL_TEMPLATES := $(wildcard res/templates/*.html)
|
||||
PY_SRC := $(wildcard src/**.py)
|
||||
|
||||
NAME ?= Cancionero San Leandro
|
||||
AUTHOR ?= 2025 Carlos Galindo, Parroquia San Leandro
|
||||
SLO_LINKS ?= false
|
||||
|
||||
|
||||
all: public public/audios public/index.html static
|
||||
|
||||
|
@ -14,7 +18,13 @@ public:
|
|||
mkdir public
|
||||
|
||||
public/index.html: $(ALL_TEMPLATES) $(PY_SRC)
|
||||
python3 src/latex_scanner.py --latex latex/cancionero.tex --audios audios --other-latex latex/canciones/
|
||||
python3 src/latex_scanner.py \
|
||||
--latex latex/cancionero.tex \
|
||||
--audios audios \
|
||||
--other-latex latex/canciones/ \
|
||||
--title $(NAME) \
|
||||
--author $(AUTHOR) \
|
||||
--links $(SLO_LINKS)
|
||||
|
||||
public/audios: audios public
|
||||
rm -f public/audios
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<footer>
|
||||
<p>
|
||||
© 2023 Carlos Galindo, Parroquia San Leandro
|
||||
© {{ metadata.author }}
|
||||
<a href="https://gitlab.com/parroquia-san-leandro/cancionero-web"><span>Código fuente</span></a>
|
||||
</p>
|
||||
</footer>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<meta charset="UTF-8">
|
||||
<title>Cancionero - Parroquia San Leandro</title>
|
||||
<title>{{ metadata.title }}</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<link rel="icon" type="image/svg+xml" href="{{ path|urlencode }}/favicon.svg"/>
|
||||
<link rel="stylesheet" type="text/css" href="{{ path|urlencode }}/main.css"/>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<header>
|
||||
<h1><a href="{{ path }}">Cancionero San Leandro</a></h1>
|
||||
<h1><a href="{{ path }}">{{ metadata.title }}</a></h1>
|
||||
{% if metadata.links %}
|
||||
<nav class="nav">
|
||||
<ul>
|
||||
<li><a href="https://sanleandrovalencia.es/"><span id="nav-web">Parroquia San Leandro</span></a></li>
|
||||
|
@ -7,4 +8,5 @@
|
|||
<li><a href="https://sanleandrovalencia.es/cancionero/"><span>Cancionero en PDF</span></a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
{% endif %}
|
||||
</header>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
{% include "head.html" with path="." only %}
|
||||
{% include "head.html" with path="." metadata=metadata only %}
|
||||
<link rel="stylesheet" type="text/css" href="index.css"/>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
{% include "head.html" with path=".." only %}
|
||||
{% include "head.html" with path=".." metadata=metadata only %}
|
||||
<link rel="stylesheet" type="text/css" href="../song.css"/>
|
||||
<script async src="../song.js"></script>
|
||||
</head>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
{% include "head.html" with path=".." only %}
|
||||
{% include "head.html" with path=".." metadata=metadata only %}
|
||||
<meta http-equiv="refresh" content="0; url = ../{{ song.url|urlencode }}">
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
{% include "head.html" with path="." only %}
|
||||
{% include "head.html" with path="." metadata=metadata only %}
|
||||
<link rel="stylesheet" type="text/css" href="song.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="index.css"/>
|
||||
<script async src="song.js"></script>
|
||||
|
|
|
@ -288,15 +288,15 @@ class SongLoader:
|
|||
key=lambda s: s.number)
|
||||
return result
|
||||
|
||||
def print_index(self, index_file, dj_engine):
|
||||
context = Context({'sorted_categories': self.sort_categories()})
|
||||
def print_index(self, index_file, dj_engine, metadata):
|
||||
context = Context(dict({'sorted_categories': self.sort_categories()}, **metadata))
|
||||
html = dj_engine.get_template("index.html").render(context)
|
||||
with open(index_file, 'w') as f:
|
||||
f.write(html)
|
||||
|
||||
@staticmethod
|
||||
def print_song(song, directory, dj_engine):
|
||||
context = Context({'song': song})
|
||||
def print_song(song, directory, dj_engine, metadata):
|
||||
context = Context(dict({'song': song}, **metadata))
|
||||
num_dir = join(directory, "%03d" % song.number)
|
||||
mkdir(num_dir)
|
||||
with open(join(num_dir, "index.html"), 'w') as f:
|
||||
|
@ -306,11 +306,11 @@ class SongLoader:
|
|||
with open(join(song_dir, "index.html"), 'w') as f:
|
||||
f.write(dj_engine.get_template("song.html").render(context))
|
||||
|
||||
def generate_html(self, output_dir, dj_engine):
|
||||
def generate_html(self, output_dir, dj_engine, metadata):
|
||||
mkdir(output_dir)
|
||||
for song in self.songs:
|
||||
self.print_song(song, output_dir, dj_engine)
|
||||
self.print_index(join(output_dir, "index.html"), dj_engine)
|
||||
self.print_song(song, output_dir, dj_engine, metadata)
|
||||
self.print_index(join(output_dir, "index.html"), dj_engine, metadata)
|
||||
|
||||
|
||||
def create_argparser():
|
||||
|
@ -323,6 +323,9 @@ def create_argparser():
|
|||
parser.add_argument("--audios", required=False, nargs=1, default=[None],
|
||||
help="The folder containing the audio files.")
|
||||
parser.add_argument("--output-dir", required=False, nargs=1, default=["public"])
|
||||
parser.add_argument("--title", required=True, nargs=1, help="The title of the webpage")
|
||||
parser.add_argument("--author", required=True, nargs=1, help="The author for the footer")
|
||||
parser.add_argument("--links", required=False, nargs=1, default=["false"])
|
||||
return parser
|
||||
|
||||
|
||||
|
@ -333,4 +336,8 @@ if __name__ == '__main__':
|
|||
loader.scan_others(args.other_latex[0], int(args.other_index[0]))
|
||||
settings.configure(USE_TZ=False, USE_I18N=False)
|
||||
e = Engine(dirs=["res/templates/"])
|
||||
loader.generate_html(args.output_dir[0], e)
|
||||
loader.generate_html(args.output_dir[0], e, {
|
||||
'title': args.title[0],
|
||||
'author': args.author[0],
|
||||
'links': args.links[0] == "true"
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue