Skip to content

Commit 3153fc3

Browse files
committed
Initial commit.
0 parents  commit 3153fc3

72 files changed

Lines changed: 8877 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.babelrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"presets": [
3+
"es2015",
4+
"stage-0",
5+
"react"
6+
]
7+
}

.bowerrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"directory": "app/static/bower_components",
3+
"ignoredDependencies": [
4+
"bootstrap",
5+
"bootstrap-sass",
6+
"bootstrap-sass-official"
7+
]
8+
}

.editorconfig

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# EditorConfig is awesome: http://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with a newline ending every file
7+
[*]
8+
end_of_line = lf
9+
insert_final_newline = true
10+
indent_style = space
11+
indent_size = 4
12+
13+
# Matches multiple files with brace expansion notation
14+
# Set default charset
15+
[*.{js,py}]
16+
charset = utf-8
17+
trim_trailing_whitespace = true
18+
insert_final_newline = true
19+
20+
# 4 space indentation
21+
[*.py]
22+
indent_style = space
23+
indent_size = 4
24+
25+
# Tab indentation (no size specified)
26+
[Makefile]
27+
indent_style = tab
28+
29+
# Indentation override for all JS under lib directory
30+
[static/js/**.js]
31+
indent_style = space
32+
indent_size = 4
33+
34+
# Matches the exact files either package.json or .travis.yml
35+
[{package.json,.travis.yml}]
36+
indent_style = space
37+
indent_size = 4
38+

.eslintrc

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"parser": "babel-eslint",
3+
"plugins": [
4+
"react"
5+
],
6+
"parserOptions": {
7+
"ecmaVersion": 6,
8+
"sourceType": "module",
9+
"ecmaFeatures": {
10+
"jsx": true
11+
}
12+
},
13+
"env": {
14+
"browser": true,
15+
"amd": true,
16+
"es6": true,
17+
"node": true,
18+
"mocha": true
19+
},
20+
"rules": {
21+
"comma-dangle": 1,
22+
"quotes": [ 1, "single" ],
23+
"no-undef": 1,
24+
"global-strict": 0,
25+
"no-extra-semi": 1,
26+
"no-underscore-dangle": 0,
27+
"no-console": 1,
28+
"no-unused-vars": 1,
29+
"no-trailing-spaces": [1, { "skipBlankLines": true }],
30+
"no-unreachable": 1,
31+
"no-alert": 0,
32+
"react/jsx-uses-react": 1,
33+
"react/jsx-uses-vars": 1
34+
}
35+
}

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

.gitignore

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
node_modules
2+
test/temp
3+
.sass-cache
4+
.tmp
5+
*.map
6+
test/bower_components/
7+
test
8+
app/static/dev
9+
10+
*.pyc
11+
*.pyo
12+
*.swp
13+
*~
14+
15+
# Packages
16+
*.egg
17+
*.egg-info
18+
build/
19+
eggs
20+
bin
21+
sdist
22+
23+
#Sphinx builds
24+
_build
25+
26+
# Installer logs
27+
pip-log.txt
28+
29+
# Flake8 violation file
30+
violations.flake8.txt
31+
32+
# Unit test / coverage reports
33+
.coverage
34+
.tox
35+
nosetests.xml
36+
__pycache__
37+
database.db
38+
39+
# Sphinx
40+
docs/_build
41+
42+
# Virtual environments
43+
env
44+
env*
45+
venv
46+
venv*
47+
48+
.webassets-cache
49+
.DS_Store
50+
*.sublime-*
51+
app.log
52+
53+
# Logs
54+
logs
55+
*.log
56+
57+
# Runtime data
58+
pids
59+
*.pid
60+
*.seed
61+
62+
# Directory for instrumented libs generated by jscoverage/JSCover
63+
lib-cov
64+
65+
# Coverage directory used by tools like istanbul
66+
coverage
67+
68+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
69+
.grunt
70+
71+
# node-waf configuration
72+
.lock-wscript
73+

.travis.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
language: python
2+
python:
3+
- "2.7"
4+
- "3.3"
5+
- "3.4"
6+
- "3.5"
7+
- "pypy"
8+
# command to install dependencies
9+
install: "pip install -r requirements.txt"
10+
# command to run tests
11+
script: make test

Makefile

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
.PHONY: docs test
2+
3+
help:
4+
@echo " env create a development environment using virtualenv"
5+
@echo " deps install dependencies using pip"
6+
@echo " clean remove unwanted files like .pyc's"
7+
@echo " lint check style with flake8"
8+
@echo " test run all your tests using py.test"
9+
10+
env:
11+
virtualenv -p /usr/local/bin/python3 venv && \
12+
. venv/bin/activate && \
13+
make deps
14+
deps:
15+
pip install -r requirements.txt
16+
17+
clean:
18+
python manage.py clean
19+
20+
lint:
21+
flake8 --exclude=venv,app/static .
22+
23+
test:
24+
py.test tests
25+
26+
dev:
27+
source venv/bin/activate && uwsgi --ini uwsgi-dev.ini --py-autoreload 1
28+
29+
prod:
30+
source venv/bin/activate && uwsgi --ini uwsgi.ini
31+
32+
createdb:
33+
source venv/bin/activate && python manage.py createdb
34+
35+
babelextract:
36+
source venv/bin/activate && \
37+
pybabel extract -F app/babel.cfg -k lazy_gettext -o app/messages.pot app
38+
39+
babelcompile:
40+
source venv/bin/activate && pybabel compile -d app/translations
41+
42+
# German
43+
germaninit:
44+
source venv/bin/activate && \
45+
pybabel init -i app/messages.pot -d app/translations -l de
46+
47+
germanupdate:
48+
source venv/bin/activate && \
49+
pybabel update -i app/messages.pot -d app/translations -l de
50+
51+

app/__init__.py

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#! ../env/bin/python
2+
3+
from flask import Flask, request, g, redirect
4+
from logging.handlers import RotatingFileHandler
5+
import logging
6+
7+
# Controllers
8+
from app.models.database import db
9+
from app.controllers.main import main
10+
from app.controllers.profile import profile
11+
from app.controllers.auth import auth
12+
from app.controllers.authorize import authorize
13+
14+
# Api controllers
15+
16+
# External controllers
17+
18+
# Misc
19+
from app.tpl_filter import tpl_filter
20+
from app.extensions import (
21+
cache,
22+
debug_toolbar,
23+
login_manager,
24+
csrf,
25+
oauth,
26+
mailgun,
27+
babel
28+
)
29+
30+
def create_app(object_name, env='prod'):
31+
"""
32+
An flask application factory, as explained here:
33+
http://flask.pocoo.org/docs/patterns/appfactories/
34+
35+
Arguments:
36+
object_name: the python path of the config object, e.g. app.settings.ProdConfig
37+
38+
env: The name of the current environment, e.g. prod or dev
39+
"""
40+
app = Flask(__name__, static_url_path='')
41+
42+
app.config.from_object(object_name)
43+
app.config['ENV'] = env
44+
45+
# templates and statics
46+
app.template_folder = app.config['TEMPLATE_FOLDER']
47+
app.static_folder = app.config['STATIC_FOLDER']
48+
49+
# initialize the cache
50+
cache.init_app(app)
51+
52+
# initialize the debug tool bar
53+
debug_toolbar.init_app(app)
54+
55+
# CSRF protection
56+
csrf.init_app(app)
57+
58+
# Oauthlib
59+
oauth.init_app(app)
60+
61+
# initialize SQLAlchemy
62+
db.init_app(app)
63+
64+
# Authentication
65+
login_manager.init_app(app)
66+
67+
# Mailgun
68+
mailgun.init_app(app)
69+
70+
# Languages
71+
babel.init_app(app)
72+
73+
# Register blueprints
74+
app.register_blueprint(main)
75+
app.register_blueprint(auth)
76+
app.register_blueprint(profile)
77+
app.register_blueprint(authorize)
78+
79+
# Api
80+
81+
# Extneral
82+
83+
# Import custom template filters
84+
app.register_blueprint(tpl_filter)
85+
86+
# @babel.localeselector
87+
# def get_locale():
88+
# return g.locale
89+
90+
# # Set lang
91+
# @app.before_request
92+
# def before_request():
93+
# lang_cookie = request.cookies.get('locale')
94+
# locale = lang_cookie if lang_cookie else 'en'
95+
96+
# if not lang_cookie:
97+
# for lang in request.accept_languages.values():
98+
# if lang[:2] in ['de', 'en']:
99+
# locale = lang[:2]
100+
# break
101+
102+
# g.locale = locale
103+
104+
# if app.config['ENV'] == 'prod':
105+
# file_handler = RotatingFileHandler('app.log', maxBytes=1024 * 1024 * 100, backupCount=20)
106+
# formatter = logging.Formatter( "%(asctime)s | %(pathname)s:%(lineno)d | %(funcName)s | %(levelname)s | %(message)s ")
107+
# file_handler.setFormatter(formatter)
108+
# app.logger.addHandler(file_handler)
109+
110+
return app

app/babel.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[python: **.py]
2+
[jinja2: **/templates/**.html]
3+
extensions=jinja2.ext.autoescape,jinja2.ext.with_

0 commit comments

Comments
 (0)