mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-24 19:54:25 -04:00
add BaseHook concept to underlie all Plugin hooks
This commit is contained in:
parent
ed5357cec9
commit
44669fab73
12 changed files with 212 additions and 79 deletions
|
@ -254,7 +254,7 @@ class ArchiveResultInline(admin.TabularInline):
|
|||
try:
|
||||
return self.parent_model.objects.get(pk=resolved.kwargs['object_id'])
|
||||
except (self.parent_model.DoesNotExist, ValidationError):
|
||||
return self.parent_model.objects.get(abid=self.parent_model.abid_prefix + resolved.kwargs['object_id'].split('_', 1)[-1])
|
||||
return self.parent_model.objects.get(pk=self.parent_model.id_from_abid(resolved.kwargs['object_id']))
|
||||
|
||||
@admin.display(
|
||||
description='Completed',
|
||||
|
@ -685,6 +685,7 @@ class ArchiveResultAdmin(ABIDModelAdmin):
|
|||
list_per_page = CONFIG.SNAPSHOTS_PER_PAGE
|
||||
|
||||
paginator = AccelleratedPaginator
|
||||
save_on_top = True
|
||||
|
||||
def change_view(self, request, object_id, form_url="", extra_context=None):
|
||||
self.request = request
|
||||
|
|
|
@ -103,7 +103,7 @@ class Tag(ABIDModel):
|
|||
@property
|
||||
def api_url(self) -> str:
|
||||
# /api/v1/core/snapshot/{uulid}
|
||||
return reverse_lazy('api-1:get_tag', args=[self.abid])
|
||||
return reverse_lazy('api-1:get_tag', args=[self.abid]) # + f'?api_key={get_or_create_api_token(request.user)}'
|
||||
|
||||
@property
|
||||
def api_docs_url(self) -> str:
|
||||
|
@ -211,12 +211,15 @@ class Snapshot(ABIDModel):
|
|||
@property
|
||||
def api_url(self) -> str:
|
||||
# /api/v1/core/snapshot/{uulid}
|
||||
return reverse_lazy('api-1:get_snapshot', args=[self.abid])
|
||||
return reverse_lazy('api-1:get_snapshot', 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_snapshot'
|
||||
|
||||
def get_absolute_url(self):
|
||||
return f'/{self.archive_path}'
|
||||
|
||||
@cached_property
|
||||
def title_stripped(self) -> str:
|
||||
return (self.title or '').replace("\n", " ").replace("\r", "")
|
||||
|
@ -476,11 +479,14 @@ class ArchiveResult(ABIDModel):
|
|||
@property
|
||||
def api_url(self) -> str:
|
||||
# /api/v1/core/archiveresult/{uulid}
|
||||
return reverse_lazy('api-1:get_archiveresult', args=[self.abid])
|
||||
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'
|
||||
|
||||
def get_absolute_url(self):
|
||||
return f'/{self.snapshot.archive_path}/{self.output_path()}'
|
||||
|
||||
@property
|
||||
def extractor_module(self):
|
||||
|
|
|
@ -40,6 +40,7 @@ INSTALLED_PLUGINS = {
|
|||
|
||||
### Plugins Globals (filled by plugantic.apps.load_plugins() after Django startup)
|
||||
PLUGINS = AttrDict({})
|
||||
HOOKS = AttrDict({})
|
||||
|
||||
CONFIGS = AttrDict({})
|
||||
BINPROVIDERS = AttrDict({})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue