Created
July 9, 2012 08:37
-
-
Save earltedly/3075129 to your computer and use it in GitHub Desktop.
Jekyll Garmin activity references
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Title: Simple Garmin tag for Jekyll | |
# Author: Ted Bradley http://monkeysandtea.com | |
# Description: easily embed a Garmin iframe using only the activity id. Has to be set to public though. | |
# | |
# Syntax {% garmin activityId [width height] %} | |
# | |
# Example: | |
# {% garmin 123456 465 548 %} | |
# | |
# Output: | |
# <iframe width='465' height='548' frameborder='0' src='http://connect.garmin.com:80/activity/embed/123456'></iframe> | |
# | |
module Jekyll | |
class GarminTag < Liquid::Tag | |
@activity = nil | |
@height = '' | |
@width = '' | |
def initialize(tag_name, markup, tokens) | |
if markup =~ /^(\d+)[ \t](\d+)[ \t](\d+)/ | |
@activity = $1 | |
@width = $2 | |
@height = $3 | |
else | |
@activity = markup | |
@width = 465 | |
@height = 548 | |
end | |
super | |
end | |
def render(context) | |
output = super | |
garmin = "<iframe width='#{@width}' height='#{@height}' frameborder='0' src='http://connect.garmin.com:80/activity/embed/#{@activity}'></iframe>" | |
end | |
end | |
end | |
Liquid::Template.register_tag('garmin', Jekyll::GarminTag) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Unfortunately the Garmin iframes currently don't seem to scale to their bounds - better to leave the width / height out.