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
  • Save manwithacat/231a95f1612ddaf933d5 to your computer and use it in GitHub Desktop.
Save manwithacat/231a95f1612ddaf933d5 to your computer and use it in GitHub Desktop.

Revisions

  1. James Barlow revised this gist Aug 2, 2015. 2 changed files with 27 additions and 14 deletions.
    8 changes: 4 additions & 4 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -2,14 +2,14 @@ This is a plugin meant for [Jekyll](https://github.com/mojombo/jekyll).

    Example use:

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

    ```
    {% youtube oHg5SJYRHA0 %}
    {% scribd 1234567 %}
    ```

    You can also specify a height and width. If you do not, it defaults to 560 x 420.
    You can also specify a height. If you do not, it defaults to 600 px

    ```
    {% youtube oHg5SJYRHA0 500 400 %}
    {% scribd 1234567 400 %}
    ```
    33 changes: 23 additions & 10 deletions youtube.rb
    Original file line number Diff line number Diff line change
    @@ -1,28 +1,41 @@
    class YouTube < Liquid::Tag
    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 = 420
    # @width = 560
    @height = 600
    else
    @width = $2.to_i
    @height = $3.to_i
    # @width = $2.to_i
    # @height = $3.to_i
    @height = $2.to_i
    end
    else
    raise "No YouTube ID provided in the \"youtube\" tag"
    raise "No Scribd ID provided in the \"scribd\" tag"
    end
    end

    def render(context)
    # "<iframe width=\"#{@width}\" height=\"#{@height}\" src=\"http://www.youtube.com/embed/#{@id}\" frameborder=\"0\"allowfullscreen></iframe>"
    "<iframe width=\"#{@width}\" height=\"#{@height}\" src=\"http://www.youtube.com/embed/#{@id}?color=white&theme=light\"></iframe>"

    "<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 "youtube", self
    end
    Liquid::Template.register_tag "scribd", self
    end
  2. @joelverhagen joelverhagen revised this gist Feb 17, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    This is a plugin meant for [https://github.com/mojombo/jekyll](Jekyll).
    This is a plugin meant for [Jekyll](https://github.com/mojombo/jekyll).

    Example use:

  3. @joelverhagen joelverhagen revised this gist Feb 17, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    This is a plugin meant for (https://github.com/mojombo/jekyll)[Jekyll].
    This is a plugin meant for [https://github.com/mojombo/jekyll](Jekyll).

    Example use:

  4. @joelverhagen joelverhagen revised this gist Feb 17, 2012. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,8 @@
    This is a plugin meant for (https://github.com/mojombo/jekyll)[Jekyll].

    Example use:

    Easily embed a YouTube video.
    Easily embed a YouTube video. Just drop this file in your `_plugins` directory.

    ```
    {% youtube oHg5SJYRHA0 %}
  5. @joelverhagen joelverhagen revised this gist Feb 17, 2012. 1 changed file with 19 additions and 20 deletions.
    39 changes: 19 additions & 20 deletions youtube.rb
    Original file line number Diff line number Diff line change
    @@ -1,29 +1,28 @@
    module Jekyll
    class YouTube < Liquid::Tag
    Syntax = /^\s*([^\s]+)(\s+(\d+)\s+(\d+)\s*)?/
    class YouTube < Liquid::Tag
    Syntax = /^\s*([^\s]+)(\s+(\d+)\s+(\d+)\s*)?/

    def initialize(tagName, markup, tokens)
    super
    def initialize(tagName, markup, tokens)
    super

    if markup =~ Syntax then
    @id = $1
    if markup =~ Syntax then
    @id = $1

    if $2.nil? then
    @width = 560
    @height = 420
    else
    @width = $2.to_i
    @height = $3.to_i
    end
    if $2.nil? then
    @width = 560
    @height = 420
    else
    raise "No YouTube ID provided in the \"youtube\" tag"
    @width = $2.to_i
    @height = $3.to_i
    end
    else
    raise "No YouTube ID provided in the \"youtube\" tag"
    end
    end

    def render(context)
    "<iframe width=\"#{@width}\" height=\"#{@height}\" src=\"http://www.youtube.com/embed/#{@id}\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"></iframe>"
    end
    def render(context)
    # "<iframe width=\"#{@width}\" height=\"#{@height}\" src=\"http://www.youtube.com/embed/#{@id}\" frameborder=\"0\"allowfullscreen></iframe>"
    "<iframe width=\"#{@width}\" height=\"#{@height}\" src=\"http://www.youtube.com/embed/#{@id}?color=white&theme=light\"></iframe>"
    end
    end

    Liquid::Template.register_tag('youtube', Jekyll::YouTube)
    Liquid::Template.register_tag "youtube", self
    end
  6. @joelverhagen joelverhagen revised this gist Feb 12, 2012. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,13 @@
    Example use:

    Easily embed a YouTube video.

    ```
    {% youtube oHg5SJYRHA0 %}
    ```

    You can also specify a height and width. If you do not, it defaults to 560 x 420.

    ```
    {% youtube oHg5SJYRHA0 500 400 %}
    ```
  7. @joelverhagen joelverhagen revised this gist Feb 12, 2012. 1 changed file with 11 additions and 0 deletions.
    11 changes: 11 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    Example use:

    Easily embed a YouTube video.
    ```
    {% youtube oHg5SJYRHA0 %}
    ```

    You can also specify a height and width. If you do not, it defaults to 560 x 420.
    ```
    {% youtube oHg5SJYRHA0 500 400 %}
    ```
  8. @joelverhagen joelverhagen created this gist Feb 12, 2012.
    29 changes: 29 additions & 0 deletions youtube.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    module Jekyll
    class YouTube < Liquid::Tag
    Syntax = /^\s*([^\s]+)(\s+(\d+)\s+(\d+)\s*)?/

    def initialize(tagName, markup, tokens)
    super

    if markup =~ Syntax then
    @id = $1

    if $2.nil? then
    @width = 560
    @height = 420
    else
    @width = $2.to_i
    @height = $3.to_i
    end
    else
    raise "No YouTube ID provided in the \"youtube\" tag"
    end
    end

    def render(context)
    "<iframe width=\"#{@width}\" height=\"#{@height}\" src=\"http://www.youtube.com/embed/#{@id}\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"></iframe>"
    end
    end
    end

    Liquid::Template.register_tag('youtube', Jekyll::YouTube)