Show HN:在你的网站上嵌入真实的 Linux 终端
Show HN: Embed a real Linux terminal on your website

原始链接: https://sandbox.bio/training/embed

您可以轻松地将交互式 `sandbox.bio` 终端嵌入到您的网站或博客中,从而在浏览器中直接执行命令。 若要开始使用,请将以下脚本标签添加到您的页面: `` 集成后,您的 `bash` 代码块(在 GitHub Pages Markdown 或标准的 `language-bash` HTML div 中)将自动出现一个“运行”按钮。 **自定义选项包括:** * **`data-cwd`**:设置初始工作目录。 * **`data-config`**:指向一个远程 JSON 文件,用于进行高级终端配置。 您还可以通过在配置文件中使用 `tools` 数组来预加载特定文件,以便用户进行交互。该数组需指定文件 URL 以及文件在终端中显示的本地路径。这是为您的技术内容创建交互式教程或演示的高效方式。

最近的一场 Hacker News 讨论中,出现了一个名为“Show HN: 在你的网站上嵌入真正的 Linux 终端”(sandbox.bio)的项目。该项目旨在简化将交互式浏览器 Linux 终端集成到教程和文档中的过程。 创作者 raboukhalil 解释说,该工具由 v86 驱动,旨在让用户无需进行繁琐的本地配置,即可练习 Git 或生物信息学工具等命令行技能。虽然一些评论者认为该项目只是一个“噱头”,或批评其文档在 WebAssembly (WASM) 实现和架构方面缺乏技术深度,但也有人对这一概念表示支持。支持者强调了“立即尝试”环境对教材的高价值,并指出免除下载和配置的必要性,显著降低了开发人员测试新工具的门槛。 尽管存在褒贬不一的反馈以及对其技术稳健性的质疑,创作者仍致力于提升该工具在培训用途中的嵌入便捷性,将其视为一种用于交互式文档的实用工具,而非仅仅是一个新奇玩意。
相关文章

原文

Embed sandbox.bio

Add a live terminal to your website or blog post

You can embed a sandbox.bio terminal directly on your website or blog post. Simply add this script tag to your page:

<script src="https://sandbox.bio/embed.js" data-cwd="embed"></script>
A blog post with Run buttons on its code blocks and a terminal docked at the bottom

If you use GitHub Pages, any Markdown code blocks you mark as ```bash will have a "Run" button that executes directly in the embedded terminal. For HTML websites, any <div> with the class "language-bash" will get a "Run" button.

You can also customize the embedded terminal by adding attributes to the script tag:

  • data-cwd="folder-name": the starting working directory in the terminal
  • data-config="https://yourwebsite.com/config.json": an optional remote config URL, using the same format as the sandboxbio.config.json file used by the GitHub integration. This file can be hosted on GitHub Pages too.

If you need to preload files in the terminal, you can use the array files inside your config, and specify the URLs to where each file lives:

{
  tools: [
    { "url": "https://<username>.github.io/<repo>/data/example.bam", "path": "example.bam" }
  ]
}
联系我们 contact @ memedata.com