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 = [ readonly_fields = [
"created_at", "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) keywords = models.CharField(max_length=255, blank=True)
has_code = models.BooleanField(default=False, blank=True) has_code = models.BooleanField(default=False, blank=True)
is_home = models.BooleanField(default=False, blank=True) is_home = models.BooleanField(default=False, blank=True)
custom_css = models.TextField(blank=True)
class Meta: class Meta:
ordering = ["-published_at"] ordering = ["-published_at"]

View file

@ -1,5 +1,8 @@
#id_content { #id_content, #id_custom_css {
font-family: "JetBrains Mono", monospace; font-family: "JetBrains Mono", monospace;
}
#id_content {
width: calc(100% - 1em); width: calc(100% - 1em);
height: 44.5em; height: 44.5em;
resize: vertical; resize: vertical;

View file

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

View file

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

View file

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