feat(blur): reveal all, and the booth blur control (r2b merge 1: D2 + D2b)
The operator ruled blur A, and made it urgent: "per booth blurring is now
important since we are showing up to 4 images."
- Reveal all: one control per booth, in the booth header and the review's
top bar, outside every data-region. It is in the markup only when
something is blurred, always `hidden` until the script shows it.
- The state is sessionStorage per booth, per tab, and nothing reaches
the server. It is carried as one `reveal-all` class on <html>, applied
before first paint from the page's own data-booth, so booth A's reveal
cannot follow you into booth B and the index is never revealed.
- Per-item reveal buttons stand down by stylesheet, and an item's own
reveal is never touched, so "blur again" restores each item as it was.
- A storage write that throws still applies the click.
- The booth blur control: a plain form to booth-dev's POST /blurbooth, so
it works with scripts off. Its label follows is_booth_blurred; from the
review it carries `back` and lands on the same item. A fogged booth's
Desk row says "◉ blurred".
- Found by rendering it: under a fogged booth every item reported
`blurred`, so an item blurred only by the booth offered an un-blur that
visibly did nothing. The gallery now carries `blurred_self`, and such an
item shows "◉ booth", a label rather than a control.
Contract docs/contracts/r2b_desk_reveal_theme.contract.md (heid contract
panel 4/4, folded). tests/mutations/r2b.toml: 14/14 proved. 765 passed.
This commit is contained in:
@@ -844,3 +844,77 @@ def test_the_desk_never_makes_a_non_web_url_clickable(tmp_path):
|
||||
benches = re.search(r'data-panel="benches".*?</section>', body, re.S).group(0)
|
||||
assert 'href="javascript:' not in benches
|
||||
assert 'href="http://h:1/"' in benches and "evil bench" in benches
|
||||
|
||||
|
||||
def _regions(body: str) -> list[str]:
|
||||
"""Every data-region element's full markup."""
|
||||
return [_region(body, rid) for rid in dict.fromkeys(re.findall(r'data-region="([^"]+)"', body))]
|
||||
|
||||
|
||||
def test_the_booth_blur_toggle_works_without_js_and_lands_back_on_the_review(tmp_path):
|
||||
"""r2b D2b: the operator's control for booth-dev's whole-booth marker. A
|
||||
plain form — scripts off, it still works — whose label says what IS
|
||||
(read from the server), in the booth header and the review's top bar; the
|
||||
review's carries `back` and lands on the same item. The Desk row says
|
||||
`blurred` so a fogged strip says why."""
|
||||
b = _booth(tmp_path, "g", {"a.png": PNG, "b.png": PNG})
|
||||
c = _client(tmp_path)
|
||||
page = c.get("/b/g/").text
|
||||
form = re.search(r'<form[^>]*action="/b/g/blurbooth".*?</form>', page, re.S).group(0)
|
||||
assert 'name="on" value="1"' in form and "blur booth" in form
|
||||
assert all(form not in r for r in _regions(page)), "a swap must never replace it"
|
||||
assert "badge-blur" not in re.search(r'data-booth="g".*?</article>', c.get("/").text, re.S).group(0)
|
||||
|
||||
r = c.post("/b/g/blurbooth", data={"on": "1"}, follow_redirects=False)
|
||||
assert r.status_code == 303 and (b / ".blurbooth").exists()
|
||||
page = c.get("/b/g/").text
|
||||
form = re.search(r'<form[^>]*action="/b/g/blurbooth".*?</form>', page, re.S).group(0)
|
||||
assert 'name="on" value="0"' in form and "booth blurred" in form
|
||||
row = re.search(r'data-booth="g".*?</article>', c.get("/").text, re.S).group(0)
|
||||
assert re.search(r'<span class="badge[^"]*badge-blur[^"]*"[^>]*>[^<]*blurred</span>', row)
|
||||
|
||||
view = c.get("/b/g/view?f=b.png").text
|
||||
vbar = re.search(r'<div class="vbar">.*?</div>\s*\n', view, re.S).group(0)
|
||||
vform = re.search(r'<form[^>]*action="/b/g/blurbooth".*?</form>', vbar, re.S).group(0)
|
||||
assert 'name="back" value="b.png"' in vform and 'name="on" value="0"' in vform
|
||||
r = c.post("/b/g/blurbooth", data={"on": "0", "back": "b.png"}, follow_redirects=False)
|
||||
assert r.headers["location"] == "/b/g/view?f=b.png" and not (b / ".blurbooth").exists()
|
||||
|
||||
|
||||
def test_reveal_all_is_in_the_markup_only_when_something_is_blurred_and_always_hidden(tmp_path):
|
||||
"""r2b D2: the control is server markup only when the booth has a blurred
|
||||
item, always with `hidden` (the script unhides it; with JS off it never
|
||||
shows), and always OUTSIDE every data-region so no in-place swap replaces
|
||||
it. Every page rendered for one booth carries `data-booth` on <html>; the
|
||||
index carries none, so nothing there can be revealed."""
|
||||
from booth.app import set_blurred
|
||||
b = _booth(tmp_path, "g", {"a.png": PNG, "b.png": PNG, "n.md": b"# n"})
|
||||
c = _client(tmp_path)
|
||||
assert not re.search(r"<button[^>]*data-reveal-all", c.get("/b/g/").text)
|
||||
set_blurred(b, "a.png", True)
|
||||
for url in ("/b/g/", "/b/g/view?f=a.png", "/b/g/view?f=b.png"):
|
||||
page = c.get(url).text
|
||||
ctl = re.findall(r'<button[^>]*data-reveal-all[^>]*>', page)
|
||||
assert len(ctl) == 1 and " hidden" in ctl[0], (url, ctl)
|
||||
assert all(not re.search(r"<button[^>]*data-reveal-all", r) for r in _regions(page)), url
|
||||
for url in ("/b/g/", "/b/g/view?f=a.png", "/b/g/view?f=n.md", "/b/g/marks"):
|
||||
assert re.search(r'<html lang="en" data-booth="g">', c.get(url).text), url
|
||||
assert re.search(r'<html lang="en">', c.get("/").text)
|
||||
|
||||
|
||||
def test_under_a_fogged_booth_each_items_blur_control_tells_the_truth(tmp_path):
|
||||
"""r2b D2b, found rendering it: in a fogged booth every item reports
|
||||
`blurred`, so an item blurred ONLY by the booth offered "◉ blurred" and an
|
||||
un-blur that visibly did nothing (the booth still fogged it). Its control
|
||||
now says it is blurred with the booth and offers no per-item action; an item
|
||||
blurred in its own right keeps its own un-blur."""
|
||||
from booth.app import set_blurred
|
||||
b = _booth(tmp_path, "g", {"a.png": PNG, "b.png": PNG})
|
||||
set_blurred(b, "a.png", True)
|
||||
(b / ".blurbooth").write_bytes(b"")
|
||||
page = _client(tmp_path).get("/b/g/").text
|
||||
fig = lambda rel: re.search(r'<figure[^>]*data-item="%s".*?</figure>' % re.escape(rel), page, re.S).group(0)
|
||||
own, booth = fig("a.png"), fig("b.png")
|
||||
assert re.search(r'action="/b/g/blur".*?name="on" value="0".*?◉ blurred', own, re.S)
|
||||
assert 'action="/b/g/blur"' not in booth
|
||||
assert "◉ booth" in booth
|
||||
|
||||
Reference in New Issue
Block a user