Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Audio/MP3 Plugin for Octopress
# Title: MP3 tag for Jekyll
# Authors: Devin Weaver, Daniel Roos (youtube changes)
# Description: Allows mp3 tag to include mp3 files embedded into the post.
# It uses the player 'audio.js' from http://kolber.github.com/audiojs/
#
# Install the plugin according to the manuel of the author by adding the necessary lines to the head-template
# and adding the files into the right directories.
#
# Please read my [blog post about it][2].
#
# [2]: http://blog.micronarrativ.org/2012/09/06/Wordpress_til_Octopress_-_Audio
#
# Syntax {% audio fileurl %}
#
# Examples:
# {% audio http://www.example.com/audio.mp3 %}
#
# Output:
# <p/>
# <center>
# <audio src="http://www.example.com/audio.mp3" preload="none" />
# </center>
# <p/>
require 'digest/md5'
module Jekyll
class AudioTag < Liquid::Tag
def initialize(tag_name, markup, tokens)
if /(?<fileurl>\S+)?/i =~ markup
@audiotagurl = fileurl
end
super
end
def render(context)
if @audiotagurl
"<p/>
<center>
<audio src=\"#{@audiotagurl}\" preload=\"none\" />
</center>
<p/>"
else
"Error processing input, expected syntax: {% audio fileurl %}"
end
end
end
end
Liquid::Template.register_tag('audio', Jekyll::AudioTag)
@jimsynz

This comment has been minimized.

Copy link

@jimsynz jimsynz commented Oct 7, 2013

Thanks for this!

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Mar 15, 2017

I no longer can find the link to your instructions on your website. do you have an updated address for the post?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment