Compare commits
3 Commits
b56ca47eb7
...
3bcc81c36f
Author | SHA1 | Date |
---|---|---|
Ryan Rix | 3bcc81c36f | |
Ryan Rix | cf283d1cc2 | |
Ryan Rix | bbd0abc8db |
|
@ -147,6 +147,8 @@ AUTH_PASSWORD_VALIDATORS = [
|
|||
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
|
||||
},
|
||||
]
|
||||
|
||||
CSRF_TRUSTED_ORIGINS = list(map(lambda it: f"https://{it}", "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(',')))
|
||||
# Look don't worry about the rest of these:1 ends here
|
||||
|
||||
# [[file:../../configuration.org::*Look don't worry about the rest of these][Look don't worry about the rest of these:2]]
|
||||
|
|
|
@ -504,6 +504,7 @@ AUTH_PASSWORD_VALIDATORS = [
|
|||
},
|
||||
]
|
||||
|
||||
CSRF_TRUSTED_ORIGINS = list(map(lambda it: f"https://{it}", "<<get_allowed_hosts()>>".split(',')))
|
||||
#+END_SRC
|
||||
|
||||
#+BEGIN_SRC python :tangle arcology/settings/__init__.py :noweb yes
|
||||
|
|
|
@ -71,6 +71,11 @@ let
|
|||
Group = "arcology";
|
||||
WorkingDirectory = cfg.dataDir;
|
||||
EnvironmentFile = cfg.environmentFile;
|
||||
|
||||
Restart="on-failure";
|
||||
RestartSec=5;
|
||||
RestartSteps=10;
|
||||
RestartMaxDelay="1min";
|
||||
# hardening...
|
||||
};
|
||||
};
|
||||
|
@ -88,6 +93,11 @@ let
|
|||
Group = "arcology";
|
||||
WorkingDirectory = cfg.dataDir;
|
||||
EnvironmentFile = cfg.environmentFile;
|
||||
|
||||
Restart="on-failure";
|
||||
RestartSec=5;
|
||||
RestartSteps=10;
|
||||
RestartMaxDelay="1min";
|
||||
# hardening...
|
||||
};
|
||||
};
|
||||
|
|
|
@ -12,7 +12,7 @@ talk about what these modules are used to do, show the management commands from
|
|||
|
||||
* Arroyo Generator Data Models
|
||||
|
||||
** NEXT document the Generator pattern described by the Abstract Base Class.
|
||||
** NEXT document the Generator pattern described by the Abstract Base Class.
|
||||
|
||||
#+begin_src python :tangle generators/models.py
|
||||
from __future__ import annotations
|
||||
|
|
60
roam.org
60
roam.org
|
@ -4,6 +4,7 @@
|
|||
:END:
|
||||
#+TITLE: Arcology Roam Models
|
||||
#+filetags: :Project:
|
||||
|
||||
#+ARCOLOGY_KEY: arcology/django/roam
|
||||
|
||||
#+BEGIN_SRC python :tangle roam/__init__.py
|
||||
|
@ -477,12 +478,6 @@ class Link(EMOM('link'), models.Model):
|
|||
related_name="outbound_links",
|
||||
on_delete=models.CASCADE,
|
||||
)
|
||||
# dest_file = models.ForeignKey(
|
||||
# File,
|
||||
# related_name="inbound_links",
|
||||
# on_delete=models.CASCADE,
|
||||
# null=True, default=None,
|
||||
# )
|
||||
source_heading = models.ForeignKey(
|
||||
Heading,
|
||||
related_name="outbound_links",
|
||||
|
@ -492,13 +487,16 @@ class Link(EMOM('link'), models.Model):
|
|||
dest_heading = models.ForeignKey(
|
||||
Heading,
|
||||
related_name="inbound_links",
|
||||
on_delete=models.CASCADE,
|
||||
on_delete=models.DO_NOTHING,
|
||||
db_constraint=False,
|
||||
null=True,
|
||||
default=None,
|
||||
to_field="node_id",
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"<Link (from: {self.source_heading_id}, to: {self.dest_heading_id}, text: {self.title})>"
|
||||
|
||||
def to_backlink_html(self) -> str:
|
||||
try:
|
||||
h = self.source_heading
|
||||
|
@ -510,32 +508,35 @@ class Link(EMOM('link'), models.Model):
|
|||
logger.info(f"{self} does not have dest heading.")
|
||||
return f'''<a class="dead-link" href="/404?text={self.title|iriencode}">{self.title}</a>'''
|
||||
|
||||
|
||||
@classmethod
|
||||
def create_from_arroyo(cls, doc: native.Document) -> List[Link]:
|
||||
heading_trail = []
|
||||
ret = []
|
||||
for heading in doc.headings:
|
||||
if heading.id is not None:
|
||||
for link in heading.links or []:
|
||||
if link.to_proto == "id":
|
||||
logger.debug(f"link: {link}")
|
||||
logger.debug(f"dest: {link.to}")
|
||||
# reset breadcrumb trail
|
||||
heading_trail = heading_trail[(heading.level-1):]
|
||||
heading_trail += [heading.id]
|
||||
for link in heading.links or []:
|
||||
if link.to_proto == "id":
|
||||
logger.debug(f"link: {link}")
|
||||
logger.debug(f"dest: {link.to}")
|
||||
|
||||
obj = cls(title=(link.text or ""))
|
||||
obj.source_file = File.objects.get(path=doc.path)
|
||||
obj.source_heading = Heading.objects.get(node_id=heading.id)
|
||||
# fudge this since we may be linking to Headings which are not yet indexed
|
||||
# dest_heading = Heading.objects.get(node_id=dest_id)
|
||||
# obj.dest_file = dest_heading.path
|
||||
obj.dest_heading_id = link.to
|
||||
logger.debug(f"save maybe {obj}")
|
||||
obj.save()
|
||||
ret.append(obj)
|
||||
else:
|
||||
# create a pseudo-link or a link that can be resolved using Reference?
|
||||
# dest_id = ""
|
||||
# dest_file = link.to
|
||||
logger.warn(f"Skipping non-id link {link}")
|
||||
obj = cls(title=(link.text or ""))
|
||||
obj.source_file = File.objects.get(path=doc.path)
|
||||
obj.source_heading = Heading.objects.get(node_id=heading_trail[-1:][0])
|
||||
# fudge this since we may be linking to Headings which are not yet indexed
|
||||
# dest_heading = Heading.objects.get(node_id=dest_id)
|
||||
# obj.dest_file = dest_heading.path
|
||||
obj.dest_heading_id = link.to
|
||||
logger.warn(f"save maybe {obj}")
|
||||
obj.save()
|
||||
ret.append(obj)
|
||||
else:
|
||||
# create a pseudo-link or a link that can be resolved using Reference?
|
||||
# dest_id = ""
|
||||
# dest_file = link.to
|
||||
logger.warn(f"Skipping non-id link {link}")
|
||||
|
||||
return ret
|
||||
#+END_SRC
|
||||
|
@ -884,6 +885,10 @@ class KeywordInline(admin.TabularInline):
|
|||
class HeadingInline(admin.TabularInline):
|
||||
model = roam.models.Heading
|
||||
|
||||
class LinkInline(admin.TabularInline):
|
||||
model = roam.models.Link
|
||||
fk_name = "source_heading"
|
||||
|
||||
class PropertyInline(admin.TabularInline):
|
||||
model = roam.models.HeadingProperty
|
||||
|
||||
|
@ -925,6 +930,7 @@ class HeadingAdmin(admin.ModelAdmin):
|
|||
TagInline,
|
||||
ReferenceInline,
|
||||
PropertyInline,
|
||||
LinkInline,
|
||||
]
|
||||
|
||||
admin.site.register(roam.models.Link)
|
||||
|
|
|
@ -10,6 +10,10 @@ class KeywordInline(admin.TabularInline):
|
|||
class HeadingInline(admin.TabularInline):
|
||||
model = roam.models.Heading
|
||||
|
||||
class LinkInline(admin.TabularInline):
|
||||
model = roam.models.Link
|
||||
fk_name = "source_heading"
|
||||
|
||||
class PropertyInline(admin.TabularInline):
|
||||
model = roam.models.HeadingProperty
|
||||
|
||||
|
@ -51,6 +55,7 @@ class HeadingAdmin(admin.ModelAdmin):
|
|||
TagInline,
|
||||
ReferenceInline,
|
||||
PropertyInline,
|
||||
LinkInline,
|
||||
]
|
||||
|
||||
admin.site.register(roam.models.Link)
|
||||
|
|
|
@ -198,12 +198,6 @@ class Link(EMOM('link'), models.Model):
|
|||
related_name="outbound_links",
|
||||
on_delete=models.CASCADE,
|
||||
)
|
||||
# dest_file = models.ForeignKey(
|
||||
# File,
|
||||
# related_name="inbound_links",
|
||||
# on_delete=models.CASCADE,
|
||||
# null=True, default=None,
|
||||
# )
|
||||
source_heading = models.ForeignKey(
|
||||
Heading,
|
||||
related_name="outbound_links",
|
||||
|
@ -213,13 +207,16 @@ class Link(EMOM('link'), models.Model):
|
|||
dest_heading = models.ForeignKey(
|
||||
Heading,
|
||||
related_name="inbound_links",
|
||||
on_delete=models.CASCADE,
|
||||
on_delete=models.DO_NOTHING,
|
||||
db_constraint=False,
|
||||
null=True,
|
||||
default=None,
|
||||
to_field="node_id",
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"<Link (from: {self.source_heading_id}, to: {self.dest_heading_id}, text: {self.title})>"
|
||||
|
||||
def to_backlink_html(self) -> str:
|
||||
try:
|
||||
h = self.source_heading
|
||||
|
@ -231,32 +228,35 @@ class Link(EMOM('link'), models.Model):
|
|||
logger.info(f"{self} does not have dest heading.")
|
||||
return f'''<a class="dead-link" href="/404?text={self.title|iriencode}">{self.title}</a>'''
|
||||
|
||||
|
||||
@classmethod
|
||||
def create_from_arroyo(cls, doc: native.Document) -> List[Link]:
|
||||
heading_trail = []
|
||||
ret = []
|
||||
for heading in doc.headings:
|
||||
if heading.id is not None:
|
||||
for link in heading.links or []:
|
||||
if link.to_proto == "id":
|
||||
logger.debug(f"link: {link}")
|
||||
logger.debug(f"dest: {link.to}")
|
||||
# reset breadcrumb trail
|
||||
heading_trail = heading_trail[(heading.level-1):]
|
||||
heading_trail += [heading.id]
|
||||
for link in heading.links or []:
|
||||
if link.to_proto == "id":
|
||||
logger.debug(f"link: {link}")
|
||||
logger.debug(f"dest: {link.to}")
|
||||
|
||||
obj = cls(title=(link.text or ""))
|
||||
obj.source_file = File.objects.get(path=doc.path)
|
||||
obj.source_heading = Heading.objects.get(node_id=heading.id)
|
||||
# fudge this since we may be linking to Headings which are not yet indexed
|
||||
# dest_heading = Heading.objects.get(node_id=dest_id)
|
||||
# obj.dest_file = dest_heading.path
|
||||
obj.dest_heading_id = link.to
|
||||
logger.debug(f"save maybe {obj}")
|
||||
obj.save()
|
||||
ret.append(obj)
|
||||
else:
|
||||
# create a pseudo-link or a link that can be resolved using Reference?
|
||||
# dest_id = ""
|
||||
# dest_file = link.to
|
||||
logger.warn(f"Skipping non-id link {link}")
|
||||
obj = cls(title=(link.text or ""))
|
||||
obj.source_file = File.objects.get(path=doc.path)
|
||||
obj.source_heading = Heading.objects.get(node_id=heading_trail[-1:][0])
|
||||
# fudge this since we may be linking to Headings which are not yet indexed
|
||||
# dest_heading = Heading.objects.get(node_id=dest_id)
|
||||
# obj.dest_file = dest_heading.path
|
||||
obj.dest_heading_id = link.to
|
||||
logger.warn(f"save maybe {obj}")
|
||||
obj.save()
|
||||
ret.append(obj)
|
||||
else:
|
||||
# create a pseudo-link or a link that can be resolved using Reference?
|
||||
# dest_id = ""
|
||||
# dest_file = link.to
|
||||
logger.warn(f"Skipping non-id link {link}")
|
||||
|
||||
return ret
|
||||
# Link:1 ends here
|
||||
|
|
Loading…
Reference in New Issue