Add copy buttons to code and command blocks on the Pages site

未關閉
#103 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
40/100
Issue 類型
功能
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
html, javascript

研究方向

Start by settling the script policy with #75, since the CSP on line 6 of docs/index.html currently blocks all scripts. The code blocks are the pre elements with code children at lines 334 through 496, and docs/assets/ is where a new same-origin script would live, with .github/workflows/pages.yml already copying that folder. Done means each block has a keyboard-reachable copy button that copies text without the span comment markup, the CSP gains script-src 'self', and the copy is announced through a live region.

由索引模型根據 Issue 內容生成。

描述

enhancement good first issue severity: medium

Summary

The site has eleven code blocks (install command, both quick starts, model setup, scope file, debug, verify, CI workflow, MCP setup) and none can be copied with one click. Visitors must hand-select multi-line commands, and selecting the "With a model" block also grabs the inline comments.

Where

  • docs/index.html:334, :361, :367, :381, :440, :443, :457, :467, :475, :496 (the <pre tabindex="0"><code> blocks)
  • docs/index.html:6 (CSP: default-src 'none'; img-src 'self'; style-src 'unsafe-inline', so no script can run today)
  • docs/index.html:588 (footer: "This page loads no fonts, scripts or trackers from other sites")
  • .github/workflows/pages.yml (copies docs/assets/ already)

Suggested fix

  • Add a small dependency-free same-origin script, for example docs/assets/site.js, loaded with defer.
  • For each pre > code, add a "Copy" button that copies the text with the <span class="c"> comment spans removed, using navigator.clipboard.writeText, and announces "Copied" through an aria-live="polite" region.
  • Change the CSP to add script-src 'self' (no inline script, no 'unsafe-inline'). The footer statement stays true because the script is same-origin.
  • Buttons are real <button> elements, reachable by keyboard, with a visible focus style, and are only inserted by the script (no dead buttons when scripts are off).
  • Decide together with #75 whether the whole site allows a same-origin script; #75 currently suggests rendered docs keep "no scripts".

Acceptance criteria

  • Every code block has a working copy button in current Chrome, Firefox and Safari.
  • Copied text has no comment spans and no trailing whitespace.
  • The CSP still forbids inline and third-party scripts.
  • Screen readers announce the copy.

Related: #75

Getting started

  • Relevant files: docs/index.html, docs/assets/, .github/workflows/pages.yml
  • How to run tests: make test (Unix) or .\make.ps1 test (Windows PowerShell); one package: go test ./internal/<pkg>

Filed by repo-audit/full-audit at a7f6edc. Severity: medium. Effort: S. audit-key: enhancement|docs/index.html|copy-button

主要語言
Go
星號
0
分支
1
PR 合併指標
30 天內沒有已合併 PR

環境準備

在 Codespaces 中開啟

在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

TMHSDigital/Spackle 的其他 Issue

查看 TMHSDigital/Spackle 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。