').previous();
$(wrapper).children().append(object);
}
@@ -101,6 +104,15 @@ function wrapFlashVideos() {
});
}
+function renderDeliciousLinks(items) {
+ var output = "
";
+ $('#delicious').html(output);
+}
+
$.domReady(function() {
testFeatures();
wrapFlashVideos();
diff --git a/.themes/classic/source/javascripts/twitter.js b/.themes/classic/source/javascripts/twitter.js
index a4e8555..b6fb0d8 100644
--- a/.themes/classic/source/javascripts/twitter.js
+++ b/.themes/classic/source/javascripts/twitter.js
@@ -1,82 +1,75 @@
// JSON-P Twitter fetcher for Octopress
// (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+='
'+''+''+prettyDate(tweets[t].created_at)+''+linkifyTweet(tweets[t].text.replace(/\n/g, '
'))+'
'+'';
- }
-}
-function linkifyTweet(text){
- return text.replace(/(https?:\/\/)([\w\-:;?&=+.%#\/]+)/gi, '
$2')
- .replace(/(^|\W)@(\w+)/g, '$1
@$2')
- .replace(/(^|\W)#(\w+)/g, '$1
#$2');
-}
-
-
-
-// jXHR.js (JSON-P XHR) | v0.1 (c) Kyle Simpson | MIT License | http://mulletxhr.com/
-// uncompressed version available in source/javascripts/libs/jXHR.js
-(function(c){var b=c.setTimeout,d=c.document,a=0;c.jXHR=function(){var e,g,n,h,m=null;function l(){try{h.parentNode.removeChild(h)}catch(o){}}function k(){g=false;e="";l();h=null;i(0)}function f(p){try{m.onerror.call(m,p,e)}catch(o){throw new Error(p)}}function j(){if((this.readyState&&this.readyState!=="complete"&&this.readyState!=="loaded")||g){return}this.onload=this.onreadystatechange=null;g=true;if(m.readyState!==4){f("Script failed to load ["+e+"].")}l()}function i(o,p){p=p||[];m.readyState=o;if(typeof m.onreadystatechange==="function"){m.onreadystatechange.apply(m,p)}}m={onerror:null,onreadystatechange:null,readyState:0,open:function(p,o){k();internal_callback="cb"+(a++);(function(q){c.jXHR[q]=function(){try{i.call(m,4,arguments)}catch(r){m.readyState=-1;f("Script failed to run ["+e+"].")}c.jXHR[q]=null}})(internal_callback);e=o.replace(/=\?/,"=jXHR."+internal_callback);i(1)},send:function(){b(function(){h=d.createElement("script");h.setAttribute("type","text/javascript");h.onload=h.onreadystatechange=function(){j.call(h)};h.setAttribute("src",e);d.getElementsByTagName("head")[0].appendChild(h)},0);i(2)},setRequestHeader:function(){},getResponseHeader:function(){return""},getAllResponseHeaders:function(){return[]}};k();return m}})(window);
-
/* 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) {
- if (navigator.appName == 'Microsoft Internet Explorer') {
+ if (navigator.appName === 'Microsoft Internet Explorer') {
return "
∞"; // because IE date parsing isn't fun.
- };
+ }
- var say = {};
- say.just_now = " now",
- say.minute_ago = "1m",
- say.minutes_ago = "m",
- say.hour_ago = "1h",
- say.hours_ago = "h",
- say.yesterday = "1d",
- say.days_ago = "d",
- say.weeks_ago = "w"
+ 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 current_date = new Date();
- 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);
+ var current_date = new Date(),
+ current_date_time = current_date.getTime(),
+ current_date_full = current_date_time + (1 * 60000),
+ date = new Date(time),
+ diff = ((current_date_full - date.getTime()) / 1000),
+ day_diff = Math.floor(diff / 86400);
- if (isNaN(day_diff) || day_diff < 0) return "
∞";
+ if (isNaN(day_diff) || day_diff < 0) { return "
∞"; }
- return day_diff == 0 && (
+ return day_diff === 0 && (
diff < 60 && say.just_now ||
diff < 120 && say.minute_ago ||
diff < 3600 && Math.floor(diff / 60) + say.minutes_ago ||
diff < 7200 && say.hour_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 && Math.ceil(day_diff / 7) + say.weeks_ago;
}
+
+function linkifyTweet(text, url) {
+ // Linkify urls, usernames, hashtags
+ text = text.replace(/(https?:\/\/)([\w\-:;?&=+.%#\/]+)/gi, '
$2')
+ .replace(/(^|\W)@(\w+)/g, '$1
@$2')
+ .replace(/(^|\W)#(\w+)/g, '$1
#$2');
+
+ // Use twitter's api to replace t.co shortened urls with expanded ones.
+ for (var u in url) {
+ if(url[u].expanded_url != null){
+ var shortUrl = new RegExp( url[u].url.replace(/https?:\/\//, ''), 'g');
+ text = text.replace(shortUrl, url[u].display_url);
+ }
+ }
+ return text
+}
+
+function showTwitterFeed(tweets, twitter_user) {
+ var timeline = document.getElementById('tweets'),
+ content = '';
+
+ for (var t in tweets) {
+ content += '
'+''+''+prettyDate(tweets[t].created_at)+''+linkifyTweet(tweets[t].text.replace(/\n/g, '
'), tweets[t].entities.urls)+'
'+'';
+ }
+ timeline.innerHTML = content;
+}
+
+function getTwitterFeed(user, count, replies) {
+ count = parseInt(count, 10);
+ $.ajax({
+ url: "http://api.twitter.com/1/statuses/user_timeline/" + user + ".json?trim_user=true&count=" + (count + 20) + "&include_entities=1&exclude_replies=" + (replies ? "0" : "1") + "&callback=?"
+ , type: 'jsonp'
+ , error: function (err) { $('#tweets li.loading').addClass('error').text("Twitter's busted"); }
+ , success: function(data) { showTwitterFeed(data.slice(0, count), user); }
+ })
+}
diff --git a/Rakefile b/Rakefile
index 2d91d20..1c7dc87 100644
--- a/Rakefile
+++ b/Rakefile
@@ -5,6 +5,7 @@ require "stringex"
## -- Rsync Deploy config -- ##
# Be sure your public key is listed in your server's ~/.ssh/authorized_keys file
ssh_user = "user@domain.com"
+ssh_port = "22"
document_root = "~/website.com/"
deploy_default = "rsync"
@@ -219,7 +220,7 @@ end
desc "Deploy website via rsync"
task :rsync do
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
desc "deploy public directory to github pages"
@@ -228,6 +229,7 @@ multitask :push do
(Dir["#{deploy_dir}/*"]).each { |f| rm_rf(f) }
Rake::Task[:copydot].invoke(public_dir, deploy_dir)
puts "\n## copying #{public_dir} to #{deploy_dir}"
+ system "cp -R #{public_dir}/* #{deploy_dir}"
cd "#{deploy_dir}" do
system "git add ."
system "git add -u"
@@ -235,7 +237,7 @@ multitask :push do
message = "Site updated at #{Time.now.utc}"
system "git commit -m \"#{message}\""
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"
end
end
@@ -275,25 +277,54 @@ task :set_root_dir, :dir do |t, args|
end
end
-desc "Setup _deploy folder and deploy branch"
-task :config_deploy, :branch do |t, args|
- puts "!! Please provide a deploy branch, eg. rake init_deploy[gh-pages] !!" unless args.branch
- puts "## Creating a clean #{args.branch} branch in ./#{deploy_dir} for Github pages deployment"
+desc "Set up _deploy folder and deploy branch for Github Pages deployment"
+task :setup_github_pages do
+ repo_url = get_stdin("Enter the read/write url for your repository: ")
+ 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
- system "git symbolic-ref HEAD refs/heads/#{args.branch}"
- system "rm .git/index"
- system "git clean -fdx"
+ system "git init"
system "echo 'My Octopress Page is coming soon …' > index.html"
system "git add ."
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.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")
File.open(__FILE__, 'w') do |f|
f.write rakefile
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
def ok_failed(condition)
diff --git a/plugins/image_tag.rb b/plugins/image_tag.rb
index 25a38df..4567000 100644
--- a/plugins/image_tag.rb
+++ b/plugins/image_tag.rb
@@ -1,46 +1,47 @@
# Title: Simple Image tag for Jekyll
-# Author: Brandon Mathis http://brandonmathis.com
-# Description: Easily output images with optional class names and title/alt attributes
+# Authors: Brandon Mathis http://brandonmathis.com
+# 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:
-# {% ima left half http://site.com/images/ninja.png Ninja Attack! %}
+# Examples:
+# {% 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:
-#
+#
+#
+#
#
module Jekyll
class ImageTag < Liquid::Tag
@img = nil
- @title = nil
- @class = ''
- @width = ''
- @height = ''
def initialize(tag_name, markup, tokens)
- if markup =~ /(\S.*\s+)?(https?:\/\/|\/)(\S+)(\s+\d+\s+\d+)?(\s+.+)?/i
- @class = $1 || ''
- @img = $2 + $3
- if $5
- @title = $5.strip
- end
- if $4 =~ /\s*(\d+)\s+(\d+)/
- @width = $1
- @height = $2
+ attributes = ['class', 'src', 'width', 'height', 'title']
+
+ if markup =~ /(?\S.*\s+)?(?(?:https?:\/\/|\/|\S+\/)\S+)(?:\s+(?\d+))?(?:\s+(?\d+))?(?\s+.+)?/i
+ @img = attributes.reduce({}) { |img, attr| img[attr] = $~[attr].strip if $~[attr]; img }
+ if /(?:"|')(?[^"']+)?(?:"|')\s+(?:"|')(?[^"']+)?(?:"|')/ =~ @img['title']
+ @img['title'] = title
+ @img['alt'] = alt
+ else
+ @img['alt'] = @img['title'].gsub!(/"/, '"') if @img['title']
end
+ @img['class'].gsub!(/"/, '') if @img['class']
end
super
end
def render(context)
- output = super
if @img
- "
"
+ "
"
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
diff --git a/plugins/jsfiddle.rb b/plugins/jsfiddle.rb
new file mode 100644
index 0000000..3ae173e
--- /dev/null
+++ b/plugins/jsfiddle.rb
@@ -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:
+#
+# Input: {% jsfiddle ccWP7 js,html,result %}
+# Output:
+#
+
+module Jekyll
+ class JsFiddle < Liquid::Tag
+ def initialize(tag_name, markup, tokens)
+ if /(?\w+)(?:\s+(?[\w,]+))?(?:\s+(?\w+))?(?:\s+(?\w+))?(?:\s+(?\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
+ ""
+ else
+ "Error processing input, expected syntax: {% jsfiddle shorttag [tabs] [skin] [height] [width] %}"
+ end
+ end
+ end
+end
+
+Liquid::Template.register_tag('jsfiddle', Jekyll::JsFiddle)
\ No newline at end of file