aboutsummaryrefslogtreecommitdiff
path: root/_plugins/generate-media-permalink.rb
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2024-11-17 20:15:02 -0300
committerEuAndreh <eu@euandre.org>2024-11-17 20:18:21 -0300
commitcfd0246b241cb6e58153e68f7e30ed56b9bf054b (patch)
tree206deba2cec12187e835c64b8a7172277be1a2cf /_plugins/generate-media-permalink.rb
parentrm tests/assert-frontmatter.sh (diff)
downloadeuandre.org-cfd0246b241cb6e58153e68f7e30ed56b9bf054b.tar.gz
euandre.org-cfd0246b241cb6e58153e68f7e30ed56b9bf054b.tar.xz
Remove jekyll infrastructure setup
Diffstat (limited to '')
-rw-r--r--_plugins/generate-media-permalink.rb61
1 files changed, 0 insertions, 61 deletions
diff --git a/_plugins/generate-media-permalink.rb b/_plugins/generate-media-permalink.rb
deleted file mode 100644
index ae635bd..0000000
--- a/_plugins/generate-media-permalink.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-module Jekyll
- class MediaPermalinkGenerator < Generator
- safe true
-
- MEDIA_EXTENSION = {
- 'podcasts' => 'ogg',
- 'screencasts' => 'webm'
- }
-
- def generate(site)
- site.collections.each do |name, collection|
- if ['podcasts', 'screencasts'].include? name then
- collection.docs.each do |document|
- date = document.data['date'].strftime('%Y-%m-%d')
- slug = document.data['slug']
- extension = MEDIA_EXTENSION[name]
- file = "#{date}-#{slug}.#{extension}"
- media = "resources/#{name}/#{file}"
- torrent = "#{media}.torrent"
- media_link = document.url.gsub(/html$/, extension)
- torrent_link = "#{media_link}.torrent"
- media_page = GeneratedSymlinkResourcePage.new(site, site.source, '', media_link)
- torrent_page = GeneratedSymlinkResourcePage.new(site, site.source, '', torrent_link)
- media_page.data['source'] = media
- media_page.data['slug'] = slug
- media_page.data['extension'] = extension
- torrent_page.data['source'] = torrent
- torrent_page.data['slug'] = slug
- torrent_page.data['extension'] = "#{extension}.torrent"
- site.pages << media_page
- site.pages << torrent_page
- end
- end
- end
- end
- end
-
- class GeneratedSymlinkResourcePage < Jekyll::Page
- def read_yaml(*)
- @data ||= {
- "generated" => true
- }
- end
-
- def write(dest)
- source = @data['source']
- slug = @data['slug']
- extension = @data['extension']
- path = destination(dest)
- path_dirname = File.dirname(path)
- FileUtils.mkdir_p(path_dirname)
- stdout = `ln -fs ../../../../#{source} #{path_dirname}/#{slug}.#{extension}`
- unless $?.success? then
- raise "Error when running 'ln' command: #{$?}"
- end
- unless stdout == '' then
- raise "Unexpected output of 'ln': #{stdout}"
- end
- end
- end
-end