This commit is contained in:
roydfalk 2024-07-30 10:01:39 +02:00
parent 8ce62aa0f7
commit 7fa85b8b0a
8 changed files with 83 additions and 9 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/.geany

View file

@ -5,8 +5,8 @@
"active": true,
"target": "https://example.org",
"label": "Example",
"image": "https://cdn.iconscout.com/icon/premium/png-128-thumb/plant-2941089-2470533.png"
"image": "https://cdn.iconscout.com/icon/premium/png-128-thumb/plant-2941089-2470533.png",
"open_in_new_tab": false
}
]
}

View file

@ -42,10 +42,23 @@ function template_render_by_name(
function main(
) : void
{
$data = \json_decode(
$data_raw = \json_decode(
\file_get_contents(__DIR__ . '/data.json'),
true
);
$data = [
'title' => ($data_raw['title'] ?? 'Portal'),
'entries' => \array_map(
fn($entry_raw) => [
'active' => ($entry_raw['active'] ?? true),
'target' => ($entry_raw['target'] ?? '#'),
'label' => ($entry_raw['label'] ?? ''),
'image' => ($entry_raw['image'] ?? ''),
'open_in_new_tab' => ($entry_raw['open_in_new_tab'] ?? false),
],
($data_raw['entries'] ?? []),
),
];
print(
template_render_by_name(
'main',
@ -57,14 +70,16 @@ function main(
fn($entry) => template_render_by_name(
'entry',
[
'a_href' => $entry['target'],
'a_target' => ($entry['open_in_new_tab'] ? '_blank' : '_self'),
'img_src' => $entry['image'],
'img_alt' => $entry['label'],
'label' => $entry['label'],
'target' => $entry['target'],
'image' => $entry['image'],
]
),
\array_values(\array_filter(
$data['entries'],
fn($entry) => ($entry['active'] ?? true)
fn($entry) => $entry['active']
))
)
),

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View file

@ -0,0 +1,57 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="340.000000pt" height="340.000000pt" viewBox="0 0 340.000000 340.000000"
preserveAspectRatio="xMidYMid meet">
<metadata>
Created by potrace 1.16, written by Peter Selinger 2001-2019
</metadata>
<g transform="translate(0.000000,340.000000) scale(0.100000,-0.100000)"
fill="#000000" stroke="none">
<path d="M565 2976 c-37 -17 -80 -62 -94 -99 -8 -19 -11 -387 -11 -1168 0
-945 2 -1145 14 -1172 16 -39 61 -82 99 -96 19 -8 308 -11 899 -11 849 0 873
1 912 20 23 11 52 36 66 57 l25 37 3 510 2 511 255 255 c257 258 285 293 285
360 0 36 -23 96 -48 123 -47 52 -140 71 -205 43 -18 -8 -86 -68 -152 -135 -66
-67 -123 -121 -127 -121 -4 0 -9 177 -10 393 l-3 393 -25 37 c-14 21 -43 46
-66 57 -39 19 -62 20 -915 20 -708 -1 -880 -3 -904 -14z m475 -136 l0 -50
-174 0 c-145 0 -177 -3 -190 -16 -14 -14 -16 -124 -16 -1064 0 -940 2 -1050
16 -1064 13 -14 56 -16 314 -16 258 0 301 2 314 16 20 20 20 48 0 68 -13 14
-53 16 -280 16 l-264 0 0 980 0 980 140 0 139 0 11 -39 c13 -50 41 -84 84
-105 51 -24 621 -24 672 0 43 21 71 55 84 105 l11 39 139 0 140 0 0 -458 0
-458 -34 -33 c-45 -44 -191 -369 -182 -406 10 -41 44 -41 131 -1 43 20 79 36
81 36 2 0 4 -144 4 -320 l0 -320 -264 0 c-227 0 -267 -2 -280 -16 -20 -20 -20
-48 0 -68 13 -14 56 -16 314 -16 258 0 301 2 314 16 14 13 16 63 16 394 0 293
3 379 13 383 6 3 29 12 50 21 l37 16 0 -440 0 -441 -25 -24 -24 -25 -861 0
-861 0 -24 25 -25 24 0 1135 0 1135 26 20 c25 20 39 21 240 21 l214 0 0 -50z
m758 -66 c-3 -101 -6 -117 -22 -130 -29 -21 -583 -21 -612 0 -16 13 -19 29
-22 130 l-4 116 332 0 332 0 -4 -116z m557 91 l25 -24 0 -433 0 -434 -43 -42
c-23 -23 -46 -42 -50 -42 -4 0 -7 195 -7 434 0 382 -2 436 -16 450 -13 13 -45
16 -190 16 l-174 0 0 50 0 50 215 0 c216 0 216 0 240 -25z m540 -630 c15 -14
25 -36 25 -53 0 -31 -33 -82 -54 -82 -6 0 -35 24 -65 54 l-52 53 31 27 c40 33
83 34 115 1z m-155 -160 l55 -55 -225 -225 -225 -225 -57 57 -58 58 222 222
c123 123 225 223 228 223 3 0 30 -25 60 -55z m-490 -556 c0 -6 -133 -69 -137
-65 -2 2 11 35 29 74 l32 72 38 -37 c21 -20 38 -40 38 -44z"/>
<path d="M916 2374 c-24 -23 -24 -365 0 -388 23 -24 365 -24 388 0 24 23 24
365 0 388 -13 13 -45 16 -194 16 -149 0 -181 -3 -194 -16z m304 -194 l0 -110
-110 0 -110 0 0 110 0 110 110 0 110 0 0 -110z"/>
<path d="M1766 2241 l-100 -100 -47 44 c-27 25 -57 45 -67 45 -23 0 -52 -30
-52 -54 0 -28 132 -156 161 -156 18 0 57 33 154 130 123 123 129 131 119 157
-7 21 -17 29 -39 31 -26 2 -43 -10 -129 -97z"/>
<path d="M916 1824 c-24 -23 -24 -365 0 -388 23 -24 365 -24 388 0 24 23 24
365 0 388 -13 13 -45 16 -194 16 -149 0 -181 -3 -194 -16z m304 -194 l0 -110
-110 0 -110 0 0 110 0 110 110 0 110 0 0 -110z"/>
<path d="M1766 1691 l-100 -100 -47 44 c-27 25 -57 45 -67 45 -23 0 -52 -30
-52 -54 0 -28 132 -156 161 -156 18 0 57 33 154 130 123 123 129 131 119 157
-7 21 -17 29 -39 31 -26 2 -43 -10 -129 -97z"/>
<path d="M916 1274 c-24 -23 -24 -365 0 -388 23 -24 365 -24 388 0 24 23 24
365 0 388 -23 24 -365 24 -388 0z m304 -194 l0 -110 -110 0 -110 0 0 110 0
110 110 0 110 0 0 -110z"/>
<path d="M1572 1228 c-24 -24 -13 -60 32 -104 l43 -44 -43 -44 c-45 -44 -56
-80 -32 -104 23 -23 58 -12 103 29 l45 42 45 -42 c45 -41 80 -52 103 -29 23
23 12 58 -29 103 l-42 45 42 45 c41 45 52 80 29 103 -23 23 -58 12 -103 -29
l-45 -42 -45 42 c-45 41 -80 52 -103 29z"/>
<path d="M1436 714 c-31 -30 -9 -84 34 -84 24 0 50 26 50 50 0 24 -26 50 -50
50 -10 0 -26 -7 -34 -16z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.5 KiB

View file

@ -1,6 +1,6 @@
<li class="option">
<a href="{{target}}">
<img src="{{image}}" alt="{{label}}"/>
<a href="{{a_href}}" target="{{a_target}}">
<img src="{{img_src}}" alt="{{img_alt}}"/>
<br/>
<span>{{label}}</span>
</a>

View file

@ -10,7 +10,7 @@
<div id="logo">
<img src="media/lag-logo.svg"/>
</div>
<div id="list"">
<div id="list">
<ul>
{{entries}}
</ul>

View file

@ -16,4 +16,5 @@ if [ $# -ge 1 ] ; then path_data=$1 && shift ; else path_data="" ; fi
mkdir --parents ${dir_build}
cp --recursive ${dir_source}/* ${dir_build}/
test -z ${path_data} || cp ${path_data} ${dir_build}/data.json
echo "-- ${dir_build}"