Skip to content

Commit 64c7e5c

Browse files
committed
[#594] Use Gulp to Run a BrowserSync Proxy Server
Refs #594: Add a Task Runner
1 parent 772818a commit 64c7e5c

File tree

4 files changed

+88
-0
lines changed

4 files changed

+88
-0
lines changed

README.rst

+21
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,27 @@ Create the database and start the dev server::
4040
./manage.py runserver 0.0.0.0:8000
4141

4242

43+
BrowserSync
44+
------------
45+
46+
BrowserSync lets you sync up actions betweens browsers & automatically reloads
47+
your browsers when a source file has been modified.
48+
49+
You'll need ``npm`` & ``gulp`` installed::
50+
51+
pacman -S npm
52+
npm install -g gulp
53+
54+
Then install our Gulp dependencies & run ``gulp`` in the project's base
55+
directory::
56+
57+
npm install
58+
gulp
59+
60+
Gulp will start the Django server for you along with a proxy server that
61+
injects the BrowserSync code at http://localhost:8010.
62+
63+
4364
Documentation
4465
--------------
4566

gulpfile.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
var browserSync = require('browser-sync').create();
2+
var exec = require('child_process').exec;
3+
var gulp = require('gulp');
4+
5+
6+
var virtualEnvActivate = '~/.virtualenvs/fec/bin/activate';
7+
8+
var watchPaths = [
9+
'fec/**/*.css',
10+
'fec/**/*.html',
11+
'fec/**/*.js',
12+
'fec/**/*.less',
13+
'fec/**/*.py',
14+
];
15+
16+
17+
gulp.task('default', ['django-server', 'proxy-server']);
18+
19+
gulp.task('django-server', function(cb) {
20+
var proc = exec(
21+
'source ' + virtualEnvActivate + '; ' +
22+
'cd fec; PYTHONUNBUFFERED=1 python manage.py runserver 0.0.0.0:8000'
23+
);
24+
proc.stdout.on('data', function(data) { process.stdout.write(data); });
25+
proc.stderr.on('data', function(data) { process.stdout.write(data); });
26+
return cb();
27+
});
28+
29+
gulp.task('proxy-server', function() {
30+
return browserSync.init(watchPaths, {
31+
proxy: '0.0.0.0:8000',
32+
port: 8010,
33+
open: false,
34+
});
35+
});
36+

package.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "fec-website",
3+
"version": "0.4.0",
4+
"description": "The mezzanine project that powers thefec.org",
5+
"main": "gulpfile.js",
6+
"directories": {
7+
"doc": "docs"
8+
},
9+
"devDependencies": {
10+
"browser-sync": "^2.7.6",
11+
"gulp": "^3.9.0"
12+
},
13+
"repository": {
14+
"type": "git",
15+
"url": "https://github.com/FederationOfEgalitarianCommunities/FECWebsite.git"
16+
},
17+
"author": "Pavan Rikhi <[email protected]> (http://sleepanarchy.com)",
18+
"license": "GPL-3.0",
19+
"bugs": "http://bugs.sleepanarchy.com/projects/fec/issues",
20+
"keywords": [
21+
"federation",
22+
"egalitarian",
23+
"communities",
24+
"mezzanine",
25+
"python",
26+
"django",
27+
"website",
28+
"fec"
29+
]
30+
}

requirements/local.txt

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ pylint-django>=0.5
88

99
Sphinx>=1.2
1010
sphinx-bootstrap-theme>=0.4
11+
django-livereload>=1.2

0 commit comments

Comments
 (0)