aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--.gitmodules3
-rw-r--r--_layouts/podcast.html9
-rw-r--r--torrent.html23
m---------vendor/webtorrent0
4 files changed, 32 insertions, 3 deletions
diff --git a/.gitmodules b/.gitmodules
index 6d301d9..f169aba 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,6 @@
[submodule "vendor/reveal.js"]
path = vendor/reveal.js
url = https://github.com/hakimel/reveal.js
+[submodule "vendor/webtorrent"]
+ path = vendor/webtorrent
+ url = https://github.com/webtorrent/webtorrent
diff --git a/_layouts/podcast.html b/_layouts/podcast.html
index 982fbc6..197943f 100644
--- a/_layouts/podcast.html
+++ b/_layouts/podcast.html
@@ -8,9 +8,12 @@ layout: post
</audio>
<div class="torrent-link">
- <a href="/resources/podcasts/{{ page.date | date: "%Y-%m-%d" }}-{{ page.slug }}.ogg.torrent">
- torrent
- </a>
+ {% capture torrent-file %}{{ site.url }}/resources/podcasts/{{ page.date | date: "%Y-%m-%d" }}-{{ page.slug }}.ogg.torrent{% endcapture %}
+ <a href="{{ torrent-file }}">torrent</a>
+ {% if site.torrent %}
+ |
+ <a href="/torrent.html?torrent={{ torrent-file | uri_escape }}">online webtorrent</a>
+ {% endif %}
</div>
{{ content }}
diff --git a/torrent.html b/torrent.html
new file mode 100644
index 0000000..7be57d0
--- /dev/null
+++ b/torrent.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <link rel="stylesheet" href="/styles.css" />
+ <title>WebTorrent player - EuAndreh</title>
+ <script src="/vendor/webtorrent/webtorrent.min.js"></script>
+ </head>
+ <body>
+ <div id="output"></div>
+ <div id="torrentLink"></div>
+ <script>
+ const params = new URLSearchParams(window.location.search);
+ const torrentID = params.get("torrent"); // "https://webtorrent.io/torrents/sintel.torrent";
+ document.querySelector("#torrentLink").innerHTML = `Downloading <a href=${torrentID}>${torrentID}</a>`;
+
+ const client = new WebTorrent();
+ client.add(torrentID, torrent =>
+ torrent.files.forEach(file => file.appendTo("#output")));
+ </script>
+ </body>
+</html>
diff --git a/vendor/webtorrent b/vendor/webtorrent
new file mode 160000
+Subproject 2d78a30a72072b859336f8d9340398d6bb2169e