mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-30 06:25:28 -04:00
cleanup plugantic and pkg apps, make BaseHook actually create its own settings
This commit is contained in:
parent
0e79a8b683
commit
b56b1cac35
29 changed files with 272 additions and 466 deletions
|
@ -1,7 +1,7 @@
|
|||
__package__ = 'archivebox.core'
|
||||
|
||||
|
||||
from typing import Optional, List, Dict, Iterable
|
||||
from typing import Optional, Dict, Iterable
|
||||
from django_stubs_ext.db.models import TypedModelMeta
|
||||
|
||||
import json
|
||||
|
@ -9,7 +9,6 @@ import json
|
|||
from pathlib import Path
|
||||
|
||||
from django.db import models
|
||||
from django.utils import timezone
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.text import slugify
|
||||
from django.core.cache import cache
|
||||
|
@ -107,7 +106,7 @@ class Tag(ABIDModel):
|
|||
|
||||
@property
|
||||
def api_docs_url(self) -> str:
|
||||
return f'/api/v1/docs#/Core%20Models/api_v1_core_get_tag'
|
||||
return '/api/v1/docs#/Core%20Models/api_v1_core_get_tag'
|
||||
|
||||
class SnapshotTag(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
|
@ -215,7 +214,7 @@ class Snapshot(ABIDModel):
|
|||
|
||||
@property
|
||||
def api_docs_url(self) -> str:
|
||||
return f'/api/v1/docs#/Core%20Models/api_v1_core_get_snapshot'
|
||||
return '/api/v1/docs#/Core%20Models/api_v1_core_get_snapshot'
|
||||
|
||||
def get_absolute_url(self):
|
||||
return f'/{self.archive_path}'
|
||||
|
@ -315,7 +314,7 @@ class Snapshot(ABIDModel):
|
|||
def latest_title(self) -> Optional[str]:
|
||||
if self.title:
|
||||
return self.title # whoopdedoo that was easy
|
||||
|
||||
|
||||
# check if ArchiveResult set has already been prefetched, if so use it instead of fetching it from db again
|
||||
if hasattr(self, '_prefetched_objects_cache') and 'archiveresult_set' in self._prefetched_objects_cache:
|
||||
try:
|
||||
|
@ -329,7 +328,7 @@ class Snapshot(ABIDModel):
|
|||
) or [None])[-1]
|
||||
except IndexError:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
try:
|
||||
# take longest successful title from ArchiveResult db history
|
||||
|
@ -395,7 +394,7 @@ class Snapshot(ABIDModel):
|
|||
class ArchiveResultManager(models.Manager):
|
||||
def indexable(self, sorted: bool = True):
|
||||
"""Return only ArchiveResults containing text suitable for full-text search (sorted in order of typical result quality)"""
|
||||
|
||||
|
||||
INDEXABLE_METHODS = [ r[0] for r in ARCHIVE_METHODS_INDEXING_PRECEDENCE ]
|
||||
qs = self.get_queryset().filter(extractor__in=INDEXABLE_METHODS, status='succeeded')
|
||||
|
||||
|
@ -466,7 +465,7 @@ class ArchiveResult(ABIDModel):
|
|||
class Meta(TypedModelMeta):
|
||||
verbose_name = 'Archive Result'
|
||||
verbose_name_plural = 'Archive Results Log'
|
||||
|
||||
|
||||
|
||||
def __str__(self):
|
||||
# return f'[{self.abid}] 📅 {self.start_ts.strftime("%Y-%m-%d %H:%M")} 📄 {self.extractor} {self.snapshot.url}'
|
||||
|
@ -480,11 +479,11 @@ class ArchiveResult(ABIDModel):
|
|||
def api_url(self) -> str:
|
||||
# /api/v1/core/archiveresult/{uulid}
|
||||
return reverse_lazy('api-1:get_archiveresult', args=[self.abid]) # + f'?api_key={get_or_create_api_token(request.user)}'
|
||||
|
||||
|
||||
@property
|
||||
def api_docs_url(self) -> str:
|
||||
return f'/api/v1/docs#/Core%20Models/api_v1_core_get_archiveresult'
|
||||
|
||||
return '/api/v1/docs#/Core%20Models/api_v1_core_get_archiveresult'
|
||||
|
||||
def get_absolute_url(self):
|
||||
return f'/{self.snapshot.archive_path}/{self.output_path()}'
|
||||
|
||||
|
|
|
@ -40,27 +40,18 @@ INSTALLED_PLUGINS = {
|
|||
**find_plugins_in_dir(USERDATA_PLUGINS_DIR, prefix='user_plugins'),
|
||||
}
|
||||
|
||||
### Plugins Globals (filled by plugantic.apps.load_plugins() after Django startup)
|
||||
### Plugins Globals (filled by builtin_plugins.npm.apps.NpmPlugin.register() after Django startup)
|
||||
PLUGINS = AttrDict({})
|
||||
HOOKS = AttrDict({})
|
||||
|
||||
CONFIGS = AttrDict({})
|
||||
BINPROVIDERS = AttrDict({})
|
||||
BINARIES = AttrDict({})
|
||||
EXTRACTORS = AttrDict({})
|
||||
REPLAYERS = AttrDict({})
|
||||
CHECKS = AttrDict({})
|
||||
ADMINDATAVIEWS = AttrDict({})
|
||||
# CONFIGS = AttrDict({})
|
||||
# BINPROVIDERS = AttrDict({})
|
||||
# BINARIES = AttrDict({})
|
||||
# EXTRACTORS = AttrDict({})
|
||||
# REPLAYERS = AttrDict({})
|
||||
# CHECKS = AttrDict({})
|
||||
# ADMINDATAVIEWS = AttrDict({})
|
||||
|
||||
PLUGIN_KEYS = AttrDict({
|
||||
'CONFIGS': CONFIGS,
|
||||
'BINPROVIDERS': BINPROVIDERS,
|
||||
'BINARIES': BINARIES,
|
||||
'EXTRACTORS': EXTRACTORS,
|
||||
'REPLAYERS': REPLAYERS,
|
||||
'CHECKS': CHECKS,
|
||||
'ADMINDATAVIEWS': ADMINDATAVIEWS,
|
||||
})
|
||||
|
||||
################################################################################
|
||||
### Django Core Settings
|
||||
|
@ -95,12 +86,11 @@ INSTALLED_APPS = [
|
|||
'signal_webhooks', # handles REST API outbound webhooks https://github.com/MrThearMan/django-signal-webhooks
|
||||
'django_object_actions', # provides easy Django Admin action buttons on change views https://github.com/crccheck/django-object-actions
|
||||
|
||||
# our own apps
|
||||
# Our ArchiveBox-provided apps
|
||||
'abid_utils', # handles ABID ID creation, handling, and models
|
||||
'plugantic', # ArchiveBox plugin API definition + finding/registering/calling interface
|
||||
'core', # core django model with Snapshot, ArchiveResult, etc.
|
||||
'api', # Django-Ninja-based Rest API interfaces, config, APIToken model, etc.
|
||||
'pkg', # ArchiveBox runtime package management interface for subdependencies
|
||||
|
||||
# ArchiveBox plugins
|
||||
*INSTALLED_PLUGINS.keys(), # all plugin django-apps found in archivebox/builtin_plugins and data/user_plugins
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue