From ba7144f6f373cee8b8a3c3881f71c73ab1759ff6 Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Mon, 22 Apr 2019 21:40:42 -0400 Subject: [PATCH] customize django admin ui chrome --- archivebox/core/admin.py | 8 ++ archivebox/core/models.py | 5 ++ archivebox/themes/admin/app_index.html | 18 +++++ archivebox/themes/admin/base.html | 94 +++++++++++++++++++++++ archivebox/themes/default/main_index.html | 2 +- 5 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 archivebox/themes/admin/app_index.html create mode 100644 archivebox/themes/admin/base.html diff --git a/archivebox/core/admin.py b/archivebox/core/admin.py index b61d93d6..d131d3e8 100644 --- a/archivebox/core/admin.py +++ b/archivebox/core/admin.py @@ -1,11 +1,19 @@ + +from datetime import datetime + from django.contrib import admin from .models import Page class PageAdmin(admin.ModelAdmin): list_display = ('timestamp', 'short_url', 'title', 'is_archived', 'num_outputs', 'added', 'updated', 'url_hash') + readonly_fields = ('num_outputs', 'is_archived', 'added', 'updated', 'bookmarked') + fields = ('url', 'timestamp', 'title', 'tags', *readonly_fields) def short_url(self, obj): return obj.url[:64] + def updated(self, obj): + return obj.isoformat() + admin.site.register(Page, PageAdmin) diff --git a/archivebox/core/models.py b/archivebox/core/models.py index 94258b1a..9c82c61d 100644 --- a/archivebox/core/models.py +++ b/archivebox/core/models.py @@ -5,6 +5,7 @@ import uuid from django.db import models from legacy.schema import Link +from legacy.util import parse_date class Page(models.Model): @@ -44,6 +45,10 @@ class Page(models.Model): def as_link(self) -> Link: return Link.from_json(self.as_json()) + @property + def bookmarked(self): + return parse_date(self.timestamp) + @property def is_archived(self): return self.as_link().is_archived diff --git a/archivebox/themes/admin/app_index.html b/archivebox/themes/admin/app_index.html new file mode 100644 index 00000000..6868b497 --- /dev/null +++ b/archivebox/themes/admin/app_index.html @@ -0,0 +1,18 @@ +{% extends "admin/index.html" %} +{% load i18n %} + +{% block bodyclass %}{{ block.super }} app-{{ app_label }}{% endblock %} + +{% if not is_popup %} +{% block breadcrumbs %} + +{% endblock %} +{% endif %} + +{% block sidebar %}{% endblock %} diff --git a/archivebox/themes/admin/base.html b/archivebox/themes/admin/base.html new file mode 100644 index 00000000..2160dfeb --- /dev/null +++ b/archivebox/themes/admin/base.html @@ -0,0 +1,94 @@ +{% load i18n static %} +{% get_current_language as LANGUAGE_CODE %}{% get_current_language_bidi as LANGUAGE_BIDI %} + + +{% block title %}{% endblock %} + +{% block extrastyle %}{% endblock %} +{% if LANGUAGE_BIDI %}{% endif %} +{% block extrahead %}{% endblock %} +{% block responsive %} + + + {% if LANGUAGE_BIDI %}{% endif %} +{% endblock %} +{% block blockbots %}{% endblock %} + +{% load i18n %} + + + + +
+ + {% if not is_popup %} + + + + {% block breadcrumbs %} + + {% endblock %} + {% endif %} + + {% block messages %} + {% if messages %} + + {% endif %} + {% endblock messages %} + + +
+ {% block pretitle %}{% endblock %} + {% block content_title %}{% if title %}

{{ title }}

{% endif %}{% endblock %} + {% block content %} + {% block object-tools %}{% endblock %} + {{ content }} + {% endblock %} + {% block sidebar %}{% endblock %} +
+
+ + + {% block footer %}{% endblock %} +
+ + + + diff --git a/archivebox/themes/default/main_index.html b/archivebox/themes/default/main_index.html index f8ab9edc..936511a1 100644 --- a/archivebox/themes/default/main_index.html +++ b/archivebox/themes/default/main_index.html @@ -190,7 +190,7 @@
Add Links   |   - Admin   |   + Admin   |   Docs