Sección para TODO

This commit is contained in:
Ales (Shagi) Zabala Alava 2019-12-07 12:24:28 +01:00
parent 3ed55a0365
commit 356497c10d
4 changed files with 62 additions and 2 deletions

1
.gitignore vendored
View File

@ -2,5 +2,6 @@
/bideoak/home /bideoak/home
/bideoak/playlist /bideoak/playlist
/bideoak/static /bideoak/static
/bideoak/todo
/libreto/pdf /libreto/pdf
index.html index.html

View File

@ -5,6 +5,7 @@ from pathlib import Path, PurePath
import subprocess import subprocess
from jinja2 import Template, Environment, PackageLoader, select_autoescape from jinja2 import Template, Environment, PackageLoader, select_autoescape
from jinja2.utils import Markup
import asstosrt import asstosrt
import srt import srt
import webvtt import webvtt
@ -104,6 +105,12 @@ class SongPage:
str(self.thumbnail.absolute()), 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): def get_context_data(self):
parsed_srt = None parsed_srt = None
if self.srt: if self.srt:
@ -137,11 +144,18 @@ class Builder:
autoescape=select_autoescape(['html']), autoescape=select_autoescape(['html']),
) )
self.env.filters['url'] = self.url self.env.filters['url'] = self.url
self.env.filters['display_boolean'] = self.display_boolean
self.current_path = self.root_folder self.current_path = self.root_folder
def url(self, path): def url(self, path):
return os.path.relpath(path, self.current_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): def render(self, template, target, context):
html_file = target / 'index.html' html_file = target / 'index.html'
page_template = self.env.get_template(template) page_template = self.env.get_template(template)
@ -153,8 +167,9 @@ class Builder:
def build(self): def build(self):
songs = [] songs = []
pending_songs = []
for entry in self.root_folder.iterdir(): for entry in self.root_folder.iterdir():
if entry.name in ['static', 'playlist', 'home']: if entry.name in ['static', 'playlist', 'home', 'todo']:
continue continue
if entry.is_dir(): if entry.is_dir():
print("building {}".format(entry.name)) print("building {}".format(entry.name))
@ -164,7 +179,10 @@ class Builder:
raise e raise e
print("Error: {}".format(e)) print("Error: {}".format(e))
continue continue
songs.append(songpage) if songpage.publish:
songs.append(songpage)
else:
pending_songs.append(songpage)
songs.sort(key=lambda a: a.name) songs.sort(key=lambda a: a.name)
global_context = { global_context = {
@ -191,6 +209,16 @@ class Builder:
self.render('playlist.html', playlist, global_context) 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' static = self.root_folder / 'static'
if not static.exists(): if not static.exists():

View File

@ -22,6 +22,16 @@ footer {
width: 100%; width: 100%;
} }
table {
width: 100%;
border: 1px solid white;
border-collapse: collapse;
}
table td, table th {
border: 1px solid white;
}
#menu { #menu {
display: inline-block; display: inline-block;
flex: 1 10em; flex: 1 10em;

View File

@ -0,0 +1,21 @@
{% extends "base.html" %}
{% block content %}
<table>
<thead>
<tr>
<th>Canción</th>
<th>Video</th>
<th>Subtitulos</th>
</tr>
</thead>
<tbody>
{% for song in pending_songs %}
<tr>
<td>{{ song.name }}</td>
<td>{{ song.video|display_boolean }}</td>
<td>{{ song.has_subtitles|display_boolean }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}