Compare commits

...

3 Commits

9 changed files with 87 additions and 27 deletions

View File

@ -856,6 +856,26 @@ These rules annotate task headings by inserting an icon before them.
}
#+end_src
This will display the header arguments to =org-babel= source blocks: You're staring right at one!
#+begin_src css :tangle arcology/static/arcology/css/app.css :mkdirp yes
span.babel-args {
text-align: right;
display: block;
}
span.babel-args::before {
max-width: 800px;
width: 50%;
height: 1px;
text-align: left;
vertical-align: middle;
background: var(--dark-gray);
content: "";
display: inline-block;
}
#+end_src
** Atom Feed Handler
:PROPERTIES:
:ID: 20240204T234814.612917

View File

@ -1,7 +1,7 @@
# [[file:../../configuration.org::*directory configuration][directory configuration:1]]
import pathlib
ARCOLOGY_BASE_DIR = str(pathlib.Path("~/org").expanduser())
ARCOLOGY_BASE_DIR = pathlib.Path("~/org").expanduser()
ARCOLOGY_EMACS_SNIPPETS_DIR = str(pathlib.Path("~/org/cce/").expanduser())
ARROYO_BASE_DIR = str(pathlib.Path("~/arroyo-nix").expanduser())
# directory configuration:1 ends here

View File

@ -71,6 +71,24 @@ section.sidebar > div.backlinks {
}
/* Org Page-specific CSS Stylings:5 ends here */
/* [[file:../../../../arcology.org::*Org Page-specific CSS Stylings][Org Page-specific CSS Stylings:6]] */
span.babel-args {
text-align: right;
display: block;
}
span.babel-args::before {
max-width: 800px;
width: 50%;
height: 1px;
text-align: left;
vertical-align: middle;
background: var(--dark-gray);
content: "";
display: inline-block;
}
/* Org Page-specific CSS Stylings:6 ends here */
/* [[file:../../../../arcology.org::*CSS][CSS:1]] */
body {
font-family: "Vulf Mono", monospace;

View File

@ -333,7 +333,7 @@ LOGGING = {
#+BEGIN_SRC python :tangle arcology/settings/generators.py :noweb yes
import pathlib
ARCOLOGY_BASE_DIR = str(pathlib.Path("~/org").expanduser())
ARCOLOGY_BASE_DIR = pathlib.Path("~/org").expanduser()
ARCOLOGY_EMACS_SNIPPETS_DIR = str(pathlib.Path("~/org/cce/").expanduser())
ARROYO_BASE_DIR = str(pathlib.Path("~/arroyo-nix").expanduser())
#+END_SRC

View File

@ -6,11 +6,11 @@
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1710219899,
"narHash": "sha256-IGWuukeJ7egGscXKDAksdPCdftqnQfsHvzQMSYq/Q84=",
"lastModified": 1710377466,
"narHash": "sha256-7p5/TWrVgK5/DeQRKT7TgbASAzTT4ctxyvK4rkIvrf8=",
"ref": "refs/heads/main",
"rev": "1b7e71d9e6b459fbdddcd51b04bda20085e90959",
"revCount": 161,
"rev": "0571f3369c7ee5b36ea3acd2eba1d8dd6de6115f",
"revCount": 162,
"type": "git",
"url": "https://code.rix.si/rrix/arroyo"
},

View File

@ -400,11 +400,13 @@ If a file is deleted, make sure it's removed from the database. Note that this i
#+begin_src python :tangle syncthonk/management/commands/watchsync.py
elif data.get("action") == "deleted":
final_path = self.expanded_path.joinpath(file_path)
f = roam.models.File.objects.get(path=final_path)
assert f
logger.debug(f"deleting {final_path}!")
f.delete()
ingest_this = False
try:
f = roam.models.File.objects.get(path=final_path)
logger.debug(f"deleting {final_path}!")
f.delete()
ingest_this = False
except roam.models.File.DoesNotExist:
pass
#+end_src
#+begin_src python :tangle syncthonk/management/commands/watchsync.py

View File

@ -2,20 +2,19 @@
:ID: 20240313T153901.656967
:END:
#+TITLE: A Localhost API for the Arcology
#+filetags: :Project:
#+FILETAGS: :Project:
#+ARCOLOGY_KEY: arcology/localapi
#+ARCOLOGY_ALLOW_CRAWL: nil
By moving the database out of EmacSQL and in to Django, I have hobbled some of the Arcology's [[id:knowledge_base][Knowledge Management]] [[id:e79d4cdc-082f-4b1d-ae08-d979802f09ee][Living Systems]] and meta-cognitive skills. =arroyo-db-query= no longer existing means that things like the [[id:20230526T105534.711282][Direnv arroyo-db integration]] stopped working, and the helpers in [[id:cce/my_nixos_configuration][My NixOS configuration]] and elsewhere rely on the stringly-typed [[id:20231217T154938.132553][Arcology generate Command]] and a =nix run= invocation to function.
I think it's worth building a small HTTP JSON API which can serve some of the common queries, to at least see if it's worth the trouble.
I think it's worth building a small HTTP JSON API which can serve some of the common queries, to at least see if it's worth the trouble..
I probably should use Django REST Framework for this, but. I'm just gonna beat two stones together until a JSON API falls out. This will probably change the first time I add a =POST= call or want to do more complex auth stuff.
* Server view scaffolding
URLs and basic imports... nothing to concern yourself with, probably.
These are URLs and basic imports... nothing to concern yourself with, probably!
#+begin_src python :tangle localapi/urls.py :mkdirp yes
from django.contrib import admin
@ -93,6 +92,8 @@ def authenticated(func):
* Keyword metadata
There is a simple set of HTTP GET APIs to query the file/key/value store:
#+begin_src python :tangle localapi/views.py
import roam.models
@ -105,6 +106,8 @@ def _json_keywords(keywords):
** /keywords/{key}
=GET http://127.0.0.1:8000/api/v1/keywords/ARCOLOGY_KEY=
#+begin_src python :tangle localapi/views.py
@authenticated
def keyword_by_key(request, key):
@ -118,6 +121,8 @@ def keyword_by_key(request, key):
** /keywords/{key}/{value}
=GET http://127.0.0.1:8000/api/v1/keywords/ARCOLOGY_KEY/arcology/localapi=
#+begin_src python :tangle localapi/views.py
@authenticated
def keyword_by_key_value(request, key, value):
@ -132,6 +137,8 @@ def keyword_by_key_value(request, key, value):
* Page and File metadata
And some really simple APIs to get information about =Page= and =File= objects out of the database:
#+begin_src python :tangle localapi/views.py
import arcology.models
@ -143,6 +150,8 @@ def _json_page(page):
)
#+end_src
=GET http://127.0.0.1:8000/api/v1/page/arcology/localapi=
#+begin_src python :tangle localapi/views.py
@authenticated
def page_metadata(request, route_key):
@ -157,10 +166,15 @@ def page_metadata(request, route_key):
))
#+end_src
=GET http://127.0.0.1:8000/api/v1/file/arcology-django/localapi.org= (yes, there is a double-slash there. it's a full path *after* the
#+begin_src python :tangle localapi/views.py
from django.conf import settings
@authenticated
def file_metadata(request, file_path):
the_file = roam.models.File.objects.get(path=file_path)
final_path = settings.ARCOLOGY_BASE_DIR.joinpath(file_path)
the_file = roam.models.File.objects.get(path=final_path)
page = the_file.page_set.first()
return JsonResponse(dict(
state="ok :)",
@ -172,11 +186,12 @@ def file_metadata(request, file_path):
))
#+end_src
* NEXT [[id:20221021T150631.404359][Arroyo Nix Library Helpers]]
emacs-lisp code along with the endpoints
* NEXT [[id:20231217T154938.132553][Arcology generate Command]]
emacs-lisp code along with the endpoints
emacs-lisp code along with the HTTP endpoints to populate things from the Generators
* NEXT NixOS deployment for endpoints in [[id:cce/my_nixos_configuration][My NixOS configuration]] or rather [[id:cce/home-manager][home-manager]]
bearer token setup and all that
this thing now needs to run as a systemd user unit!

