From ed13ec7655c3d262ef937d3d3a225a90f79e1150 Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Sat, 30 Jan 2021 05:34:19 -0500 Subject: [PATCH 1/5] remove active theme --- archivebox/config.py | 6 ++---- archivebox/config_stubs.py | 1 - archivebox/core/settings.py | 8 +++----- archivebox/main.py | 3 +-- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/archivebox/config.py b/archivebox/config.py index dc014ed5..7fd4b2fc 100644 --- a/archivebox/config.py +++ b/archivebox/config.py @@ -76,7 +76,6 @@ CONFIG_SCHEMA: Dict[str, ConfigDefaultDict] = { 'PUBLIC_SNAPSHOTS': {'type': bool, 'default': True}, 'PUBLIC_ADD_VIEW': {'type': bool, 'default': False}, 'FOOTER_INFO': {'type': str, 'default': 'Content is hosted for personal archiving purposes only. Contact server owner for any takedown requests.'}, - 'ACTIVE_THEME': {'type': str, 'default': 'default'}, }, 'ARCHIVE_METHOD_TOGGLES': { @@ -204,12 +203,11 @@ def get_real_name(key: str) -> str: ################################ Constants ##################################### PACKAGE_DIR_NAME = 'archivebox' -TEMPLATES_DIR_NAME = 'themes' +TEMPLATES_DIR_NAME = 'templates' ARCHIVE_DIR_NAME = 'archive' SOURCES_DIR_NAME = 'sources' LOGS_DIR_NAME = 'logs' -STATIC_DIR_NAME = 'static' SQL_INDEX_FILENAME = 'index.sqlite3' JSON_INDEX_FILENAME = 'index.json' HTML_INDEX_FILENAME = 'index.html' @@ -702,7 +700,7 @@ def get_code_locations(config: ConfigDict) -> SimpleConfigValueDict: 'TEMPLATES_DIR': { 'path': (config['TEMPLATES_DIR']).resolve(), 'enabled': True, - 'is_valid': (config['TEMPLATES_DIR'] / config['ACTIVE_THEME'] / 'static').exists(), + 'is_valid': (config['TEMPLATES_DIR'] / 'static').exists(), }, # 'NODE_MODULES_DIR': { # 'path': , diff --git a/archivebox/config_stubs.py b/archivebox/config_stubs.py index 988f58a1..f9c22a0c 100644 --- a/archivebox/config_stubs.py +++ b/archivebox/config_stubs.py @@ -50,7 +50,6 @@ class ConfigDict(BaseConfig, total=False): PUBLIC_INDEX: bool PUBLIC_SNAPSHOTS: bool FOOTER_INFO: str - ACTIVE_THEME: str SAVE_TITLE: bool SAVE_FAVICON: bool diff --git a/archivebox/core/settings.py b/archivebox/core/settings.py index bfc0cdc3..bcf9c073 100644 --- a/archivebox/core/settings.py +++ b/archivebox/core/settings.py @@ -11,7 +11,6 @@ from ..config import ( SECRET_KEY, ALLOWED_HOSTS, PACKAGE_DIR, - ACTIVE_THEME, TEMPLATES_DIR_NAME, SQL_INDEX_FILENAME, OUTPUT_DIR, @@ -69,13 +68,12 @@ AUTHENTICATION_BACKENDS = [ STATIC_URL = '/static/' STATICFILES_DIRS = [ - str(Path(PACKAGE_DIR) / TEMPLATES_DIR_NAME / ACTIVE_THEME / 'static'), - str(Path(PACKAGE_DIR) / TEMPLATES_DIR_NAME / 'default' / 'static'), + str(Path(PACKAGE_DIR) / TEMPLATES_DIR_NAME / 'static'), ] TEMPLATE_DIRS = [ - str(Path(PACKAGE_DIR) / TEMPLATES_DIR_NAME / ACTIVE_THEME), - str(Path(PACKAGE_DIR) / TEMPLATES_DIR_NAME / 'default'), + str(Path(PACKAGE_DIR) / TEMPLATES_DIR_NAME / 'core'), + str(Path(PACKAGE_DIR) / TEMPLATES_DIR_NAME / 'admin'), str(Path(PACKAGE_DIR) / TEMPLATES_DIR_NAME), ] diff --git a/archivebox/main.py b/archivebox/main.py index c666f5d6..c55a2c04 100644 --- a/archivebox/main.py +++ b/archivebox/main.py @@ -79,7 +79,6 @@ from .config import ( ARCHIVE_DIR_NAME, SOURCES_DIR_NAME, LOGS_DIR_NAME, - STATIC_DIR_NAME, JSON_INDEX_FILENAME, HTML_INDEX_FILENAME, SQL_INDEX_FILENAME, @@ -125,10 +124,10 @@ ALLOWED_IN_OUTPUT_DIR = { '.virtualenv', 'node_modules', 'package-lock.json', + 'static', ARCHIVE_DIR_NAME, SOURCES_DIR_NAME, LOGS_DIR_NAME, - STATIC_DIR_NAME, SQL_INDEX_FILENAME, JSON_INDEX_FILENAME, HTML_INDEX_FILENAME, From a98298103daf10f189f7c0547dee03b593ef0d9e Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Sat, 30 Jan 2021 05:35:07 -0500 Subject: [PATCH 2/5] cleanup templates and views --- archivebox/core/admin.py | 4 +- archivebox/core/templatetags/core_tags.py | 2 +- archivebox/core/urls.py | 8 +- archivebox/core/views.py | 16 +- archivebox/index/html.py | 6 +- .../admin/actions_as_select.html | 0 .../admin/app_index.html | 0 .../{themes => templates}/admin/base.html | 0 .../{themes => templates}/admin/login.html | 0 archivebox/templates/admin/private_index.html | 150 ++++++++++++ .../admin/private_index_grid.html} | 2 +- .../admin/snapshots_grid.html | 2 +- .../core/add.html} | 2 +- .../default => templates/core}/base.html | 0 .../core/index_row.html} | 6 +- .../core/minimal_index.html} | 4 +- .../core/public_index.html} | 2 +- .../core/snapshot.html} | 0 .../core/static_index.html} | 2 +- .../default => templates}/static/add.css | 0 .../default => templates}/static/admin.css | 0 .../default => templates}/static/archive.png | Bin .../static/bootstrap.min.css | 0 .../default => templates}/static/external.png | Bin .../static/jquery.dataTables.min.css | 0 .../static/jquery.dataTables.min.js | 0 .../static/jquery.min.js | 0 .../default => templates}/static/sort_asc.png | Bin .../static/sort_both.png | Bin .../static/sort_desc.png | Bin .../default => templates}/static/spinner.gif | Bin archivebox/themes/legacy/main_index.html | 215 ------------------ archivebox/themes/legacy/main_index_row.html | 16 -- etc/ArchiveBox.conf.default | 1 - 34 files changed, 179 insertions(+), 259 deletions(-) rename archivebox/{themes => templates}/admin/actions_as_select.html (100%) rename archivebox/{themes => templates}/admin/app_index.html (100%) rename archivebox/{themes => templates}/admin/base.html (100%) rename archivebox/{themes => templates}/admin/login.html (100%) create mode 100644 archivebox/templates/admin/private_index.html rename archivebox/{themes/admin/grid_change_list.html => templates/admin/private_index_grid.html} (99%) rename archivebox/{themes => templates}/admin/snapshots_grid.html (99%) rename archivebox/{themes/default/add_links.html => templates/core/add.html} (98%) rename archivebox/{themes/default => templates/core}/base.html (100%) rename archivebox/{themes/default/main_index_row.html => templates/core/index_row.html} (82%) rename archivebox/{themes/default/main_index_minimal.html => templates/core/minimal_index.html} (90%) rename archivebox/{themes/default/core/snapshot_list.html => templates/core/public_index.html} (97%) rename archivebox/{themes/default/link_details.html => templates/core/snapshot.html} (100%) rename archivebox/{themes/default/main_index.html => templates/core/static_index.html} (99%) rename archivebox/{themes/default => templates}/static/add.css (100%) rename archivebox/{themes/default => templates}/static/admin.css (100%) rename archivebox/{themes/default => templates}/static/archive.png (100%) rename archivebox/{themes/default => templates}/static/bootstrap.min.css (100%) rename archivebox/{themes/default => templates}/static/external.png (100%) rename archivebox/{themes/default => templates}/static/jquery.dataTables.min.css (100%) rename archivebox/{themes/default => templates}/static/jquery.dataTables.min.js (100%) rename archivebox/{themes/default => templates}/static/jquery.min.js (100%) rename archivebox/{themes/default => templates}/static/sort_asc.png (100%) rename archivebox/{themes/default => templates}/static/sort_both.png (100%) rename archivebox/{themes/default => templates}/static/sort_desc.png (100%) rename archivebox/{themes/default => templates}/static/spinner.gif (100%) delete mode 100644 archivebox/themes/legacy/main_index.html delete mode 100644 archivebox/themes/legacy/main_index_row.html diff --git a/archivebox/core/admin.py b/archivebox/core/admin.py index f641b177..518731f1 100644 --- a/archivebox/core/admin.py +++ b/archivebox/core/admin.py @@ -171,7 +171,7 @@ class SnapshotAdmin(SearchResultsAdminMixin, admin.ModelAdmin): saved_list_max_show_all = self.list_max_show_all # Monkey patch here plus core_tags.py - self.change_list_template = 'admin/grid_change_list.html' + self.change_list_template = 'private_index_grid.html' self.list_per_page = 20 self.list_max_show_all = self.list_per_page @@ -249,7 +249,7 @@ class ArchiveBoxAdmin(admin.AdminSite): else: context["form"] = form - return render(template_name='add_links.html', request=request, context=context) + return render(template_name='add.html', request=request, context=context) admin.site = ArchiveBoxAdmin() admin.site.register(get_user_model()) diff --git a/archivebox/core/templatetags/core_tags.py b/archivebox/core/templatetags/core_tags.py index 25f06852..9ac1ee27 100644 --- a/archivebox/core/templatetags/core_tags.py +++ b/archivebox/core/templatetags/core_tags.py @@ -14,7 +14,7 @@ register = template.Library() def snapshot_image(snapshot): result = ArchiveResult.objects.filter(snapshot=snapshot, extractor='screenshot', status='succeeded').first() if result: - return reverse('LinkAssets', args=[f'{str(snapshot.timestamp)}/{result.output}']) + return reverse('Snapshot', args=[f'{str(snapshot.timestamp)}/{result.output}']) return static('archive.png') diff --git a/archivebox/core/urls.py b/archivebox/core/urls.py index b8e4bafb..4c7b429c 100644 --- a/archivebox/core/urls.py +++ b/archivebox/core/urls.py @@ -5,22 +5,24 @@ from django.views import static from django.conf import settings from django.views.generic.base import RedirectView -from core.views import MainIndex, LinkDetails, PublicArchiveView, AddView +from core.views import HomepageView, SnapshotView, PublicIndexView, AddView # print('DEBUG', settings.DEBUG) urlpatterns = [ + path('public/', PublicIndexView.as_view(), name='public-index'), + path('robots.txt', static.serve, {'document_root': settings.OUTPUT_DIR, 'path': 'robots.txt'}), path('favicon.ico', static.serve, {'document_root': settings.OUTPUT_DIR, 'path': 'favicon.ico'}), path('docs/', RedirectView.as_view(url='https://github.com/ArchiveBox/ArchiveBox/wiki'), name='Docs'), path('archive/', RedirectView.as_view(url='/')), - path('archive/', LinkDetails.as_view(), name='LinkAssets'), + path('archive/', SnapshotView.as_view(), name='Snapshot'), path('admin/core/snapshot/add/', RedirectView.as_view(url='/add/')), - path('add/', AddView.as_view()), + path('add/', AddView.as_view(), name='add'), path('accounts/login/', RedirectView.as_view(url='/admin/login/')), path('accounts/logout/', RedirectView.as_view(url='/admin/logout/')), diff --git a/archivebox/core/views.py b/archivebox/core/views.py index 810b4740..0e19fad6 100644 --- a/archivebox/core/views.py +++ b/archivebox/core/views.py @@ -28,20 +28,20 @@ from ..util import base_url, ansi_to_html from ..index.html import snapshot_icons -class MainIndex(View): - template = 'main_index.html' - +class HomepageView(View): def get(self, request): if request.user.is_authenticated: return redirect('/admin/core/snapshot/') if PUBLIC_INDEX: - return redirect('public-index') + return redirect('/public') return redirect(f'/admin/login/?next={request.path}') -class LinkDetails(View): +class SnapshotView(View): + # render static html index from filesystem archive//index.html + def get(self, request, path): # missing trailing slash -> redirect to index if '/' not in path: @@ -91,8 +91,8 @@ class LinkDetails(View): status=404, ) -class PublicArchiveView(ListView): - template = 'snapshot_list.html' +class PublicIndexView(ListView): + template_name = 'public_index.html' model = Snapshot paginate_by = 100 ordering = ['title'] @@ -122,7 +122,7 @@ class PublicArchiveView(ListView): class AddView(UserPassesTestMixin, FormView): - template_name = "add_links.html" + template_name = "add.html" form_class = AddLinkForm def get_initial(self): diff --git a/archivebox/index/html.py b/archivebox/index/html.py index 28f25fde..3eca5f01 100644 --- a/archivebox/index/html.py +++ b/archivebox/index/html.py @@ -25,9 +25,9 @@ from ..config import ( HTML_INDEX_FILENAME, ) -MAIN_INDEX_TEMPLATE = 'main_index.html' -MINIMAL_INDEX_TEMPLATE = 'main_index_minimal.html' -LINK_DETAILS_TEMPLATE = 'link_details.html' +MAIN_INDEX_TEMPLATE = 'static_index.html' +MINIMAL_INDEX_TEMPLATE = 'minimal_index.html' +LINK_DETAILS_TEMPLATE = 'snapshot.html' TITLE_LOADING_MSG = 'Not yet archived...' diff --git a/archivebox/themes/admin/actions_as_select.html b/archivebox/templates/admin/actions_as_select.html similarity index 100% rename from archivebox/themes/admin/actions_as_select.html rename to archivebox/templates/admin/actions_as_select.html diff --git a/archivebox/themes/admin/app_index.html b/archivebox/templates/admin/app_index.html similarity index 100% rename from archivebox/themes/admin/app_index.html rename to archivebox/templates/admin/app_index.html diff --git a/archivebox/themes/admin/base.html b/archivebox/templates/admin/base.html similarity index 100% rename from archivebox/themes/admin/base.html rename to archivebox/templates/admin/base.html diff --git a/archivebox/themes/admin/login.html b/archivebox/templates/admin/login.html similarity index 100% rename from archivebox/themes/admin/login.html rename to archivebox/templates/admin/login.html diff --git a/archivebox/templates/admin/private_index.html b/archivebox/templates/admin/private_index.html new file mode 100644 index 00000000..7afb62c3 --- /dev/null +++ b/archivebox/templates/admin/private_index.html @@ -0,0 +1,150 @@ +{% extends "base.html" %} +{% load static %} + +{% block body %} +
+ +
+ + + + + + + + + + + {% for link in object_list %} + {% include 'main_index_row.html' with link=link %} + {% endfor %} + +
BookmarkedSnapshot ({{object_list|length}})FilesOriginal URL
+
+ + {% if page_obj.has_previous %} + « first + previous + {% endif %} + + + Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}. + + + {% if page_obj.has_next %} + next + last » + {% endif %} + + + {% if page_obj.has_next %} + next + last » + {% endif %} + +
+
+{% endblock %} +{% extends "admin/base_site.html" %} +{% load i18n admin_urls static admin_list %} +{% load core_tags %} + +{% block extrastyle %} + {{ block.super }} + + {% if cl.formset %} + + {% endif %} + {% if cl.formset or action_form %} + + {% endif %} + {{ media.css }} + {% if not actions_on_top and not actions_on_bottom %} + + {% endif %} +{% endblock %} + +{% block extrahead %} +{{ block.super }} +{{ media.js }} +{% endblock %} + +{% block bodyclass %}{{ block.super }} app-{{ opts.app_label }} model-{{ opts.model_name }} change-list{% endblock %} + +{% if not is_popup %} +{% block breadcrumbs %} + +{% endblock %} +{% endif %} + +{% block coltype %}{% endblock %} + +{% block content %} +
+ {% block object-tools %} +
    + {% block object-tools-items %} + {% change_list_object_tools %} + {% endblock %} +
