Compare commits
5 Commits
153c6c5ac2
...
cc8d62e000
Author | SHA1 | Date |
---|---|---|
Ryan Rix | cc8d62e000 | |
Ryan Rix | 9d17bac93a | |
Ryan Rix | 04b2f4a3e4 | |
Ryan Rix | b4378266d7 | |
Ryan Rix | 60fc52a434 |
|
@ -7,6 +7,4 @@ result
|
|||
.direnv
|
||||
|
||||
db.sqlite3
|
||||
|
||||
static/arcology/fonts/Vulf*
|
||||
# Gitignore:1 ends here
|
||||
|
|
16
arcology.org
16
arcology.org
|
@ -701,7 +701,7 @@ The main =content= block contains the =<main>= generated by the native parser, a
|
|||
|
||||
Most of the page CSS is defined below, but the content CSS is here, nearer the actual implementation of the flexbox:
|
||||
|
||||
#+begin_src css :tangle static/arcology/css/app.css :mkdirp yes
|
||||
#+begin_src css :tangle arcology/static/arcology/css/app.css :mkdirp yes
|
||||
.content {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
|
@ -730,7 +730,7 @@ Most of the page CSS is defined below, but the content CSS is here, nearer the a
|
|||
|
||||
The sidebar itself is a vertical flexbox, pushing everything but the backlinks towards the bottom of the page.
|
||||
|
||||
#+begin_src css :tangle static/arcology/css/app.css :mkdirp yes
|
||||
#+begin_src css :tangle arcology/static/arcology/css/app.css :mkdirp yes
|
||||
section.sidebar {
|
||||
display: flex;
|
||||
flex-flow: column wrap;
|
||||
|
@ -743,7 +743,7 @@ section.sidebar > div.backlinks {
|
|||
|
||||
Here are some [[https://medium.com/@massimo.cassandro/flexbox-separators-b284d6d7b747][hacks]] to put a line between the main content flexbox and the sidebar. I'm not sure I'll keep this, but it's nice to have a delimeter.
|
||||
|
||||
#+begin_src css :tangle static/arcology/css/app.css :mkdirp yes
|
||||
#+begin_src css :tangle arcology/static/arcology/css/app.css :mkdirp yes
|
||||
.content::before {
|
||||
align-self: stretch;
|
||||
content: '';
|
||||
|
@ -1030,7 +1030,7 @@ this will be extended.
|
|||
|
||||
rather than using emoji for each site, it would be nice to subtly color them based on the link_color... will need to Do Some Bullshit to make that work though maybe.
|
||||
|
||||
#+begin_src css :tangle static/arcology/css/app.css :mkdirp yes
|
||||
#+begin_src css :tangle arcology/static/arcology/css/app.css :mkdirp yes
|
||||
body {
|
||||
font-family: "Vulf Mono", monospace;
|
||||
font-style: italic;
|
||||
|
@ -1041,7 +1041,7 @@ body {
|
|||
}
|
||||
#+end_src
|
||||
|
||||
#+begin_src css :tangle static/arcology/css/app.css :mkdirp yes
|
||||
#+begin_src css :tangle arcology/static/arcology/css/app.css :mkdirp yes
|
||||
header {
|
||||
background-color: var(--light-gray);
|
||||
border-radius: 0.25em;
|
||||
|
@ -1066,7 +1066,7 @@ header h2:before {
|
|||
}
|
||||
#+end_src
|
||||
|
||||
#+begin_src css :tangle static/arcology/css/app.css :mkdirp yes
|
||||
#+begin_src css :tangle arcology/static/arcology/css/app.css :mkdirp yes
|
||||
footer {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
|
@ -1080,7 +1080,7 @@ footer a {
|
|||
}
|
||||
#+end_src
|
||||
|
||||
#+begin_src css :tangle static/arcology/css/app.css :mkdirp yes
|
||||
#+begin_src css :tangle arcology/static/arcology/css/app.css :mkdirp yes
|
||||
a {
|
||||
color: var(--primary);
|
||||
}
|
||||
|
@ -1129,7 +1129,7 @@ There are per-site CSS in [[id:20231229T164611.256424][The Arcology's Site List]
|
|||
(concat "font-style: " style ";"))
|
||||
"}"))))
|
||||
tbl)
|
||||
(write-file "~/org/arcology-django/static/arcology/css/vulf.css"))
|
||||
(write-file "~/org/arcology-django/arcology/static/arcology/css/vulf.css"))
|
||||
#+end_src
|
||||
|
||||
** Per-Site link color dynamic CSS endpoint
|
||||
|
|
|
@ -23,8 +23,7 @@ SYNCTHING_KEY = os.getenv("ARCOLOGY_SYNCTHING_KEY")
|
|||
# Environment Variables:3 ends here
|
||||
|
||||
# [[file:../../configuration.org::*Hostname configuration from =arcology.model.Site=, eventually][Hostname configuration from =arcology.model.Site=, eventually:1]]
|
||||
ALLOWED_HOSTS = [
|
||||
]
|
||||
ALLOWED_HOSTS = "thelionsrear.com,rix.si,arcology.garden,whatthefuck.computer,cce.whatthefuck.computer,cce.rix.si,engine.arcology.garden,127.0.0.1,localhost,v2.thelionsrear.com,v2.arcology.garden,cce2.whatthefuck.computer,engine2.arcology.garden".split(',')
|
||||
# Hostname configuration from =arcology.model.Site=, eventually:1 ends here
|
||||
|
||||
# [[file:../../configuration.org::*The Arcology is Modular][The Arcology is Modular:1]]
|
||||
|
@ -97,6 +96,13 @@ MIDDLEWARE = [
|
|||
"django_prometheus.middleware.PrometheusAfterMiddleware",
|
||||
]
|
||||
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'django_prometheus.cache.backends.filebased.FileBasedCache',
|
||||
'LOCATION': '/var/tmp/django_cache',
|
||||
}
|
||||
}
|
||||
|
||||
ROOT_URLCONF = "arcology.urls"
|
||||
|
||||
TEMPLATES = [
|
||||
|
@ -163,9 +169,11 @@ STORAGES = {
|
|||
},
|
||||
}
|
||||
STATICFILES_DIRS = [
|
||||
BASE_DIR / "static",
|
||||
BASE_DIR / "arcology/static",
|
||||
]
|
||||
|
||||
STATIC_ROOT = os.getenv("ARCOLOGY_STATIC_ROOT", "/var/www/arcology")
|
||||
|
||||
# Default primary key field type
|
||||
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
[{"title":"The Lion's Rear","key":"lionsrear","css_file":"arcology/css/lionsrear.css","link_color":"#cfdcc2","domains":["thelionsrear.com","rix.si"]},{"title":"The Arcology Garden","key":"garden","css_file":"arcology/css/garden.css","link_color":"#fcf6ed","domains":["arcology.garden","whatthefuck.computer"]},{"title":"The Complete Computer","key":"cce","css_file":"arcology/css/cce.css","link_color":"#dcdcec","domains":["cce.whatthefuck.computer","cce.rix.si"]},{"title":"The Arcology Site Engine","key":"arcology","css_file":"arcology/css/arcology.css","link_color":"#ccdfff","domains":["engine.arcology.garden"]},{"title":"Local Dev Environment","key":"localhost","css_file":"arcology/css/arcology.css","link_color":"#075192","domains":["127.0.0.1:8000","localhost:8000"]}]
|
||||
[{"title":"The Lion's Rear","key":"lionsrear","css_file":"arcology/css/lionsrear.css","link_color":"#cfdcc2","domains":["thelionsrear.com","rix.si","v2.thelionsrear.com"]},{"title":"The Arcology Garden","key":"garden","css_file":"arcology/css/garden.css","link_color":"#fcf6ed","domains":["arcology.garden","whatthefuck.computer","v2.arcology.garden"]},{"title":"The Complete Computer","key":"cce","css_file":"arcology/css/cce.css","link_color":"#dcdcec","domains":["cce.whatthefuck.computer","cce.rix.si","cce2.whatthefuck.computer"]},{"title":"The Arcology Site Engine","key":"arcology","css_file":"arcology/css/arcology.css","link_color":"#ccdfff","domains":["engine.arcology.garden","engine2.arcology.garden"]},{"title":"Local Dev Environment","key":"localhost","css_file":"arcology/css/arcology.css","link_color":"#075192","domains":["127.0.0.1","localhost"]}]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* [[file:../../../arcology.org::*Org Page-specific CSS Stylings][Org Page-specific CSS Stylings:1]] */
|
||||
/* [[file:../../../../arcology.org::*Org Page-specific CSS Stylings][Org Page-specific CSS Stylings:1]] */
|
||||
.content {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
|
@ -25,7 +25,7 @@
|
|||
}
|
||||
/* Org Page-specific CSS Stylings:1 ends here */
|
||||
|
||||
/* [[file:../../../arcology.org::*Org Page-specific CSS Stylings][Org Page-specific CSS Stylings:2]] */
|
||||
/* [[file:../../../../arcology.org::*Org Page-specific CSS Stylings][Org Page-specific CSS Stylings:2]] */
|
||||
section.sidebar {
|
||||
display: flex;
|
||||
flex-flow: column wrap;
|
||||
|
@ -36,7 +36,7 @@ section.sidebar > div.backlinks {
|
|||
}
|
||||
/* Org Page-specific CSS Stylings:2 ends here */
|
||||
|
||||
/* [[file:../../../arcology.org::*Org Page-specific CSS Stylings][Org Page-specific CSS Stylings:3]] */
|
||||
/* [[file:../../../../arcology.org::*Org Page-specific CSS Stylings][Org Page-specific CSS Stylings:3]] */
|
||||
.content::before {
|
||||
align-self: stretch;
|
||||
content: '';
|
||||
|
@ -49,7 +49,7 @@ section.sidebar > div.backlinks {
|
|||
}
|
||||
/* Org Page-specific CSS Stylings:3 ends here */
|
||||
|
||||
/* [[file:../../../arcology.org::*CSS][CSS:1]] */
|
||||
/* [[file:../../../../arcology.org::*CSS][CSS:1]] */
|
||||
body {
|
||||
font-family: "Vulf Mono", monospace;
|
||||
font-style: italic;
|
||||
|
@ -60,7 +60,7 @@ body {
|
|||
}
|
||||
/* CSS:1 ends here */
|
||||
|
||||
/* [[file:../../../arcology.org::*CSS][CSS:2]] */
|
||||
/* [[file:../../../../arcology.org::*CSS][CSS:2]] */
|
||||
header {
|
||||
background-color: var(--light-gray);
|
||||
border-radius: 0.25em;
|
||||
|
@ -85,7 +85,7 @@ header h2:before {
|
|||
}
|
||||
/* CSS:2 ends here */
|
||||
|
||||
/* [[file:../../../arcology.org::*CSS][CSS:3]] */
|
||||
/* [[file:../../../../arcology.org::*CSS][CSS:3]] */
|
||||
footer {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
|
@ -99,7 +99,7 @@ footer a {
|
|||
}
|
||||
/* CSS:3 ends here */
|
||||
|
||||
/* [[file:../../../arcology.org::*CSS][CSS:4]] */
|
||||
/* [[file:../../../../arcology.org::*CSS][CSS:4]] */
|
||||
a {
|
||||
color: var(--primary);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/* [[file:../../../configuration.org::*The Code][The Code:6]] */
|
||||
/* [[file:../../../../configuration.org::*The Code][The Code:6]] */
|
||||
:root {
|
||||
--alert: #cc6960;
|
||||
--primary: #707231;
|
|
@ -1,4 +1,4 @@
|
|||
/* [[file:../../../configuration.org::*The Code][The Code:3]] */
|
||||
/* [[file:../../../../configuration.org::*The Code][The Code:3]] */
|
||||
:root {
|
||||
--alert: #cc6960;
|
||||
--primary: #707231;
|
|
@ -1,4 +1,4 @@
|
|||
/* [[file:../../../configuration.org::*The Code][The Code:2]] */
|
||||
/* [[file:../../../../configuration.org::*The Code][The Code:2]] */
|
||||
:root {
|
||||
--alert: #cc6960;
|
||||
--primary: #707231;
|
|
@ -1,4 +1,4 @@
|
|||
/* [[file:../../../configuration.org::*The Code][The Code:5]] */
|
||||
/* [[file:../../../../configuration.org::*The Code][The Code:5]] */
|
||||
:root {
|
||||
--alert: #cc6960;
|
||||
--primary: #707231;
|
|
@ -1,4 +1,4 @@
|
|||
/* [[file:../../../configuration.org::*The Code][The Code:4]] */
|
||||
/* [[file:../../../../configuration.org::*The Code][The Code:4]] */
|
||||
:root {
|
||||
--alert: #cc6960;
|
||||
--primary: #707231;
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -26,17 +26,21 @@ These can be customized by the user:
|
|||
| Local Dev Environment | localhost | arcology.css | #075192 |
|
||||
|
||||
#+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 |
|
||||
| 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 |
|
||||
| localhost | localhost |
|
||||
| lionsrear | v2.thelionsrear.com |
|
||||
| garden | v2.arcology.garden |
|
||||
| cce | cce2.whatthefuck.computer |
|
||||
| arcology | engine2.arcology.garden |
|
||||
|
||||
** The Code
|
||||
|
||||
|
@ -64,6 +68,14 @@ That generates JSON that goes in to =arcology/settings/sites.json= for the [[id:
|
|||
<<elisp-join-tables()>>
|
||||
#+end_src
|
||||
|
||||
#+name: get_allowed_hosts
|
||||
#+begin_src emacs-lisp :var domains=domains-config :results none
|
||||
(thread-last domains
|
||||
(-map (pcase-lambda (`(,site ,domain))
|
||||
domain))
|
||||
(s-join ","))
|
||||
#+end_src
|
||||
|
||||
** NEXT How to re-seed these if you change the configuration?
|
||||
|
||||
for now i just blow away the database but gosh!
|
||||
|
@ -105,23 +117,23 @@ Note that they're basically the same, but you can customize it further to your s
|
|||
"}")))
|
||||
#+end_src
|
||||
|
||||
#+begin_src css :tangle static/arcology/css/default-colors.css :noweb yes
|
||||
#+begin_src css :tangle arcology/static/arcology/css/default-colors.css :noweb yes
|
||||
<<mk-site-colors(site-colors, "default-colors")>>
|
||||
#+end_src
|
||||
|
||||
#+begin_src css :tangle static/arcology/css/cce.css :noweb yes
|
||||
#+begin_src css :tangle arcology/static/arcology/css/cce.css :noweb yes
|
||||
<<mk-site-colors(site-colors, "cce")>>
|
||||
#+end_src
|
||||
|
||||
#+begin_src css :tangle static/arcology/css/lionsrear.css :noweb yes
|
||||
#+begin_src css :tangle arcology/static/arcology/css/lionsrear.css :noweb yes
|
||||
<<mk-site-colors(site-colors, "lionsrear")>>
|
||||
#+end_src
|
||||
|
||||
#+begin_src css :tangle static/arcology/css/garden.css :noweb yes
|
||||
#+begin_src css :tangle arcology/static/arcology/css/garden.css :noweb yes
|
||||
<<mk-site-colors(site-colors, "garden")>>
|
||||
#+end_src
|
||||
|
||||
#+begin_src css :tangle static/arcology/css/arcology.css :noweb yes
|
||||
#+begin_src css :tangle arcology/static/arcology/css/arcology.css :noweb yes
|
||||
<<mk-site-colors(site-colors, "arcology")>>
|
||||
#+end_src
|
||||
|
||||
|
@ -183,9 +195,8 @@ SYNCTHING_KEY = os.getenv("ARCOLOGY_SYNCTHING_KEY")
|
|||
|
||||
When I have the sites organized in an org-mode table, i'll reapproach the hostname list, and probably before then when i want to test domain-based routing.
|
||||
|
||||
#+BEGIN_SRC python :tangle arcology/settings/__init__.py
|
||||
ALLOWED_HOSTS = [
|
||||
]
|
||||
#+BEGIN_SRC python :tangle arcology/settings/__init__.py :noweb yes
|
||||
ALLOWED_HOSTS = "<<get_allowed_hosts()>>".split(',')
|
||||
#+END_SRC
|
||||
|
||||
** The Arcology is Modular
|
||||
|
@ -394,7 +405,6 @@ IGNORED_ROAM_TAGS = [
|
|||
]
|
||||
#+END_SRC
|
||||
|
||||
|
||||
* Look don't worry about the rest of these
|
||||
|
||||
#+BEGIN_SRC python :tangle arcology/settings/__init__.py :noweb yes
|
||||
|
@ -484,9 +494,11 @@ STORAGES = {
|
|||
},
|
||||
}
|
||||
STATICFILES_DIRS = [
|
||||
BASE_DIR / "static",
|
||||
BASE_DIR / "arcology/static",
|
||||
]
|
||||
|
||||
STATIC_ROOT = os.getenv("ARCOLOGY_STATIC_ROOT", "/var/www/arcology")
|
||||
|
||||
# Default primary key field type
|
||||
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
pkgs ? import <nixpkgs> {},
|
||||
lib ? pkgs.lib,
|
||||
python3,
|
||||
|
||||
arroyo_rs,
|
||||
}:
|
||||
|
||||
|
|
|
@ -34,17 +34,26 @@ let
|
|||
# might want to generate a localsettings.py or so to configure the application for deployment, rather than use process env
|
||||
|
||||
env = {
|
||||
ARCOLOGY_ENV = cfg.environment;
|
||||
ARCOLOGY_ENVIRONMENT = cfg.environment;
|
||||
ARCOLOGY_DIRECTORY = cfg.orgDir;
|
||||
ARCOLOGY_STATIC_ROOT = cfg.staticRoot;
|
||||
|
||||
ARCOLOGY_DB = "${cfg.dataDir}/databases/arcology2.db";
|
||||
ARCOLOGY_DB_PATH = "${cfg.dataDir}/databases/arcology2.db";
|
||||
ARCOLOGY_SYNCTHING_KEY = "ECNPVaubstVw34DFpeKAZfKLyGxipWiW";
|
||||
ARCOLOGY_ALLOWED_HOSTS = concatStringsSep "," cfg.domains;
|
||||
# ARCOLOGY_SYNCTHING_KEY=
|
||||
# ALLOWED_HOSTS in to settings based on cfg.domains...
|
||||
|
||||
GUNICORN_CMD_ARGS = "--bind=${cfg.address}:${toString cfg.port} -w ${toString cfg.workerCount}";
|
||||
};
|
||||
|
||||
pyenv = pkgs.python3.withPackages(pp: [cfg.packages.arcology]);
|
||||
|
||||
svcConfig = {
|
||||
system.activationScripts.arcology-collectfiles.text = ''
|
||||
echo "Setting up Arcology static files"
|
||||
ARCOLOGY_STATIC_ROOT=${cfg.staticRoot} ${cfg.packages.arcology}/bin/arcology collectstatic --no-input -c -v0
|
||||
'';
|
||||
systemd.services.arcology2-watchsync = {
|
||||
description = "Arcology Django Syncthing Watcher";
|
||||
after = ["network.target"];
|
||||
|
@ -52,10 +61,10 @@ let
|
|||
environment = env;
|
||||
preStart = ''
|
||||
${cfg.packages.arcology}/bin/arcology migrate
|
||||
${cfg.packages.arcology}/bin/arcology seed
|
||||
${cfg.packages.arcology}/bin/arcology seed || true
|
||||
'';
|
||||
script = ''
|
||||
${cfg.packages.arcology}/bin/arcology watchsync
|
||||
${cfg.packages.arcology}/bin/arcology watchsync -f ${cfg.folderId}
|
||||
'';
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
|
@ -71,7 +80,7 @@ let
|
|||
wantedBy = ["multi-user.target"];
|
||||
environment = env;
|
||||
script = ''
|
||||
${cfg.packages.arcology.gunicorn}/bin/gunicorn arcology.wsgi
|
||||
${pyenv}/bin/python -m gunicorn arcology.wsgi
|
||||
'';
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
|
@ -94,6 +103,7 @@ let
|
|||
proxy_set_header X-Forwarded-Host $http_host;
|
||||
proxy_set_header Host $host;
|
||||
'';
|
||||
locations."/static/".alias = cfg.staticRoot;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -142,8 +152,8 @@ in {
|
|||
};
|
||||
|
||||
environment = mkOption {
|
||||
type = types.enum ["prod" "dev"];
|
||||
default = "prod";
|
||||
type = types.enum ["production" "development"];
|
||||
default = "production";
|
||||
};
|
||||
|
||||
workerCount = mkOption {
|
||||
|
@ -166,6 +176,16 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
staticRoot = mkOption {
|
||||
type = types.path;
|
||||
default = "/var/lib/arcology/static/";
|
||||
description = ''
|
||||
Location where django-manage collectfiles will write the files to. If
|
||||
you let this module generate nginx virtualhosts it will be configured
|
||||
to use that for static files. Ensure this ends with a backslash.
|
||||
'';
|
||||
};
|
||||
|
||||
orgDir = mkOption {
|
||||
type = types.path;
|
||||
description = mdDoc ''
|
||||
|
@ -173,6 +193,13 @@ in {
|
|||
Arcology needs read-only access to this directory.
|
||||
'';
|
||||
};
|
||||
|
||||
folderId = mkOption {
|
||||
type = types.str;
|
||||
description = mdDoc ''
|
||||
Syncthing folder ID containing the org files.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -186,18 +213,27 @@ in {
|
|||
}
|
||||
#+end_src
|
||||
|
||||
*** INPROGRESS finish this
|
||||
*** DONE finish this
|
||||
:LOGBOOK:
|
||||
- State "DONE" from "INPROGRESS" [2024-02-15 Thu 12:07]
|
||||
- State "INPROGRESS" from "NEXT"
|
||||
:END:
|
||||
*** NEXT validate the environment variables are used
|
||||
*** DONE validate the environment variables are used
|
||||
:LOGBOOK:
|
||||
- State "DONE" from "NEXT" [2024-02-15 Thu 12:07]
|
||||
:END:
|
||||
|
||||
*** NEXT consider generating a local settings.py with our configuration overrides
|
||||
*** NEXT figure out better way to call in to Arcology and Arroyo in the service definition
|
||||
|
||||
probably just =getFlake= but augh.
|
||||
|
||||
*** NEXT service hardening
|
||||
*** NEXT static files under gunicorn/nginx
|
||||
*** INPROGRESS static files under gunicorn/nginx
|
||||
:LOGBOOK:
|
||||
- State "INPROGRESS" from "NEXT" [2024-02-15 Thu 12:08]
|
||||
CLOCK: [2024-02-15 Thu 12:08]
|
||||
:END:
|
||||
*** NEXT secret infrastructure for the syncthing key
|
||||
|
||||
or a way to load that in to the DB 🤔
|
||||
|
@ -216,8 +252,13 @@ in {
|
|||
services.arcology-ng = {
|
||||
enable = true;
|
||||
packages.arcology = arcology;
|
||||
domains = ["engine2.arcology.garden" "v2.thelionsrear.com" "v2.arcology.garden" "cce2.whatthefuck.computer"];
|
||||
domains = [
|
||||
"engine2.arcology.garden"
|
||||
"v2.thelionsrear.com"
|
||||
"v2.arcology.garden"
|
||||
"cce2.whatthefuck.computer"];
|
||||
orgDir = "/media/org";
|
||||
folderId = "p1kld-oxnwd";
|
||||
dataDir = "/srv/arcology";
|
||||
};
|
||||
}
|
||||
|
|
|
@ -296,13 +296,20 @@ class Command(BaseCommand):
|
|||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('-s', '--source_dir', type=str, default="~/org")
|
||||
parser.add_argument('-f', '--folder_id', type=str,
|
||||
help="Find directory to watch by this Syncthing Folder instead of source_dir.")
|
||||
|
||||
def handle(self, *args, **kwargs):
|
||||
self.key = settings.SYNCTHING_KEY
|
||||
assert self.key != None
|
||||
self.expanded_path = pathlib.Path(kwargs['source_dir']).expanduser()
|
||||
self.folder_id = self.get_folder_id_for_path(self.expanded_path)
|
||||
logger.info(f"fetched folder ID {self.folder_id} from syncthing API")
|
||||
if "folder_id" in kwargs.keys():
|
||||
self.folder_id = kwargs['folder_id']
|
||||
self.expanded_path = self.get_path_for_folder_id(self.folder_id)
|
||||
logger.info(f"fetched folder ID {self.folder_id} AKA {self.expanded_path} from syncthing API")
|
||||
else:
|
||||
self.expanded_path = pathlib.Path(kwargs['source_dir']).expanduser()
|
||||
self.folder_id = self.get_folder_id_for_path(self.expanded_path)
|
||||
logger.info(f"fetched folder ID {self.folder_id} AKA {self.expanded_path} from syncthing API")
|
||||
#+end_src
|
||||
|
||||
it would be nice to get the pagination key from the DB to have persistence across invocations, but re-running the ingester on startup when there isn't necessarily changes isn't really that bad, it'll just cause some disk IO while it checks file hashes:
|
||||
|
@ -318,19 +325,27 @@ it would be nice to get the pagination key from the DB to have persistence acros
|
|||
)
|
||||
#+end_src
|
||||
|
||||
The =watchsync= command queries the Syncthing [[https://docs.syncthing.net/rest/config.html][Configuration API]] to pull the folder ID out:
|
||||
The =watchsync= command queries the Syncthing [[https://docs.syncthing.net/rest/config.html][Configuration API]] to pull the folder ID or path out, whichever you didn't ask for in the Command's kwargs:
|
||||
|
||||
#+begin_src python :tangle syncthonk/management/commands/watchsync.py
|
||||
def _get_folders(self):
|
||||
url = f"http://localhost:8384/rest/config/folders"
|
||||
req = urllib.request.Request(
|
||||
url,
|
||||
headers = {"X-API-Key": self.key}
|
||||
)
|
||||
rsp = urllib.request.urlopen(req)
|
||||
return json.load(rsp)
|
||||
|
||||
def get_folder_id_for_path(self, path: pathlib.Path) -> str:
|
||||
url = f"http://localhost:8384/rest/config/folders"
|
||||
req = urllib.request.Request(
|
||||
url,
|
||||
headers = {"X-API-Key": self.key}
|
||||
)
|
||||
rsp = urllib.request.urlopen(req )
|
||||
jason = json.load(rsp)
|
||||
the_folder = next(filter(lambda folder: folder["path"] == str(path), jason))
|
||||
return the_folder["id"]
|
||||
jason = self._get_folders()
|
||||
the_folder = next(filter(lambda folder: folder["path"] == str(path), jason))
|
||||
return the_folder["id"]
|
||||
|
||||
def get_path_for_folder_id(self, folder_id: str) -> pathlib.Path:
|
||||
jason = self._get_folders()
|
||||
the_folder = next(filter(lambda folder: folder["id"] == folder_id, jason))
|
||||
return pathlib.Path(the_folder["path"])
|
||||
#+end_src
|
||||
|
||||
The functionality to query the Syncthing [[https://docs.syncthing.net/rest/events-get.html#get-rest-events-disk][Events API]], extract events and filter them to decide whether the [[id:20231217T154857.983742][Arcology ingestfiles Command]] should be invoked is pretty straightforward use of =urllib=.
|
||||
|
|
|
@ -18,7 +18,12 @@ authors = [
|
|||
package-dir = {"" = "."}
|
||||
|
||||
[tool.setuptools.package-data]
|
||||
arcology = ['settings/sites.json']
|
||||
arcology = [
|
||||
'settings/sites.json',
|
||||
'templates/arcology/*',
|
||||
'static/arcology/css/*',
|
||||
'static/arcology/fonts/*',
|
||||
]
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
where = ["."]
|
||||
|
|
|
@ -30,7 +30,12 @@ authors = [
|
|||
package-dir = {"" = "."}
|
||||
|
||||
[tool.setuptools.package-data]
|
||||
arcology = ['settings/sites.json']
|
||||
arcology = [
|
||||
'settings/sites.json',
|
||||
'templates/arcology/*',
|
||||
'static/arcology/css/*',
|
||||
'static/arcology/fonts/*',
|
||||
]
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
where = ["."]
|
||||
|
@ -49,6 +54,7 @@ build-backend = "setuptools.build_meta"
|
|||
pkgs ? import <nixpkgs> {},
|
||||
lib ? pkgs.lib,
|
||||
python3,
|
||||
|
||||
arroyo_rs,
|
||||
}:
|
||||
|
||||
|
@ -192,8 +198,6 @@ result
|
|||
.direnv
|
||||
|
||||
db.sqlite3
|
||||
|
||||
static/arcology/fonts/Vulf*
|
||||
#+end_src
|
||||
|
||||
* Django bootstraps
|
||||
|
|
|
@ -22,13 +22,20 @@ class Command(BaseCommand):
|
|||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('-s', '--source_dir', type=str, default="~/org")
|
||||
parser.add_argument('-f', '--folder_id', type=str,
|
||||
help="Find directory to watch by this Syncthing Folder instead of source_dir.")
|
||||
|
||||
def handle(self, *args, **kwargs):
|
||||
self.key = settings.SYNCTHING_KEY
|
||||
assert self.key != None
|
||||
self.expanded_path = pathlib.Path(kwargs['source_dir']).expanduser()
|
||||
self.folder_id = self.get_folder_id_for_path(self.expanded_path)
|
||||
logger.info(f"fetched folder ID {self.folder_id} from syncthing API")
|
||||
if "folder_id" in kwargs.keys():
|
||||
self.folder_id = kwargs['folder_id']
|
||||
self.expanded_path = self.get_path_for_folder_id(self.folder_id)
|
||||
logger.info(f"fetched folder ID {self.folder_id} AKA {self.expanded_path} from syncthing API")
|
||||
else:
|
||||
self.expanded_path = pathlib.Path(kwargs['source_dir']).expanduser()
|
||||
self.folder_id = self.get_folder_id_for_path(self.expanded_path)
|
||||
logger.info(f"fetched folder ID {self.folder_id} AKA {self.expanded_path} from syncthing API")
|
||||
# Ingest files on-demand using Syncthing:3 ends here
|
||||
|
||||
# [[file:../../../interfaces.org::*Ingest files on-demand using Syncthing][Ingest files on-demand using Syncthing:4]]
|
||||
|
@ -43,16 +50,24 @@ class Command(BaseCommand):
|
|||
# Ingest files on-demand using Syncthing:4 ends here
|
||||
|
||||
# [[file:../../../interfaces.org::*Ingest files on-demand using Syncthing][Ingest files on-demand using Syncthing:5]]
|
||||
def _get_folders(self):
|
||||
url = f"http://localhost:8384/rest/config/folders"
|
||||
req = urllib.request.Request(
|
||||
url,
|
||||
headers = {"X-API-Key": self.key}
|
||||
)
|
||||
rsp = urllib.request.urlopen(req)
|
||||
return json.load(rsp)
|
||||
|
||||
def get_folder_id_for_path(self, path: pathlib.Path) -> str:
|
||||
url = f"http://localhost:8384/rest/config/folders"
|
||||
req = urllib.request.Request(
|
||||
url,
|
||||
headers = {"X-API-Key": self.key}
|
||||
)
|
||||
rsp = urllib.request.urlopen(req )
|
||||
jason = json.load(rsp)
|
||||
the_folder = next(filter(lambda folder: folder["path"] == str(path), jason))
|
||||
return the_folder["id"]
|
||||
jason = self._get_folders()
|
||||
the_folder = next(filter(lambda folder: folder["path"] == str(path), jason))
|
||||
return the_folder["id"]
|
||||
|
||||
def get_path_for_folder_id(self, folder_id: str) -> pathlib.Path:
|
||||
jason = self._get_folders()
|
||||
the_folder = next(filter(lambda folder: folder["id"] == folder_id, jason))
|
||||
return pathlib.Path(the_folder["path"])
|
||||
# Ingest files on-demand using Syncthing:5 ends here
|
||||
|
||||
# [[file:../../../interfaces.org::*Ingest files on-demand using Syncthing][Ingest files on-demand using Syncthing:6]]
|
||||
|
|
Loading…
Reference in New Issue