Created
February 18, 2013 18:17
-
-
Save alalwww/4979398 to your computer and use it in GitHub Desktop.
https://github.com/dharFr/octo-about-me-from-twitter を自分用にカスタマイズ。
ロード前から site.description 削除してツイッターから取得してるよメッセージに変更。ツイッターから取得した location と description の文字サイズを小さくなるように変更。locationのあとにフォローボタンを追加。
スタイルをインライン指定してたり改行なしでHTMLつっこんでたりと超手抜き仕様。
作成したファイルは source/_includes/custom/asides/aboutmetwitter.html に配置して使う。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% if site.twitter_user %} | |
<section> | |
<h1>About Me</h1> | |
<div id="twitter-profile" style="margin-top:0.5em;"> | |
<p> | |
<strong>{{site.author}}</strong> | |
(<a href="http://twitter.com/{{site.twitter_user}}">@{{ site.twitter_user }}</a>) | |
</p> | |
<p>Getting profile from Twitter...</p> | |
</div> | |
<script type="text/javascript"> | |
$.domReady(function(){ | |
var container = $('#twitter-profile'), | |
user = "{{site.twitter_user}}"; | |
function parseTwLinks(s) { | |
var twUrl = "http://www.twitter.com/" | |
s = s.replace(/ (@([\w]+))/g, function(match, p1, p2) { | |
return " <a href='"+twUrl+p2+"'>"+p1+"</a>" | |
}).replace(/ (#([\w]+))/g, function(match, p1, p2) { | |
return " <a href='"+twUrl+"#!/search?q=%23"+p2+"'>"+p1+"</a>" | |
}) | |
return s | |
} | |
$.ajax({ | |
url: "http://api.twitter.com/1/users/show.json?include_entities=false&screen_name="+user+"&callback=?" | |
, type: 'jsonp' | |
, error: function (err) { $('#twitter-profile').addClass('error'); } | |
, success: function(data) { | |
container.html('<img class="left" src="http://api.twitter.com/1/users/profile_image/'+user+'.json?size=bigger" alt="@'+user+'"><div><strong>'+data.name+'</strong> (<a href="http://twitter.com/'+user+'">@'+user+'</a>)</div><div style="font-size:80%">'+data.location+'</div><div><a href="http://twitter.com/{{ site.twitter_user }}" class="twitter-follow-button" data-show-count="{{ site.twitter_show_follower_count }}">Follow @{{ site.twitter_user }}</a></div><p style="clear:both;font-size:80%">'+parseTwLinks(data.description)+'</p>'); | |
} | |
}) | |
}); | |
</script> | |
</section> | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment