Merge branch 'master' into site

Conflicts:
	Rakefile
This commit is contained in:
Frederic Hemberger 2011-09-26 15:49:02 +02:00
commit a032598c58
11 changed files with 261 additions and 147 deletions

3
.slugignore Normal file
View File

@ -0,0 +1,3 @@
plugins
sass
source

View File

@ -1,7 +1,8 @@
{% if site.delicious_user %} {% if site.delicious_user %}
<section> <section>
<h1>On Delicious</h1> <h1>On Delicious</h1>
<script type="text/javascript" src="http://feeds.delicious.com/v2/js/{{ site.delicious_user }}?title=&amp;count={{ site.delicious_count }}&amp;sort=date&amp;extended"></script> <div id="delicious"></div>
<script type="text/javascript" src="http://feeds.delicious.com/v1/json/{{ site.delicious_user }}?count={{ site.delicious_count }}&amp;sort=date&amp;callback=renderDeliciousLinks"></script>
<p><a href="http://delicious.com/{{ site.delicious_user }}">My Delicious Bookmarks &raquo;</a></p> <p><a href="http://delicious.com/{{ site.delicious_user }}">My Delicious Bookmarks &raquo;</a></p>
</section> </section>
{% endif %} {% endif %}

View File

@ -21,7 +21,7 @@
<link href="{{ root_url }}/favicon.png" rel="icon"> <link href="{{ root_url }}/favicon.png" rel="icon">
<link href="{{ root_url }}/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css"> <link href="{{ root_url }}/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css">
<script src="{{ root_url }}/javascripts/modernizr-2.0.js"></script> <script src="{{ root_url }}/javascripts/modernizr-2.0.js"></script>
<script src="http://s3.amazonaws.com/ender-js/jeesh.min.js"></script> <script src="{{ root_url }}/javascripts/ender.js"></script>
<script src="{{ root_url }}/javascripts/octopress.js" type="text/javascript"></script> <script src="{{ root_url }}/javascripts/octopress.js" type="text/javascript"></script>
<link href="{{ site.subscribe_rss }}" rel="alternate" title="{{site.title}}" type="application/atom+xml"> <link href="{{ site.subscribe_rss }}" rel="alternate" title="{{site.title}}" type="application/atom+xml">
{% include custom/head.html %} {% include custom/head.html %}

View File

@ -1,6 +1,6 @@
{% capture root_url %}{{ site.root | strip_slash }}{% endcapture %} {% capture root_url %}{{ site.root | strip_slash }}{% endcapture %}
{% include head.html %} {% include head.html %}
<body {% if page.body_id %} id="{{ page.body_id }}" {% endif %} {% if page.sidebar == false %} class="no-sidebar" {% endif %}> <body {% if page.body_id %} id="{{ page.body_id }}" {% endif %} {% if page.sidebar == false %} class="no-sidebar" {% endif %} {% if page.sidebar == 'collapse' %} class="collapse-sidebar sidebar-footer" {% endif %}>
<header role="banner">{% include header.html %}</header> <header role="banner">{% include header.html %}</header>
<nav role="navigation">{% include navigation.html %}</nav> <nav role="navigation">{% include navigation.html %}</nav>
<div id="main"> <div id="main">

File diff suppressed because one or more lines are too long

View File

