diff --git a/CHANGELOG.md b/CHANGELOG.md index 993c71d..9c30779 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [2.3.0] - 2026-10-31 + +### Changed + +- **Public pages restyled**: compact header with the site name from `SITE_NAME`, serif reading font for notes, one-line metadata (date · #tags · Also on …), dark mode via `prefers-color-scheme`, footer pinned to the bottom, "Log in" moved to the footer +- Home and tag pages show short notes in full; titled notes show a summary and "Read more" +- Author h-card kept for parsers but visually hidden on this single-author site +- Page titles use the note text and `SITE_NAME` instead of the slug and "StarPunk" + +### Fixed + +- Every note's metadata was styled as the page footer (centered, ruled, padded) +- Previews cut the note's HTML at 300 characters, which could break markup +- Bare URLs in notes are now links + ## [2.2.0] - 2026-10-31 ### Added diff --git a/starpunk/__init__.py b/starpunk/__init__.py index 9aa669e..31840af 100644 --- a/starpunk/__init__.py +++ b/starpunk/__init__.py @@ -449,5 +449,5 @@ def create_app(config=None): # Package version (Semantic Versioning 2.0.0) # See docs/standards/versioning-strategy.md for details -__version__ = "2.2.0" +__version__ = "2.3.0" __version_info__ = (2, 1, 0) diff --git a/starpunk/markdown_ext.py b/starpunk/markdown_ext.py new file mode 100644 index 0000000..e30b800 --- /dev/null +++ b/starpunk/markdown_ext.py @@ -0,0 +1,42 @@ +""" +Markdown extension: turn bare URLs into links (v2.3.0) + +Python-Markdown only links ; notes often contain pasted URLs. +""" + +import re +import xml.etree.ElementTree as etree + +from markdown.extensions import Extension +from markdown.inlinepatterns import InlineProcessor +from markdown.treeprocessors import Treeprocessor +from markdown.util import AtomicString + +# Stop at whitespace and brackets; trailing punctuation is not part of the URL +BARE_URL_RE = r"(?()\[\]\"']*[^\s<>()\[\]\"'.,;:!?…]" + + +class _BareUrl(InlineProcessor): + def handleMatch(self, m, data): + url = m.group(0) + el = etree.Element("a") + el.set("href", url) + el.text = AtomicString(url) + return el, m.start(0), m.end(0) + + +class _UnnestLinks(Treeprocessor): + """[https://x](https://x) would put a link inside a link; keep the outer one""" + + def run(self, root): + for outer in root.iter("a"): + for inner in list(outer.iter("a"))[1:]: + inner.tag = "span" + inner.attrib.clear() + + +class BareUrlExtension(Extension): + def extendMarkdown(self, md): + # Below links (160) and (120), so those win + md.inlinePatterns.register(_BareUrl(BARE_URL_RE, md), "bare_url", 105) + md.treeprocessors.register(_UnnestLinks(md), "unnest_links", 0) diff --git a/starpunk/models.py b/starpunk/models.py index 58cc04d..1f49fe7 100644 --- a/starpunk/models.py +++ b/starpunk/models.py @@ -34,7 +34,9 @@ DEFAULT_AUTH_STATE_EXPIRY_MINUTES = 5 DEFAULT_TOKEN_EXPIRY_DAYS = 90 # Constants - Markdown rendering -MARKDOWN_EXTENSIONS = ["extra", "codehilite", "nl2br"] +from starpunk.markdown_ext import BareUrlExtension + +MARKDOWN_EXTENSIONS = ["extra", "codehilite", "nl2br", BareUrlExtension()] # Constants - Content limits MAX_TITLE_LENGTH = 200 diff --git a/static/css/style.css b/static/css/style.css index 12660cb..6d89d21 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -1,36 +1,75 @@ /* StarPunk CSS - Minimal responsive stylesheet */ :root { - --color-text: #333; --color-text-light: #666; --color-bg: #fff; --color-bg-alt: #f5f5f5; - --color-link: #0066cc; --color-link-hover: #004499; --color-border: #ddd; + --color-text: #1f2328; --color-text-light: #59636e; --color-bg: #fff; --color-bg-alt: #f4f5f7; + --color-link: #0a5cc2; --color-link-hover: #083f85; --color-border: #e3e6ea; --color-accent-soft: #e8f0fb; --color-success: #28a745; --color-error: #dc3545; --color-warning: #ffc107; --color-info: #17a2b8; - --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif; - --font-mono: 'SF Mono', Monaco, Consolas, 'Courier New', monospace; + --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; + --font-reading: Charter, 'Bitstream Charter', 'Sitka Text', Cambria, 'Noto Serif', Georgia, serif; + --font-mono: ui-monospace, 'SF Mono', Monaco, Consolas, 'Liberation Mono', monospace; --spacing-xs: 0.25rem; --spacing-sm: 0.5rem; --spacing-md: 1rem; --spacing-lg: 2rem; --spacing-xl: 4rem; - --max-width: 42rem; --border-radius: 4px; + --max-width: 40rem; --border-radius: 6px; +} + +@media (prefers-color-scheme: dark) { + :root { + --color-text: #e4e6e9; --color-text-light: #9aa3ad; --color-bg: #121417; --color-bg-alt: #1c1f24; + --color-link: #74b0ff; --color-link-hover: #a8ceff; --color-border: #2b3038; --color-accent-soft: #1a2738; + } } * { box-sizing: border-box; margin: 0; padding: 0; } -body { font-family: var(--font-body); font-size: 1rem; line-height: 1.6; color: var(--color-text); background: var(--color-bg); padding: var(--spacing-md); } +body { + font-family: var(--font-body); font-size: 1rem; line-height: 1.6; color: var(--color-text); background: var(--color-bg); + padding: var(--spacing-md); min-height: 100vh; display: flex; flex-direction: column; + -webkit-font-smoothing: antialiased; +} -h1, h2, h3 { margin-bottom: var(--spacing-md); line-height: 1.2; font-weight: 600; } -h1 { font-size: 2rem; } h2 { font-size: 1.5rem; } h3 { font-size: 1.25rem; } +h1, h2, h3 { margin-bottom: var(--spacing-md); line-height: 1.25; font-weight: 650; letter-spacing: -0.01em; } +h1 { font-size: 1.75rem; } h2 { font-size: 1.375rem; } h3 { font-size: 1.125rem; } p { margin-bottom: var(--spacing-md); } a { color: var(--color-link); text-decoration: none; } a:hover { color: var(--color-link-hover); text-decoration: underline; } +:focus-visible { outline: 2px solid var(--color-link); outline-offset: 2px; border-radius: 2px; } -code, pre { font-family: var(--font-mono); background: var(--color-bg-alt); padding: 0.125rem 0.25rem; border-radius: var(--border-radius); font-size: 0.875rem; } +code, pre { font-family: var(--font-mono); background: var(--color-bg-alt); padding: 0.125rem 0.3rem; border-radius: var(--border-radius); font-size: 0.875em; } pre { padding: var(--spacing-md); overflow-x: auto; margin-bottom: var(--spacing-md); } +pre code { padding: 0; background: none; } -header, main, footer { max-width: var(--max-width); margin: 0 auto; } -header { margin-bottom: var(--spacing-lg); padding-bottom: var(--spacing-md); border-bottom: 2px solid var(--color-border); } -header h1 { margin-bottom: var(--spacing-sm); } -header h1 a { color: var(--color-text); text-decoration: none; } -nav { display: flex; gap: var(--spacing-md); flex-wrap: wrap; } -nav a { padding: var(--spacing-sm) var(--spacing-md); border-radius: var(--border-radius); transition: background 0.2s; } -nav a:hover { background: var(--color-bg-alt); text-decoration: none; } -main { min-height: 60vh; margin-bottom: var(--spacing-lg); } -footer { padding-top: var(--spacing-lg); border-top: 1px solid var(--color-border); text-align: center; color: var(--color-text-light); font-size: 0.875rem; } +.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; } + +/* Page frame */ +.site-header, main, .site-footer { width: 100%; max-width: var(--max-width); margin-left: auto; margin-right: auto; } +main { flex: 1; margin-bottom: var(--spacing-xl); } + +.site-header { + display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--spacing-sm) var(--spacing-lg); + padding: var(--spacing-md) 0 var(--spacing-md); margin-bottom: var(--spacing-lg); border-bottom: 1px solid var(--color-border); +} +.site-title { font-size: 1.375rem; font-weight: 700; letter-spacing: -0.02em; color: var(--color-text); } +.site-title:hover { color: var(--color-link); text-decoration: none; } +.site-nav { display: flex; align-items: center; flex-wrap: wrap; gap: var(--spacing-md); font-size: 0.9375rem; } +.site-nav > a { color: var(--color-text-light); } +.site-nav > a:hover { color: var(--color-link); text-decoration: none; } +.site-search { display: flex; } +.site-search input[type="search"] { + width: 10rem; padding: 0.3rem 0.6rem; font: inherit; font-size: 0.875rem; color: var(--color-text); + background: var(--color-bg-alt); border: 1px solid var(--color-border); border-right: 0; border-radius: var(--border-radius) 0 0 var(--border-radius); +} +.site-search button { + padding: 0.3rem 0.6rem; font: inherit; font-size: 0.875rem; cursor: pointer; color: var(--color-text-light); + background: var(--color-bg-alt); border: 1px solid var(--color-border); border-radius: 0 var(--border-radius) var(--border-radius) 0; +} +.site-search button:hover { color: var(--color-link); } + +.site-footer { padding: var(--spacing-md) 0; border-top: 1px solid var(--color-border); color: var(--color-text-light); font-size: 0.8125rem; } +.site-footer p { margin: 0; } +.site-footer a { color: var(--color-text-light); text-decoration: underline; text-decoration-color: var(--color-border); } +.site-footer a:hover { color: var(--color-link); } + +.page-title { font-size: 1.375rem; margin-bottom: var(--spacing-lg); } +.tag-name { color: var(--color-link); } +.tag-name::before { content: "#"; } .dev-mode-warning { background: var(--color-error); color: white; padding: var(--spacing-md); text-align: center; font-weight: bold; margin: calc(-1 * var(--spacing-md)); margin-bottom: var(--spacing-lg); } @@ -40,17 +79,35 @@ footer { padding-top: var(--spacing-lg); border-top: 1px solid var(--color-borde .flash-warning { background: #fff3cd; border-color: var(--color-warning); color: #856404; } .flash-info { background: #d1ecf1; border-color: var(--color-info); color: #0c5460; } +/* Notes */ .h-entry { margin-bottom: var(--spacing-lg); padding-bottom: var(--spacing-lg); border-bottom: 1px solid var(--color-border); } .h-entry:last-child { border-bottom: none; } -.note-preview .e-content { margin-bottom: var(--spacing-md); } -.note-meta { color: var(--color-text-light); font-size: 0.875rem; } +.h-entry > .p-name a { color: var(--color-text); } +.h-entry > .p-name a:hover { color: var(--color-link); } +.e-content, .p-summary { font-family: var(--font-reading); font-size: 1.125rem; line-height: 1.65; overflow-wrap: anywhere; } +.e-content > :last-child, .p-summary > :last-child { margin-bottom: 0; } +.e-content a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); } +.e-content a:hover { text-decoration-color: currentColor; } +.e-content blockquote { margin: 0 0 var(--spacing-md); padding-left: var(--spacing-md); border-left: 3px solid var(--color-border); color: var(--color-text-light); } +.e-content ul, .e-content ol { margin: 0 0 var(--spacing-md) 1.25rem; } +.e-content img { max-width: 100%; height: auto; } +.e-content h1, .e-content h2, .e-content h3 { font-family: var(--font-body); } +.read-more { margin: var(--spacing-sm) 0 0; font-size: 0.9375rem; } + +.note-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 0.4rem; margin-top: var(--spacing-sm); color: var(--color-text-light); font-size: 0.8125rem; } .note-meta a { color: var(--color-text-light); } -.note-nav { margin-top: var(--spacing-md); } +.note-meta a:hover { color: var(--color-link); } +.note-meta > :not(.visually-hidden) + :not(.visually-hidden)::before { content: "·"; margin-right: 0.4rem; color: var(--color-text-light); } +.note-tags { display: inline-flex; flex-wrap: wrap; gap: 0 0.4rem; } +.note-meta > .note-tags::before { margin-right: 0; } +.note-tags .p-category::before { content: "#"; opacity: 0.7; } +.h-entry:not(.note-preview) .note-meta { margin-top: var(--spacing-md); } +.note-nav { margin-top: var(--spacing-lg); font-size: 0.9375rem; } .empty-state { text-align: center; padding: var(--spacing-xl); color: var(--color-text-light); } .form-group { margin-bottom: var(--spacing-md); } label { display: block; margin-bottom: var(--spacing-sm); font-weight: 600; } -input[type="text"], input[type="url"], input[type="email"], textarea { width: 100%; padding: var(--spacing-sm); border: 1px solid var(--color-border); border-radius: var(--border-radius); font-family: inherit; font-size: 1rem; } +input[type="text"], input[type="url"], input[type="email"], input[type="search"], textarea { color: var(--color-text); background: var(--color-bg); width: 100%; padding: var(--spacing-sm); border: 1px solid var(--color-border); border-radius: var(--border-radius); font-family: inherit; font-size: 1rem; } textarea { font-family: var(--font-mono); resize: vertical; min-height: 10rem; } small { display: block; margin-top: var(--spacing-xs); color: var(--color-text-light); font-size: 0.875rem; } .form-checkbox { display: flex; align-items: center; gap: var(--spacing-sm); } @@ -171,11 +228,14 @@ small { display: block; margin-top: var(--spacing-xs); color: var(--color-text-l } @media (min-width: 768px) { - body { padding: var(--spacing-lg); } - h1 { font-size: 2.5rem; } h2 { font-size: 2rem; } h3 { font-size: 1.5rem; } + body { padding: var(--spacing-md) var(--spacing-lg); } + h1 { font-size: 2rem; } h2 { font-size: 1.5rem; } h3 { font-size: 1.25rem; } } @media (max-width: 767px) { + .site-nav { width: 100%; } + .site-search { flex: 1; justify-content: flex-end; } + .site-search input[type="search"] { width: 100%; max-width: 12rem; } .note-table { font-size: 0.875rem; } .note-table th, .note-table td { padding: var(--spacing-sm); } .note-actions .button { font-size: 0.75rem; padding: 0.25rem 0.5rem; } @@ -426,7 +486,7 @@ small { display: block; margin-top: var(--spacing-xs); color: var(--color-text-l .content-preview { padding: var(--spacing-sm); - background: white; + background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 4px; margin-top: var(--spacing-xs); diff --git a/templates/base.html b/templates/base.html index 4ec772d..547b08d 100644 --- a/templates/base.html +++ b/templates/base.html @@ -3,7 +3,8 @@ - {% block title %}StarPunk{% endblock %} + {% block title %}{{ config.SITE_NAME }}{% endblock %} + @@ -33,29 +34,18 @@ {% endif %} -
-

StarPunk

-