Skip to content

Instantly share code, notes, and snippets.

@oleoneto
Created December 22, 2017 20:49
Show Gist options
  • Save oleoneto/9a408d1c197aade6d5bcef110ee8ce5c to your computer and use it in GitHub Desktop.
Save oleoneto/9a408d1c197aade6d5bcef110ee8ce5c to your computer and use it in GitHub Desktop.
A script that automates the creation of a directory for a bottle app.
#!/bin/bash
# Requirements: Python, Bottle
# A script that automates the creation of a bottle app.
SITE=$1
print_usage(){
echo "usage: newbottle [appname]"
echo " newbottle -h"
echo " newbottle -st"
}
print_structure(){
echo "newbottle: Directory structure."
echo "├── app.py"
echo "├── dbconfig.py"
echo "├── forms.py"
echo "├── media"
echo "├── models.py"
echo "├── settings.py"
echo "├── sqlite3.db"
echo "├── static"
echo "│   ├── css"
echo "│   │   ├── master.css"
echo "│   ├── img"
echo "│   └── js"
echo "│   ├── api.js"
echo "│   ├── master.js"
echo "├── tests.py"
echo "├── urls.py"
echo "└── views"
echo " ├── about.html"
echo " ├── contact.html"
echo " ├── index.html"
echo " ├── media.html"
}
print_help(){
echo "newbottle: Generates a bottle app directory with database, static files, views, and more."
echo " Run newbottle -st to see a sample directory structure."
print_usage
}
make_static_and_media(){
mkdir media
mkdir -p static/css static/js static/img
touch static/css/master.css
touch static/js/master.js
touch static/js/api.js
}
make_views(){
mkdir views
touch views/index.html
touch views/about.html
touch views/media.html
touch views/contact.html
}
make_snippets(){
mkdir snippets
touch snippets/head.html
touch snippets/navigation.html
touch snippets/slider.html
touch snippets/gallery.html
touch snippets/footer.html
}
if [ "$SITE" ]; then
if [ "$SITE" = "-h" ]; then
print_help
elif [ "$SITE" = "-st" ]; then
print_structure
else
# Make a directory
mkdir -p $SITE
# Enter the directory
cd $SITE
# Make application
touch app.py
touch dbconfig.py
touch models.py
touch forms.py
touch tests.py
touch urls.py
touch settings.py
touch sqlite3.db
# Make subdirs with custom functions...
# make_snippets
make_views
make_static_and_media
echo "$SITE created."
fi
else
print_usage
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment