Skip to content

Commit

Permalink
Move Github widget
Browse files Browse the repository at this point in the history
  • Loading branch information
pusewicz committed May 2, 2010
1 parent 9f34886 commit f874e81
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 37 deletions.
36 changes: 0 additions & 36 deletions public/javascripts/widgets/github.js

This file was deleted.

13 changes: 13 additions & 0 deletions widgets/github/github.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* Github */

div.github { width: 468px; }
div.github .commit_message,
div.github .commit_repository { font-weight: bold }
div.github .content img {
width: 32px;
height: 32px;
}

div.github .content p {
line-height: 24px;
}
51 changes: 51 additions & 0 deletions widgets/github/github.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
var Github = Class.create(Widget, {
initialize: function($super, widget_id, config) {
this.messages = [];
return($super(widget_id, config));
},

handlePayload: function(payload) {
this.messages = payload;
},

build: function() {
this.contentContainer = this.buildContent();
this.headerContainer = this.buildHeader();
this.iconContainer = this.buildIcon();

this.container.insert(this.headerContainer);
this.container.insert(this.iconContainer);
this.container.insert(this.contentContainer);

new Draggable(this.container, { scroll: window });
},

update: function() {
this.contentContainer.childElements().invoke('remove');

this.messages.reverse(false).each(function(message) {
var cont = new Element('p');
cont.insert(new Element('img', { src: "http://www.gravatar.com/avatar/" + message.gravatar + ".jpg" }));
cont.insert(new Element('div', { className: 'author' }).update(message.author));
var commit_message = new Element('div', { className: 'commit' }).update(
'Commited <span class="commit_message">' + message.message + '</span> to <span class="commit_repository">' + message.repository.name + '</span>'
);
cont.insert(commit_message);
cont.insert(new Element('hr' ));
this.contentContainer.insert(cont);
}.bind(this));
},

buildContent: function() {
return(new Element("div", { 'class': 'content' }));
},

buildHeader: function() {
return(new Element("h2", { 'class': 'handle' }).update(this.title));
},

buildIcon: function() {
return(new Element("img", { src: "images/github.png", 'class': 'github icon' }));
}
});

2 changes: 1 addition & 1 deletion lib/sonia/widgets/github.rb → widgets/github/github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def handle_commits_response(multi)
rescue => e
log_backtrace(e)
end
end.flatten.compact.sort_by { |e| Time.parse(e["date"]) }.reverse[0..config.nitems]
end.flatten.compact.sort_by { |e| Time.parse(e["date"]) }.reverse[0...config.nitems]

push commits
rescue => e
Expand Down

0 comments on commit f874e81

Please sign in to comment.