mirror of
https://github.com/LamGC/wp-asciiplayer.git
synced 2026-11-26 20:55:48 +00:00
137 lines
6.0 KiB
Markdown
137 lines
6.0 KiB
Markdown
# wp-asciiplayer
|
||
|
||
Play terminal recordings in WordPress posts and pages. Add an **Asciicast Player**
|
||
block to preview the recording while you edit, or keep using the `[asciiplayer]`
|
||
shortcode in existing posts.
|
||
|
||
[中文说明](README-zh.md)
|
||
|
||
## Install
|
||
|
||
Requires **WordPress 6.3+** and **PHP 7.4+**.
|
||
|
||
1. Upload the built `wp-asciiplayer.zip` through **Plugins → Add New → Upload Plugin**.
|
||
2. Activate **Asciicast Player**.
|
||
|
||
A GitHub source ZIP needs to be built before you can install it. See the
|
||
[build instructions](SOURCE.md). The [CI workflow](.github/workflows/ci.yml)
|
||
lists the combinations we test; check the plugin with your own theme too.
|
||
|
||
## Add a recording
|
||
|
||
1. Insert an **Asciicast Player** block.
|
||
2. Paste a recording-file URL, or click **Choose recording** to select or upload a
|
||
`.cast` file from the Media Library.
|
||
3. The preview loads about half a second after you stop typing. Click **Apply URL**
|
||
to load it immediately, then play, pause or seek through the recording.
|
||
4. Use **Display** to set the width and alignment. You can choose a preset or enter
|
||
a CSS length such as `480px` or `65%`. Add a caption below the player.
|
||
5. Adjust the theme, speed, looping, controls, fit, start time and idle-time limit
|
||
in the block settings, then save your post or page.
|
||
|
||
Saved recordings load again when you reopen the editor. Previews do not autoplay,
|
||
even if you enable autoplay for the published page. Empty or invalid URLs do not
|
||
start a request. The block inserter uses a static example, so it does not fetch a
|
||
recording either.
|
||
|
||
### Display width and terminal size
|
||
|
||
The display width controls how much space the player takes on the page. It stays
|
||
within the available width. Changing it, or using `fit: width`, scales the picture
|
||
without changing the terminal's columns and rows.
|
||
|
||
Leave **Columns** and **Rows** empty to use the recording's dimensions and resize
|
||
events. To override them, use **Terminal size** in the block toolbar or sidebar;
|
||
both controls update the same settings. **Use recording size** clears the overrides.
|
||
|
||
After loading, the empty fields show the recording's original dimensions as hints.
|
||
Changing the URL updates those hints but keeps any values you entered. The hints
|
||
come from the first 64 KiB of the preview response; if they cannot be read, the
|
||
fields keep a generic placeholder. Later resize events do not change the hints.
|
||
|
||
The player includes styles to keep terminal text aligned and keyboard focus
|
||
visible. Some themes may still need CSS adjustments. Playback tips and recording
|
||
privacy information are in the sidebar's **Help** panel.
|
||
|
||
### Recording URLs
|
||
|
||
Use an HTTP(S) URL that points to the recording file, not an asciinema share page.
|
||
A file hosted on another domain must allow CORS requests from your site. Browsers
|
||
may block HTTP recordings on HTTPS pages; a same-site HTTPS URL is the simplest
|
||
option. The plugin does not proxy or copy remote files.
|
||
|
||
## Existing shortcodes
|
||
|
||
Existing posts keep working without a content migration:
|
||
|
||
```text
|
||
[asciiplayer]https://example.org/demo.cast[/asciiplayer]
|
||
[asciiplayer theme="monokai" speed="1.5" controls="false"]https://example.org/demo.cast[/asciiplayer]
|
||
[asciiplayer startAt="2" idleTimeLimit="3" style="width: 80%;"]https://example.org/demo.cast[/asciiplayer]
|
||
```
|
||
|
||
Boolean, numeric and older camelCase options are handled automatically. Inline
|
||
styles go through WordPress's safe-CSS filter; unsafe URLs, markup and executable
|
||
or object-valued options are not accepted.
|
||
|
||
You can convert supported shortcodes into blocks. Check the settings before
|
||
saving; the plugin never rewrites old posts automatically. The Classic Editor
|
||
supports shortcodes, but has no custom player-editing interface.
|
||
|
||
## Media Library uploads
|
||
|
||
You can upload `.cast` files if your account already has WordPress's `upload_files`
|
||
permission. Multisite networks must also allow the `cast` extension. The plugin
|
||
does not grant extra upload permissions or add a separate recording-management
|
||
post type.
|
||
|
||
Uploads are checked against these limits:
|
||
|
||
- **32 MiB** per file.
|
||
- **100,000** events or stream lines.
|
||
- **256 KiB** per JSONL line.
|
||
- **1,000** columns or rows in either direction.
|
||
|
||
The older asciicast v1 format is limited to **2 MiB**. Its JSON must be
|
||
pretty-printed, with the opening `{` on a line of its own; the bundled player
|
||
cannot read compact, single-line v1 files. Asciicast v2 and v3 use standard JSONL.
|
||
Lower site or server upload limits still apply. Invalid recordings are rejected;
|
||
this does not enable general JSON, HTML or SVG uploads.
|
||
|
||
## Languages
|
||
|
||
The plugin's interface includes English and Simplified Chinese (`zh_CN`).
|
||
|
||
- In the editor, choose **Users → Profile → Language**, or use the site default.
|
||
- On public pages, the language follows **Settings → General → Site Language**.
|
||
|
||
Translations are included in the ZIP and work offline. English is the fallback;
|
||
there is no separate `en_US` catalog. Other Chinese locales, including `zh_TW`, are
|
||
not automatically mapped to Simplified Chinese.
|
||
|
||
Recorded terminal output and your captions are unchanged. The bundled player's
|
||
own playback controls and help remain in English; its files are kept as supplied
|
||
by the upstream project.
|
||
|
||
## Resources and privacy
|
||
|
||
The player’s JavaScript, CSS and WebAssembly are bundled locally. The plugin does
|
||
not contact jsDelivr, add analytics or make background remote API calls. The old
|
||
`ap_use_local_resources` option is no longer used.
|
||
|
||
Recordings are different: visitors' browsers fetch the URL you choose directly.
|
||
An external host may receive their IP address, browser request details and a
|
||
referrer, depending on browser and site settings. Editor previews make the same
|
||
request whenever a valid URL loads, including when you reopen a saved block.
|
||
|
||
Use a trusted host and check recordings for sensitive terminal output before
|
||
publishing. The host's privacy policy applies; the plugin cannot make an external
|
||
recording private.
|
||
|
||
## Build and license
|
||
|
||
See [SOURCE.md](SOURCE.md) for build, test and ZIP packaging commands.
|
||
|
||
The plugin is GPL-3.0-only. The player and its dependencies keep their own
|
||
compatible licenses; see [THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md).
|