Add categories and favicon

* Reorganize resource directories (templates, less, static)
* Show categories on index
* Add favicon
This commit is contained in:
Carlos Galindo 2020-12-25 21:49:59 +01:00
commit 3eaed2eaa8
15 changed files with 180 additions and 64 deletions

View file

@ -1,25 +0,0 @@
<!DOCTYPE html>
<html lang="es">
<head>
{% include "head.html" with path="." only %}
<link rel="stylesheet" type="text/css" href="index.css"/>
</head>
<body>
{% include "header.html" with path="." %}
<h2>Índice</h2>
Las canciones sin acordes están marcadas en <span class="noChords">rojo</span>.
<ol class="songs">
{% for song in songs %}
<a href="{{ song.url }}">
<li {% if not song.chorded %}class="noChords"{% endif %}>
<span class="number">{{ song.number }}.</span>
{{ song.name }}
{% if song.author %} por {{ song.author }} {% endif %}
{% if song.origin %} basado en {{ song.origin }} {% endif %}
</li>
</a>
{% endfor %}
</ol>
{% include "footer.html" %}
</body>
</html>

12
res/less/colors.less Normal file
View file

@ -0,0 +1,12 @@
@nochordscolor: #FBB;
@nochordscolor-hover: #FAA;
@title: #369;
@subtitle: #444;
@text: #333;
@text-hover: #607D8B;
@secondary: #EEE;
@secondary-hover: #CCC;
@chord-color: darkgreen;
@transition: .5s;
@border-radius: 4px;

46
res/less/index.less Normal file
View file

@ -0,0 +1,46 @@
@import "colors";
.songs {
list-style: none;
padding: 0;
> a {
color: inherit;
text-decoration: none;
> li {
background-color: @secondary;
margin: .5em;
padding: .6em;
border-radius: @border-radius;
.number {
font-weight: bolder;
color: black;
}
&:hover {
color: @text-hover;
background-color: @secondary-hover;
transition-duration: @transition;
}
&.noChords {
background-color: @nochordscolor;
&:hover {
color: @text-hover;
background-color: @nochordscolor-hover;
}
}
}
}
}
ul.songs {
width: 100%;
margin: 1em auto;
li {
display: inline-block;
margin: .2em;
}
}
span.noChords {
background-color: @nochordscolor;
padding: 0.3em 0.4em;
border-radius: @border-radius;
display: inline-block;
}

59
res/less/main.less Normal file
View file

@ -0,0 +1,59 @@
@import "colors";
h1 {
color: @title;
margin-inline: auto;
width: max-content;
max-width: 100%;
text-align: center;
> a, > a:hover, > a:active, > a:visited {
color: @title;
}
}
h2, h3 {
color: @subtitle;
font-weight: lighter;
}
footer {
text-align: center;
}
body {
font-family: Helvetica, Arial, sans-serif;
color: @text;
max-width: 75em;
margin: 1em;
@media (min-width: 75em + 1em) {
margin: auto;
}
}
nav {
margin-inline: auto;
width: max-content;
max-width: 100%;
> ul {
padding-inline-start: 0px;
> li {
display: inline-block;
}
}
}
a {
text-decoration: none;
> span {
color: @text;
padding: 0.5em;
margin: 0.2em;
display: inline-block;
background: @secondary;
border-radius: @border-radius;
&:hover {
background: @secondary-hover;
transition-duration: @transition;
}
}
}

78
res/less/song.less Normal file
View file

@ -0,0 +1,78 @@
@import "colors.less";
table.chordedline {
border-spacing: 0px;
display: inline-block;
}
.song div {
padding: 0.5em 0;
}
.chordedline td {
padding: 0px;
}
.chord {
font-style: italic;
color: @chord-color;
}
div.chorus {
font-weight: bold;
border-left: black 2px solid;
padding-left: 0.5em;
div {
padding-left: 0.5em;
}
table {
margin-left: 0;
padding-left: 0;
padding-right: 0;
}
}
.rrep {
background-image: url(repeat-sign.svg);
display: inline-block;
width: 1em;
height: 2em;
}
.lrep {
-moz-transform: scaleX(-1);
-o-transform: scaleX(-1);
-webkit-transform: scaleX(-1);
transform: scaleX(-1);
filter: FlipV;
-ms-filter: "FlipV";
.rrep();
}
.rep {
font-style: italic;
}
.echo {
font-style: italic;
}
button, select#transposeSelect {
min-width: 2em;
min-height: 2em;
padding: .4em;
border-style: none;
border-radius: @border-radius;
background-color: @secondary;
&:hover {
background-color: @secondary-hover;
transition-duration: @transition;
}
}
select#transposeSelect {
-webkit-appearance: none;
-moz-appearance: none;
font-weight: bold;
color: black;
}

89
res/static/favicon.svg Normal file
View file

@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
data-v-fde0c5aa=""
viewBox="0 0 300 300"
class="iconAbove"
version="1.1"
id="svg18"
sodipodi:docname="favicon.svg"
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)">
<metadata
id="metadata22">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="956"
inkscape:window-height="1041"
id="namedview20"
showgrid="false"
inkscape:zoom="0.86620581"
inkscape:cx="180.22708"
inkscape:cy="192.64261"
inkscape:window-x="0"
inkscape:window-y="37"
inkscape:window-maximized="0"
inkscape:current-layer="svg18"
inkscape:document-rotation="0" />
<!---->
<defs
data-v-fde0c5aa=""
id="defs2">
<!---->
</defs>
<rect
data-v-fde0c5aa=""
fill="#f3eea8"
x="0"
y="0"
width="300"
height="300"
class="logo-background-square"
id="rect4"
style="stroke-width:1" />
<defs
data-v-fde0c5aa=""
id="defs6">
<!---->
</defs>
<defs
data-v-fde0c5aa=""
id="defs11">
<!---->
</defs>
<g
data-v-fde0c5aa=""
id="69d3071f-d543-44f2-8f59-52c9a11420f9"
stroke="none"
fill="#933547"
transform="matrix(3.0327786,0,0,3.0327786,-1.6389288,8.1593111)">
<path
d="M 95,8.539 53,22.986 V 73.27 c -1.832,-0.864 -4.27,-1.001 -6.694,-0.193 -4.192,1.397 -6.74,5.078 -5.692,8.222 1.048,3.144 5.295,4.559 9.487,3.162 3.742,-1.247 6.166,-4.314 5.899,-7.195 V 32 L 92,19.603 v 32.681 c -1.835,-0.876 -4.286,-1.019 -6.722,-0.207 -4.192,1.397 -6.74,5.078 -5.692,8.222 1.048,3.144 5.295,4.559 9.487,3.162 3.525,-1.175 5.878,-3.965 5.918,-6.692 H 95 Z M 19,9 v 43 c -1.869,-0.892 -4.481,-0.971 -6.963,-0.143 -4.269,1.423 -6.865,5.172 -5.798,8.374 1.067,3.202 5.393,4.644 9.663,3.221 3.59,-1.197 6.047,-4.038 6.087,-6.816 H 22 V 23 c 0,0 12.926,3.741 17,18 C 39,24.704 25,22 19,9 Z M 37.423,79 H 2 v 2 h 35.476 a 7.751,7.751 0 0 1 -0.053,-2 z"
id="path13" />
<path
d="M 98,81 V 79 H 58.9 a 8.662,8.662 0 0 1 -0.591,2 z M 5.078,64 H 2 v 2 H 7.87 A 8.874,8.874 0 0 1 5.078,64 Z M 98,66 v -2 h -3.769 a 13.016,13.016 0 0 1 -3.377,2 z M 78.401,64 H 59 v 2 H 81.155 A 8.74,8.74 0 0 1 78.401,64 Z M 21.09,64 a 13.4,13.4 0 0 1 -3.433,2 H 50 V 64 Z M 25,49 h 25 v 2 H 25 Z M 11.125,49 H 2 v 2 h 5.25 a 13.625,13.625 0 0 1 3.839,-1.99 z M 59,51 h 21.822 a 13.5,13.5 0 0 1 3.507,-1.769 c 0.264,-0.088 0.53,-0.16 0.796,-0.231 H 59 Z M 32.25,34 H 25 v 2 h 8.595 A 22.994,22.994 0 0 0 32.25,34 Z M 2,34 h 14 v 2 H 2 Z m 57,2 H 89 V 34 H 59.406 L 59,34.14 Z M 41.551,36 H 50 v -2 h -8.898 c 0.175,0.642 0.323,1.311 0.449,2 z M 32.734,21 h 18.028 a 2.991,2.991 0 0 1 1.263,-0.851 L 55.366,19 h -24.68 l 0.011,0.011 c 0.68,0.657 1.362,1.317 2.037,1.989 z M 2,19 h 14 v 2 H 2 Z"
id="path15" />
</g>
<!---->
</svg>

After

Width:  |  Height:  |  Size: 3.6 KiB

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 54 54"><rect x="33" width="12" height="54"/><rect x="21" width="6" height="54"/><circle cx="12" cy="34" r="3"/><circle cx="12" cy="22" r="3"/></svg>

After

Width:  |  Height:  |  Size: 201 B

12
res/static/sizes.js Normal file
View file

@ -0,0 +1,12 @@
SIZE_STEPS = [30, 50, 67, 80, 90, 100, 110, 120, 133, 150, 170, 200, 240, 300];
currSize = SIZE_STEPS.indexOf(100)
/** Changes the size of the lyrics and chords. */
function size(steps) {
if (steps === 0) {
currSize = SIZE_STEPS.indexOf(100);
}
currSize += steps;
document.getElementById('wholeSongDiv').style.fontSize = SIZE_STEPS[currSize] + '%';
}

44
res/static/transpose.js Normal file
View file

@ -0,0 +1,44 @@
ENG_INDEX = {'C': 0, 'C#': 1, 'Db': 1, 'D': 2, 'D#': 3, 'Eb': 3, 'E': 4, 'Fb': 4, 'F': 5, 'E#': 5, 'F#': 6, 'Gb': 6, 'G': 7, 'G#': 8, 'Ab': 8, 'A': 9, 'A#': 10, 'Bb': 10, 'B': 11, 'Cb': 11, 'B#': 0}
LAT_INDEX = {'Do': 0, 'Do#': 1, 'Reb': 1, 'Re': 2, 'Re#': 3, 'Mib': 3, 'Mi': 4, 'Fab': 4, 'Fa': 5, 'Mi#': 5, 'Fa#': 6, 'Solb': 6, 'Sol': 7, 'Sol#': 8, 'Lab': 8, 'La': 9, 'La#': 10, 'Sib': 10, 'Si': 11, 'Dob': 11, 'Si#': 0}
CHORDS_LAT = ['Do', 'Do#', 'Re', 'Re#', 'Mi', 'Fa', 'Fa#', 'Sol', 'Sol#', 'La', 'Sib', 'Si']
CHORDS_ENG = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'Bb', 'B']
/** Changes all chords to a given semitone relative to the original */
function transpose(n) {
transposeAdd(n - getTranspose())
}
/** Transposes all chords by n steps */
function transposeAdd(n) {
for (c of document.getElementsByClassName('c')) {
chord = c.innerHTML
if (LAT_INDEX[chord] == undefined) {
throw Error("Unknown chord: " + chord)
}
i = LAT_INDEX[chord]
j = (i + n + 12) % 12
c.innerHTML = CHORDS_LAT[j]
}
setTransposeSelector(getTranspose() + n)
}
function setTransposeSelector(n) {
while (n > 6) {
n -= 12
}
while (n < -6) {
n += 12
}
ts = document.getElementById("transposeSelect")
if (n > 0) {
ts.value = "+" + n
} else {
ts.value = n
}
}
function getTranspose() {
return Number.parseInt(document.getElementById("transposeSelect").value)
}

View file

@ -0,0 +1,6 @@
<footer>
<p>
&copy; 2020 Carlos Galindo, Parroquia San Leandro
<a href="https://gitlab.com/parroquia-san-leandro/cancionero-web"><span>Código fuente</span></a>
</p>
</footer>

8
res/templates/head.html Normal file
View file

@ -0,0 +1,8 @@
<meta charset="UTF-8">
<title>Cancionero - Parroquia San Leandro</title>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="icon" type="image/svg+xml" href="{{ path|urlencode }}/favicon.svg"/>
<link rel="stylesheet" type="text/css" href="{{ path|urlencode }}/main.css"/>
{% if specific_css %}
<link rel="stylesheet" type="text/css" href="{{ path|urlencode }}/{{ specific_css|urlencode }}"/>
{% endif %}

10
res/templates/header.html Normal file
View file

@ -0,0 +1,10 @@
<header>
<h1><a href="{{ path }}">Cancionero San Leandro</a></h1>
<nav class="nav">
<ul>
<li><a href="https://sanleandro-obispo.net/"><span>Parroquia San Leandro</span></a></li>
<li><a href="https://nube.sanleandro-obispo.net/s/X23Jzz5A6dpCfr2"><span>Grabaciones</span></a></li>
<li><a href="https://sanleandro-obispo.net/cancionero/"><span>Cancionero en PDF</span></a></li>
</ul>
</nav>
</header>

35
res/templates/index.html Normal file
View file

@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="es">
<head>
{% include "head.html" with path="." only %}
<link rel="stylesheet" type="text/css" href="index.css"/>
</head>
<body>
{% include "header.html" with path="." %}
<h2>Índice</h2>
<ul class="songs">
{% for category in sorted_categories %}
<a href="#{{ category|slugify }}">
<li>{{ category|title }}</li>
</a>
{% endfor %}
</ul>
Las canciones sin acordes están marcadas en <span class="noChords">rojo</span>.
<ol class="songs">
{% for category, songs in sorted_categories.items %}
<h3 id="{{ category|slugify }}">{{ category|title }}</h3>
{% for song in songs %}
<a href="{{ song.url }}">
<li {% if not song.chorded %}class="noChords"{% endif %}>
<span class="number">{{ song.number }}.</span>
{{ song.name }}
{% if song.author %} por {{ song.author }} {% endif %}
{% if song.origin %} basada en {{ song.origin }} {% endif %}
</li>
</a>
{% endfor %}
{% endfor %}
</ol>
{% include "footer.html" %}
</body>
</html>