@ -1,43 +1,39 @@
github = (function(){ var github = (function(){
function render(target, repos){ function render(target, repos){
var i = 0, fragment = '', t = $(target)[0]; var i = 0, fragment = '', t = $(target)[0];
for(i = 0; i < repos.length; i++) for(i = 0; i < repos.length; i++) {
fragment += '<li><a href="'+repos[i].url+'">'+repos[i].name+'</a><p>'+repos[i].description+'</p></li>'; fragment += '<li><a href="'+repos[i].url+'">'+repos[i].name+'</a><p>'+repos[i].description+'</p></li>';
t.innerHTML = fragment;
} }
return { t.innerHTML = fragment;
showRepos: function(options){ }
var feed = new jXHR(); return {
feed.onerror = function (msg,url) { showRepos: function(options){
$(options.target + ' li.loading').addClass('error').text("Error loading feed"); var feed = new jXHR();
} feed.onerror = function (msg,url) {
feed.onreadystatechange = function(data){ $(options.target + ' li.loading').addClass('error').text("Error loading feed");
if (feed.readyState === 4) { };
var repos = []; feed.onreadystatechange = function(data) {
var i; if (feed.readyState === 4) {
for (i = 0; i < data.repositories.length; i++){ var repos = [];
if (options.skip_forks && data.repositories[i].fork) for (var i = 0; i < data.repositories.length; i++){
continue; if (options.skip_forks && data.repositories[i].fork) { continue; }
repos.push(data.repositories[i]); repos.push(data.repositories[i]);
} }
repos.sort(function(a, b){ repos.sort(function(a, b) {
var a = new Date(a.pushed_at), var aDate = new Date(a.pushed_at).valueOf(),
b = new Date(b.pushed_at); bDate = new Date(b.pushed_at).valueOf();
if (a.valueOf() == b.valueOf()) return 0; if (aDate === bDate) { return 0; }
return a.valueOf() > b.valueOf() ? -1 : 1; return aDate > bDate ? -1 : 1;
}); });
if (options.count) if (options.count) { repos.splice(options.count); }
repos.splice(options.count); render(options.target, repos);
render(options.target, repos)
}
};
feed.open("GET","http://github.com/api/v2/json/repos/show/"+options.user+"?callback=?");
feed.send();
} }
}; };
feed.open("GET","http://github.com/api/v2/json/repos/show/"+options.user+"?callback=?");
feed.send();
}
};
})(); })();

View File

