Permalink
Browse files

fleshed out the user section to include name and gravatar

  • Loading branch information...
1 parent 9861b17 commit 19c0f92afb54ac4ba3c3a5edac04ea8719f26428 Lynn Wallenstein committed Sep 11, 2010
Showing with 28 additions and 13 deletions.
  1. +8 −2 README
  2. +2 −2 demo.html
  3. +18 −9 jquery.github_badge.js
  4. BIN public.png
View
10 README
@@ -6,6 +6,10 @@ Requirements:
+ jQuery 1.4.2 (This is what I developed on, I haven't tested it with older versions. If you
do and it works, drop me a line at lwallenstein@gmail.com)
+
+ + I designed this in an HTML5 template. Thus far I have not tested it in other HTML versions,
+ however you may need to adjust some components if you are concerned about validation and
+ older HTML versions.
To Install:
@@ -15,12 +19,14 @@ To Install:
STEP 1: Include the plugin script after jQuery
--------------------------------------------------------------------------------------------
- <script type="text/javascript" src="jquery.twitter.js"></script>
+ <!-- Script for GitHub Badge Widget -->
+ <script src="jquery.twitter.js"></script>
STEP 2: Include the CSS in the head of the document
--------------------------------------------------------------------------------------------
- <link rel="stylesheet" href="jquery.twitter.css" type="text/css" media="all">
+ <!-- CSS for GitHub Badge Widget: implied media="all" -->
+ <link rel="stylesheet" href="css/jquery.github_badge.css?v=1" />
STEP 3: In the body of your documents, create a container where you want the badge to display
View
@@ -13,7 +13,7 @@
}
</style>
- <link rel="stylesheet" href="jquery.twitter.css" type="text/css" media="all">
+ <link rel="stylesheet" href="jquery.twitter.css?v=1" >
</head>
<body>
@@ -26,7 +26,7 @@
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>!window.jQuery && document.write('<script src="js/jquery-1.4.2.min.js"><\/script>')</script>
- <script type="text/javascript" src="jquery.github_badge.js"></script>
+ <script src="jquery.github_badge.js"></script>
<script>
$("#sample_user_badge").GithubBadge({
View
@@ -30,7 +30,7 @@ http://creativecommons.org/licenses/by-nc/3.0/
theme: "github",
// User Badge Options
- userBadgeTitle: "My Projects",
+ userBadgeTitle: "Repositories",
repo_count: "100",
// Project Badge Options
@@ -42,20 +42,26 @@ http://creativecommons.org/licenses/by-nc/3.0/
var buildUser = function(where, options) {
- $(where).html('<div class="ghb_badge '+ options.theme +'"><h1>'+ options.userBadgeTitle +' (<a target="_blank" href="http://www.github.com/'+ options.login +'">'+ options.login +'</a>)</h1><ul id="ghb_repolist_' + options.login + '"></ul></div>');
-
+ $(where).html('<div class="ghb_badge '+ options.theme +'"><h1><a target="_blank" href="http://www.github.com/'+ options.login +'">'+ options.login +'\'s '+ options.userBadgeTitle +'</a></h1><h2>User Info</h2><div id="ghb_user_info_'+ options.login +'"></div><h2>Public '+ options.userBadgeTitle +'</h2><ul id="ghb_repo_list_' + options.login + '" class="ghb_repo_list"></ul></div>');
+
+ var requestURLUserInfo = "http://github.com/api/v2/json/user/show/" + options.login + "?callback=?";
+ $.getJSON(requestURLUserInfo, function(data){
+ // console.log(data);
+ $("#ghb_user_info_" + options.login).html('<img src="http://www.gravatar.com/avatar/'+ data.user.gravatar_id +'">' + data.user.name);
+ });
+
var requestURLRepos = "http://github.com/api/v2/json/repos/show/" + options.login + "?callback=?";
$.getJSON(requestURLRepos, function(data){
//console.log(data);
if(data.length === 0) {
- $('#ghb_repolist_' + options.login).html('<li class="no_records">' + options.login +' Does Not Have Any Repos</li>');
+ $('#ghb_repo_list_' + options.login).html('<li class="no_records">' + options.login +' Does Not Have Any Repos</li>');
} else {
$.each(data.repositories, function (i, obj) {
record ='<li><a target="_blank" href="'+ obj.url +'">'+ obj.name +'</a> <span>'+ obj.description +'</span></li>';
if (options.sorting == "ascending" ) {
- $('#ghb_repolist_' + options.login).append(record);
+ $('#ghb_repo_list_' + options.login).append(record);
} else {
- $('#ghb_repolist_' + options.login).prepend(record);
+ $('#ghb_repo_list_' + options.login).prepend(record);
}
if ( i == (options.repo_count-1) ) return false;
});
@@ -65,12 +71,12 @@ http://creativecommons.org/licenses/by-nc/3.0/
}
var buildProject = function(where, options) {
- $(where).html('<div class="ghb_badge '+ options.theme +'"><div id="ghb_repoinfo_' + options.repo_name +'"></div><h2>Open Issues</h2><ul id="ghb_issue_list_' + options.repo_name + '"></ul><h2>Commits</h2><ul id="ghb_commit_list_' + options.repo_name + '"></ul></div>');
+ $(where).html('<div class="ghb_badge '+ options.theme +'"><div id="ghb_repo_info_' + options.repo_name +'"></div><h2>Open Issues</h2><ul id="ghb_issue_list_' + options.repo_name + '"></ul><h2>Commits</h2><ul id="ghb_commit_list_' + options.repo_name + '"></ul></div>');
var requestURLRepo = "http://github.com/api/v2/json/repos/show/" + options.login + "/" + options.repo_name + "?callback=?";
$.getJSON(requestURLRepo, function(data){
// console.log(data);
- $("#ghb_repoinfo_" + options.repo_name).html('<h1><a target="_blank" href="'+ data.repository.url +'">' + data.repository.name +'</a></h1><p>' + data.repository.description + '</p>');
+ $("#ghb_repo_info_" + options.repo_name).html('<h1><a target="_blank" href="'+ data.repository.url +'">' + data.repository.name +'</a></h1><p>' + data.repository.description + '</p>');
});
var requestURLIssues = "http://github.com/api/v2/json/issues/list/" + options.login + "/" + options.repo_name + "/open?callback=?";
@@ -140,4 +146,7 @@ http://creativecommons.org/licenses/by-nc/3.0/
console.groupEnd();
}
-})(jQuery);
+})(jQuery);
+
+
+
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 19c0f92

Please sign in to comment.