112
res/templates/song.html Normal file
View file

@ -0,0 +1,112 @@
<!DOCTYPE html>
<html lang="es">
<head>
{% include "head.html" with path=".." only %}
<link rel="stylesheet" type="text/css" href="../song.css"/>
<script async src="../transpose.js"></script>
<script async src="../sizes.js"></script>
</head>
<body>
{% include "header.html" with path=".." %}
<div class="song">
<h2>{{ song.name}}</h2>
<a href="../#{{ song.category|slugify }}"><span>Categoría: {{ song.category|title }}</span></a>
{% if song.author %}
<span>por <strong>{{ song.author }}</strong></span>
{% endif %}
{% if song.origin %}
<span>basada en: <strong>{{ song.origin }}</strong></span>
{% endif %}
<h3>Ajustes</h3>
<div>
<label>Cambiar tamaño de letra </label>
<button class="small" onclick="size(-1)">-</button>
<button class="small" onclick="size(0)">Reset</button>
<button class="small" onclick="size(+1)">+</button>
</div>
{% if song.chorded %}
<div>
<label>Transponer acordes </label>
<button class="small" onclick="transposeAdd(-2)">-2</button>
<button class="small" onclick="transposeAdd(-1)">-1</button>
<select id="transposeSelect" disabled>
<option>-6</option>
<option>-5</option>
<option>-4</option>
<option>-3</option>
<option>-2</option>
<option>-1</option>
<option selected="selected">0</option>
<option>+1</option>
<option>+2</option>
<option>+3</option>
<option>+4</option>
<option>+5</option>
<option>+6</option>
</select>
<button class="small" onclick="transposeAdd(1)">+1</button>
<button class="small" onclick="transposeAdd(2)">+2</button>
<button onclick="transpose(0)">Reset</button>
</div>
{% endif %}
{% if song.capo != 0 %}
<div>
<span class="capo">Tono original: Cejilla {{ song.capo }}</span>
<button style="margin-left: 0.5em;" onclick="transpose({{ song.capo}})">Transponer para quitarla</button>
</div>
{% endif %}
<h3>Canción</h3>
<div id="wholeSongDiv">
{% for verse in song.verses %}
<div class="{{ verse.kind }}">
{% for line in verse.lines %}
{% spaceless %}
{% for chord, lyric in line.zipped_arr %}
<table class="chordedline">
<tr class="chord">
<td rowspan="{{ chord.rowspan|default:'1' }}">
{% if chord.class %}
<span class="{{ chord.class }}"></span>
{% endif %}
{% for c in chord.chord.items %}
{% if c.chord %}
<span class="c">{{ c.text|safe }}</span>
{% else %}
<span>{{ c.text|safe }}</span>
{% endif %}
{% endfor %}
</td>
</tr>
<tr class="lyric">
<td>
{% if 'rowspan' not in chord %}
<span>{{ lyric|safe }}</span>
{% endif %}
</td>
</tr>
</table>
{% endfor %}
{% if not forloop.last %} <br/> {% endif %}
{% endspaceless %}
{% endfor %}
</div>
{% endfor %}
</div>
{% for audio in audios %}
{% if forloop.first %}
<h3>Audios</h3>
{% endif %}
<div>
Audio del {{ audio.date_text }} <a href="{{ audio.audio_file|urlencode }}"><span>Descargar</span></a>
<audio controls style='width: 100%%;'>
<source src='{{ audio.audio_file|urlencode }}' type='audio/mpeg'/>
</audio>
</div>
{% endfor %}
<a href="https://gitlab.com/parroquia-san-leandro/cancionero-25/blob/master/{{ song.latex_file|urlencode }}"><span>Ver archivo original (LaTeX)</span></a>
<a href="../"><span>Índice</span></a>
<a href="../#{{ song.category|slugify }}"><span>Categoría: {{ song.category|title }}</span></a>
</div>
{% include "footer.html" %}
</body>
</html>

View file

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="es">
<head>
{% include "head.html" with path=".." only %}
<meta http-equiv="refresh" content="0; url = ../{{ song.url|urlencode }}">
</head>
<body>
{% include "header.html" with path=".." %}
<a href="../{{ song.url|urlencode }}">Redirigiendo a la canción, haz click aquí si no sucede de forma automática.</a>
{% include "footer.html" %}
</body>
</html>