commit 5eb9bb64d24ba809d3af72661c54ffa7828b6df6 Author: mouws Date: Sat Dec 20 00:16:56 2025 +0100 fucked things up with egit gui but now its cool. diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..63ce98d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,39 @@ +# Django project +/media/ +/static/ +*.sqlite3 + +# Python and others +__pycache__ +*.pyc +.DS_Store +*.swp +/venv/ +/tmp/ +/.vagrant/ +/Vagrantfile.local +node_modules/ +/npm-debug.log +/.idea/ +.vscode +coverage +.python-version + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg diff --git a/.project b/.project new file mode 100644 index 0000000..b89f360 --- /dev/null +++ b/.project @@ -0,0 +1,18 @@ + + + jacksbastards + + + + + + org.python.pydev.PyDevBuilder + + + + + + org.python.pydev.pythonNature + org.python.pydev.django.djangoNature + + diff --git a/.pydevproject b/.pydevproject new file mode 100644 index 0000000..48fce11 --- /dev/null +++ b/.pydevproject @@ -0,0 +1,166 @@ + + + + /${PROJECT_DIR_NAME} + + python interpreter + Default + + env_var:PS1 + [📦 $FLATPAK_ID \W]\$ + env_var:INVOCATION_ID + ec08f22997324076b6f99c10ec5d1f64 + PY + 314 + env_var:SWT_GTK4 + 0 + env_var:HOSTNAME + studio-desktop + env_var:LANG + en_GB.UTF-8 + env_var:GDM_LANG + en_GB.UTF-8 + env_var:XDG_CONFIG_DIRS + /app/etc/xdg:/etc/xdg + env_var:GI_TYPELIB_PATH + /app/lib/girepository-1.0 + env_var:PWD + /home/maarten + env_var:XDG_MENU_PREFIX + gnome- + env_var:DBUS_SESSION_BUS_ADDRESS + unix:path=/run/flatpak/bus + env_var:HOME + /home/maarten + env_var:WAYLAND_DISPLAY + wayland-0 + env_var:XDG_DATA_DIRS + /app/share:/usr/share:/usr/share/runtime/share:/run/host/user-share:/run/host/share + env_var:GDK_CORE_DEVICE_EVENTS + 1 + env_var:MANAGERPID + 1277 + env_var:XDG_DATA_HOME + /home/maarten/.var/app/org.eclipse.Java/data + env_var:XDG_CURRENT_DESKTOP + GNOME + env_var:FLATPAK_ID + org.eclipse.Java + env_var:SYSTEMD_EXEC_PID + 4524 + env_var:LOGNAME + maarten + env_var:PATH + /app/bin:/usr/bin + env_var:XDG_SESSION_CLASS + user + env_var:GPG_TTY + not a tty + env_var:GDK_GL + gles + env_var:XDG_SESSION_TYPE + wayland + env_var:LD_LIBRARY_PATH + + env_var:ALSA_CONFIG_DIR + /usr/share/alsa + env_var:KDEDIRS + /usr + env_var:JOURNAL_STREAM + 9:35499 + env_var:QT_IM_MODULES + wayland;ibus + env_var:XMODIFIERS + @im=ibus + env_var:DEBUGINFOD_IMA_CERT_PATH + /etc/keys/ima: + DJANGO_MANAGE_LOCATION + manage.py + env_var:MAIL + /var/spool/mail/maarten + env_var:HISTCONTROL + ignoredups + env_var:LESSOPEN + ||/usr/bin/lesspipe.sh %s + env_var:MEMORY_PRESSURE_WRITE + c29tZSAyMDAwMDAgMjAwMDAwMAA= + env_var:GDMSESSION + gnome + env_var:MANAGERPIDFDID + 1278 + env_var:GJS_DEBUG_TOPICS + JS ERROR;JS LOG + env_var:XDG_RUNTIME_DIR + /run/user/1000 + env_var:XDG_STATE_HOME + /home/maarten/.var/app/org.eclipse.Java/.local/state + env_var:LIBOVERLAY_SCROLLBAR + 0 + env_var:container + flatpak + env_var:SSH_ASKPASS + /usr/bin/ksshaskpass + env_var:SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS + 0 + env_var:XDG_SESSION_DESKTOP + gnome + env_var:USER + maarten + env_var:ALSA_CONFIG_PATH + /usr/share/alsa/alsa-flatpak.conf + env_var:DEBUGINFOD_URLS + ima:enforcing https://debuginfod.fedoraproject.org/ ima:ignore + env_var:SSH_AUTH_SOCK + /run/flatpak/ssh-auth + env_var:EDITOR + /usr/bin/nano + env_var:OXYGEN_DISABLE_INNER_SHADOWS_HACK + 1 + env_var:XAUTHORITY + /run/user/1000/.mutter-Xwaylandauth.IT3MH3 + env_var:MEMORY_PRESSURE_WATCH + /sys/fs/cgroup/user.slice/user-1000.slice/user@1000.service/session.slice/org.gnome.Shell@wayland.service/memory.pressure + env_var:GIO_LAUNCHED_DESKTOP_FILE_PID + 21757 + env_var:GNOME_SETUP_DISPLAY + :1 + env_var:PIPENV_VENV_IN_PROJECT + 1 + env_var:GST_PLUGIN_SYSTEM_PATH + /app/lib/gstreamer-1.0:/usr/lib/extensions/gstreamer-1.0:/usr/lib/x86_64-linux-gnu/codecs-extra/lib/gstreamer-1.0:/usr/lib/x86_64-linux-gnu/gstreamer-1.0 + env_var:XDG_CACHE_HOME + /home/maarten/.var/app/org.eclipse.Java/cache + env_var:PYTHONUSERBASE + /var/data/python + env_var:USERNAME + maarten + env_var:QT_IM_MODULE + ibus + env_var:SHELL + /bin/sh + env_var:SHLVL + 0 + env_var:FLATPAK_SANDBOX_DIR + /home/maarten/.var/app/org.eclipse.Java/sandbox + DJANGO_SETTINGS_MODULE + jacksbastards.settings + env_var:STEAM_FRAME_FORCE_CLOSE + 1 + env_var:AT_SPI_BUS_ADDRESS + unix:path=/run/flatpak/at-spi-bus + env_var:HISTSIZE + 1000 + env_var:GJS_DEBUG_OUTPUT + stderr + env_var:GIO_LAUNCHED_DESKTOP_FILE + /var/lib/flatpak/exports/share/applications/org.eclipse.Java.desktop + env_var:XDG_CONFIG_HOME + /home/maarten/.var/app/org.eclipse.Java/config + env_var:__EGL_EXTERNAL_PLATFORM_CONFIG_DIRS + /etc/egl/egl_external_platform.d:/usr/lib/x86_64-linux-gnu/GL/egl/egl_external_platform.d:/usr/share/egl/egl_external_platform.d + env_var:MOZ_GMP_PATH + /usr/lib64/mozilla/plugins/gmp-gmpopenh264/system-installed + env_var:DESKTOP_SESSION + gnome + + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9d35311 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,60 @@ +# Use an official Python runtime based on Debian 12 "bookworm" as a parent image. +FROM python:3.12-slim-bookworm + +# Add user that will be used in the container. +RUN useradd wagtail + +# Port used by this container to serve HTTP. +EXPOSE 8000 + +# Set environment variables. +# 1. Force Python stdout and stderr streams to be unbuffered. +# 2. Set PORT variable that is used by Gunicorn. This should match "EXPOSE" +# command. +ENV PYTHONUNBUFFERED=1 \ + PORT=8000 + +# Install system packages required by Wagtail and Django. +RUN apt-get update --yes --quiet && apt-get install --yes --quiet --no-install-recommends \ + build-essential \ + libpq-dev \ + libmariadb-dev \ + libjpeg62-turbo-dev \ + zlib1g-dev \ + libwebp-dev \ + && rm -rf /var/lib/apt/lists/* + +# Install the application server. +RUN pip install "gunicorn==20.0.4" + +# Install the project requirements. +COPY requirements.txt / +RUN pip install -r /requirements.txt + +# Use /app folder as a directory where the source code is stored. +WORKDIR /app + +# Set this directory to be owned by the "wagtail" user. This Wagtail project +# uses SQLite, the folder needs to be owned by the user that +# will be writing to the database file. +RUN chown wagtail:wagtail /app + +# Copy the source code of the project into the container. +COPY --chown=wagtail:wagtail . . + +# Use user "wagtail" to run the build commands below and the server itself. +USER wagtail + +# Collect static files. +RUN python manage.py collectstatic --noinput --clear + +# Runtime command that executes when "docker run" is called, it does the +# following: +# 1. Migrate the database. +# 2. Start the application server. +# WARNING: +# Migrating database at the same time as starting the server IS NOT THE BEST +# PRACTICE. The database should be migrated manually or using the release +# phase facilities of your hosting platform. This is used only so the +# Wagtail instance can be started with a simple "docker run" command. +CMD set -xe; python manage.py migrate --noinput; gunicorn jacksbastards.wsgi:application diff --git a/base/__init__.py b/base/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/base/__pycache__/__init__.cpython-314.pyc b/base/__pycache__/__init__.cpython-314.pyc new file mode 100644 index 0000000..76e97ab Binary files /dev/null and b/base/__pycache__/__init__.cpython-314.pyc differ diff --git a/base/__pycache__/admin.cpython-314.pyc b/base/__pycache__/admin.cpython-314.pyc new file mode 100644 index 0000000..34929ab Binary files /dev/null and b/base/__pycache__/admin.cpython-314.pyc differ diff --git a/base/__pycache__/apps.cpython-314.pyc b/base/__pycache__/apps.cpython-314.pyc new file mode 100644 index 0000000..3635311 Binary files /dev/null and b/base/__pycache__/apps.cpython-314.pyc differ diff --git a/base/__pycache__/models.cpython-314.pyc b/base/__pycache__/models.cpython-314.pyc new file mode 100644 index 0000000..ecfc872 Binary files /dev/null and b/base/__pycache__/models.cpython-314.pyc differ diff --git a/base/admin.py b/base/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/base/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/base/apps.py b/base/apps.py new file mode 100644 index 0000000..05011e8 --- /dev/null +++ b/base/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class BaseConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'base' diff --git a/base/migrations/0001_initial.py b/base/migrations/0001_initial.py new file mode 100644 index 0000000..ddac1c8 --- /dev/null +++ b/base/migrations/0001_initial.py @@ -0,0 +1,26 @@ +# Generated by Django 5.2.9 on 2025-12-19 20:27 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='NavigationSettings', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('linkedin_url', models.URLField(blank=True, verbose_name='LinkedIn URL')), + ('github_url', models.URLField(blank=True, verbose_name='GitHub URL')), + ('mastodon_url', models.URLField(blank=True, verbose_name='Mastodon URL')), + ], + options={ + 'abstract': False, + }, + ), + ] diff --git a/base/migrations/0002_remove_navigationsettings_github_url_and_more.py b/base/migrations/0002_remove_navigationsettings_github_url_and_more.py new file mode 100644 index 0000000..08b1e13 --- /dev/null +++ b/base/migrations/0002_remove_navigationsettings_github_url_and_more.py @@ -0,0 +1,45 @@ +# Generated by Django 5.2.9 on 2025-12-19 21:53 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('base', '0001_initial'), + ] + + operations = [ + migrations.RemoveField( + model_name='navigationsettings', + name='github_url', + ), + migrations.RemoveField( + model_name='navigationsettings', + name='linkedin_url', + ), + migrations.RemoveField( + model_name='navigationsettings', + name='mastodon_url', + ), + migrations.AddField( + model_name='navigationsettings', + name='facebook_url', + field=models.URLField(blank=True, verbose_name='Facebook URL'), + ), + migrations.AddField( + model_name='navigationsettings', + name='gitea_url', + field=models.URLField(blank=True, verbose_name='Gitea URL'), + ), + migrations.AddField( + model_name='navigationsettings', + name='instagram_url', + field=models.URLField(blank=True, verbose_name='Instagram URL'), + ), + migrations.AddField( + model_name='navigationsettings', + name='youtube_url', + field=models.URLField(blank=True, verbose_name='Youtube URL'), + ), + ] diff --git a/base/migrations/__init__.py b/base/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/base/migrations/__pycache__/0001_initial.cpython-314.pyc b/base/migrations/__pycache__/0001_initial.cpython-314.pyc new file mode 100644 index 0000000..e329594 Binary files /dev/null and b/base/migrations/__pycache__/0001_initial.cpython-314.pyc differ diff --git a/base/migrations/__pycache__/0002_remove_navigationsettings_github_url_and_more.cpython-314.pyc b/base/migrations/__pycache__/0002_remove_navigationsettings_github_url_and_more.cpython-314.pyc new file mode 100644 index 0000000..4d7de9f Binary files /dev/null and b/base/migrations/__pycache__/0002_remove_navigationsettings_github_url_and_more.cpython-314.pyc differ diff --git a/base/migrations/__pycache__/__init__.cpython-314.pyc b/base/migrations/__pycache__/__init__.cpython-314.pyc new file mode 100644 index 0000000..dd58ab6 Binary files /dev/null and b/base/migrations/__pycache__/__init__.cpython-314.pyc differ diff --git a/base/models.py b/base/models.py new file mode 100644 index 0000000..786ee1f --- /dev/null +++ b/base/models.py @@ -0,0 +1,29 @@ +from django.db import models +from wagtail.admin.panels import ( + FieldPanel, + MultiFieldPanel, +) +from wagtail.contrib.settings.models import ( + BaseGenericSetting, + register_setting, +) + +@register_setting +class NavigationSettings(BaseGenericSetting): + youtube_url = models.URLField(verbose_name="Youtube URL", blank=True) + facebook_url = models.URLField(verbose_name="Facebook URL", blank=True) + instagram_url = models.URLField(verbose_name="Instagram URL", blank=True) + gitea_url = models.URLField(verbose_name="Gitea URL", blank=True) + + + panels = [ + MultiFieldPanel( + [ + FieldPanel("youtube_url"), + FieldPanel("facebook_url"), + FieldPanel("instagram_url"), + FieldPanel("gitea_url"), + ], + "Social settings", + ) + ] \ No newline at end of file diff --git a/base/tests.py b/base/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/base/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/base/views.py b/base/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/base/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/blog/__init__.py b/blog/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/blog/__pycache__/__init__.cpython-314.pyc b/blog/__pycache__/__init__.cpython-314.pyc new file mode 100644 index 0000000..14bd02a Binary files /dev/null and b/blog/__pycache__/__init__.cpython-314.pyc differ diff --git a/blog/__pycache__/admin.cpython-314.pyc b/blog/__pycache__/admin.cpython-314.pyc new file mode 100644 index 0000000..5e8ae95 Binary files /dev/null and b/blog/__pycache__/admin.cpython-314.pyc differ diff --git a/blog/__pycache__/apps.cpython-314.pyc b/blog/__pycache__/apps.cpython-314.pyc new file mode 100644 index 0000000..e959b70 Binary files /dev/null and b/blog/__pycache__/apps.cpython-314.pyc differ diff --git a/blog/__pycache__/models.cpython-314.pyc b/blog/__pycache__/models.cpython-314.pyc new file mode 100644 index 0000000..56b8f75 Binary files /dev/null and b/blog/__pycache__/models.cpython-314.pyc differ diff --git a/blog/admin.py b/blog/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/blog/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/blog/apps.py b/blog/apps.py new file mode 100644 index 0000000..94788a5 --- /dev/null +++ b/blog/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class BlogConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'blog' diff --git a/blog/migrations/0001_initial.py b/blog/migrations/0001_initial.py new file mode 100644 index 0000000..b5aec4b --- /dev/null +++ b/blog/migrations/0001_initial.py @@ -0,0 +1,28 @@ +# Generated by Django 5.2.9 on 2025-12-19 16:42 + +import django.db.models.deletion +import wagtail.fields +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('wagtailcore', '0096_referenceindex_referenceindex_source_object_and_more'), + ] + + operations = [ + migrations.CreateModel( + name='BlogIndexPage', + 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')), + ('intro', wagtail.fields.RichTextField(blank=True)), + ], + options={ + 'abstract': False, + }, + bases=('wagtailcore.page',), + ), + ] diff --git a/blog/migrations/0002_blogpage.py b/blog/migrations/0002_blogpage.py new file mode 100644 index 0000000..e093525 --- /dev/null +++ b/blog/migrations/0002_blogpage.py @@ -0,0 +1,29 @@ +# Generated by Django 5.2.9 on 2025-12-19 16:59 + +import django.db.models.deletion +import wagtail.fields +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('blog', '0001_initial'), + ('wagtailcore', '0096_referenceindex_referenceindex_source_object_and_more'), + ] + + operations = [ + migrations.CreateModel( + name='BlogPage', + 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')), + ('date', models.DateField(verbose_name='Post date')), + ('intro', models.CharField(max_length=250)), + ('body', wagtail.fields.RichTextField(blank=True)), + ], + options={ + 'abstract': False, + }, + bases=('wagtailcore.page',), + ), + ] diff --git a/blog/migrations/0003_blogpagegalleryimage.py b/blog/migrations/0003_blogpagegalleryimage.py new file mode 100644 index 0000000..59e5ef9 --- /dev/null +++ b/blog/migrations/0003_blogpagegalleryimage.py @@ -0,0 +1,30 @@ +# Generated by Django 5.2.9 on 2025-12-19 17:37 + +import django.db.models.deletion +import modelcluster.fields +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('blog', '0002_blogpage'), + ('wagtailimages', '0027_image_description'), + ] + + operations = [ + migrations.CreateModel( + name='BlogPageGalleryImage', + 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(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='wagtailimages.image')), + ('page', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='gallery_images', to='blog.blogpage')), + ], + options={ + 'ordering': ['sort_order'], + 'abstract': False, + }, + ), + ] diff --git a/blog/migrations/0004_author.py b/blog/migrations/0004_author.py new file mode 100644 index 0000000..505814b --- /dev/null +++ b/blog/migrations/0004_author.py @@ -0,0 +1,26 @@ +# Generated by Django 5.2.9 on 2025-12-19 18:54 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('blog', '0003_blogpagegalleryimage'), + ('wagtailimages', '0027_image_description'), + ] + + operations = [ + migrations.CreateModel( + name='Author', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=255)), + ('author_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image')), + ], + options={ + 'verbose_name_plural': 'Authors', + }, + ), + ] diff --git a/blog/migrations/0005_blogpage_authors.py b/blog/migrations/0005_blogpage_authors.py new file mode 100644 index 0000000..399ebce --- /dev/null +++ b/blog/migrations/0005_blogpage_authors.py @@ -0,0 +1,19 @@ +# Generated by Django 5.2.9 on 2025-12-19 19:04 + +import modelcluster.fields +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('blog', '0004_author'), + ] + + operations = [ + migrations.AddField( + model_name='blogpage', + name='authors', + field=modelcluster.fields.ParentalManyToManyField(blank=True, to='blog.author'), + ), + ] diff --git a/blog/migrations/0006_blogpagetag_blogpage_tags.py b/blog/migrations/0006_blogpagetag_blogpage_tags.py new file mode 100644 index 0000000..354c61c --- /dev/null +++ b/blog/migrations/0006_blogpagetag_blogpage_tags.py @@ -0,0 +1,33 @@ +# Generated by Django 5.2.9 on 2025-12-19 19:26 + +import django.db.models.deletion +import modelcluster.contrib.taggit +import modelcluster.fields +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('blog', '0005_blogpage_authors'), + ('taggit', '0006_rename_taggeditem_content_type_object_id_taggit_tagg_content_8fc721_idx'), + ] + + operations = [ + migrations.CreateModel( + name='BlogPageTag', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('content_object', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='tagged_items', to='blog.blogpage')), + ('tag', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(app_label)s_%(class)s_items', to='taggit.tag')), + ], + options={ + 'abstract': False, + }, + ), + migrations.AddField( + model_name='blogpage', + name='tags', + field=modelcluster.contrib.taggit.ClusterTaggableManager(blank=True, help_text='A comma-separated list of tags.', through='blog.BlogPageTag', to='taggit.Tag', verbose_name='Tags'), + ), + ] diff --git a/blog/migrations/0007_blogtagindexpage.py b/blog/migrations/0007_blogtagindexpage.py new file mode 100644 index 0000000..071455c --- /dev/null +++ b/blog/migrations/0007_blogtagindexpage.py @@ -0,0 +1,25 @@ +# Generated by Django 5.2.9 on 2025-12-19 19:36 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('blog', '0006_blogpagetag_blogpage_tags'), + ('wagtailcore', '0096_referenceindex_referenceindex_source_object_and_more'), + ] + + operations = [ + migrations.CreateModel( + name='BlogTagIndexPage', + 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')), + ], + options={ + 'abstract': False, + }, + bases=('wagtailcore.page',), + ), + ] diff --git a/blog/migrations/__init__.py b/blog/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/blog/migrations/__pycache__/0001_initial.cpython-314.pyc b/blog/migrations/__pycache__/0001_initial.cpython-314.pyc new file mode 100644 index 0000000..491d6a8 Binary files /dev/null and b/blog/migrations/__pycache__/0001_initial.cpython-314.pyc differ diff --git a/blog/migrations/__pycache__/0002_blogpage.cpython-314.pyc b/blog/migrations/__pycache__/0002_blogpage.cpython-314.pyc new file mode 100644 index 0000000..b579914 Binary files /dev/null and b/blog/migrations/__pycache__/0002_blogpage.cpython-314.pyc differ diff --git a/blog/migrations/__pycache__/0003_blogpagegalleryimage.cpython-314.pyc b/blog/migrations/__pycache__/0003_blogpagegalleryimage.cpython-314.pyc new file mode 100644 index 0000000..8523f26 Binary files /dev/null and b/blog/migrations/__pycache__/0003_blogpagegalleryimage.cpython-314.pyc differ diff --git a/blog/migrations/__pycache__/0004_author.cpython-314.pyc b/blog/migrations/__pycache__/0004_author.cpython-314.pyc new file mode 100644 index 0000000..1977c72 Binary files /dev/null and b/blog/migrations/__pycache__/0004_author.cpython-314.pyc differ diff --git a/blog/migrations/__pycache__/0005_blogpage_authors.cpython-314.pyc b/blog/migrations/__pycache__/0005_blogpage_authors.cpython-314.pyc new file mode 100644 index 0000000..e70538e Binary files /dev/null and b/blog/migrations/__pycache__/0005_blogpage_authors.cpython-314.pyc differ diff --git a/blog/migrations/__pycache__/0006_blogpagetag_blogpage_tags.cpython-314.pyc b/blog/migrations/__pycache__/0006_blogpagetag_blogpage_tags.cpython-314.pyc new file mode 100644 index 0000000..2ce8868 Binary files /dev/null and b/blog/migrations/__pycache__/0006_blogpagetag_blogpage_tags.cpython-314.pyc differ diff --git a/blog/migrations/__pycache__/0007_blogtagindexpage.cpython-314.pyc b/blog/migrations/__pycache__/0007_blogtagindexpage.cpython-314.pyc new file mode 100644 index 0000000..889c89e Binary files /dev/null and b/blog/migrations/__pycache__/0007_blogtagindexpage.cpython-314.pyc differ diff --git a/blog/migrations/__pycache__/__init__.cpython-314.pyc b/blog/migrations/__pycache__/__init__.cpython-314.pyc new file mode 100644 index 0000000..d62e6d7 Binary files /dev/null and b/blog/migrations/__pycache__/__init__.cpython-314.pyc differ diff --git a/blog/models.py b/blog/models.py new file mode 100644 index 0000000..3374b60 --- /dev/null +++ b/blog/models.py @@ -0,0 +1,86 @@ +from django import forms +from django.db import models +from wagtail.models import Page, Orderable +from wagtail.fields import RichTextField +from wagtail.snippets.models import register_snippet +from wagtail.admin.panels import FieldPanel, MultiFieldPanel +from modelcluster.fields import ParentalKey, ParentalManyToManyField +from modelcluster.contrib.taggit import ClusterTaggableManager +from taggit.models import TaggedItemBase + + + +class BlogIndexPage(Page): + intro = RichTextField(blank=True) + # add the get_context method: + def get_context(self, request): + # Update context to include only published posts, ordered by reverse-chron + context = super().get_context(request) + blogpages = self.get_children().live().order_by('-first_published_at') + context['blogpages'] = blogpages + return context + +class BlogPageTag(TaggedItemBase): + content_object = ParentalKey( + 'BlogPage', + related_name='tagged_items', + on_delete=models.CASCADE + ) + +class BlogPage(Page): + date = models.DateField("Post date") + intro = models.CharField(max_length=250) + body = RichTextField(blank=True) + tags = ClusterTaggableManager(through=BlogPageTag, blank=True) + + def main_image(self): + gallery_item = self.gallery_images.first() + if gallery_item: + return gallery_item.image + else: + return None + + authors = ParentalManyToManyField('blog.Author', blank=True) + + content_panels = Page.content_panels + [ + MultiFieldPanel(["date", FieldPanel("authors", widget=forms.CheckboxSelectMultiple), "tags", + ], heading="Blog information"), + "intro", "body", "gallery_images" + ] +class BlogPageGalleryImage(Orderable): + page = ParentalKey(BlogPage, on_delete=models.CASCADE, related_name='gallery_images') + image = models.ForeignKey( + 'wagtailimages.Image', on_delete=models.CASCADE, related_name='+' + ) + caption = models.CharField(blank=True, max_length=250) + + panels = ["image", "caption"] + +class BlogTagIndexPage(Page): + + def get_context(self, request): + + # Filter by tag + tag = request.GET.get('tag') + blogpages = BlogPage.objects.filter(tags__name=tag) + + # Update template context + context = super().get_context(request) + context['blogpages'] = blogpages + return context + +@register_snippet +class Author(models.Model): + name = models.CharField(max_length=255) + author_image = models.ForeignKey( + 'wagtailimages.Image', null=True, blank=True, + on_delete=models.SET_NULL, related_name='+' + ) + + panels = ["name", "author_image"] + + def __str__(self): + return self.name + + class Meta: + verbose_name_plural = 'Authors' diff --git a/blog/templates/blog/blog_index_page.html b/blog/templates/blog/blog_index_page.html new file mode 100644 index 0000000..9257fce --- /dev/null +++ b/blog/templates/blog/blog_index_page.html @@ -0,0 +1,28 @@ +{% extends "base.html" %} + +{% load wagtailcore_tags %} + + +{% load wagtailcore_tags wagtailimages_tags %} + +{% block body_class %}template-blogindexpage{% endblock %} + +{% block content %} +

