From defc4529afbed56a9c2ab906dee1b97eb2381066 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 30 Sep 2012 22:47:59 -0500 Subject: make the github stuff look a lot nicer --- root/static/github_activity.js | 72 ++++++++++++++++++++++++++---------------- root/static/style.css | 64 ++++++++++++++++++++++++++++++++++++- root/template/index.tt | 2 +- 3 files changed, 109 insertions(+), 29 deletions(-) diff --git a/root/static/github_activity.js b/root/static/github_activity.js index a20dd12..5c4cc55 100644 --- a/root/static/github_activity.js +++ b/root/static/github_activity.js @@ -13,42 +13,34 @@ var GithubActivity = (function($, _) { var self = {}, gh = 'http://github.com/', - default_template = '
  • \ + default_template = '
  • \ <% if (type == "PushEvent") { %> \ - <%= actor %> \ - pushed \ - to \ - <%= repository.name %> on \ - <% print(created_at.substring(0, 10)); %>. \ - \ + <%= sha[0].substring(0,6) %> \ +
    <%= (sha[2].split("\\n"))[0] %>
    <% }); %>\ <% } else if (type == "GistEvent") { %> \ - <%= actor %> \ - <%= payload.action %>d gist: \ - <%= payload.desc %>.\ + <%= payload.action %>d gist: \ + <%= payload.desc %> \ <% } else if (type == "CreateEvent") { %> \ - <%= actor %> \ - created <%= payload.ref_type %> \ + created <%= payload.ref_type %> \ <%= payload.ref %> in \ - <%= repository.name %> on \ - <% print(created_at.substring(0, 10)); %>. \ + <%= repository.name %> \ <% } else if (type == "PullRequestEvent") { %> \ - <%= actor %> \ - <%= payload.action %> pull request \ + <%= payload.action %> pull request \ \ #<%= payload.number %>: <%= payload.pull_request.title %> \ - on <% print(created_at.substring(0, 10)); %>. \ <% } else if (type == "IssueCommentEvent") { %> \ - <%= actor %> \ - commented on issue \ + commented on issue \ #<% print(url.replace(/.*\\/issues\\/(\\d+)#.*/, "$1")); %> \ - in <%= repository.name %> \ - on <% print(created_at.substring(0, 10)); %>. \ + in \ + <%= repository.name %> \ <% } else { %> \ - Unknown event type <% type %>. \ + Unknown event type <% type %> \ <% } %>\
  • '; @@ -60,12 +52,38 @@ var GithubActivity = (function($, _) { var url = 'https://github.com/' + username + '.json?callback=?', template = $(tmpl_selector).html() || default_template, - compiled = _.template(template); + compiled = _.template(template), + current_date = '', + $current_list; $.getJSON(url, {}, function (data) { $.each(data.slice(0, 6), function(index, commit) { - $(selector).append(compiled(commit)); + var date = commit.created_at.substring(0, 10); + if (date != current_date) { + if (current_date) { + var $new_item = $('
  • '); + $new_item.append('
    ' + current_date + '
    '); + var $div = $('
    '); + $div.append($current_list); + $new_item.append($div); + $(selector).append($new_item); + } + + $current_list = $(''); + current_date = date; + } + var $action = $(compiled(commit)); + if (index % 2) { + $action.addClass('odd') + } + $current_list.append($action); }); + var $new_item = $('
  • '); + $new_item.append('
    ' + current_date + '
    '); + var $div = $('
    '); + $div.append($current_list); + $new_item.append($div); + $(selector).append($new_item); }); }; diff --git a/root/static/style.css b/root/static/style.css index a4eed76..d6337e4 100644 --- a/root/static/style.css +++ b/root/static/style.css @@ -132,8 +132,70 @@ a:visited { margin : 0px; padding : 2px; font-size : medium; + text-align : center; +} + +.github h5 { + background-color : #58a; + border : 1px solid; + margin : 8px 16px; + padding : 2px; + font-size : x-small; + text-align : center; +} + +.github .actions { + border : 1px solid; + float : left; } .github ul { - padding : 0px 16px; + padding : 0px; + list-style-type : none; +} + +#github-activity { + padding : 0px; + margin : 0px; +} + +.github li { + float : left; + width : 100%; +} + +.github .action.odd { + background-color : #fff; +} + +.github .action { + background-color : #ddd; + margin : 0px; + padding : 4px; + float : left; +} + +.github .date ul { + margin-right : 8px; + clear : left; +} + +.github dl { + margin : 4px 0px; +} + +.github dt { + padding : 0px 8px; + float : left; + clear : left; + margin : 0px; + width : 3em; +} + +.github dd { + float : left; + padding : 0px; + padding-left : 4px; + margin : 0px; + width : 176px; } diff --git a/root/template/index.tt b/root/template/index.tt index 476f525..6ef85f6 100644 --- a/root/template/index.tt +++ b/root/template/index.tt @@ -1,5 +1,5 @@
    -

    My GitHub activity

    +

    my github activity

    about me

    -- cgit v1.2.3-54-g00ecf