Skip to content

Instantly share code, notes, and snippets.

@manwithacat
Forked from joelverhagen/README.md
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save manwithacat/231a95f1612ddaf933d5 to your computer and use it in GitHub Desktop.

Select an option

Save manwithacat/231a95f1612ddaf933d5 to your computer and use it in GitHub Desktop.
Jekyll Scribd Embed Plugin

This is a plugin meant for Jekyll.

Example use:

Easily embed a Scribd document. Just drop this file in your _plugins directory.

{% scribd 1234567 %}

You can also specify a height. If you do not, it defaults to 600 px

{% scribd 1234567 400  %}
class Scribd < Liquid::Tag
Syntax = /^\s*([^\s]+)(\s+(\d+)\s+(\d+)\s*)?/
def initialize(tagName, markup, tokens)
super
if markup =~ Syntax then
# Document ID
@id = $1
# Embed Paramaters
@scrolling = "no"
@data_aspect_ratio = "0.75"
@data_auto_height = "false"
#Source Paramaters
@start_page = 1
@view_mode = "scroll"
@access_key = "key-" + "2cvvaz8397jnhk0mcl0v"
@show_recommendations = true
if $2.nil? then
# @width = 560
@height = 600
else
# @width = $2.to_i
# @height = $3.to_i
@height = $2.to_i
end
else
raise "No Scribd ID provided in the \"scribd\" tag"
end
end
def render(context)
"<iframe class=\"scribd_iframe_embed\" src=\"https://www.scribd.com/embeds/#{@id}/content?start_page=#{@start_page}&view_mode=#{@start_page}&access_key=#{@access_key}&show_recommendations=t#{@show_recommendations}\" data-auto-height=#{@data_auto_height} data-aspect-ratio=#{@data_aspect_ratio} scrolling=#{@scrolling} id=\"doc_#{@id}\" width=\"100%\" height=\"#{@height}\" frameborder=\"0\"></iframe>"
end
Liquid::Template.register_tag "scribd", self
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment