Last active
January 2, 2016 00:19
-
-
Save cwardzala/8222301 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"directory": "AppName/bower_components" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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