Tools Page Bookmarklets Step 4 Implementation Summary

Stage 1 - Add tools route and nav entry

  • Changes:

    • Added public GET /tools/ handling in the application route dispatch.

    • Added a shared navigation entry for Tools with its own active section.

    • Added a minimal tools.php page template so the new route resolves through the normal page shell.

  • Verification:

    • Ran php -r 'require __DIR__ . "/autoload.php"; $db = sys_get_temp_dir() . "/tools-stage1-" . bin2hex(random_bytes(4)) . ".sqlite3"; @unlink($db); $app = new ForumRewrite\Application(__DIR__, __DIR__ . "/tests/fixtures/parity_minimal_v1", $db); ob_start(); $app->handle("GET", "/tools/"); $html = ob_get_clean(); echo (strpos($html, "<h1>Tools</h1>") !== false ? "TOOLS_OK\n" : "TOOLS_FAIL\n"); echo (strpos($html, "href=\"/tools/\"") !== false ? "NAV_OK\n" : "NAV_FAIL\n");' and got TOOLS_OK and NAV_OK.

    • Ran php -r 'require __DIR__ . "/autoload.php"; $db = sys_get_temp_dir() . "/tools-stage1-routes-" . bin2hex(random_bytes(4)) . ".sqlite3"; @unlink($db); $app = new ForumRewrite\Application(__DIR__, __DIR__ . "/tests/fixtures/parity_minimal_v1", $db); ob_start(); $app->handle("GET", "/users/"); $html = ob_get_clean(); echo (strpos($html, "href=\"/tools/\"") !== false ? "USERS_NAV_TOOLS_OK\n" : "USERS_NAV_TOOLS_FAIL\n");' and got USERS_NAV_TOOLS_OK.

  • Notes:

    • Stage 1 intentionally ships only the route/nav skeleton; bookmarklet content lands in Stage 2.

    • php tests/run.php --filter LocalAppSmokeTest was not a usable targeted check because the test runner ignored --filter and surfaced unrelated pre-existing WriteApiSmokeTest failures.

Stage 2 - Add bookmarklet content and compose prefills

  • Changes:

    • Replaced the placeholder Tools page with bookmarklet cards, usage copy, and same-window/new-window distinctions.

    • Added public/assets/tools_bookmarklets.js to generate bookmarklet javascript: links from the live site origin.

    • Extended GET /compose/thread rendering to accept board_tags, subject, and body prefills so bookmarklets can open a pre-populated compose form.

  • Verification:

    • Ran php -l src/ForumRewrite/Application.php && php -l templates/pages/tools.php && php -l templates/pages/compose_thread.php and got no syntax errors.

    • Ran php -r 'require __DIR__ . "/autoload.php"; $db = sys_get_temp_dir() . "/tools-stage2-" . bin2hex(random_bytes(4)) . ".sqlite3"; @unlink($db); $app = new ForumRewrite\Application(__DIR__, __DIR__ . "/tests/fixtures/parity_minimal_v1", $db); ob_start(); $app->handle("GET", "/tools/"); $html = ob_get_clean(); echo (strpos($html, "Clip (New Window)") !== false ? "TOOLS_BOOKMARKLETS_OK\n" : "TOOLS_BOOKMARKLETS_FAIL\n"); echo (strpos($html, "/assets/tools_bookmarklets.js") !== false ? "TOOLS_SCRIPT_OK\n" : "TOOLS_SCRIPT_FAIL\n"); echo (strpos($html, "data-bookmarklet-kind=\"clip\"") !== false ? "TOOLS_DATA_OK\n" : "TOOLS_DATA_FAIL\n");' and got TOOLS_BOOKMARKLETS_OK, TOOLS_SCRIPT_OK, and TOOLS_DATA_OK.

    • Ran php -r 'require __DIR__ . "/autoload.php"; $db = sys_get_temp_dir() . "/tools-stage2-compose-" . bin2hex(random_bytes(4)) . ".sqlite3"; @unlink($db); $app = new ForumRewrite\Application(__DIR__, __DIR__ . "/tests/fixtures/parity_minimal_v1", $db); ob_start(); $app->handle("GET", "/compose/thread?board_tags=general&subject=Saved%20Title&body=Saved%20Body"); $html = ob_get_clean(); echo (strpos($html, "value=\"Saved Title\"") !== false ? "COMPOSE_SUBJECT_OK\n" : "COMPOSE_SUBJECT_FAIL\n"); echo (strpos($html, ">Saved Body</textarea>") !== false ? "COMPOSE_BODY_OK\n" : "COMPOSE_BODY_FAIL\n");' and got COMPOSE_SUBJECT_OK and COMPOSE_BODY_OK.

  • Notes:

    • The bookmarklet links are generated client-side so they capture the actual forum origin from the Tools page host instead of assuming a hard-coded deployment URL.

Stage 3 - Add smoke coverage for tools and prefills

  • Changes:

    • Added LocalAppSmokeTest::testToolsPageRendersBookmarkletsAndComposeThreadAcceptsPrefills() to cover the Tools page bookmarklet surface and compose-thread prefill behavior.

  • Verification:

    • Ran php -l tests/LocalAppSmokeTest.php and got no syntax errors.

    • Ran php -r 'require __DIR__ . "/tests/LocalAppSmokeTest.php"; $test = new LocalAppSmokeTest(); $test->testToolsPageRendersBookmarkletsAndComposeThreadAcceptsPrefills(); echo "STAGE3_TEST_OK\n";' and got STAGE3_TEST_OK.

  • Notes:

    • The stage-level verification runs the new smoke method directly because the repo test runner currently executes the full suite without method filtering, which makes targeted verification noisy when unrelated tests are already failing.