style: Public page pass (v2.3.0)
Fix note metadata inheriting page-footer styles, show full notes instead of HTML cut at 300 chars, auto-link bare URLs, one-line meta, SITE_NAME in the header and titles, serif reading font, dark mode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
16925663a3
commit
cc09098741
13 files changed
+285
-183
No files matched your search
@@ -0,0 +1,57 @@
|
||||
"""Public page markup from the v2.3.0 style pass"""
|
||||
|
||||
import markdown
|
||||
import pytest
|
||||
|
||||
from starpunk import create_app
|
||||
from starpunk.models import MARKDOWN_EXTENSIONS
|
||||
from starpunk.notes import create_note
|
||||
|
||||
|
||||
def md(text):
|
||||
return markdown.markdown(text, extensions=MARKDOWN_EXTENSIONS)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("text, expected", [
|
||||
("see https://sqlite.org/x.html.", '<a href="https://sqlite.org/x.html">https://sqlite.org/x.html</a>.'),
|
||||
("(https://a.example/p)", '(<a href="https://a.example/p">https://a.example/p</a>)'),
|
||||
("[label](https://a.example)", '<a href="https://a.example">label</a>'),
|
||||
("`https://code.example`", "<code>https://code.example</code>"),
|
||||
])
|
||||
def test_bare_urls_are_linked(text, expected):
|
||||
assert expected in md(text)
|
||||
|
||||
|
||||
def test_url_as_link_label_is_not_nested():
|
||||
assert md("[https://b.example](https://b.example)").count("<a ") == 1
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def app(tmp_path):
|
||||
data = tmp_path / "data"
|
||||
return create_app({
|
||||
"TESTING": True, "SITE_URL": "https://blog.example.com", "SITE_NAME": "My Notes",
|
||||
"ADMIN_ME": "https://example.com", "SESSION_SECRET": "x",
|
||||
"DATA_PATH": data, "NOTES_PATH": data / "notes", "DATABASE_PATH": data / "starpunk.db",
|
||||
})
|
||||
|
||||
|
||||
def test_home_shows_full_notes_and_site_name(app):
|
||||
long_text = "word " * 120 + "THE-END"
|
||||
with app.app_context():
|
||||
create_note(content=long_text, published=True, tags=["thoughts"])
|
||||
html = app.test_client().get("/").data.decode()
|
||||
assert "THE-END" in html # not cut at 300 characters
|
||||
assert '<a class="site-title" href="/">My Notes</a>' in html
|
||||
assert 'class="p-category" rel="tag"' in html
|
||||
# Notes' metadata is not styled as the page footer
|
||||
assert html.count('<footer class="site-footer">') == 1
|
||||
assert '<footer class="note-meta">' in html
|
||||
|
||||
|
||||
def test_note_page_meta_line(app):
|
||||
with app.app_context():
|
||||
note = create_note(content="Hello", published=True)
|
||||
html = app.test_client().get(f"/note/{note.slug}").data.decode()
|
||||
assert "<title>Hello · My Notes</title>" in html
|
||||
assert 'class="u-url u-uid"' in html
|
||||
Reference in new issue
Block a user