[ini]
This commit is contained in:
commit
536af7f0c3
5 changed files with 120 additions and 0 deletions
27
.editorconfig
Normal file
27
.editorconfig
Normal file
|
@ -0,0 +1,27 @@
|
|||
# see https://EditorConfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = tab
|
||||
indent_style = tab
|
||||
tab_width = 4
|
||||
insert_final_newline = true
|
||||
max_line_length = 80
|
||||
trim_trailing_whitespace = true
|
||||
curly_bracket_next_line = false
|
||||
indent_brace_style = K&R
|
||||
spaces_around_operators = true
|
||||
spaces_around_brackets = false
|
||||
quote_type = double
|
||||
|
||||
[*.y{,a}ml{,lint}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.md]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
10
data.json
Normal file
10
data.json
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"title": "Portal",
|
||||
"entries": [
|
||||
{
|
||||
"target": "https://example.org",
|
||||
"label": "Example"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
1
entry.html.tpl
Normal file
1
entry.html.tpl
Normal file
|
@ -0,0 +1 @@
|
|||
<li><a href="{{target}}">{{label}}</a></li>
|
60
index.html.php
Normal file
60
index.html.php
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
function string_coin(
|
||||
string $template,
|
||||
array $arguments
|
||||
) : string
|
||||
{
|
||||
$result = $template;
|
||||
foreach ($arguments as $key => $value) {
|
||||
$result = \str_replace(\sprintf('{{%s}}', $key), $value, $result);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
function template_render_by_name(
|
||||
string $template_name,
|
||||
array $arguments
|
||||
) : string
|
||||
{
|
||||
return string_coin(
|
||||
\file_get_contents(\sprintf('%s/%s.html.tpl', __DIR__, $template_name)),
|
||||
$arguments
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
function main(
|
||||
) : void
|
||||
{
|
||||
$data = \json_decode(
|
||||
\file_get_contents('data.json'),
|
||||
true
|
||||
);
|
||||
print(
|
||||
template_render_by_name(
|
||||
'main',
|
||||
[
|
||||
'title' => $data['title'],
|
||||
'entries' => \implode(
|
||||
"\n",
|
||||
\array_map(
|
||||
fn($entry) => template_render_by_name(
|
||||
'entry',
|
||||
[
|
||||
'label' => $entry['label'],
|
||||
'target' => $entry['target'],
|
||||
]
|
||||
),
|
||||
$data['entries']
|
||||
)
|
||||
),
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
main();
|
||||
|
||||
?>
|
22
main.html.tpl
Normal file
22
main.html.tpl
Normal file
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<style>
|
||||
html {background-color: #000; color: #FFF; margin: 0; padding: 0; font-family: monospace; font-size: 2.0em;}
|
||||
body {background-color: #000; color: #FFF; max-width: 960px; margin: auto; padding: 8px;}
|
||||
a {text-decoration: none;}
|
||||
a:not(:hover) {color: #F00; padding-left: 0; transition: 0.25s ease;}
|
||||
a:hover {color: #F88; padding-left: 8px; transition: 0.5s ease;}
|
||||
li {list-style-type: "» "; margin: 8px;}
|
||||
</style>
|
||||
<title>{{title}}</title>
|
||||
</head>
|
||||
<body>
|
||||
<ul>
|
||||
{{entries}}
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Add table
Reference in a new issue