Compare commits

...

3 Commits

Author SHA1 Message Date
Ryan Rix e72b93818b downgrade loggers 2023-12-27 19:55:30 -08:00
Ryan Rix 0c35a6ce01 load sites from a json file generated from org tables 2023-12-27 19:55:14 -08:00
Ryan Rix 020b5bdf13 update arroyo lib w/ better html export 2023-12-27 19:54:52 -08:00
9 changed files with 86 additions and 106 deletions

View File

@ -20,7 +20,7 @@ import roam.models
import logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logger.setLevel(logging.WARN)
#+end_src
** Site
@ -149,7 +149,7 @@ class Page(models.Model):
ret[h.node_id] = link
logger.info(f"link {link} from {el}")
except roam.models.Heading.DoesNotExist:
logger.warn(f"{el} does not have dest")
logger.info(f"{el} does not have dest")
return ret

View File

@ -1,6 +1,7 @@
# [[file:../../../interfaces.org::*Create Base Sites][Create Base Sites:1]]
from django.core.management.base import BaseCommand, CommandError
from django.conf import settings
import json
import arcology.models
import roam.models
@ -15,53 +16,17 @@ class Command(BaseCommand):
requires_migrations_checks = True
def handle(self, *args, **kwargs):
lionsrear = arcology.models.Site.objects.create(
key="lionsrear",
title="The Lion's Rear",
css_file="lionsrear.css",
link_color="#87af87",
)
for domain in ["thelionsrear.com", "rix.si"]:
lionsrear.sitedomain_set.create(domain=domain)
sites_path = settings.BASE_DIR / "arcology/settings/sites.json"
with open(sites_path, "r") as f:
sites = json.load(f)
garden = arcology.models.Site.objects.create(
key="garden",
title="The Arcology Garden",
css_file="garden.css",
link_color="#a6dc68",
)
for domain in ["arcology.garden", "whatthefuck.computer"]:
garden.sitedomain_set.create(domain=domain)
cce = arcology.models.Site.objects.create(
key="cce",
title="The Complete Computer",
css_file="cce.css",
link_color="#cc6960",
)
for domain in ["cce.whatthefuck.computer", "cce.rix.si"]:
cce.sitedomain_set.create(domain=domain)
arcology_site = arcology.models.Site.objects.create(
key="arcology",
title="The Arcology Site Engine",
css_file="arcology.css",
link_color="#67b4f8",
)
for domain in ["engine.arcology.garden"]:
arcology_site.sitedomain_set.create(domain=domain)
localhost_dev = arcology.models.Site.objects.create(
key="localhost",
title="Local Dev Env",
css_file="arcology.css",
link_color="#67b4f8",
)
for domain in ["localhost:8000", "127.0.0.1:8000"]:
localhost_dev.sitedomain_set.create(domain=domain)
for role in settings.ARROYO_ROLES:
generators.models.GeneratorRole.objects.create(
name=role
for site in sites:
the_site = arcology.models.Site.objects.create(
key=site["key"],
title=site["title"],
css_file=site["css_file"],
link_color=site["link_color"],
)
for domain in site["domains"]:
the_site.sitedomain_set.create(domain=domain)
# Create Base Sites:1 ends here

View File

@ -11,7 +11,7 @@ import roam.models
import logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logger.setLevel(logging.WARN)
# Data Models for routing to org-roam pages:1 ends here
# [[file:../arcology.org::*Site][Site:1]]
@ -83,7 +83,7 @@ class Page(models.Model):
ret[h.node_id] = link
logger.info(f"link {link} from {el}")
except roam.models.Heading.DoesNotExist:
logger.warn(f"{el} does not have dest")
logger.info(f"{el} does not have dest")
return ret

View File

@ -0,0 +1 @@
[{"title":"The Lion's Rear","key":"lionsrear","css_file":"lionsrear.css","link_color":"#87af87","domains":["thelionsrear.com","rix.si"]},{"title":"The Arcology Garden","key":"garden","css_file":"garden.css","link_color":"#a6dc68","domains":["arcology.garden","whatthefuck.computer"]},{"title":"The Complete Computer","key":"cce","css_file":"cce.css","link_color":"#cc9660","domains":["cce.whatthefuck.computer","cce.rix.si"]},{"title":"The Arcology Site Engine","key":"arcology","css_file":"arcology.css","link_color":"#67b4f8","domains":["engine.arcology.garden"]},{"title":"Local Dev Environment","key":"localhost","css_file":"arcology.css","link_color":"#67b4f8","domains":["127.0.0.1:8000","localhost:8000"]}]

View File

@ -9,6 +9,56 @@
user-configuration ; these could be generated from org tables if i'm feeling like a proper sicko. They should at least be much more legible but that's true of all the code i'm pulling in here..
* The Site List
These can be customized by the user:
#+NAME: sites-config
| title | key | css file | link color |
|--------------------------+-----------+---------------+------------|
| The Lion's Rear | lionsrear | lionsrear.css | #87af87 |
| The Arcology Garden | garden | garden.css | #a6dc68 |
| The Complete Computer | cce | cce.css | #cc9660 |
| The Arcology Site Engine | arcology | arcology.css | #67b4f8 |
| Local Dev Environment | localhost | arcology.css | #67b4f8 |
#+NAME: domains-config
| key | domain |
|-----------+--------------------------|
| lionsrear | thelionsrear.com |
| lionsrear | rix.si |
| garden | arcology.garden |
| garden | whatthefuck.computer |
| cce | cce.whatthefuck.computer |
| cce | cce.rix.si |
| arcology | engine.arcology.garden |
| localhost | 127.0.0.1:8000 |
| localhost | localhost:8000 |
Oh we doing some code gen in here, this is just gonna generate some JSON for now joining these two tables lul.
#+name: elisp-join-tables
#+begin_src emacs-lisp :var sites=sites-config domains=domains-config :results none
(json-encode
(-map (lambda (siterow)
(pcase-let* ((`(,title ,key ,css ,link) siterow))
`((title . ,title)
(key . ,key)
(css_file . ,css)
(link_color . ,link)
(domains . ,(-map #'cadr
(-filter (pcase-lambda (`(,dkey ,domain))
(equal key dkey))
domains))))))
sites))
#+end_src
That generates JSON that goes in to =arcology/settings/sites.json= for the [[id:20231217T154835.232283][Arcology Seed Command]] to use:
#+begin_src json :tangle arcology/settings/sites.json :noweb yes :comments none
<<elisp-join-tables()>>
#+end_src
* Service Configuration
:PROPERTIES:
:ID: 20231217T155611.177995

View File

@ -6,16 +6,15 @@
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1702323901,
"narHash": "sha256-Wucs45I0v1XI4ZrxVipxOWY9LOgqh99o4Nuf5gNSt/4=",
"ref": "arroyo-rs",
"rev": "db09908f89f625747f6ebc77319946fb7c6fd065",
"revCount": 119,
"lastModified": 1703734847,
"narHash": "sha256-55zlSQULXCmUf88tPSGc/g7RiYnuCo14eaP1kcA6V00=",
"ref": "refs/heads/main",
"rev": "f7f944d0afb9b790cbc33bf023a1ca4cbcc0b134",
"revCount": 127,
"type": "git",
"url": "https://code.rix.si/rrix/arroyo"
},
"original": {
"ref": "arroyo-rs",
"type": "git",
"url": "https://code.rix.si/rrix/arroyo"
}

View File

@ -4,7 +4,7 @@
inputs.nixpkgs.follows = "arroyo_rs/nixpkgs";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.arroyo_rs.url = "git+https://code.rix.si/rrix/arroyo?ref=arroyo-rs";
inputs.arroyo_rs.url = "git+https://code.rix.si/rrix/arroyo";
outputs = { self, nixpkgs, flake-utils, arroyo_rs }:
flake-utils.lib.eachDefaultSystem (system:

View File

@ -392,6 +392,7 @@ This needs to be run to define the base sites when the server DB is created. Eve
#+begin_src python :tangle arcology/management/commands/seed.py
from django.core.management.base import BaseCommand, CommandError
from django.conf import settings
import json
import arcology.models
import roam.models
@ -406,53 +407,17 @@ class Command(BaseCommand):
requires_migrations_checks = True
def handle(self, *args, **kwargs):
lionsrear = arcology.models.Site.objects.create(
key="lionsrear",
title="The Lion's Rear",
css_file="lionsrear.css",
link_color="#87af87",
)
for domain in ["thelionsrear.com", "rix.si"]:
lionsrear.sitedomain_set.create(domain=domain)
sites_path = settings.BASE_DIR / "arcology/settings/sites.json"
with open(sites_path, "r") as f:
sites = json.load(f)
garden = arcology.models.Site.objects.create(
key="garden",
title="The Arcology Garden",
css_file="garden.css",
link_color="#a6dc68",
)
for domain in ["arcology.garden", "whatthefuck.computer"]:
garden.sitedomain_set.create(domain=domain)
cce = arcology.models.Site.objects.create(
key="cce",
title="The Complete Computer",
css_file="cce.css",
link_color="#cc6960",
)
for domain in ["cce.whatthefuck.computer", "cce.rix.si"]:
cce.sitedomain_set.create(domain=domain)
arcology_site = arcology.models.Site.objects.create(
key="arcology",
title="The Arcology Site Engine",
css_file="arcology.css",
link_color="#67b4f8",
)
for domain in ["engine.arcology.garden"]:
arcology_site.sitedomain_set.create(domain=domain)
localhost_dev = arcology.models.Site.objects.create(
key="localhost",
title="Local Dev Env",
css_file="arcology.css",
link_color="#67b4f8",
)
for domain in ["localhost:8000", "127.0.0.1:8000"]:
localhost_dev.sitedomain_set.create(domain=domain)
for role in settings.ARROYO_ROLES:
generators.models.GeneratorRole.objects.create(
name=role
for site in sites:
the_site = arcology.models.Site.objects.create(
key=site["key"],
title=site["title"],
css_file=site["css_file"],
link_color=site["link_color"],
)
for domain in site["domains"]:
the_site.sitedomain_set.create(domain=domain)
#+end_src

View File

@ -86,7 +86,7 @@ Nix is really going this direction, I'm not sure it's worthwhile but I'm going t
inputs.nixpkgs.follows = "arroyo_rs/nixpkgs";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.arroyo_rs.url = "git+https://code.rix.si/rrix/arroyo?ref=arroyo-rs";
inputs.arroyo_rs.url = "git+https://code.rix.si/rrix/arroyo";
outputs = { self, nixpkgs, flake-utils, arroyo_rs }:
flake-utils.lib.eachDefaultSystem (system: