Permalink
Browse files

Added develop.py, which starts up the localhost webserver and runs cf…

…x run simultaneously. Added a quick-start section to the README which guides new developers to use it.
  • Loading branch information...
1 parent c0ae831 commit 35d63548c56bc63f8431e3c010ac0ebb3845eb78 @toolness committed Feb 2, 2012
Showing with 78 additions and 11 deletions.
  1. +19 −0 README.md
  2. +58 −0 develop.py
  3. +1 −11 fabfile.py
View
@@ -13,6 +13,25 @@ the add-on.
If you only want to see the demo, you don't need any of these; all you need is a modern browser.
+## Quick Start
+
+First, [install][] the Mozilla Add-on SDK if you haven't already, and activate it in a command line terminal.
+
+Then, check out the Collusion repository and enter it:
+
+ git clone git://github.com/toolness/collusion.git
+ cd collusion
+
+Finally, run:
+
+ python develop.py
+
+This will set up the web front-end for Collusion on port 8888 and start Firefox with a temporary profile that has Collusion installed. Just click on the Collusion icon at the bottom-right of the browser window to open the web front-end.
+
+At this point, any changes you make to the web front-end simply require reloading the tab containing it. Changing the add-on, however, will require quitting Firefox and running `python develop.py` again.
+
+ [install]: https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/addon-development/installation.html
+
## Software Used
The following software is bundled with the repository and doesn't need to be manually obtained.
View
@@ -0,0 +1,58 @@
+import sys
+import os
+import threading
+import subprocess
+import BaseHTTPServer
+import SimpleHTTPServer
+
+try:
+ import simplejson as json
+except ImportError:
+ import json
+
+def get_git_commit():
+ try:
+ head = open(path('.git', 'HEAD'), 'r').read()
+ if head.startswith('ref: '):
+ ref = open(path('.git', head.split()[1].strip()), 'r').read()
+ return ref.strip()
+ return head.strip()
+ except Exception:
+ return "unknown"
+
+PORT = 8888
+ROOT = os.path.abspath(os.path.dirname(__file__))
+
+path = lambda *x: os.path.join(ROOT, *x)
+types = {
+ '.json': 'application/json',
+ '.manifest': 'text/cache-manifest',
+ '.webm': 'video/webm'
+}
+
+SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map.update(types)
+
+def run(server_class=BaseHTTPServer.HTTPServer,
+ handler_class=SimpleHTTPServer.SimpleHTTPRequestHandler,
+ port=PORT):
+ os.chdir(path('website'))
+ server_address = ('', port)
+ print "Serving files in '%s' on port %d." % (os.getcwd(), port)
+ httpd = server_class(server_address, handler_class)
+ httpd.serve_forever()
+
+if __name__ == '__main__':
+ t = threading.Thread(target=run)
+ t.setDaemon(True)
+ t.start()
+
+ dep = open(path('data', 'deployment.json'), 'w')
+ dep.write(json.dumps({
+ 'name': 'development',
+ 'commit': get_git_commit(),
+ 'url': 'http://localhost:%d/' % PORT,
+ 'xpi_url': 'http://localhost:%d/xpi/' % PORT
+ }))
+ dep.close()
+
+ sys.exit(subprocess.call(['cfx', 'run'] + sys.argv[1:], cwd=ROOT))
View
@@ -1,8 +1,8 @@
import os
-import json
from fabric.api import *
from fabric.contrib.project import rsync_project
+from develop import json, get_git_commit
ROOT = os.path.abspath(os.path.dirname(__file__))
path = lambda *x: os.path.join(ROOT, *x)
@@ -12,16 +12,6 @@
except ImportError:
pass
-def get_git_commit():
- try:
- head = open(path('.git', 'HEAD'), 'r').read()
- if head.startswith('ref: '):
- ref = open(path('.git', head.split()[1].strip()), 'r').read()
- return ref.strip()
- return head.strip()
- except Exception:
- return "unknown"
-
def deployment_task(func):
def task_func(name):
if name not in env.deployments:

0 comments on commit 35d6354

Please sign in to comment.