@ -1,24 +1,27 @@
function getNav() { function getNav() {
var mobileNav = $('nav[role=navigation] fieldset[role=search]').after('<fieldset class="mobile-nav"></fieldset>').next().append('<select></select>'); var mobileNav = $('nav[role=navigation] fieldset[role=search]').after('<fieldset class="mobile-nav"></fieldset>').next().append('<select></select>');
mobileNav.children('select').append('<option value="">Navigate&hellip;</option>'); mobileNav.children('select').append('<option value="">Navigate&hellip;</option>');
$('ul[role=main-navigation]').addClass('main-navigation');
$('ul.main-navigation a').each(function(link) { $('ul.main-navigation a').each(function(link) {
mobileNav.children('select').append('<option value="'+link.href+'">&bull; '+link.text+'</option>'); mobileNav.children('select').append('<option value="'+link.href+'">&bull; '+link.text+'</option>');
}); });
mobileNav.children('select').bind('change', function(event) { mobileNav.children('select').bind('change', function(event) {
if (event.target.value) window.location.href = event.target.value; if (event.target.value) { window.location.href = event.target.value; }
}); });
} }
function addSidebarToggler() { function addSidebarToggler() {
$('#content').append('<span class="toggle-sidebar"></span>'); if(!$('body').hasClass('sidebar-footer')) {
$('.toggle-sidebar').bind('click', function(e) { $('#content').append('<span class="toggle-sidebar"></span>');
e.preventDefault(); $('.toggle-sidebar').bind('click', function(e) {
if ($('body').hasClass('collapse-sidebar')) { e.preventDefault();
$('body').removeClass('collapse-sidebar'); if ($('body').hasClass('collapse-sidebar')) {
} else { $('body').removeClass('collapse-sidebar');
$('body').addClass('collapse-sidebar'); } else {
} $('body').addClass('collapse-sidebar');
}); }
});
}
var sections = $('aside.sidebar > section'); var sections = $('aside.sidebar > section');
if (sections.length > 1) { if (sections.length > 1) {
sections.each(function(section, index){ sections.each(function(section, index){
@ -49,7 +52,7 @@ function testFeatures() {
} }
function addCodeLineNumbers() { function addCodeLineNumbers() {
if (navigator.appName == 'Microsoft Internet Explorer') { return; } if (navigator.appName === 'Microsoft Internet Explorer') { return; }
$('div.gist-highlight').each(function(code) { $('div.gist-highlight').each(function(code) {
var tableStart = '<table><tbody><tr><td class="gutter">', var tableStart = '<table><tbody><tr><td class="gutter">',
lineNumbers = '<pre class="line-numbers">', lineNumbers = '<pre class="line-numbers">',
@ -69,7 +72,7 @@ function flashVideoFallback(){
flashplayerskin = "/assets/jwplayer/glow/glow.xml"; flashplayerskin = "/assets/jwplayer/glow/glow.xml";
$('video').each(function(video){ $('video').each(function(video){
video = $(video); video = $(video);
if (!Modernizr.video.h264 && swfobject.getFlashPlayerVersion() || window.location.hash.indexOf("flash-test") != -1){ if (!Modernizr.video.h264 && swfobject.getFlashPlayerVersion() || window.location.hash.indexOf("flash-test") !== -1){
video.children('source[src$=mp4]').first().map(function(source){ video.children('source[src$=mp4]').first().map(function(source){
var src = $(source).attr('src'), var src = $(source).attr('src'),
id = 'video_'+Math.round(1 + Math.random()*(100000)), id = 'video_'+Math.round(1 + Math.random()*(100000)),
@ -89,7 +92,7 @@ function flashVideoFallback(){
function wrapFlashVideos() { function wrapFlashVideos() {
$('object').each(function(object) { $('object').each(function(object) {
object = $(object); object = $(object);
if (object.children('param[name=movie]')) { if ( $('param[name=movie]', object).length ) {
var wrapper = object.before('<div class="flash-video"><div>').previous(); var wrapper = object.before('<div class="flash-video"><div>').previous();
$(wrapper).children().append(object); $(wrapper).children().append(object);
} }
@ -101,6 +104,15 @@ function wrapFlashVideos() {
}); });
} }
function renderDeliciousLinks(items) {
var output = "<ul>";
for (var i=0,l=items.length; i<l; i++) {
output += '<li><a href="' + items[i].u + '" title="Tags: ' + items[i].t.join(', ') + '">' + items[i].d + '</a></li>';
}
output += "</ul>";
$('#delicious').html(output);
}
$.domReady(function() { $.domReady(function() {
testFeatures(); testFeatures();
wrapFlashVideos(); wrapFlashVideos();

View File

@ -1,43 +1,5 @@
// JSON-P Twitter fetcher for Octopress // JSON-P Twitter fetcher for Octopress
// (c) Brandon Mathis // MIT Lisence // (c) Brandon Mathis // MIT Lisence
function getTwitterFeed(user, count, replies) {
var feed = new jXHR();
feed.onerror = function (msg,url) {
$('#tweets li.loading').addClass('error').text("Twitter's busted");
}
feed.onreadystatechange = function(data){
if (feed.readyState === 4) {
var tweets = new Array();
var i = 0;
for (i in data){
if(tweets.length < count){
if(replies || data[i].in_reply_to_user_id == null){
tweets.push(data[i]);
}
}
}
showTwitterFeed(tweets, user);
}
};
feed.open("GET","http://twitter.com/statuses/user_timeline/"+user+".json?trim_user=true&count="+(parseInt(count)+60)+"&callback=?");
feed.send();
}
function showTwitterFeed(tweets, twitter_user){
var timeline = document.getElementById('tweets');
timeline.innerHTML='';
for (t in tweets){
timeline.innerHTML+='<li>'+'<p>'+'<a href="http://twitter.com/'+twitter_user+'/status/'+tweets[t].id_str+'">'+prettyDate(tweets[t].created_at)+'</a>'+linkifyTweet(tweets[t].text.replace(/\n/g, '<br>'))+'</p>'+'</li>';
}
}
function linkifyTweet(text){
return text.replace(/(https?:\/\/)([\w\-:;?&=+.%#\/]+)/gi, '<a href="$1$2">$2</a>')
.replace(/(^|\W)@(\w+)/g, '$1<a href="http://twitter.com/$2">@$2</a>')
.replace(/(^|\W)#(\w+)/g, '$1<a href="http://search.twitter.com/search?q=%23$2">#$2</a>');
}
// jXHR.js (JSON-P XHR) | v0.1 (c) Kyle Simpson | MIT License | http://mulletxhr.com/ // jXHR.js (JSON-P XHR) | v0.1 (c) Kyle Simpson | MIT License | http://mulletxhr.com/
// uncompressed version available in source/javascripts/libs/jXHR.js // uncompressed version available in source/javascripts/libs/jXHR.js
@ -45,38 +7,71 @@ function linkifyTweet(text){
/* Sky Slavin, Ludopoli. MIT license. * based on JavaScript Pretty Date * Copyright (c) 2008 John Resig (jquery.com) * Licensed under the MIT license. */ /* Sky Slavin, Ludopoli. MIT license. * based on JavaScript Pretty Date * Copyright (c) 2008 John Resig (jquery.com) * Licensed under the MIT license. */
function prettyDate(time) { function prettyDate(time) {
if (navigator.appName == 'Microsoft Internet Explorer') { if (navigator.appName === 'Microsoft Internet Explorer') {
return "<span>&infin;</span>"; // because IE date parsing isn't fun. return "<span>&infin;</span>"; // because IE date parsing isn't fun.
}
var say = {
just_now: " now",
minute_ago: "1m",
minutes_ago: "m",
hour_ago: "1h",
hours_ago: "h",
yesterday: "1d",
days_ago: "d",
weeks_ago: "w"
}; };
var say = {}; var current_date = new Date(),
say.just_now = " now", current_date_time = current_date.getTime(),
say.minute_ago = "1m", current_date_full = current_date_time + (1 * 60000),
say.minutes_ago = "m", date = new Date(time),
say.hour_ago = "1h", diff = ((current_date_full - date.getTime()) / 1000),
say.hours_ago = "h", day_diff = Math.floor(diff / 86400);
say.yesterday = "1d",
say.days_ago = "d",
say.weeks_ago = "w"
var current_date = new Date(); if (isNaN(day_diff) || day_diff < 0) { return "<span>&infin;</span>"; }
current_date_time = current_date.getTime();
current_date_full = current_date_time + (1 * 60000);
var date = new Date(time);
var diff = ((current_date_full - date.getTime()) / 1000);
var day_diff = Math.floor(diff / 86400);
if (isNaN(day_diff) || day_diff < 0) return "<span>&infin;</span>"; return day_diff === 0 && (
return day_diff == 0 && (
diff < 60 && say.just_now || diff < 60 && say.just_now ||
diff < 120 && say.minute_ago || diff < 120 && say.minute_ago ||
diff < 3600 && Math.floor(diff / 60) + say.minutes_ago || diff < 3600 && Math.floor(diff / 60) + say.minutes_ago ||
diff < 7200 && say.hour_ago || diff < 7200 && say.hour_ago ||
diff < 86400 && Math.floor(diff / 3600) + say.hours_ago) || diff < 86400 && Math.floor(diff / 3600) + say.hours_ago) ||
day_diff == 1 && say.yesterday || day_diff === 1 && say.yesterday ||
day_diff < 7 && day_diff + say.days_ago || day_diff < 7 && day_diff + say.days_ago ||
day_diff > 7 && Math.ceil(day_diff / 7) + say.weeks_ago; day_diff > 7 && Math.ceil(day_diff / 7) + say.weeks_ago;
} }
function linkifyTweet(text, url) {
for (var u in url) {
var shortUrl = new RegExp(url[u].url, 'g');
text = text.replace(shortUrl, '<a href="' + url[u].expanded_url + '">' + url[u].expanded_url.replace(/https?:\/\//, '') + '</a>');
}
return text.replace(/(^|\W)@(\w+)/g, '$1<a href="http://twitter.com/$2">@$2</a>')
.replace(/(^|\W)#(\w+)/g, '$1<a href="http://search.twitter.com/search?q=%23$2">#$2</a>');
}
function showTwitterFeed(tweets, twitter_user) {
var timeline = document.getElementById('tweets'),
content = '';
for (var t in tweets) {
content += '<li>'+'<p>'+'<a href="http://twitter.com/'+twitter_user+'/status/'+tweets[t].id_str+'">'+prettyDate(tweets[t].created_at)+'</a>'+linkifyTweet(tweets[t].text.replace(/\n/g, '<br>'), tweets[t].entities.urls)+'</p>'+'</li>';
}
timeline.innerHTML = content;
}
function getTwitterFeed(user, count, replies) {
var feed = new jXHR();
feed.onerror = function (msg,url) {
$('#tweets li.loading').addClass('error').text("Twitter's busted");
};
feed.onreadystatechange = function(data){
if (feed.readyState === 4) { showTwitterFeed(data, user); }
};
// Documentation: https://dev.twitter.com/docs/api/1/get/statuses/user_timeline
feed.open("GET","http://api.twitter.com/1/statuses/user_timeline/" + user + ".json?trim_user=true&count=" + (parseInt(count, 10)) + "&include_entities=1&exclude_replies=" + (replies ? "0" : "1") + "&callback=?");
feed.send();
}

View File

@ -218,7 +218,7 @@ end
desc "Deploy website via rsync" desc "Deploy website via rsync"
task :rsync do task :rsync do
puts "## Deploying website via Rsync" puts "## Deploying website via Rsync"
ok_failed system("rsync -avz --delete #{public_dir}/ #{ssh_user}:#{document_root}") ok_failed system("rsync -avze 'ssh -p #{ssh_port}' --delete #{public_dir}/ #{ssh_user}:#{document_root}")
end end
desc "deploy public directory to github pages" desc "deploy public directory to github pages"
@ -227,6 +227,7 @@ multitask :push do
(Dir["#{deploy_dir}/*"]).each { |f| rm_rf(f) } (Dir["#{deploy_dir}/*"]).each { |f| rm_rf(f) }
Rake::Task[:copydot].invoke(public_dir, deploy_dir) Rake::Task[:copydot].invoke(public_dir, deploy_dir)
puts "\n## copying #{public_dir} to #{deploy_dir}" puts "\n## copying #{public_dir} to #{deploy_dir}"
system "cp -R #{public_dir}/* #{deploy_dir}"
cd "#{deploy_dir}" do cd "#{deploy_dir}" do
system "git add ." system "git add ."
system "git add -u" system "git add -u"
@ -234,7 +235,7 @@ multitask :push do
message = "Site updated at #{Time.now.utc}" message = "Site updated at #{Time.now.utc}"
system "git commit -m \"#{message}\"" system "git commit -m \"#{message}\""
puts "\n## Pushing generated #{deploy_dir} website" puts "\n## Pushing generated #{deploy_dir} website"
system "git push origin #{deploy_branch}" system "git push origin #{deploy_branch} --force"
puts "\n## Github Pages deploy complete" puts "\n## Github Pages deploy complete"
end end
end end
@ -274,25 +275,54 @@ task :set_root_dir, :dir do |t, args|
end end
end end
desc "Setup _deploy folder and deploy branch" desc "Set up _deploy folder and deploy branch for Github Pages deployment"
task :config_deploy, :branch do |t, args| task :setup_github_pages do
puts "!! Please provide a deploy branch, eg. rake init_deploy[gh-pages] !!" unless args.branch repo_url = get_stdin("Enter the read/write url for your repository: ")
puts "## Creating a clean #{args.branch} branch in ./#{deploy_dir} for Github pages deployment" user = repo_url.match(/:([^\/]+)/)[1]
branch = (repo_url.match(/\/\w+.github.com/).nil?) ? 'gh-pages' : 'master'
project = (branch == 'gh-pages') ? repo_url.match(/\/([^\.]+)/)[1] : ''
unless `git remote -v`.match(/origin.+?octopress.git/).nil?
# If octopress is still the origin remote (from cloning) rename it to octopress
system "git remote rename origin octopress"
if branch == 'master'
# If this is a user/organization pages repository, add the correct origin remote
# and checkout the source branch for committing changes to the blog source.
system "git remote add origin #{repo_url}"
puts "Added remote #{repo_url} as origin"
system "git config branch.master.remote origin"
puts "Set origin as default remote"
system "git branch -m master source"
puts "Master branch renamed to 'source' for committing your blog source files"
else
unless !public_dir.match("#{project}").nil?
system "rake set_root_dir[#{project}]"
end
end
end
url = "http://#{user}.github.com"
url += "/#{project}" unless project == ''
jekyll_config = IO.read('_config.yml')
jekyll_config.sub!(/^url:.*$/, "url: #{url}")
File.open('_config.yml', 'w') do |f|
f.write jekyll_config
end
rm_rf deploy_dir
mkdir deploy_dir
cd "#{deploy_dir}" do cd "#{deploy_dir}" do
system "git symbolic-ref HEAD refs/heads/#{args.branch}" system "git init"
system "rm .git/index"
system "git clean -fdx"
system "echo 'My Octopress Page is coming soon &hellip;' > index.html" system "echo 'My Octopress Page is coming soon &hellip;' > index.html"
system "git add ." system "git add ."
system "git commit -m \"Octopress init\"" system "git commit -m \"Octopress init\""
system "git branch -m gh-pages" unless branch == 'master'
system "git remote add origin #{repo_url}"
rakefile = IO.read(__FILE__) rakefile = IO.read(__FILE__)
rakefile.sub!(/deploy_branch(\s*)=(\s*)(["'])[\w-]*["']/, "deploy_branch\\1=\\2\\3#{args.branch}\\3") rakefile.sub!(/deploy_branch(\s*)=(\s*)(["'])[\w-]*["']/, "deploy_branch\\1=\\2\\3#{branch}\\3")
rakefile.sub!(/deploy_default(\s*)=(\s*)(["'])[\w-]*["']/, "deploy_default\\1=\\2\\3push\\3") rakefile.sub!(/deploy_default(\s*)=(\s*)(["'])[\w-]*["']/, "deploy_default\\1=\\2\\3push\\3")
File.open(__FILE__, 'w') do |f| File.open(__FILE__, 'w') do |f|
f.write rakefile f.write rakefile
end end
end end
puts "## Deployment configured. Now you can deploy to the #{args.branch} branch with `rake deploy` ##" puts "\n---\n## Now you can deploy to #{url} with `rake deploy` ##"
end end
def ok_failed(condition) def ok_failed(condition)

View File

@ -1,46 +1,47 @@
# Title: Simple Image tag for Jekyll # Title: Simple Image tag for Jekyll
# Author: Brandon Mathis http://brandonmathis.com # Authors: Brandon Mathis http://brandonmathis.com
# Description: Easily output images with optional class names and title/alt attributes # Felix Schäfer, Frederic Hemberger
# Description: Easily output images with optional class names, width, height, title and alt attributes
# #
# Syntax {% image [class name(s)] url [title text] %} # Syntax {% img [class name(s)] [http[s]:/]/path/to/image [width [height]] [title text | "title text" ["alt text"]] %}
# #
# Example: # Examples:
# {% ima left half http://site.com/images/ninja.png Ninja Attack! %} # {% img /images/ninja.png Ninja Attack! %}
# {% img left half http://site.com/images/ninja.png Ninja Attack! %}
# {% img left half http://site.com/images/ninja.png 150 150 "Ninja Attack!" "Ninja in attack posture" %}
# #
# Output: # Output:
# <image class='left' src="http://site.com/images/ninja.png" title="Ninja Attack!" alt="Ninja Attack!"> # <img src="/images/ninja.png">
# <img class="left half" src="http://site.com/images/ninja.png" title="Ninja Attack!" alt="Ninja Attack!">
# <img class="left half" src="http://site.com/images/ninja.png" width="150" height="150" title="Ninja Attack!" alt="Ninja in attack posture">
# #
module Jekyll module Jekyll
class ImageTag < Liquid::Tag class ImageTag < Liquid::Tag
@img = nil @img = nil
@title = nil
@class = ''
@width = ''
@height = ''
def initialize(tag_name, markup, tokens) def initialize(tag_name, markup, tokens)
if markup =~ /(\S.*\s+)?(https?:\/\/|\/)(\S+)(\s+\d+\s+\d+)?(\s+.+)?/i attributes = ['class', 'src', 'width', 'height', 'title']
@class = $1 || ''
@img = $2 + $3 if markup =~ /(?<class>\S.*\s+)?(?<src>(?:https?:\/\/|\/|\S+\/)\S+)(?:\s+(?<width>\d+))?(?:\s+(?<height>\d+))?(?<title>\s+.+)?/i
if $5 @img = attributes.reduce({}) { |img, attr| img[attr] = $~[attr].strip if $~[attr]; img }
@title = $5.strip if /(?:"|')(?<title>[^"']+)?(?:"|')\s+(?:"|')(?<alt>[^"']+)?(?:"|')/ =~ @img['title']
end @img['title'] = title
if $4 =~ /\s*(\d+)\s+(\d+)/ @img['alt'] = alt
@width = $1 else
@height = $2 @img['alt'] = @img['title'].gsub!(/"/, '&#34;')
end end
@img['class'].gsub!(/"/, '')
end end
super super
end end
def render(context) def render(context)
output = super
if @img if @img
"<img class='#{@class}' src='#{@img}' width='#{@width}' height='#{@height}' alt='#{@title}' title='#{@title}'>" "<img #{@img.collect {|k,v| "#{k}=\"#{v}\"" if v}.join(" ")}>"
else else
"Error processing input, expected syntax: {% img [class name(s)] /url/to/image [width height] [title text] %}" "Error processing input, expected syntax: {% img [class name(s)] [http[s]:/]/path/to/image [width [height]] [title text | \"title text\" [\"alt text\"]] %}"
end end
end end
end end

40
plugins/jsfiddle.rb Normal file
View File

@ -0,0 +1,40 @@
# Title: jsFiddle tag for Jekyll
# Author: Brian Arnold (@brianarn)
# Description:
# Given a jsFiddle shortcode, outputs the jsFiddle iframe code.
# Using 'default' will preserve defaults as specified by jsFiddle.
#
# Syntax: {% jsfiddle shorttag [tabs] [skin] [height] [width] %}
#
# Examples:
#
# Input: {% jsfiddle ccWP7 %}
# Output: <iframe style="width: 100%; height: 300px" src="http://jsfiddle.net/ccWP7/embedded/js,resources,html,css,result/light/"></iframe>
#
# Input: {% jsfiddle ccWP7 js,html,result %}
# Output: <iframe style="width: 100%; height: 300px" src="http://jsfiddle.net/ccWP7/embedded/js,html,result/light/"></iframe>
#
module Jekyll
class JsFiddle < Liquid::Tag
def initialize(tag_name, markup, tokens)
if /(?<fiddle>\w+)(?:\s+(?<sequence>[\w,]+))?(?:\s+(?<skin>\w+))?(?:\s+(?<height>\w+))?(?:\s+(?<width>\w+))?/ =~ markup
@fiddle = fiddle
@sequence = (sequence unless sequence == 'default') || 'js,resources,html,css,result'
@skin = (skin unless skin == 'default') || 'light'
@width = width || '100%'
@height = height || '300px'
end
end
def render(context)
if @fiddle
"<iframe style=\"width: #{@width}; height: #{@height}\" src=\"http://jsfiddle.net/#{@fiddle}/embedded/#{@sequence}/#{@skin}/\"></iframe>"
else
"Error processing input, expected syntax: {% jsfiddle shorttag [tabs] [skin] [height] [width] %}"
end
end
end
end
Liquid::Template.register_tag('jsfiddle', Jekyll::JsFiddle)