diff --git a/.gitignore b/.gitignore index 5aa01d0..de1085e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,6 @@ /bideoak/home /bideoak/playlist /bideoak/static +/bideoak/todo /libreto/pdf index.html diff --git a/web/negromateweb/builder.py b/web/negromateweb/builder.py index c8d8645..1a911d5 100644 --- a/web/negromateweb/builder.py +++ b/web/negromateweb/builder.py @@ -5,6 +5,7 @@ from pathlib import Path, PurePath import subprocess from jinja2 import Template, Environment, PackageLoader, select_autoescape +from jinja2.utils import Markup import asstosrt import srt import webvtt @@ -104,6 +105,12 @@ class SongPage: str(self.thumbnail.absolute()), ]) + @property + def publish(self): + has_subtitles = self.ass or self.srt or self.vtt + has_video = self.video + return has_video and has_subtitles + def get_context_data(self): parsed_srt = None if self.srt: @@ -137,11 +144,18 @@ class Builder: autoescape=select_autoescape(['html']), ) self.env.filters['url'] = self.url + self.env.filters['display_boolean'] = self.display_boolean self.current_path = self.root_folder def url(self, path): return os.path.relpath(path, self.current_path) + def display_boolean(self, value): + if value: + return Markup('✓') + else: + return Markup('✗') + def render(self, template, target, context): html_file = target / 'index.html' page_template = self.env.get_template(template) @@ -153,8 +167,9 @@ class Builder: def build(self): songs = [] + pending_songs = [] for entry in self.root_folder.iterdir(): - if entry.name in ['static', 'playlist', 'home']: + if entry.name in ['static', 'playlist', 'home', 'todo']: continue if entry.is_dir(): print("building {}".format(entry.name)) @@ -164,7 +179,10 @@ class Builder: raise e print("Error: {}".format(e)) continue - songs.append(songpage) + if songpage.publish: + songs.append(songpage) + else: + pending_songs.append(songpage) songs.sort(key=lambda a: a.name) global_context = { @@ -191,6 +209,16 @@ class Builder: self.render('playlist.html', playlist, global_context) + todo = self.root_folder / 'todo' + self.current_path = todo + if not todo.exists(): + todo.mkdir() + todo_context = { + 'pending_songs': pending_songs, + } + todo_context.update(global_context) + self.render('todo.html', todo, todo_context) + static = self.root_folder / 'static' if not static.exists(): diff --git a/web/negromateweb/static/css/main.css b/web/negromateweb/static/css/main.css index b1d8c4b..7afbf71 100644 --- a/web/negromateweb/static/css/main.css +++ b/web/negromateweb/static/css/main.css @@ -22,6 +22,16 @@ footer { width: 100%; } +table { + width: 100%; + border: 1px solid white; + border-collapse: collapse; +} + +table td, table th { + border: 1px solid white; +} + #menu { display: inline-block; flex: 1 10em; diff --git a/web/negromateweb/templates/todo.html b/web/negromateweb/templates/todo.html new file mode 100644 index 0000000..3a30c99 --- /dev/null +++ b/web/negromateweb/templates/todo.html @@ -0,0 +1,21 @@ +{% extends "base.html" %} +{% block content %} + + + + + + + + + + {% for song in pending_songs %} + + + + + + {% endfor %} + +
CanciĆ³nVideoSubtitulos
{{ song.name }}{{ song.video|display_boolean }}{{ song.has_subtitles|display_boolean }}
+{% endblock %}