Ajout d'un logo
This commit is contained in:
parent
49c30aab8f
commit
7794003791
15 changed files with 206 additions and 4 deletions
0
blog/base/__init__.py
Normal file
0
blog/base/__init__.py
Normal file
6
blog/base/apps.py
Normal file
6
blog/base/apps.py
Normal file
|
@ -0,0 +1,6 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class BaseConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "base"
|
51
blog/base/migrations/0001_initial.py
Normal file
51
blog/base/migrations/0001_initial.py
Normal 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,
|
||||
},
|
||||
),
|
||||
]
|
17
blog/base/migrations/0002_sitesettings_title.py
Normal file
17
blog/base/migrations/0002_sitesettings_title.py
Normal 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),
|
||||
),
|
||||
]
|
0
blog/base/migrations/__init__.py
Normal file
0
blog/base/migrations/__init__.py
Normal file
20
blog/base/models.py
Normal file
20
blog/base/models.py
Normal 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"),
|
||||
]
|
|
@ -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"]
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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 #}
|
||||
|
|
16
blog/blog/templates/nav.html
Normal file
16
blog/blog/templates/nav.html
Normal 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>
|
25
blog/home/migrations/0004_homepage_logo.py
Normal file
25
blog/home/migrations/0004_homepage_logo.py
Normal 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",
|
||||
),
|
||||
),
|
||||
]
|
16
blog/home/migrations/0005_remove_homepage_logo.py
Normal file
16
blog/home/migrations/0005_remove_homepage_logo.py
Normal 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",
|
||||
),
|
||||
]
|
19
blog/home/migrations/0006_alter_homepagelink_id.py
Normal file
19
blog/home/migrations/0006_alter_homepagelink_id.py
Normal 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"
|
||||
),
|
||||
),
|
||||
]
|
|
@ -10,7 +10,7 @@ class HomePage(Page):
|
|||
|
||||
content_panels = Page.content_panels + [
|
||||
FieldPanel("body"),
|
||||
InlinePanel("links"),
|
||||
InlinePanel("links", heading="Links", label="Link"),
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -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 %}
|
||||
|
|
Loading…
Reference in a new issue