Add articles custom css
This commit is contained in:
parent
987c203cfa
commit
a013831ffd
7 changed files with 43 additions and 5 deletions
|
@ -39,7 +39,15 @@ class ArticleAdmin(admin.ModelAdmin):
|
|||
]
|
||||
},
|
||||
),
|
||||
("Content", {"fields": ("content",)}),
|
||||
(
|
||||
"Content",
|
||||
{
|
||||
"fields": (
|
||||
"content",
|
||||
"custom_css",
|
||||
)
|
||||
},
|
||||
),
|
||||
]
|
||||
readonly_fields = [
|
||||
"created_at",
|
||||
|
|
18
articles/migrations/0025_article_custom_css.py
Normal file
18
articles/migrations/0025_article_custom_css.py
Normal 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),
|
||||
),
|
||||
]
|
|
@ -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"]
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
{% extends 'articles/base.html' %}
|
||||
|
||||
{% block append_header %}
|
||||
<style>
|
||||
{{ article.custom_css }}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block title %}{{ article.title }} | {% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
|
|
@ -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 %}
|
||||
|
|
|
@ -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>
|
||||
|
|
Reference in a new issue