Sección para TODO
This commit is contained in:
		
							parent
							
								
									3ed55a0365
								
							
						
					
					
						commit
						356497c10d
					
				| 
						 | 
				
			
			@ -2,5 +2,6 @@
 | 
			
		|||
/bideoak/home
 | 
			
		||||
/bideoak/playlist
 | 
			
		||||
/bideoak/static
 | 
			
		||||
/bideoak/todo
 | 
			
		||||
/libreto/pdf
 | 
			
		||||
index.html
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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():
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 %}
 | 
			
		||||
		Reference in New Issue