diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6d94939 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.geany diff --git a/data-example.json b/data-example.json index 45b81f8..f69fc64 100644 --- a/data-example.json +++ b/data-example.json @@ -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 } ] } - diff --git a/source/index.html.php b/source/index.html.php index 66edda1..2ccd9ba 100644 --- a/source/index.html.php +++ b/source/index.html.php @@ -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'] )) ) ), diff --git a/source/media/icons/tasks.png b/source/media/icons/tasks.png new file mode 100644 index 0000000..e5e2bde Binary files /dev/null and b/source/media/icons/tasks.png differ diff --git a/source/media/icons/tasks.svg b/source/media/icons/tasks.svg new file mode 100644 index 0000000..18a7b41 --- /dev/null +++ b/source/media/icons/tasks.svg @@ -0,0 +1,57 @@ + + + + +Created by potrace 1.16, written by Peter Selinger 2001-2019 + + + + + + + + + + + + diff --git a/source/templates/entry.html.tpl b/source/templates/entry.html.tpl index f725636..3881b9a 100644 --- a/source/templates/entry.html.tpl +++ b/source/templates/entry.html.tpl @@ -1,6 +1,6 @@
  • - - {{label}} + + {{img_alt}}
    {{label}}
    diff --git a/source/templates/main.html.tpl b/source/templates/main.html.tpl index 7f3d371..47b3ff9 100644 --- a/source/templates/main.html.tpl +++ b/source/templates/main.html.tpl @@ -10,7 +10,7 @@ -
    +
      {{entries}}
    diff --git a/tools/build b/tools/build index e9ccc04..c633537 100755 --- a/tools/build +++ b/tools/build @@ -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}"