话语截图
- 作者仓库星标 47,169
- 作者仓库 discourse
- 领域
- 设计与多媒体
- 作者声明的智能体
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 运行环境证据
- 未执行;当前没有隔离运行测试证据
- 作者 / 版本 / 许可证
- @discourse · 未声明许可证
- 上下文用量评级
- 低消耗
- 接入复杂程度
- 即装即用
- 是否需要外部接口密钥
- 不需要
- 兼容的系统
- 未声明(默认跨平台)
- 运行环境要求
- 未检出明确要求
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- 读取环境变量
- 网络行为
- 仅限本地
- 安装命令数
- 无(仅作为资料)
需要注意: 未声明工具权限范围;实际权限由运行环境决定。
# Default — all themes × light/dark × desktop/mobile
TAKE_SCREENSHOTS=1 LOAD_PLUGINS=1 bin/rspec spec/system/theme_screenshots_spec.rb
# Desktop, light mode only
TAKE_SCREENSHOTS=1 LOAD_PLUGINS=1 SCREENSHOTS_DEVICES=desktop SCREENSHOTS_MODES=light \
bin/rspec spec/system/theme_screenshots_spec.rb
# Foundation only, dark only
TAKE_SCREENSHOTS=1 LOAD_PLUGINS=1 SCREENSHOTS_THEMES=foundation SCREENSHOTS_MODES=dark \
bin/rspec spec/system/theme_screenshots_spec.rb
# Add a remote theme alongside the built-ins
TAKE_SCREENSHOTS=1 LOAD_PLUGINS=1 \
SCREENSHOTS_THEME_URL=https://github.com/org/my-theme \
SCREENSHOTS_THEME_NAME=my-theme \
bin/rspec spec/system/theme_screenshots_spec.rb
# Only capture markers whose label contains "topic"
TAKE_SCREENSHOTS=1 LOAD_PLUGINS=1 SCREENSHOTS_SUBSET=topic \
bin/rspec spec/system/theme_screenshots_spec.rb
# Discourse screenshots
Drives a system spec (`spec/system/theme_screenshots_spec.rb`) that discovers all system specs containing `screenshot_marker` marker calls, runs them under each combination of theme × device × color mode, and outputs PNGs plus a single `compare.html` viewer.
## How it works
Spec authors place `screenshot_marker(label: "my-label")` at the moment they want to capture. The orchestrator auto-discovers those specs and runs only the `it` blocks that contain a marker, skipping everything else. The `only:` kwarg restricts a capture to one device leg:
```ruby
screenshot_marker(label: "search-menu", only: :desktop)
```
Output files: `tmp/theme-screenshots/raw/{device}-{theme}-{mode}-{label}.png`
Comparison viewer: `tmp/theme-screenshots/compare.html` (tabs for device and color mode)
## Matrix (default)
| Theme | Modes | Devices |
|------------|-------------|-----------------|
| Foundation | light, dark | desktop, mobile |
| Horizon | light, dark | desktop, mobile |
## How to run
```bash
TAKE_SCREENSHOTS=1 LOAD_PLUGINS=1 bin/rspec spec/system/theme_screenshots_spec.rb
```
`LOAD_PLUGINS=1` is always included so chat routes work.
### Arguments (env vars)
| Var | Default | Purpose |
|-------------------------|---------------------|---------------------------------------------------------------|
| `TAKE_SCREENSHOTS` | *(required)* | Must be `1` for the spec to run. |
| `LOAD_PLUGINS` | `1` | Always set so chat and plugin routes work. |
| `SCREENSHOTS_DIR` | `tmp/theme-screenshots` | Where PNGs and the HTML viewer are written. |
| `SCREENSHOTS_MODES` | `light,dark` | Comma-separated color modes. |
| `SCREENSHOTS_DEVICES` | `desktop,mobile` | Comma-separated devices. Mobile uses Playwright WebKit. |
| `SCREENSHOTS_THEMES` | `foundation,horizon`| Comma-separated built-in theme names to include. |
| `SCREENSHOTS_THEME_URL` | *(unset)* | Git URL of a remote theme to install and add to the matrix. |
| `SCREENSHOTS_THEME_NAME`| repo name | Filename label for the remote/extra theme. |
| `SCREENSHOTS_SUBSET` | *(unset)* | Substring filter on marker labels — only captures markers whose label contains this string. |
### Examples
```bash
# Default — all themes × light/dark × desktop/mobile
TAKE_SCREENSHOTS=1 LOAD_PLUGINS=1 bin/rspec spec/system/theme_screenshots_spec.rb
# Desktop, light mode only
TAKE_SCREENSHOTS=1 LOAD_PLUGINS=1 SCREENSHOTS_DEVICES=desktop SCREENSHOTS_MODES=light \
bin/rspec spec/system/theme_screenshots_spec.rb
# Foundation only, dark only
TAKE_SCREENSHOTS=1 LOAD_PLUGINS=1 SCREENSHOTS_THEMES=foundation SCREENSHOTS_MODES=dark \
bin/rspec spec/system/theme_screenshots_spec.rb
# Add a remote theme alongside the built-ins
TAKE_SCREENSHOTS=1 LOAD_PLUGINS=1 \
SCREENSHOTS_THEME_URL=https://github.com/org/my-theme \
SCREENSHOTS_THEME_NAME=my-theme \
bin/rspec spec/system/theme_screenshots_spec.rb
# Only capture markers whose label contains "topic"
TAKE_SCREENSHOTS=1 LOAD_PLUGINS=1 SCREENSHOTS_SUBSET=topic \
bin/rspec spec/system/theme_screenshots_spec.rb
```
## Invocation instructions
When this skill is invoked:
1. Build the command from `$ARGUMENTS`. If no arguments are given, use the default matrix.
2. Parse free-form args into env vars (composable — handle multiple at once):
- "dark only" / "light only" → `SCREENSHOTS_MODES=…`
- "desktop only" / "mobile only" → `SCREENSHOTS_DEVICES=…`
- "foundation only" / "just horizon" → `SCREENSHOTS_THEMES=…`
- A git URL for a theme → `SCREENSHOTS_THEME_URL=…`; also set `SCREENSHOTS_THEME_NAME=<label>` if the user provides a name
- A label substring (e.g. "only topic markers", "just signup") → `SCREENSHOTS_SUBSET=…`
- A directory path (e.g. "save to /tmp/foo") → `SCREENSHOTS_DIR=…`
3. Always include `LOAD_PLUGINS=1`.
4. Always prefix with `TAKE_SCREENSHOTS=1`.
5. If the user requests an unknown built-in theme name, tell them only `foundation` and `horizon` are supported — for any other theme use `SCREENSHOTS_THEME_URL`.
6. Run via `bin/rspec spec/system/theme_screenshots_spec.rb` from the repo root.
7. After the run, list the files saved (`ls` on the raw dir) and surface the `compare.html` path to the user. Show failures if `bin/rspec` exits non-zero.
## Adding markers to a spec
In any system spec, `include ThemeScreenshotMarker` and call `screenshot_marker` at the point you want to capture:
```ruby
describe "Search" do
include ThemeScreenshotMarker
it "shows search results" do
visit "/search"
search_page.type_in_search("test")
search_page.click_search_button
screenshot_marker(label: "search-results") # captured on all devices
screenshot_marker(label: "search-menu", only: :desktop) # desktop only
end
end
```
The `include ThemeScreenshotMarker` line is required — without it, `screenshot_marker` is undefined when the spec is run directly. The orchestrator also auto-includes it as a safety net, but relying on that alone will break direct spec runs.
章节与文件索引
按说明文件中的顺序排列。
它是如何运作的
矩阵(默认)
如何跑
参数(环境变量)
调用说明
文件/命令 -> spec/system/theme_screenshots_spec.rb · screenshot_marker · compare.html · screenshot_marker(label: "my-label") · only: · tmp/theme-screenshots/raw/{device}-{theme}-{mode}-{label}.png · tmp/theme-screenshots/compare.html · LOAD_PLUGINS=1
内容校验值 -> fd88dcc752ff
当前原文的自动摘译,尚未人工审校。
它是如何运作的
规范作者将
screenshot_marker(label: "my-label")放置在他们想要捕捉的时刻。编排器会自动发现这些规范,并仅运行包含标记的it块,跳过其他所有内容。only:kwarg 将捕获限制为一个设备分支: 输出文件:tmp/theme-screenshots/raw/{device}-{theme}-{mode}-{label}.png比较查看器:tmp/theme-screenshots/compare.html(设备和颜色模式选项卡)矩阵(默认)
主题·模式·设备基础·浅色、深色·桌面、移动地平线·浅色、深色·桌面、移动
如何跑
LOAD_PLUGINS=1始终包含在内,因此聊天路由有效。参数(环境变量)
变量 · 默认 · 用途
TAKE_SCREENSHOTS· (必需) · 必须是1规范才能运行。LOAD_PLUGINS·1· 始终设置聊天和插件路由。SCREENSHOTS_DIR·tmp/theme-screenshots· PNG 和 HTML 查看器的写入位置。SCREENSHOTS_MODES·light,dark· 逗号分隔的颜色模式。调用说明
调用此技能时:从
$ARGUMENTS构建命令。如果未给出参数,则使用默认矩阵。将自由格式的参数解析为环境变量(可组合 - 一次处理多个):“仅深色”/“仅浅色”→SCREENSHOTS_MODES=…“仅桌面”/“仅移动”→SCREENSHOTS_DEVICES=…