Vuelta a corregir las urls, ahora también funciona en ipfs
This commit is contained in:
parent
1a74816115
commit
e740c01e41
|
@ -4,15 +4,8 @@ from pathlib import Path, PurePath
|
||||||
|
|
||||||
from negromateweb.builder import Builder
|
from negromateweb.builder import Builder
|
||||||
|
|
||||||
if len(sys.argv) == 2:
|
|
||||||
root_path = sys.argv[1]
|
|
||||||
else:
|
|
||||||
# root_path = '/nm/'
|
|
||||||
root_path = '/'
|
|
||||||
|
|
||||||
builder = Builder(
|
builder = Builder(
|
||||||
Path('../bideoak'),
|
Path('../bideoak'),
|
||||||
Path('../libreto/libreto.pdf'),
|
Path('../libreto/libreto.pdf'),
|
||||||
root_path=PurePath(root_path)
|
|
||||||
)
|
)
|
||||||
builder.build()
|
builder.build()
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/sh
|
||||||
|
cd ..
|
||||||
|
last_hash=$(ipfs add -r bideoak|awk '$3 == "bideoak" {print $2}')
|
||||||
|
cd -
|
||||||
|
echo "$last_hash" > ipfs.txt
|
|
@ -0,0 +1 @@
|
||||||
|
QmVm7kQ3p4Sg7rT41XJEC6KbnAhhBjBCBAcbsUpZAtq5Fb
|
|
@ -13,11 +13,12 @@ import webvtt
|
||||||
class SongPage:
|
class SongPage:
|
||||||
THUMBNAIL_GEOMETRY = '200x200'
|
THUMBNAIL_GEOMETRY = '200x200'
|
||||||
|
|
||||||
def __init__(self, path):
|
def __init__(self, path, root):
|
||||||
self.name = path.name
|
self.name = path.name
|
||||||
self.original = None
|
self.original = None
|
||||||
self.author = None
|
self.author = None
|
||||||
self.path = path
|
self.path = path
|
||||||
|
self.root = root
|
||||||
self.video = None
|
self.video = None
|
||||||
self.video_type = None
|
self.video_type = None
|
||||||
self.vtt = None
|
self.vtt = None
|
||||||
|
@ -112,9 +113,11 @@ class SongPage:
|
||||||
parsed_srt = list(srt.parse(srt_str))
|
parsed_srt = list(srt.parse(srt_str))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("{}: srt parse error: {}".format(self.path.name, e))
|
print("{}: srt parse error: {}".format(self.path.name, e))
|
||||||
|
root_path = os.path.relpath(self.root, self.path)
|
||||||
return {
|
return {
|
||||||
'song': self,
|
'song': self,
|
||||||
'parsed_srt': parsed_srt,
|
'parsed_srt': parsed_srt,
|
||||||
|
'root_path': root_path,
|
||||||
}
|
}
|
||||||
|
|
||||||
def render(self, builder, context):
|
def render(self, builder, context):
|
||||||
|
@ -124,10 +127,9 @@ class SongPage:
|
||||||
|
|
||||||
|
|
||||||
class Builder:
|
class Builder:
|
||||||
def __init__(self, root_folder, libreto, root_path=PurePath('/')):
|
def __init__(self, root_folder, libreto):
|
||||||
self.root_folder = root_folder
|
self.root_folder = root_folder
|
||||||
self.libreto = libreto
|
self.libreto = libreto
|
||||||
self.root_path = root_path
|
|
||||||
self.static_dir = Path(__file__).parent / 'static'
|
self.static_dir = Path(__file__).parent / 'static'
|
||||||
|
|
||||||
self.env = Environment(
|
self.env = Environment(
|
||||||
|
@ -135,13 +137,16 @@ class Builder:
|
||||||
autoescape=select_autoescape(['html']),
|
autoescape=select_autoescape(['html']),
|
||||||
)
|
)
|
||||||
self.env.filters['url'] = self.url
|
self.env.filters['url'] = self.url
|
||||||
|
self.current_path = self.root_folder
|
||||||
|
|
||||||
def url(self, path):
|
def url(self, path):
|
||||||
return self.root_path / path.relative_to(self.root_folder)
|
return os.path.relpath(path, self.current_path)
|
||||||
|
|
||||||
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)
|
||||||
|
root_path = os.path.relpath(self.root_folder, target)
|
||||||
|
context['root_path'] = root_path
|
||||||
|
|
||||||
with html_file.open('w') as page:
|
with html_file.open('w') as page:
|
||||||
page.write(page_template.render(context))
|
page.write(page_template.render(context))
|
||||||
|
@ -154,7 +159,7 @@ class Builder:
|
||||||
if entry.is_dir():
|
if entry.is_dir():
|
||||||
print("building {}".format(entry.name))
|
print("building {}".format(entry.name))
|
||||||
try:
|
try:
|
||||||
songpage = SongPage(entry)
|
songpage = SongPage(entry, self.root_folder)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise e
|
raise e
|
||||||
print("Error: {}".format(e))
|
print("Error: {}".format(e))
|
||||||
|
@ -164,20 +169,23 @@ class Builder:
|
||||||
songs.sort(key=lambda a: a.name)
|
songs.sort(key=lambda a: a.name)
|
||||||
global_context = {
|
global_context = {
|
||||||
'songs': songs,
|
'songs': songs,
|
||||||
'root_path': self.root_path,
|
'root_folder': self.root_folder,
|
||||||
}
|
}
|
||||||
|
|
||||||
for song in songs:
|
for song in songs:
|
||||||
|
self.current_path = song.path
|
||||||
song.render(self, global_context)
|
song.render(self, global_context)
|
||||||
|
|
||||||
self.render('index.html', self.root_folder, global_context)
|
self.render('index.html', self.root_folder, global_context)
|
||||||
|
|
||||||
home = self.root_folder / 'home'
|
home = self.root_folder / 'home'
|
||||||
|
self.current_path = home
|
||||||
if not home.exists():
|
if not home.exists():
|
||||||
home.mkdir()
|
home.mkdir()
|
||||||
self.render('home.html', home, global_context)
|
self.render('home.html', home, global_context)
|
||||||
|
|
||||||
playlist = self.root_folder / 'playlist'
|
playlist = self.root_folder / 'playlist'
|
||||||
|
self.current_path = playlist
|
||||||
if not playlist.exists():
|
if not playlist.exists():
|
||||||
playlist.mkdir()
|
playlist.mkdir()
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
@font-face {
|
|
||||||
font-family: "CyrBit";
|
|
||||||
src: url("/static/css/CyrBit.ttf");
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
body {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
|
|
@ -4,23 +4,29 @@
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width" />
|
<meta name="viewport" content="width=device-width" />
|
||||||
<title>Negro Mate</title>
|
<title>Negro Mate</title>
|
||||||
<link rel="shortcut icon" href="{{ root_path }}static/css/nm_icon.png">
|
<link rel="shortcut icon" href="{{ root_path }}/static/css/nm_icon.png">
|
||||||
<link href="{{ root_path }}static/js/videojs/video-js.css" rel="stylesheet">
|
<link href="{{ root_path }}/static/js/videojs/video-js.css" rel="stylesheet">
|
||||||
<link href="{{ root_path }}static/js/libjass/lib/libjass.css" rel="stylesheet">
|
<link href="{{ root_path }}/static/js/libjass/lib/libjass.css" rel="stylesheet">
|
||||||
<link href="{{ root_path }}static/js/videojs-playlist-ui/dist/videojs-playlist-ui.vertical.css" rel="stylesheet">
|
<link href="{{ root_path }}/static/js/videojs-playlist-ui/dist/videojs-playlist-ui.vertical.css" rel="stylesheet">
|
||||||
<link href="{{ root_path }}static/css/main.css" rel="stylesheet">
|
<link href="{{ root_path }}/static/css/main.css" rel="stylesheet">
|
||||||
|
<style>
|
||||||
|
@font-face {
|
||||||
|
font-family: "CyrBit";
|
||||||
|
src: url("{{ root_path }}/static/css/CyrBit.ttf");
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<script>
|
<script>
|
||||||
window.HELP_IMPROVE_VIDEOJS = false;
|
window.HELP_IMPROVE_VIDEOJS = false;
|
||||||
</script>
|
</script>
|
||||||
<script src="{{ root_path}}static/js/videojs/video.js"></script>
|
<script src="{{ root_path }}/static/js/videojs/video.js"></script>
|
||||||
<script src="{{ root_path}}static/js/libjass/lib/libjass.js"></script>
|
<script src="{{ root_path }}/static/js/libjass/lib/libjass.js"></script>
|
||||||
<script src="{{ root_path}}static/js/videojs-playlist/dist/videojs-playlist.js"></script>
|
<script src="{{ root_path }}/static/js/videojs-playlist/dist/videojs-playlist.js"></script>
|
||||||
<script src="{{ root_path}}static/js/videojs-playlist-ui/dist/videojs-playlist-ui.js"></script>
|
<script src="{{ root_path }}/static/js/videojs-playlist-ui/dist/videojs-playlist-ui.js"></script>
|
||||||
<script src="{{ root_path}}static/js/videojs-ass/src/videojs.ass.js"></script>
|
<script src="{{ root_path }}/static/js/videojs-ass/src/videojs.ass.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header id="header">
|
<header id="header">
|
||||||
<h1><a href="{{ root_path }}home/">Negro Mate</a></h1>
|
<h1><a href="{{ root_path }}/home/">Negro Mate</a></h1>
|
||||||
</header>
|
</header>
|
||||||
<div id="content">
|
<div id="content">
|
||||||
{% block content %}{% endblock %}
|
{% block content %}{% endblock %}
|
||||||
|
@ -32,15 +38,15 @@
|
||||||
<li><a href="{{ item.path|url }}/">{{ item.name }}</a></li>
|
<li><a href="{{ item.path|url }}/">{{ item.name }}</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
<p id="playlist"><a href="{{ root_path }}playlist/">Playlist</a></p>
|
<p id="playlist"><a href="{{ root_path }}/playlist/">Playlist</a></p>
|
||||||
<p id="libreto"><a href="{{ root_path }}static/libreto/libreto.pdf"><img src="{{ root_path }}static/libreto/libreto.png" alt="libreto negro mate">Libreto</a></p>
|
<p id="libreto"><a href="{{ root_path }}/static/libreto/libreto.pdf"><img src="{{ root_path }}/static/libreto/libreto.png" alt="libreto negro mate">Libreto</a></p>
|
||||||
<p id="onion"><a href="http://fyqxyftczmxv3nmb.onion/">http://fyqxyftczmxv3nmb.onion/</a></p>
|
<p id="onion"><a href="http://fyqxyftczmxv3nmb.onion/">http://fyqxyftczmxv3nmb.onion/</a></p>
|
||||||
</nav>
|
</nav>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
<footer>
|
<footer>
|
||||||
<p>
|
<p>
|
||||||
<a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">
|
<a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">
|
||||||
<img alt="Licencia Creative Commons" style="border-width:0" src="{{ root_path }}static/css/cc-by-sa.png" />
|
<img alt="Licencia Creative Commons" style="border-width:0" src="{{ root_path }}/static/css/cc-by-sa.png" />
|
||||||
</a>
|
</a>
|
||||||
Letras adaptadas con
|
Letras adaptadas con
|
||||||
<a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">
|
<a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width" />
|
<meta name="viewport" content="width=device-width" />
|
||||||
<title>Negro Mate</title>
|
<title>Negro Mate</title>
|
||||||
<link rel="shortcut icon" href="{{ root_path }}static/css/nm_icon.png" type="image/png">
|
<link rel="shortcut icon" href="{{ root_path }}/static/css/nm_icon.png" type="image/png">
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
background-color: #232323;
|
background-color: #232323;
|
||||||
|
@ -36,6 +36,6 @@ a {
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Negro mate</h1>
|
<h1>Negro mate</h1>
|
||||||
<a href="{{ root_path }}home/">#</a>
|
<a href="{{ root_path }}/home/">#</a>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Reference in New Issue