Compare commits
3 Commits
13a90d4cd5
...
011067509a
Author | SHA1 | Date |
---|---|---|
Ryan Rix | 011067509a | |
Ryan Rix | 6a9428eb85 | |
Ryan Rix | 36018ca51f |
20
arcology.org
20
arcology.org
|
@ -856,6 +856,26 @@ These rules annotate task headings by inserting an icon before them.
|
||||||
}
|
}
|
||||||
#+end_src
|
#+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
|
** Atom Feed Handler
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:ID: 20240204T234814.612917
|
:ID: 20240204T234814.612917
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# [[file:../../configuration.org::*directory configuration][directory configuration:1]]
|
# [[file:../../configuration.org::*directory configuration][directory configuration:1]]
|
||||||
import pathlib
|
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())
|
ARCOLOGY_EMACS_SNIPPETS_DIR = str(pathlib.Path("~/org/cce/").expanduser())
|
||||||
ARROYO_BASE_DIR = str(pathlib.Path("~/arroyo-nix").expanduser())
|
ARROYO_BASE_DIR = str(pathlib.Path("~/arroyo-nix").expanduser())
|
||||||
# directory configuration:1 ends here
|
# directory configuration:1 ends here
|
||||||
|
|
|
@ -71,6 +71,24 @@ section.sidebar > div.backlinks {
|
||||||
}
|
}
|
||||||
/* Org Page-specific CSS Stylings:5 ends here */
|
/* 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]] */
|
/* [[file:../../../../arcology.org::*CSS][CSS:1]] */
|
||||||
body {
|
body {
|
||||||
font-family: "Vulf Mono", monospace;
|
font-family: "Vulf Mono", monospace;
|
||||||
|
|
|
@ -333,7 +333,7 @@ LOGGING = {
|
||||||
#+BEGIN_SRC python :tangle arcology/settings/generators.py :noweb yes
|
#+BEGIN_SRC python :tangle arcology/settings/generators.py :noweb yes
|
||||||
import pathlib
|
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())
|
ARCOLOGY_EMACS_SNIPPETS_DIR = str(pathlib.Path("~/org/cce/").expanduser())
|
||||||
ARROYO_BASE_DIR = str(pathlib.Path("~/arroyo-nix").expanduser())
|
ARROYO_BASE_DIR = str(pathlib.Path("~/arroyo-nix").expanduser())
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
|
@ -6,11 +6,11 @@
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1710219899,
|
"lastModified": 1710377466,
|
||||||
"narHash": "sha256-IGWuukeJ7egGscXKDAksdPCdftqnQfsHvzQMSYq/Q84=",
|
"narHash": "sha256-7p5/TWrVgK5/DeQRKT7TgbASAzTT4ctxyvK4rkIvrf8=",
|
||||||
"ref": "refs/heads/main",
|
"ref": "refs/heads/main",
|
||||||
"rev": "1b7e71d9e6b459fbdddcd51b04bda20085e90959",
|
"rev": "0571f3369c7ee5b36ea3acd2eba1d8dd6de6115f",
|
||||||
"revCount": 161,
|
"revCount": 162,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://code.rix.si/rrix/arroyo"
|
"url": "https://code.rix.si/rrix/arroyo"
|
||||||
},
|
},
|
||||||
|
|
|
@ -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
|
#+begin_src python :tangle syncthonk/management/commands/watchsync.py
|
||||||
elif data.get("action") == "deleted":
|
elif data.get("action") == "deleted":
|
||||||
final_path = self.expanded_path.joinpath(file_path)
|
final_path = self.expanded_path.joinpath(file_path)
|
||||||
f = roam.models.File.objects.get(path=final_path)
|
try:
|
||||||
assert f
|
f = roam.models.File.objects.get(path=final_path)
|
||||||
logger.debug(f"deleting {final_path}!")
|
logger.debug(f"deleting {final_path}!")
|
||||||
f.delete()
|
f.delete()
|
||||||
ingest_this = False
|
ingest_this = False
|
||||||
|
except roam.models.File.DoesNotExist:
|
||||||
|
pass
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+begin_src python :tangle syncthonk/management/commands/watchsync.py
|
#+begin_src python :tangle syncthonk/management/commands/watchsync.py
|
||||||
|
|
35
localapi.org
35
localapi.org
|
@ -2,20 +2,19 @@
|
||||||
:ID: 20240313T153901.656967
|
:ID: 20240313T153901.656967
|
||||||
:END:
|
:END:
|
||||||
#+TITLE: A Localhost API for the Arcology
|
#+TITLE: A Localhost API for the Arcology
|
||||||
#+filetags: :Project:
|
#+FILETAGS: :Project:
|
||||||
|
|
||||||
#+ARCOLOGY_KEY: arcology/localapi
|
#+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.
|
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.
|
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
|
* 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
|
#+begin_src python :tangle localapi/urls.py :mkdirp yes
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
@ -93,6 +92,8 @@ def authenticated(func):
|
||||||
|
|
||||||
* Keyword metadata
|
* 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
|
#+begin_src python :tangle localapi/views.py
|
||||||
import roam.models
|
import roam.models
|
||||||
|
|
||||||
|
@ -105,6 +106,8 @@ def _json_keywords(keywords):
|
||||||
|
|
||||||
** /keywords/{key}
|
** /keywords/{key}
|
||||||
|
|
||||||
|
=GET http://127.0.0.1:8000/api/v1/keywords/ARCOLOGY_KEY=
|
||||||
|
|
||||||
#+begin_src python :tangle localapi/views.py
|
#+begin_src python :tangle localapi/views.py
|
||||||
@authenticated
|
@authenticated
|
||||||
def keyword_by_key(request, key):
|
def keyword_by_key(request, key):
|
||||||
|
@ -118,6 +121,8 @@ def keyword_by_key(request, key):
|
||||||
|
|
||||||
** /keywords/{key}/{value}
|
** /keywords/{key}/{value}
|
||||||
|
|
||||||
|
=GET http://127.0.0.1:8000/api/v1/keywords/ARCOLOGY_KEY/arcology/localapi=
|
||||||
|
|
||||||
#+begin_src python :tangle localapi/views.py
|
#+begin_src python :tangle localapi/views.py
|
||||||
@authenticated
|
@authenticated
|
||||||
def keyword_by_key_value(request, key, value):
|
def keyword_by_key_value(request, key, value):
|
||||||
|
@ -132,6 +137,8 @@ def keyword_by_key_value(request, key, value):
|
||||||
|
|
||||||
* Page and File metadata
|
* 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
|
#+begin_src python :tangle localapi/views.py
|
||||||
import arcology.models
|
import arcology.models
|
||||||
|
|
||||||
|
@ -143,6 +150,8 @@ def _json_page(page):
|
||||||
)
|
)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
=GET http://127.0.0.1:8000/api/v1/page/arcology/localapi=
|
||||||
|
|
||||||
#+begin_src python :tangle localapi/views.py
|
#+begin_src python :tangle localapi/views.py
|
||||||
@authenticated
|
@authenticated
|
||||||
def page_metadata(request, route_key):
|
def page_metadata(request, route_key):
|
||||||
|
@ -157,10 +166,15 @@ def page_metadata(request, route_key):
|
||||||
))
|
))
|
||||||
#+end_src
|
#+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
|
#+begin_src python :tangle localapi/views.py
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
@authenticated
|
@authenticated
|
||||||
def file_metadata(request, file_path):
|
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()
|
page = the_file.page_set.first()
|
||||||
return JsonResponse(dict(
|
return JsonResponse(dict(
|
||||||
state="ok :)",
|
state="ok :)",
|
||||||
|
@ -172,11 +186,12 @@ def file_metadata(request, file_path):
|
||||||
))
|
))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
* NEXT [[id:20221021T150631.404359][Arroyo Nix Library Helpers]]
|
|
||||||
emacs-lisp code along with the endpoints
|
|
||||||
|
|
||||||
* NEXT [[id:20231217T154938.132553][Arcology generate Command]]
|
* 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]]
|
* 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
|
bearer token setup and all that
|
||||||
|
|
||||||
|
|
||||||
|
this thing now needs to run as a systemd user unit!
|
||||||
|
|
|
@ -77,9 +77,12 @@ def page_metadata(request, route_key):
|
||||||
# Page and File metadata:2 ends here
|
# Page and File metadata:2 ends here
|
||||||
|
|
||||||
# [[file:../localapi.org::*Page and File metadata][Page and File metadata:3]]
|
# [[file:../localapi.org::*Page and File metadata][Page and File metadata:3]]
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
@authenticated
|
@authenticated
|
||||||
def file_metadata(request, file_path):
|
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()
|
page = the_file.page_set.first()
|
||||||
return JsonResponse(dict(
|
return JsonResponse(dict(
|
||||||
state="ok :)",
|
state="ok :)",
|
||||||
|
|
|
@ -111,11 +111,13 @@ class Command(BaseCommand):
|
||||||
# [[file:../../../interfaces.org::*Ingest files on-demand using Syncthing][Ingest files on-demand using Syncthing:8]]
|
# [[file:../../../interfaces.org::*Ingest files on-demand using Syncthing][Ingest files on-demand using Syncthing:8]]
|
||||||
elif data.get("action") == "deleted":
|
elif data.get("action") == "deleted":
|
||||||
final_path = self.expanded_path.joinpath(file_path)
|
final_path = self.expanded_path.joinpath(file_path)
|
||||||
f = roam.models.File.objects.get(path=final_path)
|
try:
|
||||||
assert f
|
f = roam.models.File.objects.get(path=final_path)
|
||||||
logger.debug(f"deleting {final_path}!")
|
logger.debug(f"deleting {final_path}!")
|
||||||
f.delete()
|
f.delete()
|
||||||
ingest_this = False
|
ingest_this = False
|
||||||
|
except roam.models.File.DoesNotExist:
|
||||||
|
pass
|
||||||
# Ingest files on-demand using Syncthing:8 ends here
|
# 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]]
|
# [[file:../../../interfaces.org::*Ingest files on-demand using Syncthing][Ingest files on-demand using Syncthing:9]]
|
||||||
|
|
Loading…
Reference in New Issue