Rendering code refactor

This commit is contained in:
marc
2025-04-26 19:09:59 +02:00
parent 7a823a98ab
commit d132e6fd60
33 changed files with 638 additions and 188 deletions

View File

@@ -2,7 +2,10 @@
<h5 class="text text-beige"> Previsualització </h5>
<hr class="h-px mt-1 mb-3 bg-beige border-0">
{% if score_render_url %}
<img class="my-2" src="{{ score_render_url }}" />
<div class="flex flex-col items-center
bg-white rounded-lg">
<img class="m-4" src="{{ score_render_url }}" />
</div>
{% else %}
<ol class="text-red-400">
{% for error in errors %}

View File

@@ -47,22 +47,25 @@
{% endif %}
</h5>
<hr class="h-px mt-1 mb-3 bg-beige border-0">
<div class="flex flex-col items-center">
{% if score.img_url is not none %}
<div class="flex justify-center">
<a href="{{ score.pdf_url or score.img_url }}" target="_blank">
<img class="m-2" src="{{ score.img_url }}" />
</a>
{% if score.img_url is not none %}
<div class="flex flex-col items-center
bg-white rounded-lg ">
<div class="flex justify-center">
<a href="{{ score.pdf_url or score.img_url }}" target="_blank">
<img class="py-4 px-2 max-w-full h-auto" src="{{ score.img_url }}" />
</a>
</div>
{% if score.pdf_url is not none %}
<div class="bg-beige border rounded border-beige m-2 p-1">
<a href="{{ score.pdf_url }}" target="_blank">Obre el PDF</a>
</div>
{% if score.pdf_url is not none %}
<div class="text-beige border rounded border-beige m-2 p-1">
<a href="{{ score.pdf_url }}" target="_blank">Obre el PDF</a>
</div>
{% endif %}
{% elif score.pdf_url is not none %}
{% set pdf_url = score.pdf_url %}
{% include "fragments/pdf_viewer.html" %}
{% endif %}
</div>
{% elif score.pdf_url is not none %}
<div class="flex flex-col items-center">
{% set pdf_url = score.pdf_url %}
{% include "fragments/pdf_viewer.html" %}
</div>
{% endif %}
</div>
{% endif %}

View File

@@ -10,11 +10,13 @@
<i class="fa fa-pencil" aria-hidden="true"></i>
</button>
{% include "fragments/tema/visibility.html" %}
<button title="Canvia el títol"
{% if not tema.stats %}
<button title="Esborra el tema"
class="text-beige text-2xl mx-2"
hx-delete="/api/tema/{{ tema.id }}"
hx-swap="outerHTML">
<i class="fa fa-times" aria-hidden="true"></i>
</button>
{% endif %}
{% endif %}
</div>

View File

@@ -1,19 +1,3 @@
% -----------------------------------------------------
% Comandes últils
% -----------------------------------------------------
% Anacrusa: \partial 2 (2 = blanca)
%
% Repetició amb caselles:
% \repeat volta 2 {
% %%%
% \alternative {
% \volta 1 { %%% }
% \volta 2 { %%% }
% }
% }
%
% -----------------------------------------------------
\new ChordNames {
\chords {
\set chordChanges = ##t
@@ -50,11 +34,21 @@
% A
\mark \default
\bar "||" \break
\repeat volta 2 {
\alternative {
\volta 1 { }
\volta 2 { }
}
}
% B
\mark \default
\repeat volta 2 {
\alternative {
\volta 1 { }
\volta 2 { }
}
}
\bar "|."
}

View File

@@ -6,11 +6,9 @@
}
\header {
title = \markup { "{{ tema.title | safe }}" }
{% if tema.composer() %}
composer = "{{ tema.composer() | safe }}"
{% elif tema.origin() %}
composer = "{{ tema.origin() | safe }}"
title = \markup { "{{ tune.header.title | safe }}" }
{% if tune.header.composer %}
composer = "{{ tune.header.composer | safe }}"
{% endif %}
tagline = "Partitura generada amb LilyPond"
@@ -19,15 +17,17 @@
\markup \vspace #2
{% if tune.score_source is not none %}
\score {
\language "english"
<<
{{ score_beginning }}
{{ score_source | safe }}
{{ tune.score_source | safe }}
>>
}
{% if lyrics_text is not none %}
{% for line in lyrics_text.lines %}
{% endif %}
{% if tune.lyrics is not none %}
{% for line in tune.lyrics.lines %}
\markup {
\vspace #2
\fill-line {
@@ -42,7 +42,7 @@
\hspace #1
}
}
{% if loop.index < lyrics_text.lines|length %}
{% if loop.index < tune.lyrics.lines|length %}
\markup {
\vspace #1
\fill-line {

View File

@@ -0,0 +1,46 @@
\markup {
\vspace #2
\fill-line {
\center-column {
\large \bold "{{ tune.header.title | safe }}"
{% if tune.header.composer %}
"{{ tune.header.composer | safe }}"
{% endif %}
}
}
}
{% if tune.score_source is not none %}
\score {
\language "english"
<<
{{ tune.score_source | safe }}
>>
}
{% endif %}
{% if tune.lyrics is not none %}
{% for line in tune.lyrics.lines %}
\markup {
\vspace #2
\fill-line {
{% for paragraph in line.paragraphs %}
\hspace #1
\center-column {
{% for line in paragraph.lines %}
\line { {{ line | safe }} }
{% endfor %}
}
{% endfor %}
\hspace #1
}
}
{% if loop.index < tune.lyrics.lines|length %}
\markup {
\vspace #1
\fill-line {
\override #'(span-factor . 4/9)
\draw-hline
}
}
{% endif %}
{% endfor %}
{% endif %}

View File

@@ -0,0 +1,31 @@
{{ score_beginning }}
\version "2.24.4"
\book {
\paper {
top-margin = 10
left-margin = 15
right-margin = 15
scoreTitleMarkup = \markup {
\center-column {
\fontsize #3 \bold \fromproperty #'header:piece
\fill-line {
\null
\right-column {
\fromproperty #'header:composer
}
}
}
}
}
\header {
title = \markup { "{{ tune_set.title | safe }}" }
tagline = "Partitura generada amb LilyPond"
copyright = "Folkugat"
}
{% for tune in tune_set.tunes %}
{% include "lilypond/tune_in_set.ly" %}
{% endfor %}
}