mirror of
https://gitlab.com/parroquia-san-leandro/cancionero-web.git
synced 2024-12-22 00:33:33 +01:00
minor corrections and distribution of the generated file
This commit is contained in:
parent
6535d4d7dd
commit
890c2397e3
6 changed files with 85 additions and 31 deletions
37
canciones-updater.php
Normal file
37
canciones-updater.php
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
$song_list = "";
|
||||
foreach ($_POST["song"] as $i)
|
||||
if ($i) $song_list .= "$i ";
|
||||
|
||||
$cmd = "python3 /opt/cancionero-web-python/src/create_songbook.py";
|
||||
$cmd .= " --latex /opt/cancionero-web-python/latex/cancionero.tex";
|
||||
$cmd .= " --other-latex /opt/cancionero-web-python/latex/canciones/";
|
||||
$cmd .= " --other-index 400";
|
||||
$cmd .= " --output-dir /srv/http/canciones-updater/canciones/";
|
||||
$cmd .= " --output-file result.html";
|
||||
$cmd .= " --songs $song_list";
|
||||
echo "<pre>";
|
||||
passthru("$cmd 2>&1", $return_code);
|
||||
echo "</pre>";
|
||||
|
||||
if ($return_code) {
|
||||
http_response_code(500);
|
||||
echo "An error occurred!<br/>See the data below<br/>";
|
||||
echo "The return code was $return_code<br/>";
|
||||
echo "Command: <pre>$cmd</pre>";
|
||||
exit();
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<script>
|
||||
document.location.replace("https://canciones.sanleandro-obispo.net/misa/update_index.php")
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
You can see the result <a href="https://canciones.sanleandro-obispo.net/misa/update_index.php">here</a>.
|
||||
</body>
|
||||
</html>
|
|
@ -21,7 +21,6 @@ function changed() {
|
|||
if (lastNum.value) {
|
||||
inputs.push(lastNum)
|
||||
lastNum.name = "song[]"
|
||||
lastNum.onchange =
|
||||
lastNum.removeAttribute("onchange")
|
||||
lastNum.removeAttribute("onkeyup")
|
||||
lastNum.removeAttribute("id")
|
||||
|
@ -44,12 +43,15 @@ function changed() {
|
|||
<h1>Editor</h1>
|
||||
</header>
|
||||
<main>
|
||||
<h2>Números de las canciones</h2>
|
||||
<form action="generar.php" method="post">
|
||||
<ul id="list">
|
||||
<li><input id="lastNum" type="number" max="500" min="1" onkeyup="changed()" onchange="changed()"></li>
|
||||
</ul>
|
||||
<button type="submit">Enviar</button>
|
||||
</form>
|
||||
<h2>Índice</h2>
|
||||
<iframe src="/" height="400px" width="100%"></iframe>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
$song_list = "";
|
||||
foreach ($_POST["song"] as $i)
|
||||
if ($i) $song_list .= "$i ";
|
||||
|
||||
$cmd = "python3 ../../cancionero-web-python/src/latex_scanner.py";
|
||||
$cmd .= " --latex ../../cancionero-web-python/latex/cancionero.tex";
|
||||
$cmd .= " --other-latex ../../cancionero-web-python/latex/canciones/";
|
||||
$cmd .= " --other-index 400";
|
||||
$cmd .= " --output-dir .";
|
||||
$cmd .= " --output-file index.html";
|
||||
$cmd .= " --songs $song_list";
|
||||
exec($cmd, $output, $return_code);
|
||||
|
||||
foreach ($output as $line) echo "$line\n";
|
||||
|
||||
if ($return_code)
|
||||
echo "The return code was $return_code\n";
|
||||
|
||||
?>
|
24
res/static/misa/update_index.php
Normal file
24
res/static/misa/update_index.php
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
$ch = curl_init("https://csgj.pw/canciones/result.html");
|
||||
$fp = fopen("index.html", "w");
|
||||
|
||||
curl_setopt($ch, CURLOPT_FILE, $fp);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
|
||||
curl_exec($ch);
|
||||
curl_close($ch);
|
||||
fclose($fp);
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<script>
|
||||
setTimeout(() => document.location.replace("./"), 100);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
You can see the result <a href="./">here</a>.
|
||||
</body>
|
||||
</html>
|
|
@ -2,14 +2,15 @@ import latex_scanner
|
|||
from os.path import join
|
||||
from django.template import Engine, Context
|
||||
from django.conf import settings
|
||||
import pickle
|
||||
|
||||
|
||||
def generate_songbook(song_loader, song_numbers, out_file, dj_engine):
|
||||
def generate_songbook(songs, song_numbers, out_file, dj_engine):
|
||||
# Build the list of songs
|
||||
song_list = []
|
||||
for n in song_numbers:
|
||||
found = None
|
||||
for song in song_loader.songs:
|
||||
for song in songs:
|
||||
if song.number == n:
|
||||
found = song
|
||||
break
|
||||
|
@ -32,9 +33,19 @@ def create_argparser():
|
|||
|
||||
if __name__ == '__main__':
|
||||
args = create_argparser().parse_args()
|
||||
loader = latex_scanner.SongLoader(args.latex[0], args.audios[0])
|
||||
try:
|
||||
with open("songs.dat", "rb") as f:
|
||||
songs = pickle.load(f)
|
||||
except:
|
||||
loader = latex_scanner.SongLoader(args.latex[0])
|
||||
if args.other_latex:
|
||||
loader.scan_others(args.other_latex[0], args.other_index[0])
|
||||
songs = loader.songs
|
||||
try:
|
||||
with open("songs.dat", "wb") as f:
|
||||
pickle.dump(songs, f)
|
||||
except:
|
||||
pass
|
||||
settings.configure(USE_TZ=False, USE_I18N=False)
|
||||
e = Engine(dirs=["res/templates/"])
|
||||
generate_songbook(loader, args.songs, join(args.output_dir[0], args.output_file[0]), e)
|
||||
generate_songbook(songs, args.songs, join(args.output_dir[0], args.output_file[0]), e)
|
||||
|
|
|
@ -35,11 +35,12 @@ def extra_put(extra, index, the_type, data=None):
|
|||
|
||||
|
||||
class SongLoader:
|
||||
def __init__(self, latex_file, audio_dir):
|
||||
def __init__(self, latex_file, audio_dir=None):
|
||||
self.index = 1
|
||||
self.category = None
|
||||
self.categories = []
|
||||
self.songs = []
|
||||
if audio_dir:
|
||||
self.audio_dir = audio_dir
|
||||
self.scan(latex_file)
|
||||
|
||||
|
|
Loading…
Reference in a new issue