bootstrap
This commit is contained in:
parent
b84c3af4ae
commit
c3be6dd7ef
5
bootstrap/.gitignore
vendored
Normal file
5
bootstrap/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
.idea
|
||||
venv
|
||||
*.pyc
|
||||
data/db.sqlite
|
||||
__pycache__
|
4
bootstrap/INSTALL.sh
Executable file
4
bootstrap/INSTALL.sh
Executable file
@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
virtualenv -p python3 venv
|
||||
source venv/bin/activate
|
||||
pip install -r requirements.txt
|
19
bootstrap/README.md
Normal file
19
bootstrap/README.md
Normal file
@ -0,0 +1,19 @@
|
||||
# Project
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
virtualenv -p python3 venv
|
||||
source venv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
|
||||
```
|
||||
|
||||
## Run
|
||||
|
||||
```
|
||||
source venv/bin/activate
|
||||
python run.py
|
||||
```
|
||||
|
||||
_Powered by [oshipka](https://gitlab.com/pisquared/oshipka)_
|
@ -5,6 +5,7 @@ basepath = os.path.dirname(os.path.realpath(__file__))
|
||||
DATA_DIR = os.path.join(basepath, "data")
|
||||
DATABASE_FILE = os.path.join(DATA_DIR, "db.sqlite")
|
||||
SQLALCHEMY_DATABASE_URI = 'sqlite:///{}'.format(DATABASE_FILE)
|
||||
TEMPLATES_FOLDER = os.path.join(basepath, "webapp", "templates")
|
||||
MAKEDIRS = [
|
||||
DATA_DIR,
|
||||
]
|
||||
]
|
6
bootstrap/populate.py
Normal file
6
bootstrap/populate.py
Normal file
@ -0,0 +1,6 @@
|
||||
from webapp.models import db
|
||||
|
||||
|
||||
def populate_db(app):
|
||||
with app.app_context():
|
||||
db.session.commit()
|
1
bootstrap/requirements.txt
Normal file
1
bootstrap/requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
git+https://gitlab.com/pisquared/oshipka
|
13
bootstrap/run.py
Normal file
13
bootstrap/run.py
Normal file
@ -0,0 +1,13 @@
|
||||
from config import TEMPLATES_FOLDER
|
||||
from oshipka import init_db
|
||||
|
||||
from populate import populate_db
|
||||
from webapp.app import app
|
||||
|
||||
if __name__ == "__main__":
|
||||
if init_db(app):
|
||||
populate_db(app)
|
||||
|
||||
app.template_folder = TEMPLATES_FOLDER
|
||||
|
||||
app.run(debug=True)
|
7
bootstrap/webapp/app.py
Normal file
7
bootstrap/webapp/app.py
Normal file
@ -0,0 +1,7 @@
|
||||
from flask import render_template, request, jsonify
|
||||
|
||||
from oshipka.webapp import app
|
||||
|
||||
@app.route('/')
|
||||
def home():
|
||||
return render_template("home.html")
|
1
bootstrap/webapp/models.py
Normal file
1
bootstrap/webapp/models.py
Normal file
@ -0,0 +1 @@
|
||||
from oshipka.persistance import db
|
10598
bootstrap/webapp/static/js/jquery.js
vendored
Normal file
10598
bootstrap/webapp/static/js/jquery.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
4
bootstrap/webapp/templates/home.html
Normal file
4
bootstrap/webapp/templates/home.html
Normal file
@ -0,0 +1,4 @@
|
||||
{% extends "layout.html" %}
|
||||
|
||||
{% block content %}
|
||||
{% endblock %}
|
178
bootstrap/webapp/templates/layout.html
Normal file
178
bootstrap/webapp/templates/layout.html
Normal file
@ -0,0 +1,178 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<title>Project</title>
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family: Open Sans, Arial, sans-serif;
|
||||
color: #444;
|
||||
padding: 0 1em;
|
||||
}
|
||||
|
||||
main {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
nav {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
background: white;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@media (min-width: 1400px) {
|
||||
main {
|
||||
margin: 0 150px;
|
||||
}
|
||||
|
||||
aside {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
margin: 0;
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
#archive-container {
|
||||
display: block !important;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
input[type=text], textarea {
|
||||
width: 100%;
|
||||
padding: 0.5em;
|
||||
font-family: Open Sans, Arial sans-serif;
|
||||
font-size: 1em;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
textarea {
|
||||
height: 5em;
|
||||
}
|
||||
|
||||
.input-label {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
blockquote > h1 {
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
blockquote > h2 {
|
||||
font-size: 1.5em;
|
||||
}
|
||||
|
||||
blockquote > h3 {
|
||||
font-size: 1.25em;
|
||||
}
|
||||
|
||||
cite:before {
|
||||
content: "\2014 ";
|
||||
}
|
||||
|
||||
cite {
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
.search-form {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.flash {
|
||||
padding: 4px;
|
||||
margin: 4px;
|
||||
top: 1em;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.flash.error {
|
||||
border: 1px solid #f22;
|
||||
background-color: #faa;
|
||||
color: #f22;
|
||||
}
|
||||
|
||||
.flash.message, .flash.info {
|
||||
border: 1px solid #28f;
|
||||
background-color: #cef;
|
||||
color: #28f;
|
||||
}
|
||||
|
||||
.flash.success {
|
||||
border: 1px solid #2f8;
|
||||
background-color: #cfe;
|
||||
color: #094;
|
||||
}
|
||||
|
||||
.danger {
|
||||
color: #f22;
|
||||
}
|
||||
|
||||
.pull-right {
|
||||
float: right;
|
||||
}
|
||||
|
||||
pre {
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
table {
|
||||
border-spacing: 0;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
table tr {
|
||||
background-color: #fff;
|
||||
border-top: 1px solid #aaa;
|
||||
}
|
||||
|
||||
table tr:nth-child(2n) {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
table th, table td {
|
||||
padding: 6px 12px;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.vertical-padding {
|
||||
height: 80px;
|
||||
}
|
||||
</style>
|
||||
{% block style %}{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
<nav>
|
||||
{% include "navigation.html" %}
|
||||
</nav>
|
||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||
{% if messages %}
|
||||
{% for category, message in messages %}
|
||||
<div class="flash {{ category }}">{{ message }}</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
<div class="vertical-padding"></div>
|
||||
<aside>
|
||||
{% block aside %}{% endblock %}
|
||||
</aside>
|
||||
<main>
|
||||
{% if ctx and ctx.messages %}
|
||||
{% for message in ctx.messages %}
|
||||
<div class="flash {{ message.type.value }}">
|
||||
<a href="/messages/{{ message.id }}/dismiss"
|
||||
style="float:right;">x</a>
|
||||
{{ message.body|safe }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% block content %}{% endblock %}
|
||||
</main>
|
||||
<script src="{{ url_for('static', filename='js/jquery.js') }}"></script>
|
||||
{% block script %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
1
bootstrap/webapp/templates/navigation.html
Normal file
1
bootstrap/webapp/templates/navigation.html
Normal file
@ -0,0 +1 @@
|
||||
<a href="{{ url_for('home') }}">Home</a> |
|
59
oshipka.sh
Executable file
59
oshipka.sh
Executable file
@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
if [ -v $OSHIPKA_PATH ]; then
|
||||
echo "You need to specify OSHIPKA_PATH env variable"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "oshipka is at: $OSHIPKA_PATH"
|
||||
|
||||
#!/usr/bin/env bash
|
||||
HELP="
|
||||
Usage $0 [ bootstrap ]
|
||||
|
||||
bootstrap [PROJECT_PATH] Create a new project in PROJECT_PATH
|
||||
"
|
||||
|
||||
bootstrap() {
|
||||
shift
|
||||
PROJECT_PATH=$1
|
||||
if [[ -z "$PROJECT_PATH" ]]; then
|
||||
read -p "Enter project path: " PROJECT_PATH
|
||||
fi
|
||||
if [[ -z "$PROJECT_PATH" ]]; then
|
||||
echo "ERROR: Specify project path"
|
||||
exit 1
|
||||
else
|
||||
echo "INFO: Project path: $PROJECT_PATH"
|
||||
PROJECT_PATH=`realpath $PROJECT_PATH`
|
||||
echo "INFO: Absolute project path: $PROJECT_PATH"
|
||||
if [[ "$PROJECT_PATH" == $OSHIPKA_PATH* ]]; then
|
||||
echo "ERROR: Project path can't be inside this directory. Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
if [ -d $PROJECT_PATH ]; then
|
||||
echo "ERROR: Project path exists. Please remove or specify another. Exiting..."
|
||||
exit 1
|
||||
else
|
||||
echo "INFO: Project path doesn't exist, creating..."
|
||||
mkdir -p $PROJECT_PATH
|
||||
fi
|
||||
fi
|
||||
PROJECT_NAME=$(basename $PROJECT_PATH)
|
||||
echo "INFO: Bootstrapping project $PROJECT_NAME..."
|
||||
mkdir -p ${PROJECT_PATH}
|
||||
cp -r ${OSHIPKA_PATH}/bootstrap/* ${PROJECT_PATH}/
|
||||
}
|
||||
|
||||
command_main() {
|
||||
INITIAL_COMMAND=$1
|
||||
case "$INITIAL_COMMAND" in
|
||||
bootstrap) bootstrap "$@"
|
||||
;;
|
||||
*) >&2 echo -e "${HELP}"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
return $?
|
||||
}
|
||||
|
||||
command_main "$@"
|
@ -3,7 +3,6 @@ import os
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
|
||||
from config import SQLALCHEMY_DATABASE_URI, MAKEDIRS, DATABASE_FILE
|
||||
from oshipka.persistance.populate import populate_db
|
||||
|
||||
db = SQLAlchemy()
|
||||
|
||||
@ -18,4 +17,4 @@ def init_db(app):
|
||||
if not os.path.exists(DATABASE_FILE):
|
||||
with app.app_context():
|
||||
db.create_all()
|
||||
populate_db(app)
|
||||
return True
|
||||
|
@ -1,8 +0,0 @@
|
||||
|
||||
|
||||
|
||||
def populate_db(app):
|
||||
with app.app_context():
|
||||
pass
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user