View File

@ -77,9 +77,12 @@ def page_metadata(request, route_key):
# Page and File metadata:2 ends here
# [[file:../localapi.org::*Page and File metadata][Page and File metadata:3]]
from django.conf import settings
@authenticated
def file_metadata(request, file_path):
the_file = roam.models.File.objects.get(path=file_path)
final_path = settings.ARCOLOGY_BASE_DIR.joinpath(file_path)
the_file = roam.models.File.objects.get(path=final_path)
page = the_file.page_set.first()
return JsonResponse(dict(
state="ok :)",

View File

@ -111,11 +111,13 @@ class Command(BaseCommand):
# [[file:../../../interfaces.org::*Ingest files on-demand using Syncthing][Ingest files on-demand using Syncthing:8]]
elif data.get("action") == "deleted":
final_path = self.expanded_path.joinpath(file_path)
f = roam.models.File.objects.get(path=final_path)
assert f
logger.debug(f"deleting {final_path}!")
f.delete()
ingest_this = False
try:
f = roam.models.File.objects.get(path=final_path)
logger.debug(f"deleting {final_path}!")
f.delete()
ingest_this = False
except roam.models.File.DoesNotExist:
pass
# Ingest files on-demand using Syncthing:8 ends here
# [[file:../../../interfaces.org::*Ingest files on-demand using Syncthing][Ingest files on-demand using Syncthing:9]]