Permalink
Browse files

adds creators avatar to card feed

  • Loading branch information...
1 parent d6b8ef2 commit 98e5f3747b1e4769b003926bf7800f9b82d8965b @rauhryan rauhryan committed Apr 7, 2013
@@ -12,6 +12,14 @@ def issue(number)
gh.issues(number).extend(Card).merge!({:repo => {:owner => {:login => user}, :name => repo }})
end
+ def milestones
+ gh.milestones.all.each { |m| m.extend(Milestone) }.each{ |i| i.merge!({"repo" => {:owner => {:login => user}, :name => repo }}) }.sort_by { |i| i["_data"]["order"] || i["number"].to_f}
+ end
+
+ def milestone(number)
+ gh.milestones(number).extend(Milestone).merge!({:repo => {:owner => {:login => user}, :name => repo }})
+ end
+
module Card
def current_state
@@ -45,12 +53,12 @@ def events
client.events.all.to_a
end
- def comments
+ def all_comments
client.comments.all.to_a
end
def feed
- the_feed = { :comments => comments, :events => events }
+ the_feed = { :comments => self.all_comments, :events => events }
return self.merge! the_feed
end
@@ -107,11 +115,24 @@ def self.extended(klass)
end
- def milestones
- gh.milestones.all.each { |m| m.extend(Milestone) }
- end
module Milestone
+
+ def reorder(index)
+ embed_data({"order" => index.to_f})
+ patch :description => self.description
+ end
+
+ def client
+ c = Huboard.client.repos(self[:repo][:owner][:login], self[:repo][:name])
+ c.milestones self.number
+ end
+
+ def patch(hash)
+ m = client.patch hash
+ m.extend(Milestone).merge! :repo => self["repo"]
+ end
+
def embed_data(data = nil)
if !data
r = /@huboard:(.*)/
View
@@ -1,24 +1,5 @@
require 'ghee'
module Stint
- class Issue
- def initialize(issue)
- @issue = issue
- end
-
- def events
- @issue.events.all.map { |x| x }
- end
-
- def comments
- @issue.comments.all.map { |x| x }
- end
-
- def feed
- the_feed = { :comments => comments, :events => events }
- return @issue.merge! the_feed
- end
-
- end
class Github
def initialize(gh)
@@ -51,13 +32,6 @@ def milestone(user_name, repo, number)
gh.repos(user_name, repo).milestones number
end
-
- def feed_for_issue(user, repo, number)
- issue = Stint::Issue.new issue_by_id(user, repo, number)
- issue.feed
- end
-
-
def update_milestone(user_name, repo, milestone)
gh.repos(user_name, repo).milestones(milestone[:number]).patch(milestone)
end
View
@@ -70,7 +70,7 @@ def reorder_issue(user_name, repo, number, index)
def feed_for_issue(user, repo, number)
api = Huboard.adapter_for(user, repo)
- issue = api.issue number
+ issue = api.issue(number).feed
actions = { :actions => {
:labels => {
@@ -90,16 +90,11 @@ def update_issue_labels(user, repo, number, labels)
end
def reorder_milestone(user_name, repo, number, index, status)
- post_data = {:number => number}
- milestone = github.milestone user_name, repo, number
- _data = embedded_data(milestone["description"]).reject { |key| key.to_s == "status" }
- if _data.empty?
- post_data["description"] = milestone["description"].concat "\r\n\r\n<!---\r\n@huboard:#{JSON.dump({"order" => index.to_f})}\r\n-->\r\n"
- else
- post_data["description"] = milestone["description"].gsub /@huboard:.*/, "@huboard:#{JSON.dump(_data.merge({"order" => index.to_f}))}"
- end
- github.update_milestone user_name, repo, post_data
+ milestone = Huboard.adapter_for(user_name, repo).milestone number
+
+ milestone.reorder index
+
end
View

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -101,7 +101,7 @@
}
-.fullscreen-card-activity {
+.fullscreen-card {
.card-comment {
overflow:hidden;
margin-bottom: 10px;
@@ -8,7 +8,7 @@
<h2> <%= title %> </h2>
</div>
</div>
- <div class="fullscreen-card-description">
+ <div class="fullscreen-card-description card-comment">
<img src="https://secure.gravatar.com/avatar/<%= user.gravatar_id%>?s=30" />
<div class="comment-body">
<%= body_html %>

0 comments on commit 98e5f37

Please sign in to comment.