Mercurial > bzezpatch
changeset 9:8345b393df5b
added /config endpoint for dynamic templating of page.
author | Atul Varma <avarma@mozilla.com> |
---|---|
date | Wed, 02 Jun 2010 23:57:45 -0700 |
parents | be87610d9abb |
children | 5e305b2569fe |
files | bzezpatch/app.py dev_server.py static-files/ajax-loader.gif static-files/app.js static-files/index.html |
diffstat | 5 files changed, 51 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/bzezpatch/app.py Wed Jun 02 23:25:13 2010 -0700 +++ b/bzezpatch/app.py Wed Jun 02 23:57:45 2010 -0700 @@ -12,9 +12,11 @@ DEFAULT_ALLOW_SCHEMES = ('http', 'https') - def __init__(self, root_dir, hg, allow_schemes=DEFAULT_ALLOW_SCHEMES): + def __init__(self, root_dir, hg, public_config, + allow_schemes=DEFAULT_ALLOW_SCHEMES): self.root_dir = root_dir self.hg = hg + self.public_config = public_config self.allow_schemes = allow_schemes self.static_files_dir = os.path.join(self.root_dir, 'static-files') @@ -46,6 +48,9 @@ if path == '/': path = '/index.html' + if path == '/config' and method == 'GET': + return ok_response(json.dumps(self.public_config), + mimetype=self.JSON_TYPE) if path == '/try' and method == 'POST': try: info = json.loads(input)
--- a/dev_server.py Wed Jun 02 23:25:13 2010 -0700 +++ b/dev_server.py Wed Jun 02 23:57:45 2010 -0700 @@ -8,8 +8,14 @@ if __name__ == '__main__': repopath = os.path.expanduser('~/Documents/jetpack-sdk') hg = bzezpatch.hg.Hg(hg='hg', canonical_repo=repopath) + public_config = { + 'title': 'Jetpack SDK', + 'homepage': 'http://jetpack.mozillalabs.com', + 'repo': 'http://hg.mozilla.org/labs/jetpack-sdk' + } app = bzezpatch.app.App(root_dir=os.getcwd(), hg=hg, + public_config=public_config, allow_schemes=('http', 'https', 'file')) httpd = make_server('127.0.0.1', 8000, app) print "serving on port 8000"
--- a/static-files/app.js Wed Jun 02 23:25:13 2010 -0700 +++ b/static-files/app.js Wed Jun 02 23:57:45 2010 -0700 @@ -19,6 +19,15 @@ $(window).ready( function() { + jQuery.get( + "config", + function(config) { + $(".project-name").text(config.title); + $(".homepage-link").attr("href", config.homepage).text(config.title); + $(".repo-link").attr("href", config.repo).text(config.repo); + $("#container").fadeIn(); + }); + $("form").submit( function(event) { event.preventDefault();
--- a/static-files/index.html Wed Jun 02 23:25:13 2010 -0700 +++ b/static-files/index.html Wed Jun 02 23:57:45 2010 -0700 @@ -6,6 +6,16 @@ body { font-family: Helvetica Neue, sans-serif; font-size: 10pt; + line-height: 1.5em; + } + + a { + color: black; + text-decoration: underline; + } + + a:hover { + background: yellow; } input { @@ -18,12 +28,18 @@ width: 40em; } + #container { + display: none; + width: 45em; + } + #success, #failure { display: none; } .code { font-family: Monaco, monospace; + font-size: 9pt; white-space: pre-wrap; } @@ -38,7 +54,6 @@ form { padding-left: 2em; - line-height: 2em; } .thinking { @@ -49,15 +64,22 @@ </style> </head> <body> +<div id="container"> +<h1>Easy Patch Generator: <span class="project-name"></span></h1> +<p>This page attempts to make it easier to contribute code to +the <a class="homepage-link"></a> project.</p> +<p>Just fork the project at <a class="repo-link"></a> at +a publicly-accessible place like <a +href="http://bitbucket.org/">bitbucket.org</a>, make your +changes there, and use the form below to automatically +generate a patch suitable for submission to Bugzilla.</p> <form> - <div> - URL of HG repository containing your changes: - <input id="pull-url" type="text"/> - </div> - <input type="submit" value="Make Patch"> + <p>URL of HG repository containing your changes:</p> + <p><input id="pull-url" type="text"/></p> + <input type="submit" value="Generate Patch"> </form> <div id="success"> - <p>Yay, we got a patch!</p> + <p>Patch generated!</p> <textarea class="patch code"></textarea> </div> <div id="failure"> @@ -66,5 +88,6 @@ </div> <script src="jquery.js"></script> <script src="app.js"></script> +</div> </body> </html>