├── LICENSE ├── README.md └── jsbin.rb /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Dave, the JS Bin bot 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | jsbin octopress plugin 2 | ================ 3 | 4 | Given a bin url, generates the embed code for jsbin with defined panels. A bin url is either just the code: `abcefg` or you can include the revision `abcefg/4` or you can point to latest: `abcefg/latest`. If you don't specify a revision, latest will be automatically selected. 5 | 6 | * panels: html, js, css, console, output (default: html,css,js,output) 7 | 8 | ## Syntax 9 | 10 | ```ruby 11 | {% jsbin bin [panels] %} 12 | ``` 13 | 14 | ## Examples: 15 | 16 | Input: 17 | 18 | ```ruby 19 | {% jsbin exedab %} 20 | ``` 21 | 22 | Output: 23 | 24 | ```html 25 | JS Bin 26 | ``` 27 | 28 | Input: 29 | 30 | ```ruby 31 | {% jsbin exedab js,html %} 32 | ``` 33 | 34 | Output: 35 | 36 | ```html 37 | JS Bin 38 | ``` 39 | 40 | ### Contributors 41 | 42 | * [hemanth](https://github.com/hemanth) 43 | * [remy](https://github.com/remy) 44 | -------------------------------------------------------------------------------- /jsbin.rb: -------------------------------------------------------------------------------- 1 | # Title: jsbin tag for Jekyll 2 | # Author: Remy Sharp (@rem) 3 | # Description: 4 | # Given a bin url, generates the embed code for jsbin with defined panels. 5 | # A bin url is either just the code: `abcefg` or you can include the revision 6 | # `abcefg/4` or you can point to latest: `abcefg/latest` 7 | # 8 | # Panels: html, js, css, console, output (default: html,css,js,output) 9 | # 10 | # Syntax: {% jsbin bin %} 11 | # 12 | # Examples: 13 | # 14 | # Input: {% jsbin exedab %} 15 | # Output: JS Bin 16 | # 17 | # Input: {% jsbin exedab js,html %} 18 | # Output: JS Bin 19 | # 20 | module Jekyll 21 | class JSBin < Liquid::Tag 22 | def initialize(tag_name, markup, tokens) 23 | if /(?[^\s\/]+)(\/(?\d))?(?:\s+(?[\w,]+))?/ =~ markup 24 | @bin = jsbin 25 | @revision = revision || 'latest' 26 | @sequence = (sequence unless sequence == 'all') || 'html,css,js,output' 27 | end 28 | end 29 | 30 | def render(context) 31 | if @bin 32 | <JS Bin 34 | 35 | HTML 36 | else 37 | "Error processing input, expected syntax: {% jsbin bin [panels] %}" 38 | end 39 | end 40 | end 41 | end 42 | 43 | Liquid::Template.register_tag('jsbin', Jekyll::JSBin) 44 | --------------------------------------------------------------------------------