Skip to content

Instantly share code, notes, and snippets.

@cute
Forked from cwardzala/.bowerrc
Created March 11, 2014 09:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cute/9482302 to your computer and use it in GitHub Desktop.
Save cute/9482302 to your computer and use it in GitHub Desktop.
{
"directory": "AppName/bower_components"
}
from bottle import get, jinja2_view as view
from common.config import CONFIG
@get('/')
@view('index.html')
def index():
return {
'some': 'other data',
'js': CONFIG.js
}
import logging
class ConfigSection(object):
pass
class Config(object):
def __init__(self):
# "global" config
self.foo = 'bar'
self.js = {
'main': 'main-built',
'loader': 'require.js'
}
# Dashboard
self.app = ConfigSection()
self.app.debug = False
self.app.host = '0.0.0.0'
self.app.port = 3000
self.app.reloader = False
# Logging
self.logging = ConfigSection()
self.logging.dateformat = '%Y-%m-%d %H:%M:%S'
self.logging.format = '%(asctime)s | %(name)s | %(levelname)-8s | %(message)s'
self.logging.path = 'log'
self.logging.masterlevel = logging.WARNING
self.logging.filelevel = logging.WARNING
self.logging.stderrlevel = logging.ERROR
# Auth
self.auth = ConfigSection()
self.auth.login_path = '/login'
# Releases
self.release = ConfigSection()
self.release.types = ['other', 'SDK', 'SDK w/ Dependencies', 'Sample App', 'Core']
self.release.platforms = ['other', 'Android', 'iOS', 'Javascript', 'Java']
CONFIG = Config()
# Local (dev) settings can override the main settings
try:
from local_config import LocalConfig
CONFIG = LocalConfig()
except ImportError:
pass
# On the remote server:
git fetch origin # may not be necessary
git pull origin master
source venv/bin/activate && pip install -rU AppName/requirements.txt
npm install
bower install
grunt build
supervisorctl restart appname
/AppName
/AppName
/bower_components - directory where Bower will install components. (set by .bowerrc)
Gruntfile.js - details all the project's grunt tasks.
.bowerrc - tells bower where to install components.
bower.json - details Bower dependencies and application information.
package.json - lists npm (node) dependencies and application information.
module.exports = function(grunt) {
require('time-grunt')(grunt);
require('load-grunt-tasks')(grunt);
var spawn = require('child_process').spawn,
appConfig = grunt.file.readJSON('package.json'),
python_server;
var pathsConfig = function (appName) {
this.app = appName || appConfig.name;
return {
app: this.app,
bower: this.app + '/bower_components',
css: this.app + '/static/css',
scss: this.app + '/static/sass',
js: this.app + '/static/js',
runScript: './run_' + this.app.toLowerCase() + '.sh'
}
};
grunt.initConfig({
paths: pathsConfig(),
pkg: appConfig,
sass: {
options: {
includePaths: ['<%= paths.bower %>']
},
dist: {
options: {
// outputStyle: 'compressed'
},
files: {
'<%= paths.css %>/styles.css': '<%= paths.scss %>/styles.scss'
}
}
},
requirejs: {
dist: {
// Options: https://github.com/jrburke/r.js/blob/master/build/example.build.js
options: {
baseUrl: '<%= paths.js %>',
mainConfigFile: '<%= paths.js %>/main.js',
optimize: 'none',
preserveLicenseComments: false,
useStrict: true,
wrap: true,
name: 'main',
optimize: 'uglify2',
out: '<%= paths.js %>/main-built.js'
}
}
},
watch: {
grunt: {
files: ['Gruntfile.js']
},
sass: {
files: '<%= paths.scss %>/**/*.scss',
tasks: ['sass']
}
}
});
grunt.registerTask('runApp', function () {
python_server = spawn(grunt.config.data.paths.runScript, [], {
cwd: grunt.config.data.paths.app
});
python_server.stdout.on('data', function (data) {
grunt.log.write('stdout: ' + data + '\n');
});
python_server.stderr.on('data', function (data) {
grunt.log.write('stderr: ' + data + '\n');
});
python_server.on('close', function (code) {
grunt.log.write('child process exited with code ' + code + '\n');
});
});
grunt.registerTask('server', ['runApp', 'watch']);
grunt.registerTask('build', ['sass', 'requirejs']);
grunt.registerTask('default', ['build','watch']);
}
<!doctype html>
<html lang="en">
<head>
<!-- head stuff -->
</head>
<body id="main">
<!-- Other body stuff -->
<script src="/static/js/vendor/{{ js.loader }}" data-main="/static/js/{{ js.main }}"></script>
</body>
</html>
import logging
from config import Config
WORKING_DIR = '/Users/jsmith/AppName'
class LocalConfig(Config):
def __init__(self):
super(LocalConfig, self).__init__()
# Logging
self.logging.path = WORKING_DIR + '/log'
self.logging.masterlevel = logging.DEBUG
self.logging.filelevel = logging.DEBUG
self.logging.stderrlevel = logging.DEBUG
# App
self.app.debug = True
self.app.reloader = True
self.app.port = 3001
self.js = {
'main': 'main',
'loader': 'require.js'
}
{
"name": "AppName",
"version": "0.0.1",
"devDependencies": {
"node-sass": "~0.7.0",
"grunt": "~0.4.1",
"grunt-contrib-watch": "~0.5.3",
"grunt-sass": "~0.8.0",
"grunt-contrib-requirejs": "~0.4.1",
"load-grunt-tasks": "~0.2.0",
"time-grunt": "~0.2.3"
}
}
#!/bin/bash
# directory of this script
DIR=$(cd $(dirname "$0"); pwd)
cd $DIR
export PYTHONPATH=$DIR/lib
export PATH=$DIR/../venv/bin
exec python $DIR/app.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment