mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-13 22:54:27 -04:00
customize django admin ui chrome
This commit is contained in:
parent
b44281919d
commit
ba7144f6f3
5 changed files with 126 additions and 1 deletions
|
@ -1,11 +1,19 @@
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
from .models import Page
|
from .models import Page
|
||||||
|
|
||||||
class PageAdmin(admin.ModelAdmin):
|
class PageAdmin(admin.ModelAdmin):
|
||||||
list_display = ('timestamp', 'short_url', 'title', 'is_archived', 'num_outputs', 'added', 'updated', 'url_hash')
|
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):
|
def short_url(self, obj):
|
||||||
return obj.url[:64]
|
return obj.url[:64]
|
||||||
|
|
||||||
|
def updated(self, obj):
|
||||||
|
return obj.isoformat()
|
||||||
|
|
||||||
admin.site.register(Page, PageAdmin)
|
admin.site.register(Page, PageAdmin)
|
||||||
|
|
|
@ -5,6 +5,7 @@ import uuid
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
from legacy.schema import Link
|
from legacy.schema import Link
|
||||||
|
from legacy.util import parse_date
|
||||||
|
|
||||||
|
|
||||||
class Page(models.Model):
|
class Page(models.Model):
|
||||||
|
@ -44,6 +45,10 @@ class Page(models.Model):
|
||||||
def as_link(self) -> Link:
|
def as_link(self) -> Link:
|
||||||
return Link.from_json(self.as_json())
|
return Link.from_json(self.as_json())
|
||||||
|
|
||||||
|
@property
|
||||||
|
def bookmarked(self):
|
||||||
|
return parse_date(self.timestamp)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_archived(self):
|
def is_archived(self):
|
||||||
return self.as_link().is_archived
|
return self.as_link().is_archived
|
||||||
|
|
18
archivebox/themes/admin/app_index.html
Normal file
18
archivebox/themes/admin/app_index.html
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
{% extends "admin/index.html" %}
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block bodyclass %}{{ block.super }} app-{{ app_label }}{% endblock %}
|
||||||
|
|
||||||
|
{% if not is_popup %}
|
||||||
|
{% block breadcrumbs %}
|
||||||
|
<div class="breadcrumbs">
|
||||||
|
<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
|
||||||
|
›
|
||||||
|
{% for app in app_list %}
|
||||||
|
{{ app.name }}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% block sidebar %}{% endblock %}
|
94
archivebox/themes/admin/base.html
Normal file
94
archivebox/themes/admin/base.html
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
{% load i18n static %}<!DOCTYPE html>
|
||||||
|
{% get_current_language as LANGUAGE_CODE %}{% get_current_language_bidi as LANGUAGE_BIDI %}
|
||||||
|
<html lang="{{ LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif %}>
|
||||||
|
<head>
|
||||||
|
<title>{% block title %}{% endblock %}</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="{% block stylesheet %}{% static "admin/css/base.css" %}{% endblock %}">
|
||||||
|
{% block extrastyle %}{% endblock %}
|
||||||
|
{% if LANGUAGE_BIDI %}<link rel="stylesheet" type="text/css" href="{% block stylesheet_rtl %}{% static "admin/css/rtl.css" %}{% endblock %}">{% endif %}
|
||||||
|
{% block extrahead %}{% endblock %}
|
||||||
|
{% block responsive %}
|
||||||
|
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0">
|
||||||
|
<link rel="stylesheet" type="text/css" href="{% static "admin/css/responsive.css" %}">
|
||||||
|
{% if LANGUAGE_BIDI %}<link rel="stylesheet" type="text/css" href="{% static "admin/css/responsive_rtl.css" %}">{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
{% block blockbots %}<meta name="robots" content="NONE,NOARCHIVE">{% endblock %}
|
||||||
|
</head>
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
<body class="{% if is_popup %}popup {% endif %}{% block bodyclass %}{% endblock %}"
|
||||||
|
data-admin-utc-offset="{% now "Z" %}">
|
||||||
|
|
||||||
|
<!-- Container -->
|
||||||
|
<div id="container">
|
||||||
|
|
||||||
|
{% if not is_popup %}
|
||||||
|
<!-- Header -->
|
||||||
|
<div id="header">
|
||||||
|
<div id="branding">
|
||||||
|
{% block branding %}{% endblock %}
|
||||||
|
</div>
|
||||||
|
{% block usertools %}
|
||||||
|
{% if has_permission %}
|
||||||
|
<div id="user-tools">
|
||||||
|
<a href="/add/">Add Links</a> /
|
||||||
|
<a href="/">Main Index</a> /
|
||||||
|
<a href="https://github.com/pirate/ArchiveBox/wiki">Docs</a>
|
||||||
|
|
||||||
|
{% block welcome-msg %}
|
||||||
|
{% trans 'User' %}
|
||||||
|
<strong>{% firstof user.get_short_name user.get_username %}</strong>
|
||||||
|
{% endblock %}
|
||||||
|
{% block userlinks %}
|
||||||
|
{% if user.is_active and user.is_staff %}
|
||||||
|
{% url 'django-admindocs-docroot' as docsroot %}
|
||||||
|
{% if docsroot %}
|
||||||
|
<a href="{{ docsroot }}">{% trans 'Documentation' %}</a> /
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% if user.has_usable_password %}
|
||||||
|
<a href="{% url 'admin:password_change' %}">{% trans 'Change password' %}</a> /
|
||||||
|
{% endif %}
|
||||||
|
<a href="{% url 'admin:logout' %}">{% trans 'Log out' %}</a>
|
||||||
|
{% endblock %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
{% block nav-global %}{% endblock %}
|
||||||
|
</div>
|
||||||
|
<!-- END Header -->
|
||||||
|
{% block breadcrumbs %}
|
||||||
|
<div class="breadcrumbs">
|
||||||
|
<a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
|
||||||
|
{% if title %} › {{ title }}{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% block messages %}
|
||||||
|
{% if messages %}
|
||||||
|
<ul class="messagelist">{% for message in messages %}
|
||||||
|
<li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message|capfirst }}</li>
|
||||||
|
{% endfor %}</ul>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock messages %}
|
||||||
|
|
||||||
|
<!-- Content -->
|
||||||
|
<div id="content" class="{% block coltype %}colM{% endblock %}">
|
||||||
|
{% block pretitle %}{% endblock %}
|
||||||
|
{% block content_title %}{% if title %}<h1>{{ title }}</h1>{% endif %}{% endblock %}
|
||||||
|
{% block content %}
|
||||||
|
{% block object-tools %}{% endblock %}
|
||||||
|
{{ content }}
|
||||||
|
{% endblock %}
|
||||||
|
{% block sidebar %}{% endblock %}
|
||||||
|
<br class="clear">
|
||||||
|
</div>
|
||||||
|
<!-- END Content -->
|
||||||
|
|
||||||
|
{% block footer %}<div id="footer"></div>{% endblock %}
|
||||||
|
</div>
|
||||||
|
<!-- END Container -->
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -190,7 +190,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-10" style="text-align: right">
|
<div class="col-sm-10" style="text-align: right">
|
||||||
<a href="/add/">Add Links</a> |
|
<a href="/add/">Add Links</a> |
|
||||||
<a href="/admin/">Admin</a> |
|
<a href="/admin/core/page/">Admin</a> |
|
||||||
<a href="https://github.com/pirate/ArchiveBox/wiki">Docs</a>
|
<a href="https://github.com/pirate/ArchiveBox/wiki">Docs</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue