Add articles custom css

This commit is contained in:
Gabriel Augendre 2020-12-25 11:53:49 +01:00
parent 987c203cfa
commit a013831ffd
No known key found for this signature in database
GPG key ID: 1E693F4CE4AEE7B4
7 changed files with 43 additions and 5 deletions

View file

@ -39,7 +39,15 @@ class ArticleAdmin(admin.ModelAdmin):
]
},
),
("Content", {"fields": ("content",)}),
(
"Content",
{
"fields": (
"content",
"custom_css",
)
},
),
]
readonly_fields = [
"created_at",

View file

@ -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),
),
]

View file

@ -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"]

View file

@ -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;

View file

@ -1,5 +1,11 @@
{% extends 'articles/base.html' %}
{% block append_header %}
<style>
{{ article.custom_css }}
</style>
{% endblock %}
{% block title %}{{ article.title }} | {% endblock %}
{% block content %}

View file

@ -1,7 +1,9 @@
{% extends 'articles/base.html' %}
{% block override_header %}
{% include "articles/snippets/style_home.html" %}
{% block append_header %}
<style>
{{ article.custom_css }}
</style>
{% endblock %}
{% block title %}{% endblock %}

View file

@ -18,7 +18,7 @@
{% endif %}
{% include "articles/snippets/favicon.html" %}
{% include "articles/snippets/analytics.html" %}
{% block override_header %}{% endblock %}
{% block append_header %}{% endblock %}
</head>
<body>
<header>