-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 88d4554
Showing
9 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.json | ||
*.pyc | ||
*.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
runtime: python27 | ||
api_version: 1 | ||
threadsafe: true | ||
|
||
skip_files: | ||
- ^.*\.json | ||
- ^dev/.* | ||
|
||
handlers: | ||
- url: /.* | ||
script: zenchart.app | ||
|
||
libraries: | ||
- name: jinja2 | ||
version: latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
{% block body %}{% endblock %} | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$(echo $PATH|grep -q google_appengine) || export PATH=$PATH:~/bin/google_appengine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
# ID from https://console.cloud.google.com/home/dashboard | ||
appcfg.py -A zengraph-1260 -V v1 update . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<html> | ||
<body> | ||
{% if repos %} | ||
<h1>Repositories</h1> | ||
<ul> | ||
{% for repo in repos %} | ||
<li><a href="{{repo.url()}}">{{repo.name}}</a></li> | ||
{% endfor %} | ||
</ul> | ||
{% else %} | ||
<p>No repos found</p> | ||
{% endif %} | ||
|
||
<h1>Add a repo</h1> | ||
<form action="/addRepo" method="post"> | ||
<div>Github Repository Name: <input type="text" name="repoName"></div> | ||
<div>Github User Name: <input type="text" name="githubUser"></div> | ||
<div>Github Access Token: <input type="text" name="githubToken"></div> | ||
<div>Zenhub Access Token: <input type="text" name="zenhubToken"></div> | ||
<div><input type="submit" value="Add"></div> | ||
</form> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
indexes: | ||
|
||
# AUTOGENERATED | ||
|
||
# This index.yaml is automatically updated whenever the dev_appserver | ||
# detects that a new type of query is run. If you want to manage the | ||
# index.yaml file manually, remove the above marker line (the line | ||
# saying "# AUTOGENERATED"). If you want to manage some indexes | ||
# manually, move them above the marker line. The index.yaml file is | ||
# automatically uploaded to the admin console when you next deploy | ||
# your application using appcfg.py. | ||
|
||
- kind: Repo | ||
ancestor: yes | ||
properties: | ||
- name: name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{% extends "base.html" %} | ||
{% block body %} | ||
<h1><a href="/">Home</a> >> {{ repo.name }}<h1> | ||
|
||
|
||
<form action="{{ repo.url() + '/delete' }}" method="post"> | ||
<div><input type="submit" value="Delete this repo"></div> | ||
<form> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/usr/bin/python | ||
import os | ||
import webapp2, jinja2, logging | ||
import urllib, cgi | ||
from google.appengine.ext import ndb | ||
|
||
JINJA_ENVIRONMENT = jinja2.Environment( | ||
loader=jinja2.FileSystemLoader(os.path.dirname(__file__)), | ||
extensions=['jinja2.ext.autoescape'], | ||
autoescape=True) | ||
|
||
# TODO: In the future this should come from the current user id | ||
repoKey = ndb.Key('Repo', 'allrepos') | ||
|
||
class Auth(ndb.Model): | ||
zenhubToken = ndb.StringProperty() | ||
githubUser = ndb.StringProperty() | ||
githubToken = ndb.StringProperty() | ||
|
||
class Issue(ndb.Model): | ||
number = ndb.IntegerProperty(indexed=True) | ||
repoName = ndb.StringProperty(indexed=True) | ||
data = ndb.JsonProperty() | ||
updated = ndb.DateTimeProperty(auto_now=True) | ||
|
||
class Repo(ndb.Model): | ||
auth = ndb.StructuredProperty(Auth) | ||
name = ndb.StringProperty(indexed=True) | ||
data = ndb.JsonProperty() | ||
updated = ndb.DateTimeProperty(auto_now=True) | ||
def url(self): | ||
return '/repo/%s' % urllib.quote(str(self.key.id()), safe='') | ||
|
||
class MainPage(webapp2.RequestHandler): | ||
def get(self): | ||
repos = Repo.query(ancestor = repoKey).order(Repo.name).fetch(50) | ||
self.response.write(JINJA_ENVIRONMENT.get_template('index.html').render({'repos': repos})) | ||
|
||
class AddRepo(webapp2.RequestHandler): | ||
def post(self): | ||
name = self.request.get('repoName') | ||
repo = Repo(parent=repoKey) | ||
repo.name = name | ||
repo.auth = Auth() | ||
repo.auth.zenhubToken = self.request.get('zenhubToken') | ||
repo.auth.githubToken = self.request.get('githubToken') | ||
repo.auth.githubUser = self.request.get('githubUser') | ||
repo.put() | ||
self.redirect(repo.url()) | ||
|
||
class RepoPage(webapp2.RequestHandler): | ||
def get(self, id): | ||
repo = Repo.get_by_id(int(id), parent=repoKey) | ||
if not repo: | ||
self.response.set_status(404) | ||
else: | ||
self.response.write(JINJA_ENVIRONMENT.get_template('repo.html').render({'repo': repo})) | ||
|
||
class DeleteRepoPage(webapp2.RequestHandler): | ||
def post(self, id): | ||
repo = Repo.get_by_id(int(id), parent=repoKey) | ||
if repo: | ||
repo.key.delete() | ||
self.redirect('/') | ||
|
||
app = webapp2.WSGIApplication([ | ||
('/', MainPage), | ||
('/addRepo', AddRepo), | ||
webapp2.Route(r'/repo/<id:\d+>', RepoPage), | ||
webapp2.Route(r'/repo/<id:\d+>/delete', DeleteRepoPage), | ||
],debug=True) |