caddy: make the hosts list website a bit nicer

This commit is contained in:
Tigor Hutasuhut 2024-09-07 09:55:12 +07:00
parent 9706e7f2b3
commit 89c2b3076b

View file

@ -17,29 +17,35 @@ in
reverse_proxy 192.168.100.1 reverse_proxy 192.168.100.1
''; '';
services.caddy.virtualHosts."hosts.tigor.web.id".extraConfig = services.caddy.virtualHosts."tigor.web.id".extraConfig =
let let
domains = attrsets.mapAttrsToList (name: _: strings.removePrefix "https://" name) config.services.caddy.virtualHosts; domains = attrsets.mapAttrsToList (name: _: strings.removePrefix "https://" name) config.services.caddy.virtualHosts;
sortedDomains = lists.sort (a: b: a < b) domains; sortedDomains = lists.sort (a: b: a < b) domains;
list = map (domain: /*html*/ ''<div class="col col-sm-6 col-md-4 col-lg-3"><a href="https://${domain}">${domain}</a></div>'') sortedDomains; list = map
(domain: /*html*/ ''
<div class="col col-sm-6 col-md-4 col-lg-3 text-center align-middle">
<a href="https://${domain}">${domain}</a>
</div>'')
sortedDomains;
items = strings.concatStringsSep "\n" list; items = strings.concatStringsSep "\n" list;
html = /*html*/ ''<!DOCTYPE html> html = /*html*/
<html> ''<!DOCTYPE html>
<head> <html>
<title>Hosted Sites</title> <head>
<link <title>Hosted Sites</title>
rel="stylesheet" <link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
crossorigin="anonymous"> integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
</head> crossorigin="anonymous">
<body class="container"> </head>
<h1 class="text-center">Hosted Sites</h1> <body class="container">
<div class="row g-2"> <h1 class="text-center">Hosted Sites</h1>
${items} <div class="row g-4">
</div> ${items}
</body> </div>
</html>''; </body>
</html>'';
in in
'' ''
header Content-Type text/html header Content-Type text/html