Update templates and the template-generator script.

- Add linear-gradient in the chocolate template
- Add "Tisane de Noël" template
- Add the logic to populate the gradient colors in the script
- Add template definition in the products definitions csv
This commit is contained in:
2025-12-04 17:55:38 +01:00
parent a608e41c6a
commit 97480dedb0
4 changed files with 1604 additions and 53 deletions

View File

@@ -31,3 +31,5 @@ sel;Grillades - Viande et Légumes;Sel de Camargue, Thym*, Origan*, Sarriette*,
sel;Herbes de Provence;Sel de Camargue, Thym*, Origan*, Sarriette*, Romarin*;;6307a6;Sel - Herbes de Provence.svg;True
sel;Poisson et Viande Blanche;Sel de Camargue, Thym*, Sauge*, Agastache*, Bleuet*;;5b7aff;Sel - Poisson et Viande Blanche.svg;True
chocolat;Menthe Poivrée;"Chocolat de couverture noir* (pâte de cacao*, sucre de canne*, beurre de cacao*; peut contenir : *lait), *crème entière* (crème de lait à 30% de matière grasse*, stabilisants : carraghénanes), menthe poivrée*";;007e49;Chocolat - Menthe Poivrée.svg;True
chocolat;Lavande et Fleurs;"Chocolat de couverture noir* (pâte de cacao*, sucre de canne*, beurre de cacao*; peut contenir : *lait), *crème entière* (crème de lait à 30% de matière grasse*, stabilisants : carraghénanes), Lavande*, Monarde*, Souci*, Bleuet*";;6307a6;Chocolat - Lavande et Fleurs - Monarde Souci Bleuet.svg;True;0723a6;6307a6;ff0019;ff8b00;
tisanenoel;Tisane de Noël;Basilic cannelle*, Basilic thaï*, Thym*, Menthe verte*, Mélisse*, Écorce d'orange*, Écorce de cannelle*;;ff0000;Tisane - Tisane de Noël - Basilic cannelle Basilic thaï Thym Menthe verte Mélisse Écorce d'orange Écorce de cannelle.svg;True
Can't render this file because it has a wrong number of fields in line 34.

View File

@@ -22,6 +22,7 @@ templates = {
'pesto': f"{TEMPLATES_DIR}/Pesto.svg",
'sirop': f"{TEMPLATES_DIR}/Sirop.svg",
'tisane': f"{TEMPLATES_DIR}/Tisane.svg",
'tisanenoel': f"{TEMPLATES_DIR}/Tisane Noël.svg",
'sel': f"{TEMPLATES_DIR}/Sel.svg",
}
@@ -50,11 +51,21 @@ def main():
ingredients = [e if not e.startswith('*') else ALLERGEN_BEGIN_STYLE + e[1:] + ALLERGEN_END_STYLE for e in ingredients]
ingredients_sub = ", ".join(ingredients)
AB_logo_visibility = 'inline' if row[6] == 'True' else 'none'
# Set the 4 linear-gradient stop colors if they are set in the csv, otherwise default to the template's background color
if 7+4 <= len(row):
gradient_color0, gradient_color1, gradient_color2, gradient_color3 = row[7:7+4]
else:
gradient_color0 = gradient_color1 = gradient_color2 = gradient_color3 = row[4]
subs = {
'designation': row[1].strip(),
'ingredients': ingredients_sub,
'description': row[3].strip(),
'color': row[4],
'gradient_color0': gradient_color0,
'gradient_color1': gradient_color1,
'gradient_color2': gradient_color2,
'gradient_color3': gradient_color3,
'AB': AB_logo_visibility,
'designation_fontsize': JAM_DESIGNATION_FONTSIZE_DEFAULT,
}

View File

@@ -20,6 +20,26 @@
xmlns:dc="http://purl.org/dc/elements/1.1/">
<defs
id="defs929">
<linearGradient
inkscape:collect="always"
id="linearGradient8793">
<stop
style="stop-color:#${gradient_color0};stop-opacity:1;"
offset="0"
id="stop8789" />
<stop
style="stop-color:#${gradient_color1};stop-opacity:1;"
offset="0.33000001"
id="stop10635" />
<stop
style="stop-color:#${gradient_color2};stop-opacity:1;"
offset="0.66000003"
id="stop10637" />
<stop
style="stop-color:#${gradient_color3};stop-opacity:1;"
offset="1"
id="stop8791" />
</linearGradient>
<rect
x="203.87482"
y="162.76645"
@@ -620,6 +640,15 @@
width="134.27728"
height="38.101315"
id="rect169275-2" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient8793"
id="linearGradient8795"
x1="1.0034179e-07"
y1="70"
x2="47.999779"
y2="70"
gradientUnits="userSpaceOnUse" />
</defs>
<sodipodi:namedview
inkscape:document-rotation="0"
@@ -637,10 +666,10 @@
inkscape:window-height="1435"
inkscape:window-width="2190"
showgrid="false"
inkscape:current-layer="layer3"
inkscape:current-layer="layer5"
inkscape:document-units="mm"
inkscape:cy="192.75503"
inkscape:cx="54.011917"
inkscape:cy="204.23256"
inkscape:cx="81.017875"
inkscape:zoom="2.9623092"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
@@ -691,6 +720,46 @@
width="47.999779"
id="rect1878-9-8-2"
style="display:inline;opacity:1;fill:#${color};fill-opacity:0.36078432;stroke:none;stroke-width:2.82885;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.473118;paint-order:stroke fill markers" />
<rect
inkscape:label="Bandeau Bloc Composition"
ry="0"
y="-35"
x="-47.999779"
height="22"
width="47.999779"
id="rect1878-9-8"
style="display:inline;fill-opacity:0.360784;stroke:none;stroke-width:3.16274;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.473118;paint-order:stroke fill markers"
transform="rotate(180,-8.8249455,-16.947161)" />
<rect
inkscape:label="Bandeau Titre Composition"
ry="0"
y="-35"
x="-47.999779"
height="4.9999771"
width="47.999779"
id="rect1878-9-8-5"
style="display:inline;fill-opacity:0.360784;stroke:none;stroke-width:1.82601;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.473118;paint-order:stroke fill markers"
transform="rotate(180,-8.8249455,-16.947161)" />
<rect
inkscape:label="Bandeau Titre Infusion 2"
ry="0"
y="59"
x="1.0034179e-07"
height="22"
width="47.999779"
id="rect1878-6"
style="display:inline;fill-opacity:1;stroke:none;stroke-width:3.65202;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.473118;paint-order:stroke fill markers;fill:url(#linearGradient8795);opacity:0.36"
transform="translate(-17.649891,-33.894322)" />
<rect
inkscape:label="Bandeau Titre Infusion"
ry="0"
y="59"
x="1.0034179e-07"
height="22"
width="47.999779"
id="rect22255"
style="display:inline;fill-opacity:1;stroke:none;stroke-width:3.65202;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.473118;paint-order:stroke fill markers;fill:url(#linearGradient8795);opacity:0.36"
transform="translate(-17.649891,-33.894322)" />
</g>
<g
inkscape:groupmode="layer"
@@ -1124,57 +1193,37 @@
inkscape:label="Bloc Texte Conservation"><tspan
x="-111.76953"
y="270.68079"
id="tspan43604"><tspan
id="tspan22523"><tspan
style="text-align:start"
id="tspan43602">À conserver dans un endroit sec, à l'abri de
id="tspan22521">À conserver dans un endroit sec, à l'abri de
</tspan></tspan><tspan
x="-111.76953"
y="277.34745"
id="tspan43608"><tspan
id="tspan22527"><tspan
style="text-align:start"
id="tspan43606">la lumière.
id="tspan22525">la lumière.
</tspan></tspan><tspan
x="-111.76953"
y="284.0141"
id="tspan43616"><tspan
id="tspan22535"><tspan
style="text-align:start"
id="tspan43610">À consommer de préférence avant : </tspan><tspan
id="tspan22529">À consommer de préférence avant : </tspan><tspan
style="font-weight:bold;text-align:start"
id="tspan43612">${dluo}</tspan><tspan
id="tspan22531">${dluo}</tspan><tspan
style="text-align:start"
id="tspan43614">
id="tspan22533">
</tspan></tspan><tspan
x="-111.76953"
y="290.68076"
id="tspan43620"><tspan
id="tspan22539"><tspan
style="font-weight:bold;text-align:start"
id="tspan43618">*Produits issus de l'agriculture biologique.</tspan></tspan></text>
id="tspan22537">*Produits issus de l'agriculture biologique.</tspan></tspan></text>
</g>
<g
inkscape:groupmode="layer"
id="layer3"
inkscape:label="Textes À Modifier"
style="display:inline">
<rect
inkscape:label="Bandeau Bloc Composition"
ry="0"
y="-35"
x="-47.999779"
height="22"
width="47.999779"
id="rect1878-9-8"
style="display:inline;fill-opacity:0.360784;stroke:none;stroke-width:3.16274;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.473118;paint-order:stroke fill markers"
transform="scale(-1)" />
<rect
inkscape:label="Bandeau Titre Composition"
ry="0"
y="-35"
x="-47.999779"
height="4.9999771"
width="47.999779"
id="rect1878-9-8-5"
style="display:inline;fill-opacity:0.360784;stroke:none;stroke-width:1.82601;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.473118;paint-order:stroke fill markers"
transform="scale(-1)" />
<g
style="display:inline;stroke-width:1.00001"
inkscape:label="Bloc Titre Composition"
@@ -1221,24 +1270,6 @@
id="rect1460" /></flowRegion><flowPara
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:10px;font-family:sans-serif;-inkscape-font-specification:sans-serif;text-align:start;text-anchor:start;stroke-width:1.00001;font-size:8.00003669px"
id="flowPara168235">${ingredients}</flowPara></flowRoot>
<rect
inkscape:label="Bandeau Titre Infusion 2"
ry="0"
y="59"
x="1.0034179e-07"
height="22"
width="47.999779"
id="rect1878-6-5"
style="display:inline;fill-opacity:0.360784;stroke:none;stroke-width:3.65202;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.473118;paint-order:stroke fill markers" />
<rect
inkscape:label="Bandeau Titre Infusion"
ry="0"
y="59"
x="1.0034179e-07"
height="22"
width="47.999779"
id="rect1878-6"
style="display:inline;fill-opacity:0.360784;stroke:none;stroke-width:3.65202;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.473118;paint-order:stroke fill markers" />
<flowRoot
inkscape:label="Culture a la main"
transform="matrix(0.26458212,0,0,0.26458212,-66.840166,-16.855178)"
@@ -1284,8 +1315,8 @@
inkscape:label="Désignation"><tspan
x="244.91243"
y="187.77976"
id="tspan43624"><tspan
id="tspan22543"><tspan
style="font-weight:normal;font-stretch:normal;font-family:Karumbi;-inkscape-font-specification:Karumbi"
id="tspan43622">${designation}</tspan></tspan></text>
id="tspan22541">${designation}</tspan></tspan></text>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

1507
templates/Tisane Noël.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 1.2 MiB