aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/timeline
diff options
context:
space:
mode:
Diffstat (limited to 'pydis_site/apps/timeline')
-rw-r--r--pydis_site/apps/timeline/README.md44
-rw-r--r--pydis_site/apps/timeline/__init__.py0
-rw-r--r--pydis_site/apps/timeline/apps.py45
-rw-r--r--pydis_site/apps/timeline/entries/2023-01-30_retirement-of-joe-and-sebastiaan.md12
-rw-r--r--pydis_site/apps/timeline/entries/2023-07-11_new-paste-service.md12
-rw-r--r--pydis_site/apps/timeline/urls.py9
-rw-r--r--pydis_site/apps/timeline/views.py20
7 files changed, 142 insertions, 0 deletions
diff --git a/pydis_site/apps/timeline/README.md b/pydis_site/apps/timeline/README.md
new file mode 100644
index 00000000..a4272c4d
--- /dev/null
+++ b/pydis_site/apps/timeline/README.md
@@ -0,0 +1,44 @@
+# The "timeline" app
+
+The [timeline page](https://www.pythondiscord.com/timeline/) on our website is
+powered by this Django application.
+
+## The entries
+
+Timeline entries are written in markdown files with YAML frontmatter under the
+`entries` directory.
+
+Each file represents a timeline entry. The files are named with the format
+`<date>_<name>.md`:
+- `date`: The date is in the `YYYY-MM-DD` format, intended for easy sorting in
+ editor/shell command directory listings. It's also used to sort the entries
+ before rendering the timeline page.
+- `name`: The name component is an arbitrary slug in **kebab-case**. This is used
+ for linking to individual timeline entries on the page, and will be set in
+ the `id` attribute.
+
+Each file contains:
+- YAML frontmatter. This defines some metadata shown next to each entry in
+ the timeline, including:
+ - Date: User-facing date label.
+ - Icon: The CSS class to be used for the icon. Set to `pydis` to use the
+ pydis logo image.
+ - Icon color: The CSS class that sets the background color of the icon. Leave
+ empty if the pydis logo is used.
+- Markdown content.
+
+
+## Directory structure
+
+The app has a single view in `views.py` that takes care of reading the `.md`
+files in the `entires` directory. This is a standard Django view, mounted in
+`urls.py` as usual.
+
+The `tests` directory validates that our redirects and helper functions work as
+expected. If you made changes to the app and are looking for guidance on adding
+new tests, the [Django tutorial introducing automated
+testing](https://docs.djangoproject.com/en/dev/intro/tutorial05/) is a good
+place to start.
+
+This application does not use the database and as such does not have models nor
+migrations.
diff --git a/pydis_site/apps/timeline/__init__.py b/pydis_site/apps/timeline/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/pydis_site/apps/timeline/__init__.py
diff --git a/pydis_site/apps/timeline/apps.py b/pydis_site/apps/timeline/apps.py
new file mode 100644
index 00000000..8f27297f
--- /dev/null
+++ b/pydis_site/apps/timeline/apps.py
@@ -0,0 +1,45 @@
+from pathlib import Path
+
+from django.apps import AppConfig
+import frontmatter
+import markdown
+
+from pydis_site import settings
+
+
+ENTRIES_PATH = Path(settings.BASE_DIR, "pydis_site", "apps", "timeline", "entries")
+
+
+class TimelineConfig(AppConfig):
+ """AppConfig instance for Timeline app."""
+
+ name = 'pydis_site.apps.timeline'
+
+ def ready(self) -> None:
+ """Fetch all the timeline entries."""
+ self.entries = []
+
+ for path in ENTRIES_PATH.rglob("*.md"):
+ metadata, content = frontmatter.parse(path.read_text(encoding="utf-8"))
+
+ md = markdown.Markdown()
+ html = str(md.convert(content))
+
+ # Strip `.md` file extension from filename and split it into the
+ # date (for sorting) and slug (for linking).
+ key, slug = path.name[:-3].split("_")
+ entry = {
+ "key": key,
+ "slug": slug,
+ "title": metadata["title"],
+ "date": metadata["date"],
+ "icon": metadata["icon"],
+ # This key might not be used if the icon uses the pydis logo.
+ "icon_color": metadata.get("icon_color"),
+ "content": html,
+ }
+
+ self.entries.append(entry)
+
+ # Sort the entries in reverse-chronological order.
+ self.entries.sort(key=lambda e: e['key'], reverse=True)
diff --git a/pydis_site/apps/timeline/entries/2023-01-30_retirement-of-joe-and-sebastiaan.md b/pydis_site/apps/timeline/entries/2023-01-30_retirement-of-joe-and-sebastiaan.md
new file mode 100644
index 00000000..1629c1f5
--- /dev/null
+++ b/pydis_site/apps/timeline/entries/2023-01-30_retirement-of-joe-and-sebastiaan.md
@@ -0,0 +1,12 @@
+---
+title: Retirement of Joe and Sebastiaan
+date: 2023-01-30
+icon: pydis
+---
+
+Having been at the helm of Python Discord for over 5 and 3 years respectively,
+Joe and Sebastiaan retire and step down. They gain the **@Founders** role and
+continue as advisors to the **@Directors**, the new name of the original
+**@Owners** role.
+
+At the same time, Mina and Zig join Leon as co-directors.
diff --git a/pydis_site/apps/timeline/entries/2023-07-11_new-paste-service.md b/pydis_site/apps/timeline/entries/2023-07-11_new-paste-service.md
new file mode 100644
index 00000000..818fa2f9
--- /dev/null
+++ b/pydis_site/apps/timeline/entries/2023-07-11_new-paste-service.md
@@ -0,0 +1,12 @@
+---
+title: Switch to new paste service
+date: 2023-07-11
+icon: fa-regular fa-clipboard
+icon_color: pastel-pink
+---
+
+We migrate over to [pinnwand](https://github.com/supakeen/pinnwand) as the
+service that powers our paste bin over at <https://paste.pythondiscord.com/>.
+We made the switch as it comes with native light/dark modes, support for
+multi-file pastes, additional support for text highlighting languages, and
+plus, it's written in Python!
diff --git a/pydis_site/apps/timeline/urls.py b/pydis_site/apps/timeline/urls.py
new file mode 100644
index 00000000..e4f1d6c6
--- /dev/null
+++ b/pydis_site/apps/timeline/urls.py
@@ -0,0 +1,9 @@
+from django_distill import distill_path
+
+from .views import TimelineView
+
+app_name = "timeline"
+
+urlpatterns = [
+ distill_path("", TimelineView.as_view(), name="index"),
+]
diff --git a/pydis_site/apps/timeline/views.py b/pydis_site/apps/timeline/views.py
new file mode 100644
index 00000000..380dfe53
--- /dev/null
+++ b/pydis_site/apps/timeline/views.py
@@ -0,0 +1,20 @@
+from django.apps import apps
+from django.core.handlers.wsgi import WSGIRequest
+from django.http import HttpResponse
+from django.shortcuts import render
+from django.views import View
+
+APP_NAME = "timeline"
+
+class TimelineView(View):
+ """A vertical timeline showcasing milestones in the history of Python Discord."""
+
+ def get(self, request: WSGIRequest) -> HttpResponse:
+ """Render the timeline."""
+ app = apps.get_app_config(APP_NAME)
+
+ return render(
+ request,
+ template_name="timeline/timeline.html",
+ context={ "entries": app.entries },
+ )