Skip to content

Commit

Permalink
Merge pull request #1072 from ecds/feature/homepage-featured-story
Browse files Browse the repository at this point in the history
Update homepage model/template to add featured story
  • Loading branch information
blms authored Sep 23, 2024
2 parents 2fcc03f + dfca105 commit f85f0a3
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 8 deletions.
43 changes: 43 additions & 0 deletions apps/cms/migrations/0005_homepage_featured_story.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Generated by Django 3.2.25 on 2024-09-13 16:25

from django.db import migrations, models

class Migration(migrations.Migration):

dependencies = [
("cms", "0004_auto_20200224_2038"),
]

operations = [
migrations.AddField(
model_name="homepage",
name="featured_story_image",
field=models.ForeignKey(
blank=True,
help_text="Thumbnail image for the featured story",
null=True,
on_delete=models.deletion.SET_NULL,
related_name="+",
to="wagtailimages.image",
),
),
migrations.AddField(
model_name="homepage",
name="featured_story_summary",
field=models.TextField(
blank=True, help_text="A summary or excerpt of the featured story"
),
),
migrations.AddField(
model_name="homepage",
name="featured_story_title",
field=models.CharField(
blank=True, help_text="Title of the featured story", max_length=255
),
),
migrations.AddField(
model_name="homepage",
name="featured_story_url",
field=models.URLField(blank=True, help_text="Link to the featured story"),
),
]
26 changes: 25 additions & 1 deletion apps/cms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from modelcluster.fields import ParentalManyToManyField
from wagtail.models import Page
from wagtail.fields import RichTextField, StreamField
from wagtail.admin.panels import FieldPanel
from wagtail.admin.panels import FieldPanel, MultiFieldPanel
from wagtailautocomplete.edit_handlers import AutocompletePanel
from django.db import models
from apps.cms.blocks import BaseStreamBlock
Expand Down Expand Up @@ -257,13 +257,37 @@ class HomePage(Page):
collections = Collection.objects.all()[:8]
volumes = Manifest.objects.all()[:8]

featured_story_title = models.CharField(
help_text="Title of the featured story", blank=True, max_length=255
)
featured_story_summary = models.TextField(
help_text="A summary or excerpt of the featured story", blank=True
)
featured_story_image = models.ForeignKey(
'wagtailimages.Image',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='+',
help_text="Thumbnail image for the featured story",
)
featured_story_url = models.URLField(
help_text="Link to the featured story", blank=True
)

content_panels = Page.content_panels + [
FieldPanel('tagline', classname="full"),
FieldPanel('content_display', classname="full"),
AutocompletePanel('featured_collections', target_model="kollections.Collection"),
FieldPanel('featured_collections_sort_order', classname="full"),
AutocompletePanel('featured_volumes', target_model="manifests.Manifest"),
FieldPanel('featured_volumes_sort_order', classname="full"),
MultiFieldPanel(children=[
FieldPanel('featured_story_title'),
FieldPanel('featured_story_summary'),
FieldPanel('featured_story_image'),
FieldPanel('featured_story_url'),
], heading='Featured story (optional)'),
]

def featured_volume_count(self):
Expand Down
18 changes: 13 additions & 5 deletions apps/templates/_home/_featured_story.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
{% load wagtailimages_tags %}

<div class="uk-section uk-section-default section-offset">
<div class="uk-container">
<div class="uk-child-width-expand@s" uk-grid>
{% if page.featured_story_image %}
<div class="uk-width-1-4@s">
<img src="https://images.unsplash.com/photo-1512820790803-83ca734da794?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwzNjUyOXwwfDF8c2VhcmNofDF8fGJvb2slMkN8ZW58MHx8fHwxNjM0NTY2ODcy&ixlib=rb-1.2.1&q=80&w=400" alt="Image" class="uk-width-1-1">
{% image page.featured_story_image max-700x700 class="uk-width-1-1" %}
</div>
<div class="uk-width-3-4@s">
<h2 class="title uk-margin-small-bottom">Reviving Sacred Song: The Sounding Spirit Collaborative and Its Impact on American Vernacular Music History</h2>
{% else %}
<div class="uk-width-4-4@s">
{% endif%}
<h2 class="title uk-margin-small-bottom">{{ page.featured_story_title }}</h2>
<p class="truncate-text paragraph">
The Sounding Spirit Collaborative engages sacred music from a dynamic era of American history. We make accessible and interpret historical sacred vernacular songbooks printed across territories and states spanning the southern United States from 1850 to 1925. Our ongoing scholarly edition and digital library work leverages collaborations between scholars, practitioners, librarians, and technologists to bring interdisciplinary, multi-modal expertise to the study and dissemination of these music books. These collaborations invite both scholarly and confessional reconsiderations of the role of sacred song in the lived experience of diverse communities. Working with texts and tunes often marginalized in music history, singers and scholars join Sounding Spirit in claiming a more diverse canon of southern vernacular sacred music.
{{ page.featured_story_summary }}
</p>
<a class="uk-margin-top text-anchor uk-text-medium uk-text-bold">Read Full Story</a>
<a href="{{ page.featured_story_url }}" class="uk-margin-top text-anchor uk-text-medium uk-text-bold">
Read Full Story
</a>
</div>
</div>
</div>
</div>
</div>
6 changes: 4 additions & 2 deletions apps/templates/cms/home_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
<div class="content">
{% include '_home/_nav.html' %}
{% include '_home/_hero.html' %}
{% include '_home/_featured_story.html' %}
{% if page.featured_story_title and page.featured_story_url %}
{% include '_home/_featured_story.html' %}
{% endif %}
{% if page.featured_volumes.all.count != 0 %}
{% include '_home/_featured_volumes.html' %}
{% endif %}
Expand All @@ -31,4 +33,4 @@
</div>
{% endif %}

{% endblock %}
{% endblock %}

0 comments on commit f85f0a3

Please sign in to comment.