Added styling for github follow button, improved javascripts for adding GitHub and Twitter sidebars

This commit is contained in:
Brandon Mathis 2012-06-05 16:08:18 -05:00
parent d37c1babc7
commit 5528f9acec
8 changed files with 44 additions and 42 deletions

View File

@ -11,7 +11,6 @@
width: image-width($img);
height: image-height($img);
position: absolute; left: 3px;
top: 3px;
}
} @else if $icon {
padding-left: icon-sprite-width($icon) + 6px;
@ -19,7 +18,6 @@
vertical-align: middle;
@extend .icon-#{$icon};
position: absolute; left: 3px;
top: 3px;
}
}
}
@ -67,12 +65,18 @@
.googleplus-share {
@extend .simple-social-button;
@include social-button-bg('googleplus', #db583b);
&:before { top: 5px; }
}
.facebook-share {
@extend .simple-social-button;
@include social-button-bg('facebook', #4e5a9b);
&:before { top: 3px; }
}
.twitter-share, .sidebar a.twitter-follow-button {
@extend .simple-social-button;
@include social-button-bg('twitter');
}
.sidebar .github-follow {
@extend .simple-social-button;
@include social-button-bg('github');
}

View File

@ -5,3 +5,9 @@
{% include twitter_sharing.html %}
{% endunless %}
{% include custom/after_footer.html %}
{% if site.github_user %}
<script src="{{ root_url }}/javascripts/github.js" type="text/javascript"></script>
{% endif %}
{% if site.twitter_user %}
<script src="{{ root_url }}/javascripts/twitter.js" type="text/javascript"> </script>
{% endif %}

View File

@ -1,30 +1,11 @@
{% if site.github_user %}
<section>
<h1>GitHub Repos</h1>
<ul id="gh_repos">
<h1>On GitHub</h1>
<ul id="gh_repos" data-user="{{site.github_user}}" data-count="{{site.github_repo_count}}" data-skip="{{site.github_skip_forks}}">
<li class="loading">Status updating...</li>
</ul>
{% if site.github_show_profile_link %}
<a href="https://github.com/{{site.github_user}}">@{{site.github_user}}</a> on GitHub
<a class="github-follow" href="https://github.com/{{site.github_user}}">Follow @{{site.github_user}}</a>
{% endif %}
<script type="text/javascript">
$(document).ready(function(){
if (!window.jXHR){
var jxhr = document.createElement('script');
jxhr.type = 'text/javascript';
jxhr.src = '{{ root_url}}/javascripts/libs/jXHR.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(jxhr, s);
}
github.showRepos({
user: '{{site.github_user}}'
, count: {{site.github_repo_count}}
, skip_forks: {{site.github_skip_forks}}
, target: '#gh_repos'
});
});
</script>
<script src="{{ root_url }}/javascripts/github.js" type="text/javascript"></script>
</section>
{% endif %}

View File

@ -1,19 +1,9 @@
{% if site.twitter_user %}
<section>
<h1>Latest Tweets</h1>
<ul id="tweets">
<ul id="tweets" data-user="{{site.twitter_user}}" data-count="{{site.twitter_tweet_count}}" data-replies="{{site.twitter_show_replies}}">
<li class="loading">Status updating...</li>
</ul>
<script type="text/javascript">
$(document).ready(function(){
twitter.getFeed({
user: "{{site.twitter_user}}"
, count: {{site.twitter_tweet_count}}
, replies: {{site.twitter_show_replies}}
});
});
</script>
<script src="{{ root_url }}/javascripts/twitter.js" type="text/javascript"> </script>
{% if site.twitter_follow_button %}
<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>
{% else %}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 568 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 B

View File

@ -1,18 +1,18 @@
var github = (function(){
function render(target, repos){
var i = 0, fragment = '', t = $(target)[0];
function render(target, data){
var i = 0, repos = '';
for(i = 0; i < repos.length; i++) {
fragment += '<li><a href="'+repos[i].html_url+'">'+repos[i].name+'</a><p>'+repos[i].description+'</p></li>';
for(i = 0; i < data.length; i++) {
repos += '<li><a href="'+data[i].html_url+'">'+data[i].name+'</a><p>'+data[i].description+'</p></li>';
}
t.innerHTML = fragment;
target.html(repos);
}
return {
showRepos: function(options){
$.ajax({
url: "https://api.github.com/users/"+options.user+"/repos?callback=?"
, dataType: 'jsonp'
, error: function (err) { $(options.target + ' li.loading').addClass('error').text("Error loading feed"); }
, error: function (err) { options.target.find('.loading').addClass('error').text("Error loading feed"); }
, success: function(data) {
var repos = [];
if (!data.data) { return; }
@ -35,3 +35,14 @@ var github = (function(){
}
};
})();
$(document).ready(function(){
g = $('#gh_repos');
github.showRepos({
user: g.attr('data-user')
, count: parseInt(g.attr('data-count'))
, skip_forks: g.attr('data-skip') == 'true'
, target: g
});
});

View File

@ -72,7 +72,8 @@ var twitter = (function(){
return {
getFeed: function(options){
count = parseInt(options.count, 10);
count = options.count;
console.log(options);
$.ajax({
url: "http://api.twitter.com/1/statuses/user_timeline/" + options.user + ".json?trim_user=true&count=" + (count + 20) + "&include_entities=1&exclude_replies=" + (options.replies ? "0" : "1") + "&callback=?"
, dataType: 'jsonp'
@ -82,3 +83,12 @@ var twitter = (function(){
}
}
})();
$(document).ready(function(){
t = $('#tweets');
twitter.getFeed({
user: t.attr('data-user')
, count: parseInt(t.attr('data-count'), 10)
, replies: t.attr('data-replies') == 'true'
});
});