Created
May 12, 2012 22:43
-
-
Save matiskay/2669541 to your computer and use it in GitHub Desktop.
Flash Scaffold
This file contains hidden or 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 | |
# PRECONDITIONS | |
# virtualenv | |
# virtualenv -> http://flask.pocoo.org/docs/installation/#virtualenv | |
makeapp () { | |
{ | |
echo "from flask import Flask, render_template" | |
echo "" | |
echo "app = Flask(__name__)" | |
echo "app.debug = True" | |
echo "" | |
echo "@app.route('/')" | |
echo "def index():" | |
echo " return render_template('index.html')" | |
echo "" | |
echo "if __name__ == '__main__':" | |
echo " app.run()" | |
} > app.py | |
} | |
makeindex () { | |
{ | |
echo "{% extends 'base.html' %}" | |
echo "{% block title %}Welcome Aboard{% endblock %}" | |
echo "{% block content %}Welcome Aboard{% endblock %}" | |
} > index.html | |
} | |
makebase () { | |
{ | |
echo '<!DOCTYPE html>' | |
echo '<html>' | |
echo ' <head>' | |
echo ' <meta charset="UTF-8" />' | |
echo ' <title>{% block title %}{% endblock %}</title>' | |
echo " <link type=\"text/css\" rel=\"stylesheet\" href=\"{{ url_for('static', filename='css/style.css') }}\" />" | |
echo ' </head>' | |
echo ' <body>' | |
echo ' {% block content %}{% endblock %}' | |
echo " <script type=\"text/javascript\" src=\"{{ url_for('static', filename='js/jquery.js') }}\"></script>" | |
echo " <script type=\"text/javascript\" src=\"{{ url_for('static', filename='js/underscore.js') }}\"></script>" | |
echo " <script type=\"text/javascript\" src=\"{{ url_for('static', filename='js/custom.js') }}\"></script>" | |
echo ' </body>' | |
echo '</html>' | |
} > base.html | |
} | |
tests_folder() { | |
mkdir tests | |
} | |
core_folder() { | |
mkdir core | |
} | |
files() { | |
touch __init__.py | |
touch context_processors.py | |
touch forms.py | |
touch models.py | |
touch settings.py | |
touch urls.py | |
} | |
PROJECT_NAME=$1 | |
BASE=${PWD}/${PROJECT_NAME} | |
if [[ ! -n $1 ]]; then | |
echo 'Please, provide the following parameters: project_name' | |
echo '' | |
echo 'For example: ' | |
echo '' | |
echo " $ bash $0 project_name" | |
echo "" | |
exit 1 | |
fi | |
mkdir $PROJECT_NAME || exit | |
cd $PROJECT_NAME | |
# Generate the virtualenv called env | |
virtualenv --no-site-packages env | |
# Activation the virtualenv | |
. env/bin/activate | |
# Install flask | |
pip install flask | |
# Generate app.py | |
makeapp | |
# Generate a static folder for static files | |
mkdir static | |
cd static || exit | |
mkdir js | |
cd js || exit | |
printf "Downloading %s \n" "jquery 1.6.1" | |
wget -q "http://code.jquery.com/jquery-1.6.1.js" -O jquery.js | |
wget -q "http://documentcloud.github.com/underscore/underscore.js" -O underscore.js | |
touch custom.js | |
# Generate a css folder | |
cd $BASE/static | |
mkdir css | |
cd css || exit | |
touch style.css | |
cd $BASE | |
# Generate a template folder for templates | |
mkdir templates | |
cd templates || exit | |
makeindex | |
makebase | |
echo "go to your directory : $PWD" | |
echo '. env/bin/activate' | |
echo 'Run python app.py' | |
echo 'Now flask is up and running' | |
echo 'Open a new terminal and start coding' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment