create data/instances.php to demonstrate out-of-code configuration, and use it to dynamically generate the instance list (#8)

see title.
the workflow here (i.e. a file data/*.php, which only has a data structure and is used to generate content elsewhere) could also be used for easier per-instance customization.

[you can see what this looks like live here](https://4get.silly.computer/about)

Co-authored-by: cynic <kurisufag1@gmail.com>
Reviewed-on: #8
Co-authored-by: cynic <admin@cynic.moe>
Co-committed-by: cynic <admin@cynic.moe>
This commit is contained in:
cynic 2023-08-29 16:11:47 -05:00 committed by lolcat
parent 6dfe114c85
commit 4cf2d73836
2 changed files with 61 additions and 8 deletions

View File

@ -18,6 +18,19 @@ echo
'</head>' . '</head>' .
'<body class="' . $frontend->getthemeclass(false) . 'about">'; '<body class="' . $frontend->getthemeclass(false) . 'about">';
include "data/instances.php";
$compiledinstancelist = "";
foreach ($instancelist as $instance)
{
$compiledinstancelist .= "<tr> <td>".$instance["name"]."</td>";
$compiledinstancelist .= "<td> <a href=\"".$instance["address"]["uri"]."\">".$instance["address"]["displayname"]."</a>";
foreach ($instance["altaddresses"] as $alt)
{
$compiledinstancelist .= "<a href=\"".$alt["uri"]."\">(".$alt["displayname"].")</a></td>";
}
$compiledinstancelist .= "</tr>";
}
$left = $left =
'<a href="/" class="link">&lt; Go back</a> '<a href="/" class="link">&lt; Go back</a>
@ -87,14 +100,7 @@ $left =
<td>Name</td> <td>Name</td>
<td>Address</td> <td>Address</td>
</tr> </tr>
<tr> '.$compiledinstancelist.'
<td>lolcat\'s instance (master)</td>
<td><a href="https://4get.ca">4get.ca</a><a href="http://4getwebfrq5zr4sxugk6htxvawqehxtdgjrbcn2oslllcol2vepa23yd.onion">(tor)</a></td>
</tr>
<tr>
<td>zzls\'s instance</td>
<td><a href="https://4get.zzls.xyz/">4get.zzls.xyz</a><a href="http://4get.zzlsghu6mvvwyy75mvga6gaf4znbp3erk5xwfzedb4gg6qqh2j6rlvid.onion">(tor)</a></td>
</tr>
</table> </table>
<a href="#schizo"><h2 id="schizo">How can I trust you?</h2></a> <a href="#schizo"><h2 id="schizo">How can I trust you?</h2></a>

47
data/instances.php Normal file
View File

@ -0,0 +1,47 @@
<?php
/*
this file exists to separate instance data from the actual about page
HTML, and to make it easier to add/modify instances cleanly.
*/
$instancelist = [
[
"name" => "lolcat's instance (master)",
"address" => [
"uri" => "https://4get.ca/",
"displayname" => "4get.ca"
],
"altaddresses" => [ // all these address blocks will be linked in parentheses
[ // e.g. 4get.ca (tor) (i2p) etc.
"uri" => "http://4getwebfrq5zr4sxugk6htxvawqehxtdgjrbcn2oslllcol2vepa23yd.onion",
"displayname" => "tor"
]
]
],
[
"name" => "zzls's instance",
"address" => [
"uri" => "https://4get.zzls.xyz/",
"displayname" => "4get.zzls.xyz"
],
"altaddresses" => [
[
"uri" => "http://4get.zzlsghu6mvvwyy75mvga6gaf4znbp3erk5xwfzedb4gg6qqh2j6rlvid.onion",
"displayname" => "tor"
]
]
],
[
"name" => "4get on a silly computer",
"address" => [
"uri" => "https://4get.silly.computer",
"displayname" => "4get.silly.computer"
],
"altaddresses" => [
[
"uri" => "https://4get.cynic.moe/",
"displayname" => "fallback domain"
]
]
],
]
?>