update bbb to use dns

master
Steve Ayerhart 2023-09-06 15:04:55 -04:00
parent 7ddfae364c
commit 1fb2321d5a
Signed by: steve
GPG Key ID: BB368A0698AE49B7
5 changed files with 49 additions and 12 deletions

View File

@ -1,4 +1,4 @@
USING: kernel furnace.actions sequences validators accessors html.forms http.server.responses http.server.dispatchers formatting ;
USING: kernel furnace.actions sequences validators accessors html.forms http.server.responses http.server.dispatchers formatting assocs ;
USING: bonerbonerboner.dns ;
IN: bonerbonerboner.actions
@ -31,11 +31,14 @@ TUPLE: bbb-dispatcher < dispatcher ;
TUPLE: subdomain-link subdomain url ;
: get-subdomain-links ( -- subdomain-links )
get-subdomains >alist [ first "bbb" = ] reject
[ first dup "https://%s.bonerbonerboner.com" sprintf subdomain-link boa ] map ;
: <meta-action> ( -- action )
<page-action>
[
get-subdomains
[ dup "name" "https://%s.bonerbonerboner.com" sprintf subdomain-link boa ]
map "subdomains" set-value
get-subdomain-links "subdomains" set-value
] >>init
{ bbb-dispatcher "meta" } >>template ;

View File

@ -0,0 +1,24 @@
<?xml version='1.0'?>
<!DOCTYPE html>
<t:chloe xmlns:t="http://factorcode.org/chloe/1.0">
<html class="@subdomain" lang="en">
<head>
<title>boners</title>
<meta name="viewport"
content="width=device-width, initial-scale=1" />
<link rel="stylesheet" type="text/css"
href="https://static.bonerbonerboner.com/css/meta.css" />
</head>
<body>
<t:bind-each t:name="subdomains">
<section class="@subdomain">
<h1>
<a href="@url">
<t:label t:name="subdomain"/>
</a>
</h1>
</section>
</t:bind-each>
</body>
</html>
</t:chloe>

View File

@ -1,5 +1,8 @@
USING: kernel regexp dns hashtables sequences splitting assocs urls arrays http http.client json json.http io.sockets.secure accessors ;
USING: prettyprint ;
USING: io.encodings.utf8 io.encodings.string ;
USE: bonerboner.server
IN: bonerbonerboner
: start-bonerbonerboner ( -- )
start-bbb-site current-bbb-server set ;
MAIN: start-bonerbonerboner

View File

@ -1,14 +1,21 @@
USING: kernel regexp dns hashtables sequences splitting assocs urls arrays http http.client json json.http io.sockets.secure accessors ;
USING: kernel regexp dns hashtables sequences splitting assocs urls arrays http http.client json json.http io.sockets.secure accessors environment ;
USING: prettyprint ;
IN: bonerbonerboner.dns
CONSTANT: bbb-domain "bonerbonerboner.com"
CONSTANT: meta R/ ^meta=/
CONSTANT: do-key "TODO: ADD TO ENV"
CONSTANT: do-api-base-url URL" https://api.digitalocean.com/v2/"
: do-key ( -- key )
"DO_API_KEY" os-env ;
! ensure we have at least a couple dns servers
: init-dns-servers ( -- )
"208.67.222.222" "208.67.220.220" [ add-dns-server ] bi@ ;
: get-subdomain-metadata ( -- assoc )
init-dns-servers
bbb-domain dns-TXT-query TXT-message>strings
H{ }
[
@ -19,7 +26,7 @@ CONSTANT: do-api-base-url URL" https://api.digitalocean.com/v2/"
] reduce ;
: get-subdomains ( -- seq )
get-subdomain-metadata keys ;
get-subdomain-metadata ;
: post-domain-records-url ( -- url )
do-api-base-url URL" domains/bonerbonerboner.com/records" derive-url ;

View File

@ -17,6 +17,6 @@ SYMBOL: current-bbb-server
f >>secure
8069 >>insecure ;
: start-bbb-site ( -- )
: start-bbb-site ( -- server )
<bbb> main-responder set-global
<bbb-website-server> start-server current-bbb-server set ;
<bbb-website-server> start-server ;