Skip to content

Commit c7b31a1

Browse files
committed
feat: init asciinema-player
1 parent 9f81e08 commit c7b31a1

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

modules/markup/asciicast/asciicast.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ func (Renderer) Extensions() []string {
3232
}
3333

3434
const (
35-
playerClassName = "asciicast-player-container"
36-
playerSrcAttr = "data-asciicast-player-src"
35+
playerClassName = "asciinema-player-container"
36+
playerSrcAttr = "data-asciinema-player-src"
3737
)
3838

3939
// SanitizerRules implements markup.Renderer

web_src/js/asciinema/player.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import * as AsciinemaPlayer from 'asciinema-player';
2+
3+
export function initAsciinemaPlayer() {
4+
const players = document.getElementsByClassName('asciinema-player-container');
5+
console.log('start');
6+
for (const player of players) {
7+
console.log('init');
8+
AsciinemaPlayer.create(player.getAttribute('data-asciinema-player-src'), player, {
9+
fit: 'both',
10+
preload: true,
11+
poster: 'npt:100:0:0',
12+
});
13+
}
14+
}

web_src/js/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ import {initRepoCommentForm, initRepository} from './features/repo-legacy.js';
9090
import {initFormattingReplacements} from './features/formatting.js';
9191
import {initMcaptcha} from './features/mcaptcha.js';
9292
import {initCopyContent} from './features/copycontent.js';
93+
import {initAsciinemaPlayer} from './asciinema/player.js';
9394

9495
// Run time-critical code as soon as possible. This is safe to do because this
9596
// script appears at the end of <body> and rendered HTML is accessible at that point.
@@ -198,4 +199,6 @@ $(document).ready(() => {
198199
initUserSettings();
199200
initViewedCheckboxListenerFor();
200201
checkAppUrl();
202+
203+
initAsciinemaPlayer();
201204
});

0 commit comments

Comments
 (0)