mirror of
https://github.com/LamGC/wp-asciiplayer.git
synced 2026-11-26 20:55:48 +00:00
docs: make bilingual readmes practical and conversational
This commit is contained in:
@@ -1,90 +1,68 @@
|
||||
# wp-asciiplayer
|
||||
|
||||
An Asciicast Player block for WordPress, with real playback in the editor and
|
||||
backwards-compatible `[asciiplayer]` shortcodes.
|
||||
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)
|
||||
|
||||
## Languages
|
||||
|
||||
Plugin-owned UI includes English and Simplified Chinese (`zh_CN`). The editor
|
||||
follows **Users → Profile → Language** (or the site default); public pages follow
|
||||
**Settings → General → Site Language**. Catalogs ship inside the ZIP and need no
|
||||
translation server at runtime. English is the source/fallback language, so a
|
||||
separate `en_US` catalog is unnecessary. `zh_TW` and other locales are not silently
|
||||
mapped to Simplified Chinese. Recorded terminal output and author captions stay
|
||||
unchanged. The bundled upstream player's own playback controls and help remain
|
||||
English; its vendor files are not modified.
|
||||
|
||||
## Install
|
||||
|
||||
1. Install the built `wp-asciiplayer.zip` through **Plugins → Add New → Upload Plugin**.
|
||||
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 must be built first; it does not contain generated assets. See [SOURCE.md](SOURCE.md).
|
||||
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.
|
||||
|
||||
**Requirements:** WordPress 6.3+ and PHP 7.4+.
|
||||
## Add a recording
|
||||
|
||||
Compatibility must be checked against your site and theme; CI tests the versions
|
||||
listed in the [CI workflow](.github/workflows/ci.yml).
|
||||
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.
|
||||
|
||||
## Block editor
|
||||
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.
|
||||
|
||||
1. Insert **Asciicast Player**.
|
||||
2. Paste an HTTP(S) recording-file URL (for example a `.cast` file), or use
|
||||
**Choose recording** to select/upload a `.cast` file in the WordPress Media
|
||||
Library. The preview loads after a short pause; **Apply URL** loads it immediately.
|
||||
3. Play, pause and seek in the editor. **Display** offers width presets or a custom
|
||||
CSS length (for example `480px` or `65%`), plus left/center/right alignment.
|
||||
The width stays within the available space. Add a caption below the player.
|
||||
4. Use **Terminal size** in the floating block toolbar for quick **Columns**/**Rows**
|
||||
edits, or expand the **Terminal size** sidebar panel. Both edit the same values.
|
||||
- Empty fields show the recording’s original columns/rows as placeholders after
|
||||
loading. Changing the URL refreshes these hints without clearing your explicit
|
||||
overrides; reset clears overrides, so recorded resize events remain active.
|
||||
- Terminal size is separate from display width: leave **Columns** and **Rows** blank
|
||||
to use the cast file's dimensions and recorded resize events. Override either
|
||||
axis only when intentional; use **Use recording size** to clear both.
|
||||
- Display width and `fit: width` scale the existing grid without changing
|
||||
terminal columns.
|
||||
5. Change theme, speed, looping, controls, fit, start time and idle-time limit
|
||||
from the remaining block settings.
|
||||
6. Save the post or page; the same locally bundled player is used on the front end.
|
||||
### Display width and terminal size
|
||||
|
||||
### Preview behavior
|
||||
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.
|
||||
|
||||
Existing saved blocks load their valid recording URL automatically on reopening
|
||||
the editor. Typed URL changes are debounced for 500ms; empty or invalid URLs do
|
||||
not start a recording request.
|
||||
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.
|
||||
|
||||
Preview does not autoplay even when front-end autoplay is enabled.
|
||||
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.
|
||||
|
||||
Recording/privacy and playback explanations are available in the collapsed
|
||||
**Help** sidebar panel, keeping the block canvas focused on editing.
|
||||
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.
|
||||
|
||||
The inserter preview is a local static example and never loads a recording.
|
||||
### Recording URLs
|
||||
|
||||
### Theme compatibility
|
||||
|
||||
Terminal typography is scoped against common theme `pre`/`span` styles so
|
||||
character scaling stays aligned with the player grid. A theme with additional
|
||||
custom rules may still require compatibility testing; keyboard focus indicators
|
||||
remain visible.
|
||||
|
||||
### Recording source
|
||||
|
||||
The source must be a recording-file URL, not an asciinema share-page URL.
|
||||
|
||||
A recording on another origin must allow CORS requests from your WordPress site.
|
||||
HTTP recordings on an HTTPS site may be blocked as mixed content. Use a same-site
|
||||
HTTPS URL when possible.
|
||||
|
||||
The plugin does not proxy or copy remote files, grant new upload capabilities,
|
||||
or add a recording-management post type.
|
||||
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
|
||||
|
||||
Old articles remain supported; no content migration is required:
|
||||
Existing posts keep working without a content migration:
|
||||
|
||||
```text
|
||||
[asciiplayer]https://example.org/demo.cast[/asciiplayer]
|
||||
@@ -92,54 +70,67 @@ Old articles remain supported; no content migration is required:
|
||||
[asciiplayer startAt="2" idleTimeLimit="3" style="width: 80%;"]https://example.org/demo.cast[/asciiplayer]
|
||||
```
|
||||
|
||||
Boolean and numeric options are typed, and historical camelCase options are
|
||||
normalized after WordPress lowercases shortcode attribute names. Inline styles
|
||||
are filtered through WordPress safe-CSS handling; unsafe protocols and markup
|
||||
are rejected/escaped. Unsupported executable/object options are not accepted.
|
||||
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.
|
||||
|
||||
The Classic Editor continues to support shortcodes; it has no custom visual UI.
|
||||
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.
|
||||
|
||||
The block supports a shortcode-to-block transform for supported options. Review
|
||||
converted settings before saving; articles are never rewritten automatically.
|
||||
## Media Library uploads
|
||||
|
||||
## Local resources and privacy
|
||||
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.
|
||||
|
||||
All player JavaScript, CSS, and WebAssembly are included in the plugin. The old
|
||||
`ap_use_local_resources` switch is no longer used, and jsDelivr is not contacted.
|
||||
No analytics or background remote API calls are added.
|
||||
Uploads are checked against these limits:
|
||||
|
||||
A recording URL you choose is fetched directly by the visitor's browser. Its host
|
||||
can receive the visitor's IP address, browser request metadata and possibly a
|
||||
referrer, according to browser/site policy. Editor previews have the same effect
|
||||
automatically when a valid URL is present, including when reopening saved blocks.
|
||||
- **32 MiB** per file.
|
||||
- **100,000** events or stream lines.
|
||||
- **256 KiB** per JSONL line.
|
||||
- **1,000** columns or rows in either direction.
|
||||
|
||||
Choose a trusted host and review recordings for sensitive terminal output before
|
||||
publishing them. The host's own privacy policy applies; the plugin cannot make an external recording private.
|
||||
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.
|
||||
|
||||
## Media Library upload limits
|
||||
## Languages
|
||||
|
||||
The plugin adds only `.cast` uploads for users who already have WordPress
|
||||
`upload_files` permission. On multisite, the network must also allow the `cast`
|
||||
extension. Existing site/server upload limits still apply.
|
||||
The plugin's interface includes English and Simplified Chinese (`zh_CN`).
|
||||
|
||||
Each upload is fully validated:
|
||||
- In the editor, choose **Users → Profile → Language**, or use the site default.
|
||||
- On public pages, the language follows **Settings → General → Site Language**.
|
||||
|
||||
- At most **32 MiB**.
|
||||
- At most **100,000 events/stream lines**.
|
||||
- At most **256 KiB per JSONL line**.
|
||||
- Dimensions up to **1,000 columns/rows**.
|
||||
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.
|
||||
|
||||
Legacy v1 is limited to **2 MiB** and must be pretty-printed
|
||||
with its opening JSON object on a separate line because the bundled player cannot
|
||||
read compact single-line v1. v2/v3 use their standard JSONL format. Invalid files
|
||||
are rejected; generic JSON, HTML and SVG uploads are not enabled.
|
||||
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.
|
||||
|
||||
Original-size hints inspect at most the first 64 KiB of the same preview response.
|
||||
If metadata is unavailable, the fields keep a generic placeholder rather than
|
||||
guessing dimensions. Recorded resize events do not replace the initial-size hint.
|
||||
## Resources and privacy
|
||||
|
||||
## Development
|
||||
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.
|
||||
|
||||
See [SOURCE.md](SOURCE.md) for locked build and ZIP packaging commands. Source
|
||||
code is GPL-3.0-only. The player and its dependencies retain their own compatible
|
||||
licenses; see [THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md).
|
||||
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).
|
||||
|
||||
Reference in New Issue
Block a user