-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from chnm/refactor/forensic-display
Use Wagtail for the forensic images page
- Loading branch information
Showing
11 changed files
with
290 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# Generated by Django 4.2.13 on 2024-10-17 20:41 | ||
|
||
import django.db.models.deletion | ||
import modelcluster.fields | ||
import wagtail.fields | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("wagtailcore", "0093_uploadedfile"), | ||
("wagtailimages", "0026_delete_uploadedimage"), | ||
("essays", "0021_essaypage_preview_image"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="ForensicPage", | ||
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", | ||
), | ||
), | ||
("body", wagtail.fields.RichTextField(blank=True)), | ||
("link_to_manuscript_page", models.URLField(blank=True)), | ||
( | ||
"preview_image", | ||
models.ForeignKey( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
related_name="+", | ||
to="wagtailimages.image", | ||
), | ||
), | ||
], | ||
options={ | ||
"abstract": False, | ||
}, | ||
bases=("wagtailcore.page",), | ||
), | ||
migrations.CreateModel( | ||
name="GalleryImage", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
( | ||
"sort_order", | ||
models.IntegerField(blank=True, editable=False, null=True), | ||
), | ||
("caption", models.CharField(blank=True, max_length=250)), | ||
( | ||
"image", | ||
models.ForeignKey( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
related_name="+", | ||
to="wagtailimages.image", | ||
), | ||
), | ||
( | ||
"page", | ||
modelcluster.fields.ParentalKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="gallery_images", | ||
to="essays.forensicpage", | ||
), | ||
), | ||
], | ||
options={ | ||
"ordering": ["sort_order"], | ||
"abstract": False, | ||
}, | ||
), | ||
] |
38 changes: 38 additions & 0 deletions
38
essays/migrations/0023_forensicpage_related_manuscript_page_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Generated by Django 4.2.13 on 2024-10-18 14:23 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("denig", "0043_alter_image_caption"), | ||
("wagtailimages", "0026_delete_uploadedimage"), | ||
("essays", "0022_forensicpage_galleryimage"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="forensicpage", | ||
name="related_manuscript_page", | ||
field=models.ForeignKey( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
related_name="+", | ||
to="denig.document", | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name="forensicpage", | ||
name="preview_image", | ||
field=models.ForeignKey( | ||
blank=True, | ||
help_text="If no preview image is provided, the first image in the gallery will be used.", | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
related_name="+", | ||
to="wagtailimages.image", | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
{% extends "base.html" %} | ||
|
||
{% load wagtailcore_tags %} | ||
{% load wagtailimages_tags %} | ||
|
||
{% block body_class %}essay-page top{% endblock %} | ||
|
||
{% block content %} | ||
<div x-data="{ | ||
modalOpen: false, | ||
modalImage: '', | ||
modalCaption: '' | ||
}"> | ||
|
||
<div class="prose relative max-w-4xl mx-auto py-12"> | ||
<h1>{{ page.title }}</h1> | ||
</div> | ||
|
||
<div class="prose relative max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-4"> | ||
|
||
{% if page.intro %} | ||
<div class="intro text-xl">{{ page.intro }}</div> | ||
{% endif %} | ||
|
||
{{ page.body|richtext }} | ||
{% if page.related_manuscript_page %} | ||
<a href="{{ page.related_manuscript_page.get_absolute_url }}" class="link hover:no-underline">← | ||
View manuscript page</a> | ||
· Click an image below to view a larger version. | ||
{% endif %} | ||
|
||
|
||
{% if page.gallery_images %} | ||
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4"> | ||
{% for item in page.gallery_images.all %} | ||
{% image item.image width-1200 as large_img %} | ||
<div class="relative overflow-hidden cursor-pointer" | ||
@click="modalOpen = true; modalImage = '{{ large_img.url }}'; modalCaption = '{{ item.caption|escapejs }}'"> | ||
{% image item.image fill-400x300 as img %} | ||
<img src="{{ img.url }}" alt="{{ item.image.title }}" | ||
class="w-full h-full object-cover transition duration-300 ease-in-out transform hover:scale-105" /> | ||
</div> | ||
{% endfor %} | ||
</div> | ||
{% endif %} | ||
|
||
</div> | ||
|
||
<!-- Modal --> | ||
<div x-show="modalOpen" | ||
class="fixed inset-0 z-50 overflow-auto bg-black bg-opacity-90 flex items-center justify-center" | ||
x-transition:enter="transition ease-out duration-300" x-transition:enter-start="opacity-0" | ||
x-transition:enter-end="opacity-100" x-transition:leave="transition ease-in duration-300" | ||
x-transition:leave-start="opacity-100" x-transition:leave-end="opacity-0" @click.away="modalOpen = false"> | ||
<div class="relative bg-white rounded-lg max-w-5xl max-h-[95vh] overflow-hidden shadow-2xl"> | ||
<button @click="modalOpen = false" | ||
class="absolute top-0 right-0 m-4 p-2 bg-winterthur-dk-blue text-white hover:bg-winterthur-dker-blue rounded-full shadow-lg z-10"> | ||
<svg class="h-10 w-10" fill="none" stroke="currentColor" viewBox="0 0 24 24" | ||
xmlns="http://www.w3.org/2000/svg"> | ||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"> | ||
</path> | ||
</svg> | ||
</button> | ||
<div class="flex items-center justify-center w-full h-full"> | ||
<img :src="modalImage" alt="Large version" class="max-w-full max-h-full object-contain"> | ||
</div> | ||
<div x-show="modalCaption" class="p-4 bg-white bg-opacity-75 absolute bottom-0 left-0 right-0"> | ||
<p x-text="modalCaption" class="text-gray-800 text-lg"></p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} |
Oops, something went wrong.