Permalink
Browse files

Simplifying the viewTypes

  • Loading branch information...
Zach Moazeni
Zach Moazeni committed May 11, 2012
1 parent 56ef12c commit 6ee45ba4d4bbcc94b92be22aaa9e83233d85b707
Showing with 86 additions and 92 deletions.
  1. +22 −16 coffee/site.coffee
  2. +64 −76 js/site.js
View
@@ -79,40 +79,46 @@ class Event extends Spine.Model
super(args)
@commits ||= []
- groupKey: ->
- "#{@repo.name}-#{@created_at_short_string()}"
+ groupKey: -> "#{@repo.name}-#{@created_at_short_string()}"
addCommits: (newCommits) ->
newCommits.forEach((e) => @commits.push(e)) if newCommits
viewType: ->
- switch @type
+ defaultTypes = {
+ ForkEvent: "fork"
+ FollowEvent:"follow"
+ DeleteEvent:"skip"
+ WatchEvent: "watch"
+ GollumEvent:"gollum"
+ }
+
+ return defaultTypes[@type] if defaultTypes[@type]
+
+ view = switch @type
when "PullRequestReviewCommentEvent"
- if @payload.comment._links then "pull_request_comment" else "skip"
+ "pull_request_comment" if @payload.comment._links
when "IssueCommentEvent"
- if @payload.issue then "issue_comment" else "skip"
+ "issue_comment" if @payload.issue
when "IssuesEvent"
- if @payload.action == "opened" then "issue" else "skip"
+ "issue" if @payload.action == "opened"
when "CommitCommentEvent"
- if @payload.comment then "commit_comment" else "skip"
- when "ForkEvent" then "fork"
- when "FollowEvent" then "follow"
+ "commit_comment" if @payload.comment
when "PullRequestEvent"
- if @payload.action == "opened" && @payload.pull_request._links then "pull_request" else "skip"
+ "pull_request" if @payload.action == "opened" && @payload.pull_request._links
when "GistEvent"
- if @payload.action == "create" && @payload.gist then "gist" else "skip"
+ "gist" if @payload.action == "create" && @payload.gist
when "CreateEvent"
switch @payload.ref_type
when "branch"
- if @payload.ref == "master" then "skip" else "branch"
+ "branch" if @payload.ref != "master"
else @payload.ref_type
when "PushEvent"
- if @payload.commits?.length > 0 then "push" else "skip"
- when "DeleteEvent" then "skip"
- when "WatchEvent" then "watch"
- when "GollumEvent" then "gollum"
+ "push" if @payload.commits?.length > 0
else "item"
+ view || "skip"
+
viewInfo: ->
view = @viewType()
context = switch view
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 6ee45ba

Please sign in to comment.