Skip to content

Commit 87e8409

Browse files
committed
Replace data-asciicinema with <ascii-cinema> Vue component
1 parent 220e7d8 commit 87e8409

File tree

8 files changed

+67
-17
lines changed

8 files changed

+67
-17
lines changed
Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,2 @@
11
<link rel="stylesheet" href="/css/asciinema-player.css">
22
<script src="/lib/js/asciinema-player.js"></script>
3-
<script>
4-
document.addEventListener("DOMContentLoaded", () => {
5-
document.querySelectorAll('[data-asciicinema]').forEach(el => {
6-
const path = el.dataset.asciicinema
7-
const options = el.dataset.options
8-
? new Function(`return (${el.dataset.options})`)()
9-
: { loop: true, poster:'npt:00:01' }
10-
AsciinemaPlayer.create(path, el, options)
11-
})
12-
})
13-
</script>

MyApp/Pages/Shared/DocsPage.cshtml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,13 @@ if (document.querySelector('.hide-title')) {
273273
}
274274
</script>
275275

276+
@*Only load additional deps for pages with custom .mjs*@
277+
@if (docMjs != null)
278+
{
279+
@await Html.PartialAsync("MermaidIncludes")
280+
@await Html.PartialAsync("AsciiCinemaIncludes")
281+
}
282+
276283
<script type="module">
277284
import { ref } from "vue"
278285
import { mount } from "app.mjs"

MyApp/_pages/ai-server/comfy-extension.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ cat install.sh | bash
2525

2626
This process will also persist the configuration in the `.env` file in the ComfyUI Agent directory, so you can easily restart the ComfyUI Agent with the same configuration.
2727

28-
<div data-asciicinema="/pages/ai-server/agent-comfy-install.cast"
29-
data-options="{loop:true,poster:'npt:00:09',theme:'dracula',rows:16}"></div>
28+
<ascii-cinema src="/pages/ai-server/agent-comfy-install.cast"
29+
loop="true" poster="npt:00:09" theme="dracula" rows="13" />
3030

3131
:::info
3232
On the first run, the ComfyUI Agent will download the models you selected during the installation process. This can take some time depending on the size of the models and your internet connection speed.

MyApp/_pages/ai-server/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ cd ai-server && cat install.sh | bash
2222
The installer will detect common environment variables for its supported AI Providers including OpenAI, Anthropic,
2323
Mistral AI, Google, etc. and prompt if you would like to include any others in your AI Server configuration.
2424

25-
<div data-asciicinema="/pages/ai-server/ai-server-install.cast"
26-
data-options="{loop:true,poster:'npt:00:21',theme:'dracula',rows:13}"></div>
25+
<ascii-cinema src="/pages/ai-server/ai-server-install.cast"
26+
loop="true" poster="npt:00:21" theme="dracula" rows="12" />
2727

2828
## Accessing AI Server
2929

@@ -44,8 +44,8 @@ If needed you can reset the process by deleting your local `App_Data` directory
4444

4545
If your server also has a GPU you can ask the installer to also install the [ComfyUI Agent](/ai-server/comfy-extension) locally:
4646

47-
<div data-asciicinema="https://docs.servicestack.net/pages/ai-server/agent-comfy-install.cast"
48-
data-options="{loop:true,poster:'npt:00:09',theme:'dracula',rows:16}"></div>
47+
<ascii-cinema src="/pages/ai-server/agent-comfy-install.cast"
48+
loop="true" poster="npt:00:09" theme="dracula" rows="13" />
4949

5050
The ComfyUI Agent is a separate Docker agent for running [ComfyUI](https://www.comfy.org),
5151
[Whisper](https://github.com/openai/whisper) and [FFmpeg](https://www.ffmpeg.org) on servers with GPUs to handle
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import AsciiCinema from '../components/AsciiCinema.mjs'
2+
3+
export default {
4+
install(app) {
5+
},
6+
components: {
7+
AsciiCinema,
8+
},
9+
setup() {
10+
return { }
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import AsciiCinema from '../components/AsciiCinema.mjs'
2+
3+
export default {
4+
install(app) {
5+
},
6+
components: {
7+
AsciiCinema,
8+
},
9+
setup() {
10+
return { }
11+
}
12+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { ref, onMounted } from "vue"
2+
3+
export default {
4+
template:`
5+
<div ref="el"></div>
6+
`,
7+
props:['src','loop','poster','theme','rows'],
8+
setup(props) {
9+
const el = ref()
10+
11+
onMounted(() => {
12+
console.log('globalThis.AsciinemaPlayer', globalThis.AsciinemaPlayer)
13+
globalThis.AsciinemaPlayer.create(props.src, el.value, props)
14+
})
15+
16+
return { el }
17+
}
18+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import AsciiCinema from '../components/AsciiCinema.mjs'
2+
3+
export default {
4+
install(app) {
5+
},
6+
components: {
7+
AsciiCinema,
8+
},
9+
setup() {
10+
return { }
11+
}
12+
}

0 commit comments

Comments
 (0)