+ {% endblock %} + {% if cl.formset and cl.formset.errors %} +

+ {% if cl.formset.total_error_count == 1 %}{% translate "Please correct the error below." %}{% else %}{% translate "Please correct the errors below." %}{% endif %} +

+ {{ cl.formset.non_form_errors }} + {% endif %} +
+
+ {% block search %}{% search_form cl %}{% endblock %} + {% block date_hierarchy %}{% if cl.date_hierarchy %}{% date_hierarchy cl %}{% endif %}{% endblock %} + +
{% csrf_token %} + {% if cl.formset %} +
{{ cl.formset.management_form }}
+ {% endif %} + + {% block result_list %} + {% if action_form and actions_on_top and cl.show_admin_actions %}{% admin_actions %}{% endif %} + {% comment %} + Table grid + {% result_list cl %} + {% endcomment %} + {% snapshots_grid cl %} + {% if action_form and actions_on_bottom and cl.show_admin_actions %}{% admin_actions %}{% endif %} + {% endblock %} + {% block pagination %}{% pagination cl %}{% endblock %} +
+
+ {% block filters %} + {% if cl.has_filters %} +
+

{% translate 'Filter' %}

+ {% if cl.has_active_filters %}

+ ✖ {% translate "Clear all filters" %} +

{% endif %} + {% for spec in cl.filter_specs %}{% admin_list_filter cl spec %}{% endfor %} +
+ {% endif %} + {% endblock %} +
+
+{% endblock %} diff --git a/archivebox/themes/admin/grid_change_list.html b/archivebox/templates/admin/private_index_grid.html similarity index 99% rename from archivebox/themes/admin/grid_change_list.html rename to archivebox/templates/admin/private_index_grid.html index 6894efd7..b60f3a3e 100644 --- a/archivebox/themes/admin/grid_change_list.html +++ b/archivebox/templates/admin/private_index_grid.html @@ -88,4 +88,4 @@ {% endblock %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/archivebox/themes/admin/snapshots_grid.html b/archivebox/templates/admin/snapshots_grid.html similarity index 99% rename from archivebox/themes/admin/snapshots_grid.html rename to archivebox/templates/admin/snapshots_grid.html index a7a2d4f9..10788060 100644 --- a/archivebox/themes/admin/snapshots_grid.html +++ b/archivebox/templates/admin/snapshots_grid.html @@ -159,4 +159,4 @@ footer { {% endfor %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/archivebox/themes/default/add_links.html b/archivebox/templates/core/add.html similarity index 98% rename from archivebox/themes/default/add_links.html rename to archivebox/templates/core/add.html index fa8b441f..0f161885 100644 --- a/archivebox/themes/default/add_links.html +++ b/archivebox/templates/core/add.html @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "core/base.html" %} {% load static %} {% load i18n %} diff --git a/archivebox/themes/default/base.html b/archivebox/templates/core/base.html similarity index 100% rename from archivebox/themes/default/base.html rename to archivebox/templates/core/base.html diff --git a/archivebox/themes/default/main_index_row.html b/archivebox/templates/core/index_row.html similarity index 82% rename from archivebox/themes/default/main_index_row.html rename to archivebox/templates/core/index_row.html index eae60ea9..cba3ec39 100644 --- a/archivebox/themes/default/main_index_row.html +++ b/archivebox/templates/core/index_row.html @@ -4,9 +4,9 @@ {% if link.bookmarked_date %} {{ link.bookmarked_date }} {% else %} {{ link.added }} {% endif %} {% if link.is_archived %} - + {% else %} - + {% endif %} @@ -28,7 +28,7 @@ {{link.icons}} {{link.num_outputs}} {% else %} 📄 - {{link.num_outputs}} + {{link.num_outputs}} {% endif %} diff --git a/archivebox/themes/default/main_index_minimal.html b/archivebox/templates/core/minimal_index.html similarity index 90% rename from archivebox/themes/default/main_index_minimal.html rename to archivebox/templates/core/minimal_index.html index dcfaa23f..3c69a831 100644 --- a/archivebox/themes/default/main_index_minimal.html +++ b/archivebox/templates/core/minimal_index.html @@ -16,9 +16,9 @@ {% for link in links %} - {% include "main_index_row.html" with link=link %} + {% include "index_row.html" with link=link %} {% endfor %} - \ No newline at end of file + diff --git a/archivebox/themes/default/core/snapshot_list.html b/archivebox/templates/core/public_index.html similarity index 97% rename from archivebox/themes/default/core/snapshot_list.html rename to archivebox/templates/core/public_index.html index dd8ebf15..327042ea 100644 --- a/archivebox/themes/default/core/snapshot_list.html +++ b/archivebox/templates/core/public_index.html @@ -28,7 +28,7 @@ {% for link in object_list %} - {% include 'main_index_row.html' with link=link %} + {% include 'index_row.html' with link=link %} {% endfor %} diff --git a/archivebox/themes/default/link_details.html b/archivebox/templates/core/snapshot.html similarity index 100% rename from archivebox/themes/default/link_details.html rename to archivebox/templates/core/snapshot.html diff --git a/archivebox/themes/default/main_index.html b/archivebox/templates/core/static_index.html similarity index 99% rename from archivebox/themes/default/main_index.html rename to archivebox/templates/core/static_index.html index 269c9825..07066e27 100644 --- a/archivebox/themes/default/main_index.html +++ b/archivebox/templates/core/static_index.html @@ -234,7 +234,7 @@ {% for link in links %} - {% include 'main_index_row.html' with link=link %} + {% include 'index_row.html' with link=link %} {% endfor %} diff --git a/archivebox/themes/default/static/add.css b/archivebox/templates/static/add.css similarity index 100% rename from archivebox/themes/default/static/add.css rename to archivebox/templates/static/add.css diff --git a/archivebox/themes/default/static/admin.css b/archivebox/templates/static/admin.css similarity index 100% rename from archivebox/themes/default/static/admin.css rename to archivebox/templates/static/admin.css diff --git a/archivebox/themes/default/static/archive.png b/archivebox/templates/static/archive.png similarity index 100% rename from archivebox/themes/default/static/archive.png rename to archivebox/templates/static/archive.png diff --git a/archivebox/themes/default/static/bootstrap.min.css b/archivebox/templates/static/bootstrap.min.css similarity index 100% rename from archivebox/themes/default/static/bootstrap.min.css rename to archivebox/templates/static/bootstrap.min.css diff --git a/archivebox/themes/default/static/external.png b/archivebox/templates/static/external.png similarity index 100% rename from archivebox/themes/default/static/external.png rename to archivebox/templates/static/external.png diff --git a/archivebox/themes/default/static/jquery.dataTables.min.css b/archivebox/templates/static/jquery.dataTables.min.css similarity index 100% rename from archivebox/themes/default/static/jquery.dataTables.min.css rename to archivebox/templates/static/jquery.dataTables.min.css diff --git a/archivebox/themes/default/static/jquery.dataTables.min.js b/archivebox/templates/static/jquery.dataTables.min.js similarity index 100% rename from archivebox/themes/default/static/jquery.dataTables.min.js rename to archivebox/templates/static/jquery.dataTables.min.js diff --git a/archivebox/themes/default/static/jquery.min.js b/archivebox/templates/static/jquery.min.js similarity index 100% rename from archivebox/themes/default/static/jquery.min.js rename to archivebox/templates/static/jquery.min.js diff --git a/archivebox/themes/default/static/sort_asc.png b/archivebox/templates/static/sort_asc.png similarity index 100% rename from archivebox/themes/default/static/sort_asc.png rename to archivebox/templates/static/sort_asc.png diff --git a/archivebox/themes/default/static/sort_both.png b/archivebox/templates/static/sort_both.png similarity index 100% rename from archivebox/themes/default/static/sort_both.png rename to archivebox/templates/static/sort_both.png diff --git a/archivebox/themes/default/static/sort_desc.png b/archivebox/templates/static/sort_desc.png similarity index 100% rename from archivebox/themes/default/static/sort_desc.png rename to archivebox/templates/static/sort_desc.png diff --git a/archivebox/themes/default/static/spinner.gif b/archivebox/templates/static/spinner.gif similarity index 100% rename from archivebox/themes/default/static/spinner.gif rename to archivebox/templates/static/spinner.gif diff --git a/archivebox/themes/legacy/main_index.html b/archivebox/themes/legacy/main_index.html deleted file mode 100644 index 74e7bf65..00000000 --- a/archivebox/themes/legacy/main_index.html +++ /dev/null @@ -1,215 +0,0 @@ - - - - Archived Sites - - - - - - - - - -
-
- -
-
- - - - - - - - - - $rows -
BookmarkedSnapshot ($num_links)FilesOriginal URL
- - - diff --git a/archivebox/themes/legacy/main_index_row.html b/archivebox/themes/legacy/main_index_row.html deleted file mode 100644 index 9112eace..00000000 --- a/archivebox/themes/legacy/main_index_row.html +++ /dev/null @@ -1,16 +0,0 @@ - - $bookmarked_date - - - - $title - $tags - - - - 📄 - $num_outputs - - - $url - diff --git a/etc/ArchiveBox.conf.default b/etc/ArchiveBox.conf.default index fe3bcdde..982a1931 100644 --- a/etc/ArchiveBox.conf.default +++ b/etc/ArchiveBox.conf.default @@ -24,7 +24,6 @@ # PUBLIC_INDEX = True # PUBLIC_SNAPSHOTS = True # FOOTER_INFO = Content is hosted for personal archiving purposes only. Contact server owner for any takedown requests. -# ACTIVE_THEME = default [ARCHIVE_METHOD_TOGGLES] From 6edae6a17f01edbe2644b10a5be3c58ce7b0fd34 Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Sat, 30 Jan 2021 05:35:17 -0500 Subject: [PATCH 3/5] add future api spec design --- archivebox/core/admin.py | 10 ++++++++++ archivebox/core/urls.py | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/archivebox/core/admin.py b/archivebox/core/admin.py index 518731f1..8c3c3599 100644 --- a/archivebox/core/admin.py +++ b/archivebox/core/admin.py @@ -24,6 +24,16 @@ from main import add, remove from config import OUTPUT_DIR from extractors import archive_links +# Admin URLs +# /admin/ +# /admin/login/ +# /admin/core/ +# /admin/core/snapshot/ +# /admin/core/snapshot/:uuid/ +# /admin/core/tag/ +# /admin/core/tag/:uuid/ + + # TODO: https://stackoverflow.com/questions/40760880/add-custom-button-to-django-admin-panel def update_snapshots(modeladmin, request, queryset): diff --git a/archivebox/core/urls.py b/archivebox/core/urls.py index 4c7b429c..182e4dca 100644 --- a/archivebox/core/urls.py +++ b/archivebox/core/urls.py @@ -33,6 +33,37 @@ urlpatterns = [ path('index.html', RedirectView.as_view(url='/')), path('index.json', static.serve, {'document_root': settings.OUTPUT_DIR, 'path': 'index.json'}), - path('', MainIndex.as_view(), name='Home'), - path('public/', PublicArchiveView.as_view(), name='public-index'), + path('', HomepageView.as_view(), name='Home'), ] + + # # Proposed UI URLs spec + # path('', HomepageView) + # path('/add', AddView) + # path('/public', PublicIndexView) + # path('/snapshot/:slug', SnapshotView) + + # path('/admin', admin.site.urls) + # path('/accounts', django.contrib.auth.urls) + + # # Prposed REST API spec + # # :slugs can be uuid, short_uuid, or any of the unique index_fields + # path('api/v1/'), + # path('api/v1/core/' [GET]) + # path('api/v1/core/snapshot/', [GET, POST, PUT]), + # path('api/v1/core/snapshot/:slug', [GET, PATCH, DELETE]), + # path('api/v1/core/archiveresult', [GET, POST, PUT]), + # path('api/v1/core/archiveresult/:slug', [GET, PATCH, DELETE]), + # path('api/v1/core/tag/', [GET, POST, PUT]), + # path('api/v1/core/tag/:slug', [GET, PATCH, DELETE]), + + # path('api/v1/cli/', [GET]) + # path('api/v1/cli/{add,list,config,...}', [POST]), # pass query as kwargs directly to `run_subcommand` and return stdout, stderr, exitcode + + # path('api/v1/extractors/', [GET]) + # path('api/v1/extractors/:extractor/', [GET]), + # path('api/v1/extractors/:extractor/:func', [GET, POST]), # pass query as args directly to chosen function + + # future, just an idea: + # path('api/v1/scheduler/', [GET]) + # path('api/v1/scheduler/task/', [GET, POST, PUT]), + # path('api/v1/scheduler/task/:slug', [GET, PATCH, DELETE]), From 1ce0eca2176a65a10161783ea12a89729bc4072d Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Sat, 30 Jan 2021 05:35:29 -0500 Subject: [PATCH 4/5] add trailing slashes to canonical paths --- archivebox/index/schema.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/archivebox/index/schema.py b/archivebox/index/schema.py index bc3a25da..5c5eb0f0 100644 --- a/archivebox/index/schema.py +++ b/archivebox/index/schema.py @@ -417,7 +417,7 @@ class Link: 'favicon_path': 'favicon.ico', 'google_favicon_path': 'https://www.google.com/s2/favicons?domain={}'.format(self.domain), 'wget_path': wget_output_path(self), - 'warc_path': 'warc', + 'warc_path': 'warc/', 'singlefile_path': 'singlefile.html', 'readability_path': 'readability/content.html', 'mercury_path': 'mercury/content.html', @@ -425,8 +425,8 @@ class Link: 'screenshot_path': 'screenshot.png', 'dom_path': 'output.html', 'archive_org_path': 'https://web.archive.org/web/{}'.format(self.base_url), - 'git_path': 'git', - 'media_path': 'media', + 'git_path': 'git/', + 'media_path': 'media/', } if self.is_static: # static binary files like PDF and images are handled slightly differently. From cc80ceb0a27d1aa0564f43e4d21d069272eab3c0 Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Sat, 30 Jan 2021 05:47:33 -0500 Subject: [PATCH 5/5] fix icons in public index --- archivebox/index/html.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/archivebox/index/html.py b/archivebox/index/html.py index 3eca5f01..cff50085 100644 --- a/archivebox/index/html.py +++ b/archivebox/index/html.py @@ -146,9 +146,15 @@ def snapshot_icons(snapshot) -> str: for extractor, _ in EXTRACTORS: if extractor not in exclude: - exists = extractor_items[extractor] is not None + exists = False + if extractor_items[extractor] is not None: + outpath = (Path(path) / canon[f"{extractor}_path"]) + if outpath.is_dir(): + exists = any(outpath.glob('*.*')) + elif outpath.is_file(): + exists = outpath.stat().st_size > 100 output += format_html(output_template, path, canon[f"{extractor}_path"], str(exists), - extractor, icons.get(extractor, "?")) + extractor, icons.get(extractor, "?")) if extractor == "wget": # warc isn't technically it's own extractor, so we have to add it after wget exists = list((Path(path) / canon["warc_path"]).glob("*.warc.gz"))