From 234d78d862e46a6def8ba017575d86306bad00ce Mon Sep 17 00:00:00 2001 From: mi Date: Fri, 7 Nov 2025 18:37:45 +1000 Subject: [PATCH] :sparkles: plain mode --- app.py | 12 +++++++++++- comics_data.py | 10 ++++++++-- static/css/style.css | 6 ++++++ static/js/comic-nav.js | 33 ++++++++++++++++++++++++++++----- templates/comic.html | 4 +++- 5 files changed, 56 insertions(+), 9 deletions(-) diff --git a/app.py b/app.py index 6f43196..78631b7 100644 --- a/app.py +++ b/app.py @@ -1,6 +1,6 @@ import os from flask import Flask, render_template, abort, jsonify, request -from comics_data import COMICS, FULL_WIDTH_DEFAULT +from comics_data import COMICS, FULL_WIDTH_DEFAULT, PLAIN_DEFAULT app = Flask(__name__) @@ -17,12 +17,22 @@ def is_full_width(comic): return FULL_WIDTH_DEFAULT +def is_plain(comic): + """Determine if a comic should be plain mode based on global and per-comic settings""" + # If comic explicitly sets plain, use that value + if 'plain' in comic: + return comic['plain'] + # Otherwise use the global default + return PLAIN_DEFAULT + + def enrich_comic(comic): """Add computed properties to comic data""" if comic is None: return None enriched = comic.copy() enriched['full_width'] = is_full_width(comic) + enriched['plain'] = is_plain(comic) return enriched diff --git a/comics_data.py b/comics_data.py index 5add939..bc5036d 100644 --- a/comics_data.py +++ b/comics_data.py @@ -5,6 +5,10 @@ # Individual comics can override this with 'full_width': False FULL_WIDTH_DEFAULT = False +# Global setting: Set to True to hide header and remove nav border by default +# Individual comics can override this with 'plain': False +PLAIN_DEFAULT = False + COMICS = [ { 'number': 1, @@ -13,14 +17,16 @@ COMICS = [ 'date': '2025-01-01', 'alt_text': 'The very first comic', 'author_note': 'This is where your comic journey begins!', - 'full_width': True # Optional: override FULL_WIDTH_DEFAULT for this comic + 'full_width': True, # Optional: override FULL_WIDTH_DEFAULT for this comic + 'plain': True, # Optional: override PLAIN_DEFAULT for this comic }, { 'number': 2, 'filename': 'comic-002.jpg', 'date': '2025-01-08', 'alt_text': 'The second comic', - 'full_width': True # Override FULL_WIDTH_DEFAULT + 'full_width': True, + 'plain': True, }, { 'number': 3, diff --git a/static/css/style.css b/static/css/style.css index fb46d1d..3f7fb77 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -188,6 +188,12 @@ main { max-width: 100%; } +/* Plain comic variant - no header, no nav border */ +.comic-container-plain .comic-navigation { + border-top: none; + padding-top: 0; +} + .comic-header { margin-bottom: 1.5rem; padding-bottom: 1rem; diff --git a/static/js/comic-nav.js b/static/js/comic-nav.js index 6ea9675..846c531 100644 --- a/static/js/comic-nav.js +++ b/static/js/comic-nav.js @@ -27,6 +27,8 @@ // Update the page with comic data function displayComic(comic) { + const title = comic.title || `#${comic.number}`; + // Update container class for full-width option const container = document.querySelector('.comic-container'); if (comic.full_width) { @@ -35,12 +37,33 @@ container.classList.remove('comic-container-fullwidth'); } - // Update title - const title = comic.title || `#${comic.number}`; - document.querySelector('.comic-header h1').textContent = title; + // Update container class for plain mode + if (comic.plain) { + container.classList.add('comic-container-plain'); + } else { + container.classList.remove('comic-container-plain'); + } - // Update date - document.querySelector('.comic-date').textContent = comic.date; + // Show/hide header based on plain mode + const header = document.querySelector('.comic-header'); + if (comic.plain) { + if (header) { + header.style.display = 'none'; + } + } else { + if (header) { + header.style.display = 'block'; + } else { + // Create header if it doesn't exist + const newHeader = document.createElement('div'); + newHeader.className = 'comic-header'; + newHeader.innerHTML = '

'; + container.insertBefore(newHeader, container.firstChild); + } + // Update title and date + document.querySelector('.comic-header h1').textContent = title; + document.querySelector('.comic-date').textContent = comic.date; + } // Update image and its link const comicImageDiv = document.querySelector('.comic-image'); diff --git a/templates/comic.html b/templates/comic.html index 2fa96bd..2e35022 100644 --- a/templates/comic.html +++ b/templates/comic.html @@ -5,11 +5,13 @@ {% block og_image %}{{ request.url_root }}static/images/thumbs/{{ comic.filename }}{% endblock %} {% block content %} -
+
+ {% if not comic.plain %}

{{ comic.title if comic.title else '#' ~ comic.number }}

{{ comic.date }}

+ {% endif %}
{% if comic.number < total_comics %}