From 899f2060f33d5ef99719389900cebb6f98fae0c8 Mon Sep 17 00:00:00 2001 From: mi Date: Thu, 13 Nov 2025 14:43:24 +1000 Subject: [PATCH] :wrench: configurable comic title --- app.py | 3 ++- comics_data.py | 3 +++ scripts/generate_rss.py | 4 ++-- static/js/comic-nav.js | 9 ++++++++- static/openapi.yaml | 4 ++-- templates/base.html | 14 +++++++------- 6 files changed, 24 insertions(+), 13 deletions(-) diff --git a/app.py b/app.py index da9ab0b..a2b1ae5 100644 --- a/app.py +++ b/app.py @@ -2,7 +2,7 @@ import os from datetime import datetime from flask import Flask, render_template, abort, jsonify, request from comics_data import ( - COMICS, FULL_WIDTH_DEFAULT, PLAIN_DEFAULT, HEADER_IMAGE, FOOTER_IMAGE, + COMICS, COMIC_NAME, FULL_WIDTH_DEFAULT, PLAIN_DEFAULT, HEADER_IMAGE, FOOTER_IMAGE, COMPACT_FOOTER, ARCHIVE_FULL_WIDTH, USE_COMIC_NAV_ICONS, USE_HEADER_NAV_ICONS, USE_FOOTER_SOCIAL_ICONS, SOCIAL_INSTAGRAM, SOCIAL_YOUTUBE, SOCIAL_EMAIL, API_SPEC_LINK @@ -19,6 +19,7 @@ app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY', 'your-secret-key') def inject_global_settings(): """Make global settings available to all templates""" return { + 'comic_name': COMIC_NAME, 'header_image': HEADER_IMAGE, 'footer_image': FOOTER_IMAGE, 'compact_footer': COMPACT_FOOTER, diff --git a/comics_data.py b/comics_data.py index 3200ac2..60a5da1 100644 --- a/comics_data.py +++ b/comics_data.py @@ -1,6 +1,9 @@ # Comic data # Edit this file to add, remove, or modify comics +# Global setting: The name of your comic/website +COMIC_NAME = 'Sunday Comics' + # Global setting: Set to True to make all comics full-width by default # Individual comics can override this with 'full_width': False FULL_WIDTH_DEFAULT = False diff --git a/scripts/generate_rss.py b/scripts/generate_rss.py index 6526fb5..22bf1d7 100755 --- a/scripts/generate_rss.py +++ b/scripts/generate_rss.py @@ -10,11 +10,11 @@ from xml.dom import minidom # Add parent directory to path so we can import comics_data sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from comics_data import COMICS +from comics_data import COMICS, COMIC_NAME # Configuration - update these for your site SITE_URL = "http://localhost:3000" # Change to your actual domain -SITE_TITLE = "Sunday Comics" +SITE_TITLE = COMIC_NAME SITE_DESCRIPTION = "A webcomic about life, the universe, and everything" SITE_LANGUAGE = "en-us" diff --git a/static/js/comic-nav.js b/static/js/comic-nav.js index d30eb11..c823976 100644 --- a/static/js/comic-nav.js +++ b/static/js/comic-nav.js @@ -3,6 +3,7 @@ 'use strict'; let totalComics = 0; + let comicName = ''; // Will be extracted from initial page title // Fetch and display a comic async function loadComic(comicId) { @@ -109,7 +110,7 @@ updateNavButtons(comic.number, comic.formatted_date); // Update page title - document.title = `${title} - Sunday Comics`; + document.title = `${title} - ${comicName}`; // Update URL without reload history.pushState({ comicId: comic.number }, '', `/comic/${comic.number}`); @@ -231,6 +232,12 @@ return; } + // Extract comic name from initial page title (e.g., "Latest Comic - Sunday Comics" -> "Sunday Comics") + const titleParts = document.title.split(' - '); + if (titleParts.length > 1) { + comicName = titleParts[titleParts.length - 1]; + } + // Get total comics count from the page totalComics = parseInt(document.querySelector('.comic-container').dataset.totalComics || 0); diff --git a/static/openapi.yaml b/static/openapi.yaml index 6caa3dc..84622fa 100644 --- a/static/openapi.yaml +++ b/static/openapi.yaml @@ -1,7 +1,7 @@ openapi: 3.0.3 info: - title: Sunday Comics API - description: API for accessing webcomic data from the Sunday Comics platform + title: Webcomic API + description: API for accessing webcomic data version: 1.0.0 contact: url: http://127.0.0.1:3000 diff --git a/templates/base.html b/templates/base.html index 3ca6b1e..748d4cd 100644 --- a/templates/base.html +++ b/templates/base.html @@ -3,7 +3,7 @@ - {% block title %}{{ title }}{% endblock %} - Sunday Comics + {% block title %}{{ title }}{% endblock %} - {{ comic_name }} @@ -11,7 +11,7 @@ - + @@ -29,13 +29,13 @@ - + {% block extra_css %}{% endblock %} {% if header_image %}
- Sunday Comics Header + {{ comic_name }} Header
{% endif %} @@ -44,7 +44,7 @@
{% if not header_image %} {% endif %}
{% if footer_image %} {% endif %}