From 39a59b88db0449ddb152822ffe0f431815bd8f9f Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sun, 19 Jun 2022 13:23:41 +0100 Subject: [PATCH] Add skeleton listing page --- static/src/scss/_content.scss | 2 +- static/src/scss/_listing.scss | 31 +++++++++++++ static/src/scss/base.scss | 1 + website/common/migrations/0004_listingpage.py | 46 +++++++++++++++++++ website/common/models.py | 18 +++++++- .../common/templates/common/content_page.html | 4 +- .../common/templates/common/listing-item.html | 16 +++++++ .../common/templates/common/listing_page.html | 13 ++++++ website/common/templatetags/util_tags.py | 8 ++++ 9 files changed, 134 insertions(+), 5 deletions(-) create mode 100644 static/src/scss/_listing.scss create mode 100644 website/common/migrations/0004_listingpage.py create mode 100644 website/common/templates/common/listing-item.html create mode 100644 website/common/templates/common/listing_page.html create mode 100644 website/common/templatetags/util_tags.py diff --git a/static/src/scss/_content.scss b/static/src/scss/_content.scss index cc3ac59..7ab8049 100644 --- a/static/src/scss/_content.scss +++ b/static/src/scss/_content.scss @@ -1,3 +1,3 @@ -.content { +section.content { font-size: 1.25rem; } diff --git a/static/src/scss/_listing.scss b/static/src/scss/_listing.scss new file mode 100644 index 0000000..1859806 --- /dev/null +++ b/static/src/scss/_listing.scss @@ -0,0 +1,31 @@ +.listing-item { + border-top: none !important; + + .image-column { + display: flex; + align-items: center; + } + + .media img { + object-fit: cover; + width: 100%; + height: 175px; + } + + .media { + max-height: 175px; + } + + .subtitle { + margin-bottom: 0.25rem !important; + } + + .media-content .content { + overflow: hidden; + } + + .media-content { + padding-left: 0; + padding-right: 0; + } +} diff --git a/static/src/scss/base.scss b/static/src/scss/base.scss index 839708b..97e5182 100644 --- a/static/src/scss/base.scss +++ b/static/src/scss/base.scss @@ -7,6 +7,7 @@ @import "footer"; @import "hero"; @import "content"; +@import "listing"; html, body { diff --git a/website/common/migrations/0004_listingpage.py b/website/common/migrations/0004_listingpage.py new file mode 100644 index 0000000..8c39e5e --- /dev/null +++ b/website/common/migrations/0004_listingpage.py @@ -0,0 +1,46 @@ +# Generated by Django 4.0.5 on 2022-06-19 10:42 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("wagtailcore", "0069_log_entry_jsonfield"), + ("wagtailimages", "0024_index_image_file_hash"), + ("common", "0003_alter_contentpage_hero_image"), + ] + + operations = [ + migrations.CreateModel( + name="ListingPage", + fields=[ + ( + "page_ptr", + models.OneToOneField( + auto_created=True, + on_delete=django.db.models.deletion.CASCADE, + parent_link=True, + primary_key=True, + serialize=False, + to="wagtailcore.page", + ), + ), + ("subtitle", models.CharField(blank=True, max_length=255)), + ( + "hero_image", + models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.SET_NULL, + to="wagtailimages.image", + ), + ), + ], + options={ + "abstract": False, + }, + bases=("wagtailcore.page",), + ), + ] diff --git a/website/common/models.py b/website/common/models.py index 19ec8f9..09bbb24 100644 --- a/website/common/models.py +++ b/website/common/models.py @@ -1,3 +1,5 @@ +from typing import Any + from django.db import models from django.utils.functional import classproperty from wagtail.admin.panels import FieldPanel @@ -18,13 +20,25 @@ class BasePage(Page): return "page-" + cls._meta.db_table.replace("_", "-") -class ContentPage(BasePage): +class BaseContentMixin(models.Model): subtitle = models.CharField(max_length=255, blank=True) hero_image = models.ForeignKey( get_image_model_string(), null=True, blank=True, on_delete=models.SET_NULL ) - content_panels = BasePage.content_panels + [ + content_panels = [ FieldPanel("subtitle"), FieldPanel("hero_image"), ] + + class Meta: + abstract = True + + +class ContentPage(BasePage, BaseContentMixin): # type: ignore[misc] + subpage_types: list[Any] = [] + content_panels = BasePage.content_panels + BaseContentMixin.content_panels + + +class ListingPage(BasePage, BaseContentMixin): # type: ignore[misc] + content_panels = BasePage.content_panels + BaseContentMixin.content_panels diff --git a/website/common/templates/common/content_page.html b/website/common/templates/common/content_page.html index 3f5fe6c..e0ca9c1 100644 --- a/website/common/templates/common/content_page.html +++ b/website/common/templates/common/content_page.html @@ -4,8 +4,8 @@ {% include "common/hero.html" %} -
+
{% lorem 10 p %} -
+ {% endblock content %} diff --git a/website/common/templates/common/listing-item.html b/website/common/templates/common/listing-item.html new file mode 100644 index 0000000..9abd09a --- /dev/null +++ b/website/common/templates/common/listing-item.html @@ -0,0 +1,16 @@ +
+
+
+

+ +

+
+
+
+

Title

+

2022-04-15 4 minutes #programming #security #website

+ {% lorem 1 p %} +
+
+
+
diff --git a/website/common/templates/common/listing_page.html b/website/common/templates/common/listing_page.html new file mode 100644 index 0000000..f38e1b5 --- /dev/null +++ b/website/common/templates/common/listing_page.html @@ -0,0 +1,13 @@ +{% extends "wagtail_base.html" %} + +{% load util_tags %} + +{% block content %} + +{% include "common/hero.html" %} + +{% for i in 3|range %} + {% include "common/listing-item.html" %} +{% endfor %} + +{% endblock content %} diff --git a/website/common/templatetags/util_tags.py b/website/common/templatetags/util_tags.py new file mode 100644 index 0000000..2f71243 --- /dev/null +++ b/website/common/templatetags/util_tags.py @@ -0,0 +1,8 @@ +from django.template import Library + +register = Library() + + +@register.filter(name="range") +def do_range(stop: int) -> range: + return range(stop)