{{ page.title }}

+ +
{{ page.intro|richtext }}
+ + {% for post in blogpages %} + {% with post=post.specific %} +

{{ post.title }}

+ + {% with post.main_image as main_image %} + {% if main_image %}{% image main_image fill-160x100 %}{% endif %} + {% endwith %} + +

{{ post.intro }}

+ {{ post.body|richtext }} + {% endwith %} + {% endfor %} + +{% endblock %} \ No newline at end of file diff --git a/blog/templates/blog/blog_page.html b/blog/templates/blog/blog_page.html new file mode 100644 index 0000000..123a4d9 --- /dev/null +++ b/blog/templates/blog/blog_page.html @@ -0,0 +1,47 @@ +{% load wagtailcore_tags wagtailimages_tags %} + +{% block body_class %}template-blogpage{% endblock %} + +{% block content %} +

{{ page.title }}

+

{{ page.date }}

+ + {% with authors=page.authors.all %} + {% if authors %} +

Posted by:

+ + {% endif %} + {% endwith %} + +
{{ page.intro }}
+ + {{ page.body|richtext }} + + {% for item in page.gallery_images.all %} +
+ {% image item.image fill-320x240 %} +

{{ item.caption }}

+
+ {% endfor %} + +

Return to blog

+ + {% with tags=page.tags.all %} + {% if tags %} +
+

Tags

+ {% for tag in tags %} + + {% endfor %} +
+ {% endif %} + {% endwith %} + +{% endblock %} \ No newline at end of file diff --git a/blog/templates/blog/blog_tag_index_page.html b/blog/templates/blog/blog_tag_index_page.html new file mode 100644 index 0000000..15f6608 --- /dev/null +++ b/blog/templates/blog/blog_tag_index_page.html @@ -0,0 +1,21 @@ +{% extends "base.html" %} +{% load wagtailcore_tags %} + +{% block content %} + + {% if request.GET.tag %} +

Showing pages tagged "{{ request.GET.tag }}"

+ {% endif %} + + {% for blogpage in blogpages %} + +

+ {{ blogpage.title }}
+ Revised: {{ blogpage.latest_revision_created_at }}
+

+ + {% empty %} + No pages found with that tag. + {% endfor %} + +{% endblock %} \ No newline at end of file diff --git a/blog/tests.py b/blog/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/blog/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/blog/views.py b/blog/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/blog/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/db.sqlite3 b/db.sqlite3 new file mode 100644 index 0000000..b760276 Binary files /dev/null and b/db.sqlite3 differ diff --git a/home/__init__.py b/home/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/home/__pycache__/__init__.cpython-314.pyc b/home/__pycache__/__init__.cpython-314.pyc new file mode 100644 index 0000000..17ed8c8 Binary files /dev/null and b/home/__pycache__/__init__.cpython-314.pyc differ diff --git a/home/__pycache__/apps.cpython-314.pyc b/home/__pycache__/apps.cpython-314.pyc new file mode 100644 index 0000000..72f9131 Binary files /dev/null and b/home/__pycache__/apps.cpython-314.pyc differ diff --git a/home/__pycache__/models.cpython-314.pyc b/home/__pycache__/models.cpython-314.pyc new file mode 100644 index 0000000..d867a63 Binary files /dev/null and b/home/__pycache__/models.cpython-314.pyc differ diff --git a/home/apps.py b/home/apps.py new file mode 100644 index 0000000..e7d1c7e --- /dev/null +++ b/home/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class HomeConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "home" diff --git a/home/migrations/0001_initial.py b/home/migrations/0001_initial.py new file mode 100644 index 0000000..67f201d --- /dev/null +++ b/home/migrations/0001_initial.py @@ -0,0 +1,31 @@ +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("wagtailcore", "0040_page_draft_title"), + ] + + operations = [ + migrations.CreateModel( + name="HomePage", + fields=[ + ( + "page_ptr", + models.OneToOneField( + on_delete=models.CASCADE, + parent_link=True, + auto_created=True, + primary_key=True, + serialize=False, + to="wagtailcore.Page", + ), + ), + ], + options={ + "abstract": False, + }, + bases=("wagtailcore.page",), + ), + ] diff --git a/home/migrations/0002_create_homepage.py b/home/migrations/0002_create_homepage.py new file mode 100644 index 0000000..a3e918e --- /dev/null +++ b/home/migrations/0002_create_homepage.py @@ -0,0 +1,66 @@ +from django.db import migrations + + +def create_homepage(apps, schema_editor): + # Get models + ContentType = apps.get_model("contenttypes.ContentType") + Page = apps.get_model("wagtailcore.Page") + Site = apps.get_model("wagtailcore.Site") + HomePage = apps.get_model("home.HomePage") + + # Delete the default homepage (of type Page) as created by wagtailcore.0002_initial_data, + # if it exists + page_content_type = ContentType.objects.get( + model="page", app_label="wagtailcore" + ) + Page.objects.filter( + content_type=page_content_type, slug="home", depth=2 + ).delete() + + # Create content type for homepage model + homepage_content_type, __ = ContentType.objects.get_or_create( + model="homepage", app_label="home" + ) + + # Create a new homepage + homepage = HomePage.objects.create( + title="Home", + draft_title="Home", + slug="home", + content_type=homepage_content_type, + path="00010001", + depth=2, + numchild=0, + url_path="/home/", + ) + + # Create a site with the new homepage set as the root + Site.objects.create(hostname="localhost", root_page=homepage, is_default_site=True) + + +def remove_homepage(apps, schema_editor): + # Get models + ContentType = apps.get_model("contenttypes.ContentType") + HomePage = apps.get_model("home.HomePage") + + # Delete the default homepage + # Page and Site objects CASCADE + HomePage.objects.filter(slug="home", depth=2).delete() + + # Delete content type for homepage model + ContentType.objects.filter(model="homepage", app_label="home").delete() + + +class Migration(migrations.Migration): + + run_before = [ + ("wagtailcore", "0053_locale_model"), + ] + + dependencies = [ + ("home", "0001_initial"), + ] + + operations = [ + migrations.RunPython(create_homepage, remove_homepage), + ] diff --git a/home/migrations/0003_homepage_body.py b/home/migrations/0003_homepage_body.py new file mode 100644 index 0000000..4a2cf82 --- /dev/null +++ b/home/migrations/0003_homepage_body.py @@ -0,0 +1,19 @@ +# Generated by Django 5.2.9 on 2025-12-19 16:25 + +import wagtail.fields +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('home', '0002_create_homepage'), + ] + + operations = [ + migrations.AddField( + model_name='homepage', + name='body', + field=wagtail.fields.RichTextField(blank=True), + ), + ] diff --git a/home/migrations/0004_homepage_hero_cta_homepage_hero_cta_link_and_more.py b/home/migrations/0004_homepage_hero_cta_homepage_hero_cta_link_and_more.py new file mode 100644 index 0000000..178d9a3 --- /dev/null +++ b/home/migrations/0004_homepage_hero_cta_homepage_hero_cta_link_and_more.py @@ -0,0 +1,36 @@ +# Generated by Django 5.2.9 on 2025-12-19 20:13 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('home', '0003_homepage_body'), + ('wagtailcore', '0096_referenceindex_referenceindex_source_object_and_more'), + ('wagtailimages', '0027_image_description'), + ] + + operations = [ + migrations.AddField( + model_name='homepage', + name='hero_cta', + field=models.CharField(blank=True, help_text='Text to display on Call to Action', max_length=255, verbose_name='Hero CTA'), + ), + migrations.AddField( + model_name='homepage', + name='hero_cta_link', + field=models.ForeignKey(blank=True, help_text='Choose a page to link to for the Call to Action', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailcore.page', verbose_name='Hero CTA link'), + ), + migrations.AddField( + model_name='homepage', + name='hero_text', + field=models.CharField(blank=True, help_text='Write an introduction for the site', max_length=255), + ), + migrations.AddField( + model_name='homepage', + name='image', + field=models.ForeignKey(blank=True, help_text='Homepage image', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image'), + ), + ] diff --git a/home/migrations/__init__.py b/home/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/home/migrations/__pycache__/0001_initial.cpython-314.pyc b/home/migrations/__pycache__/0001_initial.cpython-314.pyc new file mode 100644 index 0000000..cabf939 Binary files /dev/null and b/home/migrations/__pycache__/0001_initial.cpython-314.pyc differ diff --git a/home/migrations/__pycache__/0002_create_homepage.cpython-314.pyc b/home/migrations/__pycache__/0002_create_homepage.cpython-314.pyc new file mode 100644 index 0000000..0953fdc Binary files /dev/null and b/home/migrations/__pycache__/0002_create_homepage.cpython-314.pyc differ diff --git a/home/migrations/__pycache__/0003_homepage_body.cpython-314.pyc b/home/migrations/__pycache__/0003_homepage_body.cpython-314.pyc new file mode 100644 index 0000000..bd97b12 Binary files /dev/null and b/home/migrations/__pycache__/0003_homepage_body.cpython-314.pyc differ diff --git a/home/migrations/__pycache__/0004_homepage_hero_cta_homepage_hero_cta_link_and_more.cpython-314.pyc b/home/migrations/__pycache__/0004_homepage_hero_cta_homepage_hero_cta_link_and_more.cpython-314.pyc new file mode 100644 index 0000000..6b10212 Binary files /dev/null and b/home/migrations/__pycache__/0004_homepage_hero_cta_homepage_hero_cta_link_and_more.cpython-314.pyc differ diff --git a/home/migrations/__pycache__/__init__.cpython-314.pyc b/home/migrations/__pycache__/__init__.cpython-314.pyc new file mode 100644 index 0000000..31b2af7 Binary files /dev/null and b/home/migrations/__pycache__/__init__.cpython-314.pyc differ diff --git a/home/models.py b/home/models.py new file mode 100644 index 0000000..b16edf7 --- /dev/null +++ b/home/models.py @@ -0,0 +1,50 @@ +from django.db import models +from wagtail.models import Page +from wagtail.fields import RichTextField +from wagtail.admin.panels import FieldPanel, MultiFieldPanel + + +class HomePage(Page): + # add the Hero section of HomePage: + image = models.ForeignKey( + "wagtailimages.Image", + null=True, + blank=True, + on_delete=models.SET_NULL, + related_name="+", + help_text="Homepage image", + ) + hero_text = models.CharField( + blank=True, + max_length=255, help_text="Write an introduction for the site" + ) + hero_cta = models.CharField( + blank=True, + verbose_name="Hero CTA", + max_length=255, + help_text="Text to display on Call to Action", + ) + hero_cta_link = models.ForeignKey( + "wagtailcore.Page", + null=True, + blank=True, + on_delete=models.SET_NULL, + related_name="+", + verbose_name="Hero CTA link", + help_text="Choose a page to link to for the Call to Action", + ) + + body = RichTextField(blank=True) + + content_panels = Page.content_panels + [ + MultiFieldPanel( + [ + FieldPanel("image"), + FieldPanel("hero_text"), + FieldPanel("hero_cta"), + FieldPanel("hero_cta_link"), + ], + heading="Hero section", + ), + FieldPanel('body'), + ] \ No newline at end of file diff --git a/home/static/css/welcome_page.css b/home/static/css/welcome_page.css new file mode 100644 index 0000000..bad2933 --- /dev/null +++ b/home/static/css/welcome_page.css @@ -0,0 +1,184 @@ +html { + box-sizing: border-box; +} + +*, +*:before, +*:after { + box-sizing: inherit; +} + +body { + max-width: 960px; + min-height: 100vh; + margin: 0 auto; + padding: 0 15px; + color: #231f20; + font-family: 'Helvetica Neue', 'Segoe UI', Arial, sans-serif; + line-height: 1.25; +} + +a { + background-color: transparent; + color: #308282; + text-decoration: underline; +} + +a:hover { + color: #ea1b10; +} + +h1, +h2, +h3, +h4, +h5, +p, +ul { + padding: 0; + margin: 0; + font-weight: 400; +} + +svg:not(:root) { + overflow: hidden; +} + +.header { + display: flex; + justify-content: space-between; + align-items: center; + padding-top: 20px; + padding-bottom: 10px; + border-bottom: 1px solid #e6e6e6; +} + +.logo { + width: 150px; + margin-inline-end: 20px; +} + +.logo a { + display: block; +} + +.figure-logo { + max-width: 150px; + max-height: 55.1px; +} + +.release-notes { + font-size: 14px; +} + +.main { + padding: 40px 0; + margin: 0 auto; + text-align: center; +} + +.figure-space { + max-width: 265px; +} + +@keyframes pos { + 0%, 100% { + transform: rotate(-6deg); + } + 50% { + transform: rotate(6deg); + } +} + +.egg { + fill: #43b1b0; + animation: pos 3s ease infinite; + transform: translateY(50px); + transform-origin: 50% 80%; +} + +.main-text { + max-width: 400px; + margin: 5px auto; +} + +.main-text h1 { + font-size: 22px; +} + +.main-text p { + margin: 15px auto 0; +} + +.footer { + display: flex; + flex-wrap: wrap; + justify-content: space-between; + border-top: 1px solid #e6e6e6; + padding: 10px; +} + +.option { + display: block; + padding: 10px 10px 10px 34px; + position: relative; + text-decoration: none; +} + +.option svg { + width: 24px; + height: 24px; + fill: gray; + border: 1px solid #d9d9d9; + padding: 5px; + border-radius: 100%; + top: 10px; + inset-inline-start: 0; + position: absolute; +} + +.option h2 { + font-size: 19px; + text-decoration: underline; +} + +.option p { + padding-top: 3px; + color: #231f20; + font-size: 15px; + font-weight: 300; +} + +@media (max-width: 996px) { + body { + max-width: 780px; + } +} + +@media (max-width: 767px) { + .option { + flex: 0 0 50%; + } +} + +@media (max-width: 599px) { + .main { + padding: 20px 0; + } + + .figure-space { + max-width: 200px; + } + + .footer { + display: block; + width: 300px; + margin: 0 auto; + } +} + +@media (max-width: 360px) { + .header-link { + max-width: 100px; + } +} diff --git a/home/templates/home/home_page.html b/home/templates/home/home_page.html new file mode 100644 index 0000000..62c3e69 --- /dev/null +++ b/home/templates/home/home_page.html @@ -0,0 +1,19 @@ +{% extends "base.html" %} +{% load wagtailcore_tags wagtailimages_tags %} + +{% block body_class %}template-homepage{% endblock %} + +{% block content %} +
+

