Ajout d'un logo

This commit is contained in:
Edgar P. Burkhart 2024-06-14 15:56:37 +02:00
parent 49c30aab8f
commit 7794003791
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
15 changed files with 206 additions and 4 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
INSTALLED_APPS = [
"base",
"home",
"search",
"wagtail.contrib.forms",
"wagtail.contrib.redirects",
"wagtail.contrib.settings",
"wagtail.embeds",
"wagtail.sites",
"wagtail.users",
@ -73,6 +75,7 @@ TEMPLATES = [
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"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
# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators
@ -189,3 +194,5 @@ WAGTAILDOCS_EXTENSIONS = [
"xlsx",
"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>
<html lang="en">
<head>
@ -28,10 +28,13 @@
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' %}">
{% 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>
<body>
{% wagtailuserbar %}
<main class="container-fluid">
{% include "nav.html" %}
<main class="container">
{% block content %}{% endblock %}
</main>
{# 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 + [
FieldPanel("body"),
InlinePanel("links"),
InlinePanel("links", heading="Links", label="Link"),
]

View file

@ -8,6 +8,10 @@
</section>
{% endif %}
<section class="grid">
{% for link in page.links.all %}<a href="{{ link.link }}"><article>{{ link.title }}</article></a>{% endfor %}
{% for link in page.links.all %}
<a href="{{ link.link }}">
<article>{{ link.title }}</article>
</a>
{% endfor %}
</section>
{% endblock content %}