From ee892b908a7e1b3b8c1fccb1c4d8b8d54c94f174 Mon Sep 17 00:00:00 2001 From: SkyArrow Date: Wed, 25 Jan 2012 01:24:40 +0800 Subject: use site config --- source/_includes/article.html | 6 +- source/_includes/banner.html | 12 ++- source/_includes/custom/after_footer.html | 3 +- source/_includes/header.html | 14 ++- source/_includes/post/sharing.html | 8 +- source/javascripts/twitter.js | 152 +++++++++++++++--------------- 6 files changed, 109 insertions(+), 86 deletions(-) diff --git a/source/_includes/article.html b/source/_includes/article.html index 347a52d..ddb24f3 100644 --- a/source/_includes/article.html +++ b/source/_includes/article.html @@ -3,12 +3,12 @@
{{ content | excerpt }} {% capture excerpted %}{{ content | has_excerpt }}{% endcapture %} - {% if excerpted == 'true' %}閱讀全文{% endif %} + {% if excerpted == 'true' %}{{ site.excerpt_link }}{% endif %}
{% include post/date.html %}{{ time }}
{% include post/categories.html %}
- {% if site.disqus_short_name and post.comments == true %} + {% if site.disqus_short_name and post.comments == true and site.disqus_show_comment_count == true %} {% endif %}
@@ -18,7 +18,7 @@
{% include post/date.html %}{{ time }}
{% include post/categories.html %}
- {% if site.disqus_short_name and page.comments == true %} + {% if site.disqus_short_name and page.comments == true and site.disqus_show_comment_count == true %} {% endif %}
diff --git a/source/_includes/banner.html b/source/_includes/banner.html index 5839bd4..e2493c9 100644 --- a/source/_includes/banner.html +++ b/source/_includes/banner.html @@ -1,7 +1,15 @@ +{% if site.twitter_user %} \ No newline at end of file + + + +{% endif %} \ No newline at end of file diff --git a/source/_includes/custom/after_footer.html b/source/_includes/custom/after_footer.html index 50003bb..1ea5c22 100644 --- a/source/_includes/custom/after_footer.html +++ b/source/_includes/custom/after_footer.html @@ -2,5 +2,4 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/source/_includes/header.html b/source/_includes/header.html index ac544be..234ffae 100644 --- a/source/_includes/header.html +++ b/source/_includes/header.html @@ -6,10 +6,18 @@
- Facebook - Google+ - Twitter + {% if site.facebook_user %} + Facebook + {% endif %} + {% if site.googleplus_user %} + Google+ + {% endif %} + {% if site.twitter_user %} + Twitter + {% endif %} + {% if site.subscribe_rss %} RSS + {% endif %}
{% include custom/header.html %} \ No newline at end of file diff --git a/source/_includes/post/sharing.html b/source/_includes/post/sharing.html index d41d1e0..b099de9 100644 --- a/source/_includes/post/sharing.html +++ b/source/_includes/post/sharing.html @@ -1,8 +1,14 @@
+ {% if site.facebook_like %} + {% endif %} + {% if site.twitter_tweet_button %} - + {% endif %} + {% if site.google_plus_one %} + + {% endif %}
diff --git a/source/javascripts/twitter.js b/source/javascripts/twitter.js index 92fb7b1..3be21a0 100644 --- a/source/javascripts/twitter.js +++ b/source/javascripts/twitter.js @@ -1,90 +1,92 @@ (function($){ - var banner = $('#banner'), - feed = banner.find('.feed'), - interval = 10000, - speed = 500; + $.fn.getTwitterFeed = function(userid, count){ + var banner = $(this), + feed = banner.find('.feed'), + interval = 10000, + speed = 500; - var linkify = function(text){ - text = text.replace(/(https?:\/\/)([\w\-:;?&=+.%#\/]+)/gi, '$2').replace(/(^|\W)@(\w+)/g, '$1@$2').replace(/(^|\W)#(\w+)/g, '$1#$2'); + var linkify = function(text){ + text = text.replace(/(https?:\/\/)([\w\-:;?&=+.%#\/]+)/gi, '$2').replace(/(^|\W)@(\w+)/g, '$1@$2').replace(/(^|\W)#(\w+)/g, '$1#$2'); - return text; - } + return text; + } - var relativeDate = function(date){ - if (navigator.appName === 'Microsoft Internet Explorer') return ''; + var relativeDate = function(date){ + if (navigator.appName === 'Microsoft Internet Explorer') return ''; - var unit = { - now: '現在', - minute: '1 分鐘前', - minutes: ' 分鐘前', - hour: '1 小時前', - hours: ' 小時前', - day: '昨天', - days: ' 天前', - week: '1 週前', - weeks: ' 週前' - }; + var unit = { + now: '現在', + minute: '1 分鐘前', + minutes: ' 分鐘前', + hour: '1 小時前', + hours: ' 小時前', + day: '昨天', + days: ' 天前', + week: '1 週前', + weeks: ' 週前' + }; - var current = new Date(), - tweet = new Date(date), - diff = (((current.getTime() + (1 * 60000)) - tweet.getTime()) / 1000), - day_diff = Math.floor(diff / 86400); - - if (day_diff == 0){ - if (diff < 60) return unit.now; - else if (diff < 120) return unit.minute; - else if (diff < 3600) return Math.floor(diff / 60) + unit.minutes; - else if (diff < 7200) return unit.hour; - else if (diff < 86400) return Math.floor(diff / 3600) + unit.hours; - else return ''; - } else if (day_diff == 1) { - return unit.day; - } else if (day_diff < 7) { - return day_diff + unit.days; - } else if (day_diff == 7) { - return unit.week; - } else if (day_diff > 7) { - return Math.ceil(day_diff / 7) + unit.weeks; - } else { - return ''; + var current = new Date(), + tweet = new Date(date), + diff = (((current.getTime() + (1 * 60000)) - tweet.getTime()) / 1000), + day_diff = Math.floor(diff / 86400); + + if (day_diff == 0){ + if (diff < 60) return unit.now; + else if (diff < 120) return unit.minute; + else if (diff < 3600) return Math.floor(diff / 60) + unit.minutes; + else if (diff < 7200) return unit.hour; + else if (diff < 86400) return Math.floor(diff / 3600) + unit.hours; + else return ''; + } else if (day_diff == 1) { + return unit.day; + } else if (day_diff < 7) { + return day_diff + unit.days; + } else if (day_diff == 7) { + return unit.week; + } else if (day_diff > 7) { + return Math.ceil(day_diff / 7) + unit.weeks; + } else { + return ''; + } } - } - if ($(window).width() > 600){ - banner.show(); + if ($(window).width() > 600){ + banner.show(); - $.getJSON('http://twitter.com/status/user_timeline/tommy351.json?count=10&callback=?', function(json){ - var length = json.length, - fragment = document.createDocumentFragment(), - counts = 0, - timeout; + $.getJSON('http://twitter.com/status/user_timeline/'+userid+'.json?count='+count+'&callback=?', function(json){ + var length = json.length, + fragment = document.createDocumentFragment(), + counts = 0, + timeout; - for (var i=0; i'+relativeDate(json[i].created_at)+''; - fragment.appendChild(item); - } + for (var i=0; i'+relativeDate(json[i].created_at)+''; + fragment.appendChild(item); + } - var play = function(){ - timeout = setTimeout(function(){ - feed.animate({top: '-='+30}, speed, function(){ - $(this).append($(this).children().eq(counts).clone()); - counts++; - play(); - }); - }, interval); - } + var play = function(){ + timeout = setTimeout(function(){ + feed.animate({top: '-='+30}, speed, function(){ + $(this).append($(this).children().eq(counts).clone()); + counts++; + play(); + }); + }, interval); + } - var pause = function(){ - clearTimeout(timeout); - } + var pause = function(){ + clearTimeout(timeout); + } - banner.on('mouseenter', pause).on('mouseleave', play) - .children('.loading').hide().end() - .children('.container').show() - .children('.feed').append(fragment); + banner.on('mouseenter', pause).on('mouseleave', play) + .children('.loading').hide().end() + .children('.container').show() + .children('.feed').append(fragment); - play(); - }); - } + play(); + }); + } + }; })(jQuery); \ No newline at end of file -- cgit v1.1-2-g2b99