{{ page.title }}

+ {% image page.image fill-480x320 %} +

{{ page.hero_text }}

+ {% if page.hero_cta_link %} + + {% firstof page.hero_cta page.hero_cta_link.title %} + + {% endif %} +
+ + {{ page.body|richtext }} +{% endblock content %} \ No newline at end of file diff --git a/home/templates/home/welcome_page.html b/home/templates/home/welcome_page.html new file mode 100644 index 0000000..dcacaf3 --- /dev/null +++ b/home/templates/home/welcome_page.html @@ -0,0 +1,52 @@ +{% load i18n wagtailcore_tags %} + +
+ + +
+
+
+ +
+
+

{% trans "Welcome to your new Wagtail site!" %}

+

{% trans 'Please feel free to join our community on Slack, or get started with one of the links below.' %}

+
+
+ diff --git a/home/tests.py b/home/tests.py new file mode 100644 index 0000000..2a737de --- /dev/null +++ b/home/tests.py @@ -0,0 +1,42 @@ +from home.models import HomePage + +from wagtail.models import Page, Site +from wagtail.test.utils import WagtailPageTestCase + + +class HomeSetUpTests(WagtailPageTestCase): + """ + Tests for basic page structure setup and HomePage creation. + """ + + def test_root_create(self): + root_page = Page.objects.get(pk=1) + self.assertIsNotNone(root_page) + + def test_homepage_create(self): + root_page = Page.objects.get(pk=1) + homepage = HomePage(title="Home") + root_page.add_child(instance=homepage) + self.assertTrue(HomePage.objects.filter(title="Home").exists()) + + +class HomeTests(WagtailPageTestCase): + """ + Tests for homepage functionality and rendering. + """ + + def setUp(self): + """ + Create a homepage instance for testing. + """ + root_page = Page.get_first_root_node() + Site.objects.create(hostname="testsite", root_page=root_page, is_default_site=True) + self.homepage = HomePage(title="Home") + root_page.add_child(instance=self.homepage) + + def test_homepage_is_renderable(self): + self.assertPageIsRenderable(self.homepage) + + def test_homepage_template_used(self): + response = self.client.get(self.homepage.url) + self.assertTemplateUsed(response, "home/home_page.html") diff --git a/jacksbastards/__init__.py b/jacksbastards/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/jacksbastards/__pycache__/__init__.cpython-314.pyc b/jacksbastards/__pycache__/__init__.cpython-314.pyc new file mode 100644 index 0000000..3100385 Binary files /dev/null and b/jacksbastards/__pycache__/__init__.cpython-314.pyc differ diff --git a/jacksbastards/__pycache__/urls.cpython-314.pyc b/jacksbastards/__pycache__/urls.cpython-314.pyc new file mode 100644 index 0000000..b02f1fd Binary files /dev/null and b/jacksbastards/__pycache__/urls.cpython-314.pyc differ diff --git a/jacksbastards/settings/__init__.py b/jacksbastards/settings/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/jacksbastards/settings/__pycache__/__init__.cpython-314.pyc b/jacksbastards/settings/__pycache__/__init__.cpython-314.pyc new file mode 100644 index 0000000..ee5e045 Binary files /dev/null and b/jacksbastards/settings/__pycache__/__init__.cpython-314.pyc differ diff --git a/jacksbastards/settings/__pycache__/base.cpython-314.pyc b/jacksbastards/settings/__pycache__/base.cpython-314.pyc new file mode 100644 index 0000000..0813cbe Binary files /dev/null and b/jacksbastards/settings/__pycache__/base.cpython-314.pyc differ diff --git a/jacksbastards/settings/__pycache__/dev.cpython-314.pyc b/jacksbastards/settings/__pycache__/dev.cpython-314.pyc new file mode 100644 index 0000000..ff517f7 Binary files /dev/null and b/jacksbastards/settings/__pycache__/dev.cpython-314.pyc differ diff --git a/jacksbastards/settings/base.py b/jacksbastards/settings/base.py new file mode 100644 index 0000000..000fe8a --- /dev/null +++ b/jacksbastards/settings/base.py @@ -0,0 +1,185 @@ +""" +Django settings for jacksbastards project. + +Generated by 'django-admin startproject' using Django 6.0. + +For more information on this file, see +https://docs.djangoproject.com/en/6.0/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/6.0/ref/settings/ +""" + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +from pathlib import Path + +PROJECT_DIR = Path(__file__).resolve().parent.parent +BASE_DIR = PROJECT_DIR.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/6.0/howto/deployment/checklist/ + + +# Application definition + +INSTALLED_APPS = [ + "home", + "blog", + "base", + "search", + "wagtail.contrib.forms", + "wagtail.contrib.redirects", + "wagtail.contrib.settings", + "wagtail.embeds", + "wagtail.sites", + "wagtail.users", + "wagtail.snippets", + "wagtail.documents", + "wagtail.images", + "wagtail.search", + "wagtail.admin", + "wagtail", + "modelcluster", + "taggit", + "django_filters", + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.staticfiles", +] + +MIDDLEWARE = [ + "django.middleware.security.SecurityMiddleware", + "django.contrib.sessions.middleware.SessionMiddleware", + "django.middleware.common.CommonMiddleware", + "django.middleware.csrf.CsrfViewMiddleware", + "django.contrib.auth.middleware.AuthenticationMiddleware", + "django.contrib.messages.middleware.MessageMiddleware", + "django.middleware.clickjacking.XFrameOptionsMiddleware", + "wagtail.contrib.redirects.middleware.RedirectMiddleware", +] + +ROOT_URLCONF = "jacksbastards.urls" + +TEMPLATES = [ + { + "BACKEND": "django.template.backends.django.DjangoTemplates", + "DIRS": [ + PROJECT_DIR / "templates", + ], + "APP_DIRS": True, + "OPTIONS": { + "context_processors": [ + "django.template.context_processors.debug", + "django.template.context_processors.request", + "django.contrib.auth.context_processors.auth", + "django.contrib.messages.context_processors.messages", + "wagtail.contrib.settings.context_processors.settings", + ], + }, + }, +] + +WSGI_APPLICATION = "jacksbastards.wsgi.application" + + +# Database +# https://docs.djangoproject.com/en/6.0/ref/settings/#databases + +DATABASES = { + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": BASE_DIR / "db.sqlite3", + } +} + + +# Password validation +# https://docs.djangoproject.com/en/6.0/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", + }, + { + "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", + }, + { + "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", + }, + { + "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/6.0/topics/i18n/ + +LANGUAGE_CODE = "en-us" + +TIME_ZONE = "UTC" + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/6.0/howto/static-files/ + +STATICFILES_FINDERS = [ + "django.contrib.staticfiles.finders.FileSystemFinder", + "django.contrib.staticfiles.finders.AppDirectoriesFinder", +] + +STATICFILES_DIRS = [ + PROJECT_DIR / "static", +] + +STATIC_ROOT = BASE_DIR / "static" +STATIC_URL = "/static/" + +MEDIA_ROOT = BASE_DIR / "media" +MEDIA_URL = "/media/" + +# Default storage settings +# See https://docs.djangoproject.com/en/6.0/ref/settings/#std-setting-STORAGES +STORAGES = { + "default": { + "BACKEND": "django.core.files.storage.FileSystemStorage", + }, + "staticfiles": { + "BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage", + }, +} + +# Django sets a maximum of 1000 fields per form by default, but particularly complex page models +# can exceed this limit within Wagtail's page editor. +DATA_UPLOAD_MAX_NUMBER_FIELDS = 10_000 + + +# Wagtail settings + +WAGTAIL_SITE_NAME = "jacksbastards" + +# Search +# https://docs.wagtail.org/en/stable/topics/search/backends.html +WAGTAILSEARCH_BACKENDS = { + "default": { + "BACKEND": "wagtail.search.backends.database", + } +} + +# Base URL to use when referring to full URLs within the Wagtail admin backend - +# e.g. in notification emails. Don't include '/admin' or a trailing slash +WAGTAILADMIN_BASE_URL = "http://example.com" + +# Allowed file extensions for documents in the document library. +# This can be omitted to allow all files, but note that this may present a security risk +# if untrusted users are allowed to upload files - +# see https://docs.wagtail.org/en/stable/advanced_topics/deploying.html#user-uploaded-files +WAGTAILDOCS_EXTENSIONS = ['csv', 'docx', 'key', 'odt', 'pdf', 'pptx', 'rtf', 'txt', 'xlsx', 'zip'] diff --git a/jacksbastards/settings/dev.py b/jacksbastards/settings/dev.py new file mode 100644 index 0000000..95e83a5 --- /dev/null +++ b/jacksbastards/settings/dev.py @@ -0,0 +1,18 @@ +from .base import * + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = "django-insecure-c@#kgredf)k#l1m@ebn&koyuva$f^1^7u_2g4ohc9imf4=ue^f" + +# SECURITY WARNING: define the correct hosts in production! +ALLOWED_HOSTS = ["*"] + +EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" + + +try: + from .local import * +except ImportError: + pass diff --git a/jacksbastards/settings/production.py b/jacksbastards/settings/production.py new file mode 100644 index 0000000..936a45f --- /dev/null +++ b/jacksbastards/settings/production.py @@ -0,0 +1,14 @@ +from .base import * + +DEBUG = False + +# ManifestStaticFilesStorage is recommended in production, to prevent +# outdated JavaScript / CSS assets being served from cache +# (e.g. after a Wagtail upgrade). +# See https://docs.djangoproject.com/en/6.0/ref/contrib/staticfiles/#manifeststaticfilesstorage +STORAGES["staticfiles"]["BACKEND"] = "django.contrib.staticfiles.storage.ManifestStaticFilesStorage" + +try: + from .local import * +except ImportError: + pass diff --git a/jacksbastards/static/css/jacksbastards.css b/jacksbastards/static/css/jacksbastards.css new file mode 100644 index 0000000..e69de29 diff --git a/jacksbastards/static/js/jacksbastards.js b/jacksbastards/static/js/jacksbastards.js new file mode 100644 index 0000000..e69de29 diff --git a/jacksbastards/templates/404.html b/jacksbastards/templates/404.html new file mode 100644 index 0000000..f19ab95 --- /dev/null +++ b/jacksbastards/templates/404.html @@ -0,0 +1,11 @@ +{% extends "base.html" %} + +{% block title %}Page not found{% endblock %} + +{% block body_class %}template-404{% endblock %} + +{% block content %} +

