Permalink
Browse files

Big one: add templates for GitHub events

  • Loading branch information...
pangratz committed Jul 24, 2012
1 parent 95114aa commit ab996d78341e52a6fbfb0b042173cf13783b0ad6
View
@@ -0,0 +1,18 @@
+.profilePic {
+ float: left;
+ margin: 3px;
+ margin-right: 10px;
+}
+
+.profilePic > img {
+ border-radius: 3px;
+}
+
+.info {
+ float: none;
+}
+
+div.additional-info {
+ margin-left: 5px;
+ margin-top: 5px;
+}
View
@@ -2,6 +2,7 @@ require('jquery');
require('handlebars');
require('ember');
require('ember-data');
+require('moment');
require('dashboard/ext');
Dashboard = Ember.Application.create({
View
@@ -1,9 +1,48 @@
require('dashboard/core');
+require('dashboard/handlebars_helpers');
Dashboard.ApplicationView = Ember.View.extend({
templateName: 'application'
});
+Dashboard.EventsView = Ember.View.extend({
+ templateName: 'events',
+ EventView: Ember.View.extend({
+ templateName: 'events/githubEvent',
+
+ timeAgoString: function() {
+ var timeAgo = this.get('event.created_at');
+ return moment(timeAgo).fromNow();
+ }.property('timeAgo'),
+
+ avatarUrl: function() {
+ var gravatarId = this.get('event.actor.gravatar_id');
+ return 'http://www.gravatar.com/avatar/%@'.fmt(gravatarId);
+ }.property('event.actor.gravatar_id'),
+
+ DetailView: Ember.View.extend({
+ className: 'info'.w(),
+
+ templateName: function() {
+ var type = this.get('event.type');
+ return 'events/%@-template'.fmt(type);
+ }.property('event.type'),
+
+ ActorView: Ember.View.extend({
+ layoutName: 'events/actor',
+ defaultTemplate: Ember.Handlebars.compile(''),
+ tagName: '',
+ eventBinding: 'parentView.event',
+
+ href: function() {
+ var login = this.get('event.actor.login');
+ return 'https://github.com/%@'.fmt(login);
+ }.property('event.actor.login')
+ })
+ })
+ })
+});
+
Dashboard.RepositoryView = Ember.View.extend({
templateName: 'repository'
});
@@ -0,0 +1,5 @@
+<ul class="unstyled">
+{{#each event in controller}}
+ {{view view.EventView eventBinding="event"}}
+{{/each}}
+</ul>
@@ -0,0 +1,3 @@
+{{#view view.ActorView actorBinding="event.actor"}}
+ commented on <a {{bindAttr href="event.payload.comment.html_url"}}>commit</a>
+{{/view}}
@@ -0,0 +1,6 @@
+{{#view view.ActorView}}
+ created {{event.payload.ref_type}}
+ {{#if event.payload.ref}}
+ <a href="https://github.com/{{unbound event.repo.name}}/tree/{{unbound event.payload.ref}}">{{event.payload.ref}}</a>
+ {{/if}}
+{{/view}}
@@ -0,0 +1,3 @@
+{{#view view.ActorView}}
+ deleted {{event.payload.ref_type}} {{event.payload.ref}}
+{{/view}}
@@ -0,0 +1,3 @@
+{{#view view.ActorView}}
+ created download <a {{bindAttr href="event.payload.download.html_url"}} >{{event.payload.download.name}}</a>
+{{/view}}
@@ -0,0 +1,4 @@
+{{#view view.ActorView}}
+ forked
+ <a {{bindAttr href="event.payload.forkee.html_url"}}>repository</a>
+{{/view}}
@@ -0,0 +1,8 @@
+{{#view view.ActorView}}
+ modified the <a href="{{unbound event.repo.html_url}}/wiki">wiki</a>
+{{/view}}
+<div class="additional-info" >
+ {{#each event.payload.pages }}
+ <span>{{echo "action"}} <a {{bindAttr href="html_url"}}>{{page_name}}</a></span>
+ {{/each}}
+</div>
@@ -0,0 +1,9 @@
+{{#view view.ActorView}}
+ commented on issue
+ <a href="{{unbound event.payload.issue.html_url}}#issuecomment-{{unbound event.payload.comment.id}}">
+ #{{event.payload.issue.number}}
+ </a>
+{{/view}}
+<div class="additional-info" >
+ {{event.payload.issue.title}}
+</div>
@@ -0,0 +1,4 @@
+{{#view view.ActorView}}
+ {{event.payload.action}} issue
+ <a {{bindAttr href="event.payload.issue.html_url"}}>#{{event.payload.issue.number}}</a>
+{{/view}}
@@ -0,0 +1,3 @@
+{{#view view.ActorView}}
+ added <a {{bindAttr href="event.payload.member.html_url"}} >{{event.payload.member.login}}</a> as a collaborator
+{{/view}}
@@ -0,0 +1,4 @@
+{{#view view.ActorView}}
+ {{event.payload.action}} Pull Request
+ <a {{bindAttr href="event.payload.pull_request.html_url"}}>#{{event.payload.number}}</a>
+{{/view}}
@@ -0,0 +1,9 @@
+{{#view view.ActorView}}
+ reviewed on commit
+ <a {{bindAttr href="event.payload.comment._links.html.href"}}>
+ {{trim event.payload.comment.commit_id length=7}}
+ </a>
+{{/view}}
+<div class="additional-info" >
+ {{event.payload.comment.body}}
+</div>
@@ -0,0 +1,4 @@
+{{#view view.ActorView}}
+ pushed to
+ <a href="https://github.com/{{unbound event.repo.name}}/commit/{{unbound event.payload.head}}">{{event.payload.ref}}</a>
+{{/view}}
@@ -0,0 +1 @@
+{{#view view.ActorView}} {{event.payload.action}} watching{{/view}}
@@ -0,0 +1 @@
+<strong><a {{action showUser context="event.actor.login"}} >{{event.actor.login}}</a> {{yield}}</strong>
@@ -0,0 +1,9 @@
+{{view.timeAgoString}}
+
+<div class="profilePic" >
+ <img width="30" {{bindAttr src="view.avatarUrl"}} ></img>
+</div>
+
+{{view view.DetailView eventBinding="event" }}
+
+<dl class="dl-horizontal">
@@ -16,4 +16,10 @@ module("Dashboard.RepositoriesView");
test("it exists", function() {
ok(Dashboard.RepositoriesView, "it exists");
+});
+
+module("Dashboard.EventsView");
+
+test("it exists", function() {
+ ok(Dashboard.EventsView, "it exists");
});
Oops, something went wrong.

0 comments on commit ab996d7

Please sign in to comment.