From a013831ffd8762bc602b7435f4810b35f93bfb11 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Fri, 25 Dec 2020 11:53:49 +0100 Subject: [PATCH] Add articles custom css --- articles/admin.py | 10 +++++++++- articles/migrations/0025_article_custom_css.py | 18 ++++++++++++++++++ articles/models.py | 1 + articles/static/admin_articles.css | 5 ++++- .../templates/articles/article_detail.html | 6 ++++++ articles/templates/articles/article_list.html | 6 ++++-- articles/templates/articles/base.html | 2 +- 7 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 articles/migrations/0025_article_custom_css.py diff --git a/articles/admin.py b/articles/admin.py index ca10299..65180f2 100644 --- a/articles/admin.py +++ b/articles/admin.py @@ -39,7 +39,15 @@ class ArticleAdmin(admin.ModelAdmin): ] }, ), - ("Content", {"fields": ("content",)}), + ( + "Content", + { + "fields": ( + "content", + "custom_css", + ) + }, + ), ] readonly_fields = [ "created_at", diff --git a/articles/migrations/0025_article_custom_css.py b/articles/migrations/0025_article_custom_css.py new file mode 100644 index 0000000..d9e0bec --- /dev/null +++ b/articles/migrations/0025_article_custom_css.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.3 on 2020-12-25 10:47 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("articles", "0024_auto_20201224_1746"), + ] + + operations = [ + migrations.AddField( + model_name="article", + name="custom_css", + field=models.TextField(blank=True), + ), + ] diff --git a/articles/models.py b/articles/models.py index e7d6c2f..d87fdd6 100644 --- a/articles/models.py +++ b/articles/models.py @@ -46,6 +46,7 @@ class Article(AdminUrlMixin, models.Model): keywords = models.CharField(max_length=255, blank=True) has_code = models.BooleanField(default=False, blank=True) is_home = models.BooleanField(default=False, blank=True) + custom_css = models.TextField(blank=True) class Meta: ordering = ["-published_at"] diff --git a/articles/static/admin_articles.css b/articles/static/admin_articles.css index 615606b..7a76432 100644 --- a/articles/static/admin_articles.css +++ b/articles/static/admin_articles.css @@ -1,5 +1,8 @@ -#id_content { +#id_content, #id_custom_css { font-family: "JetBrains Mono", monospace; +} + +#id_content { width: calc(100% - 1em); height: 44.5em; resize: vertical; diff --git a/articles/templates/articles/article_detail.html b/articles/templates/articles/article_detail.html index 1e0e2aa..a48fdd3 100644 --- a/articles/templates/articles/article_detail.html +++ b/articles/templates/articles/article_detail.html @@ -1,5 +1,11 @@ {% extends 'articles/base.html' %} +{% block append_header %} + +{% endblock %} + {% block title %}{{ article.title }} | {% endblock %} {% block content %} diff --git a/articles/templates/articles/article_list.html b/articles/templates/articles/article_list.html index 7a95e9f..82545bc 100644 --- a/articles/templates/articles/article_list.html +++ b/articles/templates/articles/article_list.html @@ -1,7 +1,9 @@ {% extends 'articles/base.html' %} -{% block override_header %} - {% include "articles/snippets/style_home.html" %} +{% block append_header %} + {% endblock %} {% block title %}{% endblock %} diff --git a/articles/templates/articles/base.html b/articles/templates/articles/base.html index 0f6f1cc..fddcc78 100644 --- a/articles/templates/articles/base.html +++ b/articles/templates/articles/base.html @@ -18,7 +18,7 @@ {% endif %} {% include "articles/snippets/favicon.html" %} {% include "articles/snippets/analytics.html" %} - {% block override_header %}{% endblock %} + {% block append_header %}{% endblock %}