Permalink
Browse files

super hacky alpha just to get up and running

  • Loading branch information...
1 parent 554bc94 commit 454f0454b4a77a3b0777db01b2bd301cbe247534 @snarfed committed Apr 1, 2012
View
@@ -26,19 +26,29 @@ def message(self):
"""Extracts and returns the human-readable string message for this event."""
type = self.json['type']
payload = self.json['payload']
+ message = ''
# TODO: unit tests for more of these
# TODO: PullRequestReviewCommentEvent, CommitCommentEvent
if type == 'PushEvent':
- return '\n'.join(c['message'] for c in payload['commits'])
+ message = '\n'.join(c['message'] for c in payload['commits'])
elif type == 'IssuesEvent':
- return '\n'.join(payload['issue']['labels'] + [payload['issue']['body']])
+ # this doesn't work. labels is a dict?!?
+ # message = '\n'.join(payload['issue']['labels'] + [payload['issue']['body']])
+ message = payload['issue']['body']
elif type == 'IssueCommentEvent':
- return payload['comment']['body']
+ message = payload['comment']['body']
elif type == 'PullRequestEvent':
- return payload['pull_request']['body']
+ message = payload['pull_request']['body']
- return None
+ return unicode(message)
+
+ def template_file(self):
+ """Returns the string filename of the template for rendering this event."""
+ type = self.json['type']
+ if type.endswith('Event'):
+ type = type[:-5]
+ return 'templates/github_%s.html' % type.lower()
def __eq__(self, other):
return self.json == other.json
@@ -72,11 +82,11 @@ def get_events(usernames):
raise NotImplementedError()
@staticmethod
- def search_recent_events(phrase):
- """Return recent events with the given phrase in their message.
+ def search_recent_events(phrases):
+ """Return recent events with any of the given phrases in their message.
Args:
- phrase: string
+ phrases: sequence of strings
"""
raise NotImplementedError()
@@ -103,11 +113,15 @@ def get_events(usernames):
return [Event(json=e) for e in itertools.chain(*events)]
@staticmethod
- def search_recent_events(phrase):
+ def search_recent_events(phrases):
events_json = GitHub.jsonfetch(GitHub.EVENTS_URL)
events = [Event(json=e) for e in events_json]
- logging.warning('@@ %r' % e.message())
- return [e for e in events if phrase in str(e.message())]
+ def any_query_matches(event):
+ return any(p in event.message() for p in phrases)
+
+ # TODO: revert
+ # return [e for e in events if any_query_matches(e)]
+ return [e for e in events if e.message()]
@staticmethod
def jsonfetch(url):
View
@@ -19,6 +19,12 @@
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext.webapp import template
+ # <link href="https://a248.e.akamai.net/assets.github.com/stylesheets/bundles/github-e2fb92c4dcb5e5b1ce2ffd0e84d6bf80937d9197.css" media="screen" rel="stylesheet" type="text/css" />
+ # <link href="https://a248.e.akamai.net/assets.github.com/stylesheets/bundles/github2-98a6177ed18ac7b415e311fdb34652f17ad0038c.css" media="screen" rel="stylesheet" type="text/css" />
+
+ # <script src="https://a248.e.akamai.net/assets.github.com/javascripts/bundles/jquery-225576cef50ef2097c9f9fbcd8953c1572544611.js" type="text/javascript"></script>
+ # <script src="https://a248.e.akamai.net/assets.github.com/javascripts/bundles/github-353ded132c604f1bdf010516392d71052f37ffcf.js" type="text/javascript"></script>
+
HEADER = """
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
@@ -29,13 +35,21 @@
<script type="text/javascript" src="/static/ticker.js"></script>
<link href="/static/style.css" rel="stylesheet" type="text/css" />
<title>Super Happy Code!</title>
+
</head>
<body onload="">
-<h1>Super Happy Code</h1>
+<h1>Super Happy Code!</h1>
+<h2>(GitHub checkins here now)</h2>
+
+<body class="logged_in page-profile mine linux env-production " data-blob-contribs-enabled="yes">
+<div id="wrapper">
+<div class="last">
"""
FOOTER = """
+</div>
+</div>
</body>
</html>
"""
@@ -109,13 +123,12 @@ def get(self):
LAT = 37.442796
LON = -122.161466
RADIUS = 0.5
- QUERY = 'shbp'
+ PHRASES = ('shbp',)
self.response.out.write(HEADER)
for host in self.HOSTS:
- for events in host.search_recent_events(QUERY):
- self.response.out.write(template.render('templates/host-meta.xrds',
- event.json))
+ for event in host.search_recent_events(PHRASES):
+ self.response.out.write(template.render(event.template_file(), event.json))
self.response.out.write(FOOTER)
View
@@ -2,20 +2,20 @@
* Stylesheet for the front page, mostly the demo form.
*/
-div#description {
- max-width: 700px;
+div.gravatar img {
+ padding: 2px;
+ border: 1px solid lightgray;
+ float: left;
+ margin: 1em;
}
-img#logo {
- float: right;
+ul, li, div.message, blockquote {
+ list-style: none;
+ display: inline;
}
-select, input[type=text] {
- border: 1px solid gray;
-}
-
-iframe {
- width: 100%;
- min-height: 40em;
- border: 1px solid gray;
+hr {
+ clear: both;
+ margin: 1em;
+ color: lightgray;
}
@@ -1,12 +1,16 @@
+<hr />
+<div class="alert watch_started"><div class="body">
+<span class="mini-icon fork"></span>
+
<div class="title">
- <a href="/bslatkin">bslatkin</a> <span>forked</span> <a href="/anvie/SoyTemplate">anvie/SoyTemplate</a>
- <time class="js-relative-date" datetime="2011-12-01T00:00:28Z" title="2011-12-01 00:00:28">December 01, 2011</time>
+ <a href="/{{ actor.login }}">{{ actor.login }}</a> <span>forked</span> <a href="/{{ payload.owner.login }}/{{ repo.name }}">{{ payload.owner.login }}/{{ repo.name }}</a>
+ <time>March 31, 2011</time>
</div>
<div class="details">
- <div class="gravatar"><img height="30" src="https://secure.gravatar.com/avatar/1bef0d1d7fd68013c64da7a190f2d2db?s=140&amp;d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png" width="30" /></div>
+ <div class="gravatar"><img height="30" src="https://secure.gravatar.com/avatar/{{ actor.gravatar_id }}?s=140&amp;d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png" width="30" /></div>
<div class="message">
- Forked repository is at <a href="https://github.com/bslatkin/SoyTemplate">bslatkin/SoyTemplate</a>
+ Forked repository is at <a href="https://github.com/{{ repo.name }}">{{ repo.name }}</a>
</div>
</div>
</div></div>
- <div class="alert issues_comment"><div class="body"><span class="mini-icon issue-comment"></span>
+
@@ -1,17 +1,20 @@
+<hr />
+<div class="alert issues_comment"><div class="body">
+<span class="mini-icon issue-comment"></span>
+
<div class="title">
- <a href="/bslatkin">bslatkin</a>
+ <a href="/{{ actor.login }}">{{ actor.login }}</a>
<span>commented</span> on
- <a href="https://github.com/bslatkin/clip-it-good/issues/3#issuecomment-1598922" title="Bumped version number">pull request 3</a> on <a href="/bslatkin/clip-it-good">bslatkin/clip-it-good</a>
- <time class="js-relative-date" datetime="2011-07-18T17:05:08Z" title="2011-07-18 17:05:08">July 18, 2011</time>
+ <a href="https://github.com/bslatkin/clip-it-good/issues/3#issuecomment-1598922" title="Bumped version number">pull request 3</a> on <a href="/{{ repo.name }}">{{ repo.name }}</a>
+ <time>March 31, 2011</time>
</div>
<div class="details">
- <div class="gravatar"><img height="30" src="https://secure.gravatar.com/avatar/1bef0d1d7fd68013c64da7a190f2d2db?s=140&amp;d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png" width="30" /></div>
+ <div class="gravatar"><img height="30" src="https://secure.gravatar.com/avatar/{{ actor.gravatar_id }}?s=140&amp;d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png" width="30" /></div>
<div class="message">
<blockquote title="thanks">
<p>thanks</p>
</blockquote>
</div>
</div>
</div></div>
- <div class="alert push"><div class="body"><span class="mini-icon push"></span>
@@ -1,16 +1,18 @@
-<div class="title">
+<hr />
+<div class="alert issues"><div class="body">
+<span class="mini-icon issue"></span>
- <a href="/rtyler">rtyler</a> <span>closed</span> <a href="https://github.com/rtyler/dummy/issues/5" title="Test one two three four">issue 5</a> on <a href="/rtyler/dummy">rtyler/dummy</a>
- <time class="js-relative-date" datetime="2012-03-31T09:34:21Z" title="2012-03-31 09:34:21">March 31, 2012</time>
+<div class="title">
+ <a href="/{{ actor.login }}">{{ actor.login }}</a> <span>closed</span> <a href="https://github.com/rtyler/dummy/issues/5" title="Test one two three four">issue 5</a> on <a href="/rtyler/dummy">rtyler/dummy</a>
+ <time>March 31, 2011</time>
</div>
<div class="details">
- <div class="gravatar"><img height="30" src="https://secure.gravatar.com/avatar/d565139dbbafc06e7daf4826ca0f0228?s=140&amp;d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png" width="30" /></div>
+ <div class="gravatar"><img height="30" src="https://secure.gravatar.com/avatar/{{ actor.gravatar_id }}?s=140&amp;d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png" width="30" /></div>
<div class="message">
<blockquote>
Test one two three four
</blockquote>
</div>
</div>
</div></div>
- <div class="alert issues_comment"><div class="body"><span class="mini-icon issue-comment"></span>
@@ -1,9 +1,13 @@
+<hr />
+<div class="alert watch_started"><div class="body">
+<span class="mini-icon pull"></span>
+
<div class="title">
- <a href="/bslatkin">bslatkin</a> <span>opened</span> <a href="https://github.com/anvie/SoyTemplate/pull/2">pull request 2</a> on <a href="/anvie/SoyTemplate">anvie/SoyTemplate</a>
- <time class="js-relative-date" datetime="2011-12-01T00:07:40Z" title="2011-12-01 00:07:40">December 01, 2011</time>
+ <a href="/{{ actor.login }}">{{ actor.login }}</a> <span>opened</span> <a href="https://github.com/anvie/SoyTemplate/pull/2">pull request 2</a> on <a href="/anvie/SoyTemplate">anvie/SoyTemplate</a>
+ <time>March 31, 2011</time>
</div>
<div class="details">
- <div class="gravatar"><img height="30" src="https://secure.gravatar.com/avatar/1bef0d1d7fd68013c64da7a190f2d2db?s=140&amp;d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png" width="30" /></div>
+ <div class="gravatar"><img height="30" src="https://secure.gravatar.com/avatar/{{ actor.gravatar_id }}?s=140&amp;d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png" width="30" /></div>
<div class="message">
<blockquote>Support for template parameters</blockquote>
1 commit with
@@ -12,4 +16,3 @@
</div>
</div>
</div></div>
- <div class="alert push"><div class="body"><span class="mini-icon push"></span>
@@ -1,27 +1,28 @@
-<!-- <link href="https://a248.e.akamai.net/assets.github.com/stylesheets/bundles/github-e2fb92c4dcb5e5b1ce2ffd0e84d6bf80937d9197.css" media="screen" rel="stylesheet" type="text/css" /> -->
-<!-- <link href="https://a248.e.akamai.net/assets.github.com/stylesheets/bundles/github2-98a6177ed18ac7b415e311fdb34652f17ad0038c.css" media="screen" rel="stylesheet" type="text/css" /> -->
+<hr />
+<div class="alert push"><div class="body">
+<span class="mini-icon push"></span>
<div class="title">
<a href="/{{ actor.login }}">{{ actor.login }}</a> <span>pushed</span>
- to <a href="/{{ repo.name }}">{{ /repo.name }}</a>
- <time class="js-relative-date" datetime="2012-03-31T14:28:01Z" title="2012-03-31 14:28:01">March 31, 2012</time>
+ to <a href="/{{ repo.name }}">{{ repo.name }}</a>
+ <time>March 31, 2011</time>
</div>
<div class="details">
<div class="gravatar"><img height="30" src="https://secure.gravatar.com/avatar/{{ actor.gravatar_id }}?s=140&amp;d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png" width="30" /></div>
<div class="commits">
<ul>
<li>
- <code><a href="/{{ repo.name }}/commit/{{ payload.commits[0].sha }}">{{ payload.push_id }}</a></code>
+ <code><a href="/{{ repo.name }}/commit/{{ payload.commits.0.sha }}">{{ payload.push_id }}</a></code>
<div class="message">
<blockquote>
- {{ payload.commits[0].message }}
+ {{ payload.commits.0.message }}
</blockquote>
</div>
</li>
</ul>
</div>
</div>
-<!-- <div class="alert push"><div class="body"><span class="mini-icon push"></span> -->
+</div></div>
@@ -1,14 +0,0 @@
-<div class="title">
- <a href="/bslatkin">bslatkin</a>
- <span>added</span>
- <a href="/bradfitz">bradfitz</a> to <a href="/bslatkin/Baboon-Simulator">bslatkin/Baboon-Simulator</a>
- <time class="js-relative-date" datetime="2011-12-27T23:46:53Z" title="2011-12-27 23:46:53">December 27, 2011</time>
-</div>
-<div class="details">
- <div class="gravatar"><img height="30" src="https://secure.gravatar.com/avatar/1bef0d1d7fd68013c64da7a190f2d2db?s=140&amp;d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png" width="30" /></div>
- <div class="message">
- Baboon-Simulator is at <a href="/bslatkin/Baboon-Simulator">bslatkin/Baboon-Simulator</a>
- </div>
-</div>
-</div></div>
- <div class="alert create"><div class="body"><span class="mini-icon create"></span>
@@ -1,13 +1,16 @@
+<hr />
+<div class="alert watch_started"><div class="body">
+<span class="mini-icon watching"></span>
+
<div class="title">
- <a href="/Falicon">Falicon</a> <span>started watching</span> <a href="/documentcloud/backbone">documentcloud/backbone</a>
- <time class="js-relative-date" datetime="2012-03-22T18:27:27Z" title="2012-03-22 18:27:27">March 22, 2012</time>
+ <a href="/{{ actor.login }}">{{ actor.login }}</a> <span>started watching</span> <a href="/{{ repo.name }}">{{ repo.name }}</a>
+ <time>March 31, 2011</time>
</div>
<div class="details">
- <div class="gravatar"><img height="30" src="https://secure.gravatar.com/avatar/dd72ba9de6187137e032280b36169980?s=140&amp;d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png" width="30" /></div>
- <div class="message">
- backbone's description:
-<blockquote>Give your JS App some Backbone with Models, Views, Collections, and Events</blockquote>
- </div>
+ <div class="gravatar"><img height="30" src="https://secure.gravatar.com/avatar/{{ actor.gravatar_id }}?s=140&amp;d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png" width="30" /></div>
+<!-- <div class="message"> -->
+<!-- {{ repo.name }}'s description: -->
+<!-- <blockquote></blockquote> -->
+<!-- </div> -->
</div>
</div></div>
- <div class="alert watch_started"><div class="body"><span class="mini-icon watching"></span>

0 comments on commit 454f045

Please sign in to comment.