Page not found

+ +

Sorry, this page could not be found.

+{% endblock %} diff --git a/jacksbastards/templates/500.html b/jacksbastards/templates/500.html new file mode 100644 index 0000000..77379e5 --- /dev/null +++ b/jacksbastards/templates/500.html @@ -0,0 +1,13 @@ + + + + + Internal server error + + + +

Internal server error

+ +

Sorry, there seems to be an error. Please try again soon.

+ + diff --git a/jacksbastards/templates/base.html b/jacksbastards/templates/base.html new file mode 100644 index 0000000..c11a35f --- /dev/null +++ b/jacksbastards/templates/base.html @@ -0,0 +1,48 @@ +{% load static wagtailcore_tags wagtailuserbar %} + + + + + + + {% block title %} + {% if page.seo_title %}{{ page.seo_title }}{% else %}{{ page.title }}{% endif %} + {% endblock %} + {% block title_suffix %} + {% wagtail_site as current_site %} + {% if current_site and current_site.site_name %}- {{ current_site.site_name }}{% endif %} + {% endblock %} + + {% if page.search_description %} + + {% endif %} + + + {# Force all links in the live preview panel to be opened in a new tab #} + {% if request.in_preview_panel %} + + {% endif %} + + {# Global stylesheets #} + + + {% block extra_css %} + {# Override this in templates to add extra stylesheets #} + {% endblock %} + + + + {% wagtailuserbar %} + + {% block content %}{% endblock %} + + {% include "includes/footer.html" %} + + {# Global javascript #} + + + {% block extra_js %} + {# Override this in templates to add extra javascript #} + {% endblock %} + + diff --git a/jacksbastards/templates/includes/footer.html b/jacksbastards/templates/includes/footer.html new file mode 100644 index 0000000..be9cb7b --- /dev/null +++ b/jacksbastards/templates/includes/footer.html @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/jacksbastards/urls.py b/jacksbastards/urls.py new file mode 100644 index 0000000..c2e8a0c --- /dev/null +++ b/jacksbastards/urls.py @@ -0,0 +1,35 @@ +from django.conf import settings +from django.urls import include, path +from django.contrib import admin + +from wagtail.admin import urls as wagtailadmin_urls +from wagtail import urls as wagtail_urls +from wagtail.documents import urls as wagtaildocs_urls + +from search import views as search_views + +urlpatterns = [ + path("django-admin/", admin.site.urls), + path("admin/", include(wagtailadmin_urls)), + path("documents/", include(wagtaildocs_urls)), + path("search/", search_views.search, name="search"), +] + + +if settings.DEBUG: + from django.conf.urls.static import static + from django.contrib.staticfiles.urls import staticfiles_urlpatterns + + # Serve static and media files from development server + urlpatterns += staticfiles_urlpatterns() + urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + +urlpatterns = urlpatterns + [ + # For anything not caught by a more specific rule above, hand over to + # Wagtail's page serving mechanism. This should be the last pattern in + # the list: + path("", include(wagtail_urls)), + # Alternatively, if you want Wagtail pages to be served from a subpath + # of your site, rather than the site root: + # path("pages/", include(wagtail_urls)), +] diff --git a/jacksbastards/wsgi.py b/jacksbastards/wsgi.py new file mode 100644 index 0000000..25971b8 --- /dev/null +++ b/jacksbastards/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for jacksbastards project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/6.0/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "jacksbastards.settings.dev") + +application = get_wsgi_application() diff --git a/manage.py b/manage.py new file mode 100755 index 0000000..7c8894b --- /dev/null +++ b/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "jacksbastards.settings.dev") + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/media/images/0ceee003-8038-4c03-a7e5-e6f67e3121.2e16d0ba.fill-320x240.jpg b/media/images/0ceee003-8038-4c03-a7e5-e6f67e3121.2e16d0ba.fill-320x240.jpg new file mode 100644 index 0000000..dec5f3c Binary files /dev/null and b/media/images/0ceee003-8038-4c03-a7e5-e6f67e3121.2e16d0ba.fill-320x240.jpg differ diff --git a/media/images/0ceee003-8038-4c03-a7e5-e6f67e312151.max-165x165.jpg b/media/images/0ceee003-8038-4c03-a7e5-e6f67e312151.max-165x165.jpg new file mode 100644 index 0000000..7959e8c Binary files /dev/null and b/media/images/0ceee003-8038-4c03-a7e5-e6f67e312151.max-165x165.jpg differ diff --git a/media/images/43b8e519-7d2d-4d23-9c01-25593dd85e.2e16d0ba.fill-160x100.jpg b/media/images/43b8e519-7d2d-4d23-9c01-25593dd85e.2e16d0ba.fill-160x100.jpg new file mode 100644 index 0000000..72fa751 Binary files /dev/null and b/media/images/43b8e519-7d2d-4d23-9c01-25593dd85e.2e16d0ba.fill-160x100.jpg differ diff --git a/media/images/43b8e519-7d2d-4d23-9c01-25593dd85e.2e16d0ba.fill-320x240.jpg b/media/images/43b8e519-7d2d-4d23-9c01-25593dd85e.2e16d0ba.fill-320x240.jpg new file mode 100644 index 0000000..2be62b6 Binary files /dev/null and b/media/images/43b8e519-7d2d-4d23-9c01-25593dd85e.2e16d0ba.fill-320x240.jpg differ diff --git a/media/images/43b8e519-7d2d-4d23-9c01-25593dd85e2d.max-165x165.jpg b/media/images/43b8e519-7d2d-4d23-9c01-25593dd85e2d.max-165x165.jpg new file mode 100644 index 0000000..1025505 Binary files /dev/null and b/media/images/43b8e519-7d2d-4d23-9c01-25593dd85e2d.max-165x165.jpg differ diff --git a/media/images/43b8e519-7d2d-4d23-9c01-25593dd85e2d.max-800x600.jpg b/media/images/43b8e519-7d2d-4d23-9c01-25593dd85e2d.max-800x600.jpg new file mode 100644 index 0000000..d62f067 Binary files /dev/null and b/media/images/43b8e519-7d2d-4d23-9c01-25593dd85e2d.max-800x600.jpg differ diff --git a/media/images/43b8e519-7d2d-4d23-9c01-25593dd85e2d.original.jpg b/media/images/43b8e519-7d2d-4d23-9c01-25593dd85e2d.original.jpg new file mode 100644 index 0000000..bbf82ea Binary files /dev/null and b/media/images/43b8e519-7d2d-4d23-9c01-25593dd85e2d.original.jpg differ diff --git a/media/images/97c465ba-2947-4fc9-a4c7-12b8334921.2e16d0ba.fill-160x100.jpg b/media/images/97c465ba-2947-4fc9-a4c7-12b8334921.2e16d0ba.fill-160x100.jpg new file mode 100644 index 0000000..1fa4cef Binary files /dev/null and b/media/images/97c465ba-2947-4fc9-a4c7-12b8334921.2e16d0ba.fill-160x100.jpg differ diff --git a/media/images/97c465ba-2947-4fc9-a4c7-12b8334921.2e16d0ba.fill-320x240.jpg b/media/images/97c465ba-2947-4fc9-a4c7-12b8334921.2e16d0ba.fill-320x240.jpg new file mode 100644 index 0000000..7f68699 Binary files /dev/null and b/media/images/97c465ba-2947-4fc9-a4c7-12b8334921.2e16d0ba.fill-320x240.jpg differ diff --git a/media/images/97c465ba-2947-4fc9-a4c7-12b83349219f.max-165x165.jpg b/media/images/97c465ba-2947-4fc9-a4c7-12b83349219f.max-165x165.jpg new file mode 100644 index 0000000..54a5d5d Binary files /dev/null and b/media/images/97c465ba-2947-4fc9-a4c7-12b83349219f.max-165x165.jpg differ diff --git a/media/images/f6c80e0e-25d3-4915-a92f-a733939cf9.2e16d0ba.fill-480x320.jpg b/media/images/f6c80e0e-25d3-4915-a92f-a733939cf9.2e16d0ba.fill-480x320.jpg new file mode 100644 index 0000000..3a74b99 Binary files /dev/null and b/media/images/f6c80e0e-25d3-4915-a92f-a733939cf9.2e16d0ba.fill-480x320.jpg differ diff --git a/media/images/f6c80e0e-25d3-4915-a92f-a733939cf9d9.max-165x165.jpg b/media/images/f6c80e0e-25d3-4915-a92f-a733939cf9d9.max-165x165.jpg new file mode 100644 index 0000000..cded801 Binary files /dev/null and b/media/images/f6c80e0e-25d3-4915-a92f-a733939cf9d9.max-165x165.jpg differ diff --git a/media/original_images/0ceee003-8038-4c03-a7e5-e6f67e312151.jpeg b/media/original_images/0ceee003-8038-4c03-a7e5-e6f67e312151.jpeg new file mode 100644 index 0000000..84d3036 Binary files /dev/null and b/media/original_images/0ceee003-8038-4c03-a7e5-e6f67e312151.jpeg differ diff --git a/media/original_images/43b8e519-7d2d-4d23-9c01-25593dd85e2d.jpeg b/media/original_images/43b8e519-7d2d-4d23-9c01-25593dd85e2d.jpeg new file mode 100644 index 0000000..8aceb79 Binary files /dev/null and b/media/original_images/43b8e519-7d2d-4d23-9c01-25593dd85e2d.jpeg differ diff --git a/media/original_images/97c465ba-2947-4fc9-a4c7-12b83349219f.jpeg b/media/original_images/97c465ba-2947-4fc9-a4c7-12b83349219f.jpeg new file mode 100644 index 0000000..234af6c Binary files /dev/null and b/media/original_images/97c465ba-2947-4fc9-a4c7-12b83349219f.jpeg differ diff --git a/media/original_images/f6c80e0e-25d3-4915-a92f-a733939cf9d9.jpeg b/media/original_images/f6c80e0e-25d3-4915-a92f-a733939cf9d9.jpeg new file mode 100644 index 0000000..a43011f Binary files /dev/null and b/media/original_images/f6c80e0e-25d3-4915-a92f-a733939cf9d9.jpeg differ diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e903d49 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +Django>=5.2,<5.3 +wagtail>=7.2,<7.3 diff --git a/search/__init__.py b/search/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/search/__pycache__/__init__.cpython-314.pyc b/search/__pycache__/__init__.cpython-314.pyc new file mode 100644 index 0000000..d676f5a Binary files /dev/null and b/search/__pycache__/__init__.cpython-314.pyc differ diff --git a/search/__pycache__/views.cpython-314.pyc b/search/__pycache__/views.cpython-314.pyc new file mode 100644 index 0000000..c85beee Binary files /dev/null and b/search/__pycache__/views.cpython-314.pyc differ diff --git a/search/templates/search/search.html b/search/templates/search/search.html new file mode 100644 index 0000000..476427f --- /dev/null +++ b/search/templates/search/search.html @@ -0,0 +1,38 @@ +{% extends "base.html" %} +{% load static wagtailcore_tags %} + +{% block body_class %}template-searchresults{% endblock %} + +{% block title %}Search{% endblock %} + +{% block content %} +

Search

+ +
+ + +
+ +{% if search_results %} + + +{% if search_results.has_previous %} +Previous +{% endif %} + +{% if search_results.has_next %} +Next +{% endif %} +{% elif search_query %} +No results found +{% endif %} +{% endblock %} diff --git a/search/views.py b/search/views.py new file mode 100644 index 0000000..678bb7e --- /dev/null +++ b/search/views.py @@ -0,0 +1,46 @@ +from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator +from django.template.response import TemplateResponse + +from wagtail.models import Page + +# To enable logging of search queries for use with the "Promoted search results" module +# +# uncomment the following line and the lines indicated in the search function +# (after adding wagtail.contrib.search_promotions to INSTALLED_APPS): + +# from wagtail.contrib.search_promotions.models import Query + + +def search(request): + search_query = request.GET.get("query", None) + page = request.GET.get("page", 1) + + # Search + if search_query: + search_results = Page.objects.live().search(search_query) + + # To log this query for use with the "Promoted search results" module: + + # query = Query.get(search_query) + # query.add_hit() + + else: + search_results = Page.objects.none() + + # Pagination + paginator = Paginator(search_results, 10) + try: + search_results = paginator.page(page) + except PageNotAnInteger: + search_results = paginator.page(1) + except EmptyPage: + search_results = paginator.page(paginator.num_pages) + + return TemplateResponse( + request, + "search/search.html", + { + "search_query": search_query, + "search_results": search_results, + }, + )