asciinema.org/app/views/docs/embedding.html.md

160 lines
5.2 KiB
Markdown
Raw Normal View History

2015-10-14 11:00:09 +00:00
<% content_for(:title, 'Sharing & embedding') %>
2015-10-14 11:00:09 +00:00
# Sharing & embedding
2015-10-14 11:00:09 +00:00
You can share any recording by copying its URL and sending it to a friend or
posting it on a social network. asciinema.org supports oEmbed/Open Graph/Twitter
Card protocols, displaying a nice thumbnail where possible.
You can also easily embedded an asciicast on any HTML page. If you want to put a
2015-03-31 14:36:03 +00:00
recording in a blog post, project's documentation or in a conference talk
2015-10-14 11:00:09 +00:00
slides, you can do it by copy-pasting one of the the embed scripts.
## Sharing a link
You can get the share link for a specific asciicast by clicking on "Share" link
on asciicast page.
Any of the options listed in "Customizing the playback" section below can be
appended to the asciicast URL as the query params, e.g.:
https://asciinema.org/a/14?t=25&speed=2&theme=solarized-dark
Visiting this link will start the playback at 25s and play at double speed,
using Solarized Dark terminal theme.
2015-10-14 11:00:09 +00:00
## Embedding image link
2015-03-31 14:36:03 +00:00
Embedding as an image link is useful in places where scripts are not allowed,
e.g. in a project's README file.
2015-10-14 11:00:09 +00:00
You can get the embed snippets for a specific asciicast by clicking on "Share"
2015-03-31 14:36:03 +00:00
link on asciicast page.
2015-10-14 11:00:09 +00:00
This is how they look for asciicast 14:
2015-03-31 14:36:03 +00:00
HTML:
<a href="https://asciinema.org/a/14"><img src="https://asciinema.org/a/14.png" width="836"/></a>
Markdown:
[![asciicast](https://asciinema.org/a/14.png)](https://asciinema.org/a/14)
2015-10-14 11:00:09 +00:00
You can pass extra options (listed in "Customizing the playback" below) to the
linked URL as query params. For example, to start the playback automatically
when opening linked asciicast page append `?autoplay=1` to the asciicast URL in
`href` attribute:
2015-03-31 14:36:03 +00:00
<a href="https://asciinema.org/a/14?autoplay=1"><img src="https://asciinema.org/a/14.png" width="836"/></a>
2015-10-14 11:00:09 +00:00
## Embedding the player
2015-03-31 14:36:03 +00:00
2015-10-14 11:00:09 +00:00
If you're embedding on your own page or on a site which permits script tags, you
can use the full player widget.
You can get the widget script for a specific asciicast by clicking on "Embed"
link on asciicast page.
It looks like this:
<script type="text/javascript" src="https://asciinema.org/a/14.js" id="asciicast-14" async></script>
The player shows up right at the place where the script is pasted. Let's look
at the following markup:
<p>This is some text.</p>
<script type="text/javascript" src="https://asciinema.org/a/14.js" id="asciicast-14" async></script>
<p>This is some other text.</p>
2015-03-31 14:36:03 +00:00
The player is displayed between the two paragraphs, as a `div` element with
"asciicast" class.
2015-10-14 11:00:09 +00:00
The embed script supports all customization options (see the section below). An
option can be specified by adding it as a
<code>data-<em>option-name</em>="<em>value</em>"</code> attribute to the script
tag.
2015-10-14 11:00:09 +00:00
For example, to make the embedded player auto start playback when loaded and use
big font, use the following script:
2015-10-14 11:00:09 +00:00
<script type="text/javascript" src="https://asciinema.org/a/14.js" id="asciicast-14" async data-autoplay="true" data-size="big"></script>
2015-10-14 11:00:09 +00:00
## Customizing the playback
2015-10-14 11:00:09 +00:00
The player supports several options that control the behavior and look of it.
Append them to the URL (`?speed=2&theme=tango`) or set them as data attributes
on embed script (`data-speed="2" data-theme="tango"`).
2015-10-14 11:00:09 +00:00
### t
2015-10-14 11:00:09 +00:00
The `t` option specifies the time at which the playback should start. The
default is `t=0` (play from the beginning).
2015-10-14 11:00:09 +00:00
Accepted formats: `ss`, `mm:ss`, `hh:mm:ss`.
2015-10-14 11:00:09 +00:00
NOTE: when `t` is specified then `autoplay=1` is implied. To prevent the player
from starting automatically when `t` option is set you have to explicitly set
`autoplay=0`.
2015-10-14 11:00:09 +00:00
### autoplay
2015-10-14 11:00:09 +00:00
The `autoplay` option controls whether the playback should automatically start
when the player loads. Accepted values:
* 0 / false - do not start playback automatically (default)
* 1 / true - start playback automatically
### preload
The `preload` option controls whether the player should immediately start
fetching the recording.
2016-04-21 15:03:48 +00:00
* 0 / false - do not preload the recording, wait for user action
* 1 / true - preload the recording
2016-04-21 15:03:48 +00:00
Defaults to 1 for asciinema.org URLs, to 0 for embed script.
2015-10-14 11:00:09 +00:00
### loop
The `loop` option allows for looping the playback. This option is usually
combined with `autoplay` option. Accepted values:
* 0 / false - disable looping (default)
* 1 / true - enable looping
2015-10-14 11:00:09 +00:00
### speed
2015-10-14 11:00:09 +00:00
The `speed` option alters the playback speed. The default speed is 1 which
means it plays at the unaltered, original speed.
### size
The `size` option alters the size of the terminal font. There are 3 available
sizes:
* small (default)
* medium
* big
### theme
The `theme` option allows overriding a theme used for the terminal. It defaults
2015-10-18 15:52:11 +00:00
to a theme set by the asciicast author (or to "asciinema" if not set by the
author). The available themes are:
2015-10-14 11:00:09 +00:00
2015-10-18 15:52:11 +00:00
* asciinema
2015-10-14 11:00:09 +00:00
* tango
* solarized-dark
* solarized-light
2015-10-18 15:52:11 +00:00
* monokai
2015-03-31 14:36:03 +00:00
## oEmbed / Open Graph / Twitter Card
asciinema supports [oEmbed](http://oembed.com/), [Open Graph](http://ogp.me/)
2015-03-31 15:36:33 +00:00
and [Twitter Card](https://dev.twitter.com/cards/overview) APIs. When you share
an asciicast on Twitter, Slack, Facebook, Google+ or any other site which
supports one of these APIs, the asciicast is presented in a rich form (usually
with a title, author, description and a thumbnail image), linking to your
recording on asciinema.org.