Compare commits

..

3 commits

15 changed files with 214 additions and 6 deletions

0
blog/base/__init__.py Normal file
View file

6
blog/base/apps.py Normal file
View file

@ -0,0 +1,6 @@
from django.apps import AppConfig
class BaseConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "base"

View file

@ -0,0 +1,51 @@
# Generated by Django 5.0.6 on 2024-06-14 13:23
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
("wagtailcore", "0093_uploadedfile"),
("wagtailimages", "0026_delete_uploadedimage"),
]
operations = [
migrations.CreateModel(
name="SiteSettings",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"logo",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="+",
to="wagtailimages.image",
),
),
(
"site",
models.OneToOneField(
editable=False,
on_delete=django.db.models.deletion.CASCADE,
to="wagtailcore.site",
),
),
],
options={
"abstract": False,
},
),
]

View file

@ -0,0 +1,17 @@
# Generated by Django 5.0.6 on 2024-06-14 13:46
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("base", "0001_initial"),
]
operations = [
migrations.AddField(
model_name="sitesettings",
name="title",
field=models.CharField(blank=True, max_length=32),
),
]

View file

20
blog/base/models.py Normal file
View file

@ -0,0 +1,20 @@
from django.db import models
from wagtail.admin.panels import FieldPanel
from wagtail.contrib.settings.models import BaseSiteSetting, register_setting
@register_setting
class SiteSettings(BaseSiteSetting):
title = models.CharField(max_length=32, blank=True)
logo = models.ForeignKey(
"wagtailimages.Image",
on_delete=models.CASCADE,
related_name="+",
null=True,
blank=True,
)
panels = [
FieldPanel("title"),
FieldPanel("logo"),
]

View file

@ -24,10 +24,12 @@ BASE_DIR = os.path.dirname(PROJECT_DIR)
# Application definition # Application definition
INSTALLED_APPS = [ INSTALLED_APPS = [
"base",
"home", "home",
"search", "search",
"wagtail.contrib.forms", "wagtail.contrib.forms",
"wagtail.contrib.redirects", "wagtail.contrib.redirects",
"wagtail.contrib.settings",
"wagtail.embeds", "wagtail.embeds",
"wagtail.sites", "wagtail.sites",
"wagtail.users", "wagtail.users",
@ -73,6 +75,7 @@ TEMPLATES = [
"django.template.context_processors.request", "django.template.context_processors.request",
"django.contrib.auth.context_processors.auth", "django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages", "django.contrib.messages.context_processors.messages",
"wagtail.contrib.settings.context_processors.settings",
], ],
}, },
}, },
@ -91,6 +94,8 @@ DATABASES = {
} }
} }
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
# Password validation # Password validation
# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators # https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators
@ -189,3 +194,5 @@ WAGTAILDOCS_EXTENSIONS = [
"xlsx", "xlsx",
"zip", "zip",
] ]
WAGTAILIMAGES_EXTENSIONS = ["gif", "jpg", "jpeg", "png", "webp", "svg"]

View file

@ -0,0 +1,18 @@
:root {
--pico-font-family: InterVariable, sans-serif;
--pico-font-weight: 350;
font-feature-settings: "ss01", "ss02", "ss03";
}
h1, h2, h3 {
--pico-font-weight: 250;
}
h4, h5, h6 {
--pico-font-weight: 700;
}
strong {
--pico-font-weight: 550;
}
nav img {
height: 2rem;
}

View file

@ -1,4 +1,4 @@
{% load static wagtailcore_tags wagtailuserbar %} {% load static wagtailcore_tags wagtailimages_tags wagtailuserbar %}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
@ -25,13 +25,16 @@
<link rel="stylesheet" href="https://rsms.me/inter/inter.css"> <link rel="stylesheet" href="https://rsms.me/inter/inter.css">
<link rel="preconnect" href="https://cdn.jsdelivr.net/"> <link rel="preconnect" href="https://cdn.jsdelivr.net/">
<link rel="stylesheet" <link rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.fluid.classless.lime.min.css" /> href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.lime.min.css" />
<link rel="stylesheet" type="text/css" href="{% static 'css/blog.css' %}"> <link rel="stylesheet" type="text/css" href="{% static 'css/blog.css' %}">
{% block extra_css %}{# Override this in templates to add extra stylesheets #}{% endblock %} {% block extra_css %}{# Override this in templates to add extra stylesheets #}{% endblock %}
{% image settings.base.SiteSettings.logo width-32 format-png preserve-svg as favicon %}
<link rel="icon" href="{{ favicon.url }}">
</head> </head>
<body> <body>
{% wagtailuserbar %} {% wagtailuserbar %}
<main> {% include "nav.html" %}
<main class="container">
{% block content %}{% endblock %} {% block content %}{% endblock %}
</main> </main>
{# Global javascript #} {# Global javascript #}

View file

@ -0,0 +1,16 @@
{% load wagtailimages_tags %}
<nav class="container">
<ul>
<li>{% srcset_image settings.base.SiteSettings.logo height-{32,64} format-png preserve-svg %}</li>
{% if settings.base.SiteSettings.title %}
<li>
<a href="/">
<strong>{{ settings.base.SiteSettings.title }}</strong>
</a>
</li>
{% endif %}
</ul>
<ul>
<li>Lien</li>
</ul>
</nav>

View file

@ -0,0 +1,25 @@
# Generated by Django 5.0.6 on 2024-06-14 13:04
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("home", "0003_homepage_body_homepagelink"),
("wagtailimages", "0026_delete_uploadedimage"),
]
operations = [
migrations.AddField(
model_name="homepage",
name="logo",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="+",
to="wagtailimages.image",
),
),
]

View file

@ -0,0 +1,16 @@
# Generated by Django 5.0.6 on 2024-06-14 13:18
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("home", "0004_homepage_logo"),
]
operations = [
migrations.RemoveField(
model_name="homepage",
name="logo",
),
]

View file

@ -0,0 +1,19 @@
# Generated by Django 5.0.6 on 2024-06-14 13:24
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("home", "0005_remove_homepage_logo"),
]
operations = [
migrations.AlterField(
model_name="homepagelink",
name="id",
field=models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
]

View file

@ -10,7 +10,7 @@ class HomePage(Page):
content_panels = Page.content_panels + [ content_panels = Page.content_panels + [
FieldPanel("body"), FieldPanel("body"),
InlinePanel("links"), InlinePanel("links", heading="Links", label="Link"),
] ]

View file

@ -1,7 +1,17 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load wagtailcore_tags %}
{% block content %} {% block content %}
<h1>{{ page.title }}</h1> <h1>{{ page.title }}</h1>
{% if page.body %}
<section> <section>
{% for link in page.links.all %}<a href="{{ link.link }}"><article>{{ link.title }}</article></a>{% endfor %} {{ page.body|richtext }}
</section>
{% endif %}
<section class="grid">
{% for link in page.links.all %}
<a href="{{ link.link }}">
<article>{{ link.title }}</article>
</a>
{% endfor %}
</section> </section>
{% endblock content %} {% endblock content %}