Skip to content

Commit

Permalink
Use Gulp to build JavaScript and CSS.
Browse files Browse the repository at this point in the history
Mostly ported from MusicBrainz Server setup.
  • Loading branch information
gentlecat committed Dec 18, 2015
1 parent 8e94920 commit 887220f
Show file tree
Hide file tree
Showing 127 changed files with 352 additions and 36,175 deletions.
8 changes: 8 additions & 0 deletions .babelrc
@@ -0,0 +1,8 @@
{
"presets": ["es2015", "stage-2"],
"plugins": [
"transform-react-jsx",
"transform-react-constant-elements",
"transform-react-inline-elements"
]
}
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -37,6 +37,9 @@ hl_extractor/svm_models
hl_extractor/profile.conf
hl_extractor/profile.conf.in

# Node.js
/node_modules

# Other stuff
/static/download
export
Expand Down
3 changes: 2 additions & 1 deletion admin/install_web_server.sh
@@ -1,3 +1,4 @@
#!/bin/sh

apt-get -y install memcached node-less python-virtualenv python-dev ipython pxz
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
apt-get -y install memcached python-virtualenv python-dev ipython pxz nodejs
9 changes: 9 additions & 0 deletions admin/setup_app.sh
@@ -1,13 +1,22 @@
#!/bin/sh

# Setting up the application
if [ $# -eq 1 ]
then
cd $1
else
echo "Application directory is not specified. Using current directory!"
fi

echo "source venv-acousticbrainz/bin/activate" > ~/.bashrc
virtualenv ../venv-acousticbrainz
source ../venv-acousticbrainz/bin/activate

pip install -U pip
pip install -r requirements.txt

python manage.py init_db
python manage.py init_test_db

npm install
./node_modules/.bin/gulp

This comment has been minimized.

Copy link
@alastair

alastair Jan 1, 2016

Collaborator

I'd like to see a file watcher to run gulp when stuff changes (for development). Can we add a script somewhere which is easy to start up? I've heard that this can be problematic on virtualbox shared folders. Have you encountered it before?

This comment has been minimized.

Copy link
@gentlecat

gentlecat Jan 1, 2016

Author Contributor

Yeah, it doesn't seem to work with gulp-watch. From MBS: https://github.com/metabrainz/musicbrainz-server/blob/master/root/static/gulpfile.js#L249-L275. Will try to look into that later.

3 changes: 0 additions & 3 deletions config.py.sample
Expand Up @@ -52,7 +52,4 @@ MEMCACHED_NAMESPACE = "AB"
#SMTP_PORT = 25
#MAIL_FROM_DOMAIN = "acousticbrainz.org"

# Set to True if Less should be compiled in browser. Set to False if styling is pre-compiled.
COMPILE_LESS = True

FILE_STORAGE_DIR = "./files"
16 changes: 7 additions & 9 deletions fabfile.py
Expand Up @@ -6,10 +6,12 @@

import os


def vpsql():
"""Connect to the acousticbrainz database running on vagrant."""
local("psql -h localhost -p 15432 -U postgres acousticbrainz")


def vssh():
"""SSH to a running vagrant host."""
curdir = os.path.dirname(os.path.abspath(__file__))
Expand All @@ -19,6 +21,7 @@ def vssh():

local("ssh -F .vagrant/ssh_config -o 'ControlMaster auto' -o 'ControlPath ~/.ssh/ab_vagrant_control' -o 'ControlPersist 4h' acousticbrainz")


def git_pull():
local("git pull origin")
print(green("Updated local code.", bold=True))
Expand All @@ -29,14 +32,9 @@ def install_requirements():
print(green("Installed requirements.", bold=True))


def compile_styling():
"""Compile main.less into main.css.
This command requires Less (CSS pre-processor). More information about it can be
found at http://lesscss.org/.
"""
style_path = "webserver/static/css/"
local("lessc --clean-css %smain.less > %smain.css" % (style_path, style_path))
print(green("Style sheets have been compiled successfully.", bold=True))
def build_static():
local("./node_modules/.bin/gulp")
print(green("Static files have been built successfully.", bold=True))

This comment has been minimized.

Copy link
@alastair

alastair Jan 1, 2016

Collaborator

success only if local succeeds!

This comment has been minimized.

Copy link
@gentlecat

gentlecat Jan 2, 2016

Author Contributor

I removed it for now. fe4b43e



def clear_memcached():
Expand All @@ -51,7 +49,7 @@ def clear_memcached():
def deploy():
git_pull()
install_requirements()
compile_styling()
build_static()
clear_memcached()


Expand Down
2 changes: 2 additions & 0 deletions gulpfile.js
@@ -0,0 +1,2 @@
require('babel-core/register');
require('./webserver/static/gulpfile');
32 changes: 32 additions & 0 deletions package.json
@@ -0,0 +1,32 @@
{
"name": "acousticbrainz-server",
"version": "0.0.0",
"description": "package.json for keeping track of nodejs dependencies for acousticbrainz-server",
"repository": {
"type": "git",
"url": "https://github.com/metabrainz/acousticbrainz-server.git"
},
"dependencies": {
"babel-core": "6.2.1",
"babel-plugin-transform-react-constant-elements": "6.1.20",
"babel-plugin-transform-react-inline-elements": "6.1.20",
"babel-plugin-transform-react-jsx": "6.2.0",
"babel-preset-es2015": "6.1.18",
"babel-preset-stage-2": "6.1.18",
"babelify": "7.2.0",
"bootstrap": "3.3.6",
"gulp": "3.9.0",
"gulp-less": "3.0.5",
"gulp-rev": "6.0.1",
"gulp-streamify": "1.0.2",
"highcharts": "4.2.0",
"jquery": "2.1.4",
"less-plugin-clean-css": "1.5.1",
"lodash": "3.10.1",
"q": "1.4.1",
"react": "0.14.3",
"vinyl-source-stream": "1.1.0",
"yarb": "0.5.1"
},
"private": true
}
5 changes: 5 additions & 0 deletions webserver/__init__.py
Expand Up @@ -47,11 +47,16 @@ def create_app():
from webserver.errors import init_error_handlers
init_error_handlers(app)

# Static files
import static_manager
static_manager.read_manifest()

# Template utilities
app.jinja_env.add_extension('jinja2.ext.do')
from webserver import utils
app.jinja_env.filters['date'] = utils.reformat_date
app.jinja_env.filters['datetime'] = utils.reformat_datetime
app.jinja_env.filters['make_static_path'] = static_manager.get_file_path

This comment has been minimized.

Copy link
@alastair

alastair Jan 1, 2016

Collaborator

what about setting an app context processor instead? http://blog.bouni.de/blog/2013/04/24/call-functions-out-of-jinjs2-templates/

This comment has been minimized.

Copy link
@alastair

alastair Jan 1, 2016

Collaborator

I don't like changing the name either. The function name in static_manager should be the same as what is in the context

This comment has been minimized.

Copy link
@gentlecat

gentlecat Jan 1, 2016

Author Contributor

Fixed both in abc1d06.

This comment has been minimized.

Copy link
@gentlecat

gentlecat Jan 1, 2016

Author Contributor

...and in 62fe651.


# Blueprints
from webserver.views.index import index_bp
Expand Down
1 change: 1 addition & 0 deletions webserver/static/.gitignore
@@ -0,0 +1 @@
build
2 changes: 0 additions & 2 deletions webserver/static/css/.gitignore

This file was deleted.

158 changes: 0 additions & 158 deletions webserver/static/css/highlight.css

This file was deleted.

0 comments on commit 887220f

Please sign in to comment.