Skip to content

Commit b6db696

Browse files
committed
Modernize.
1 parent df31c28 commit b6db696

18 files changed

+106
-284
lines changed

activate

-79
This file was deleted.

app/Dockerfile

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
FROM debian:8
1+
FROM debian:9
22
ENV DEBIAN_FRONTEND noninteractive
3-
3+
ENV LC_ALL=C.UTF-8
4+
ENV LANG=C.UTF-8
5+
ENV VIRTUAL_ENV=/usr/local
6+
ENV FLASK_APP=/usr/local/src/jekylledit/jekylledit/__init__.py
7+
WORKDIR /usr/local/src/jekylledit
48
EXPOSE 8000
59

610
RUN apt-get -qq update && apt-get -qq -y --no-install-recommends install \
@@ -16,15 +20,10 @@ RUN apt-get -qq update && apt-get -qq -y --no-install-recommends install \
1620
rsync \
1721
ssh
1822

19-
COPY requirements.txt /venv/requirements.txt
20-
RUN python3 -m venv /venv \
21-
&& /venv/bin/pip install -r /venv/requirements.txt \
22-
&& /venv/bin/pip freeze > /venv/requirements-freezed.txt
23+
COPY requirements.txt /tmp/requirements.txt
24+
RUN python3 -m venv /usr/local \
25+
&& /usr/local/bin/pip install -r /tmp/requirements.txt
2326

2427
RUN git config --global push.default matching
2528

26-
COPY . /venv/app
27-
28-
ARG VERSION
29-
ARG SETUP_MODE
30-
RUN /venv/app/setup.sh $VERSION $SETUP_MODE
29+
COPY jekylledit /usr/local/src/jekylledit/jekylledit

app/jekylledit/__main__.py

-27
This file was deleted.

app/jekylledit/controllers/auth.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
from flask import Blueprint, _request_ctx_stack, abort, jsonify, make_response, \
1010
redirect, render_template, request, url_for
11-
from flask.ext.login import LoginManager, current_user, login_user, logout_user
12-
from flask.ext.principal import Identity, Permission, PermissionDenied, Principal
11+
from flask_login import LoginManager, current_user, login_user, logout_user
12+
from flask_principal import Identity, Permission, PermissionDenied, Principal
1313
from ..ext.identitytoolkit import Gitkit
1414
from itsdangerous import URLSafeTimedSerializer
1515

@@ -20,7 +20,7 @@
2020
blueprint = Blueprint('auth', __name__)
2121
login_manager = LoginManager(app)
2222
principal = Principal(app, use_sessions=False, skip_static=True)
23-
if not app.config['DEVELOPMENT']:
23+
if not app.debug:
2424
gitkit = Gitkit(app, {
2525
'widget': 'auth.widget',
2626
'sign_in_success': 'auth.sign_in_success',
@@ -88,7 +88,7 @@ def permission_denied(exc):
8888

8989
@blueprint.route('/widget', methods={'GET', 'POST'})
9090
def widget():
91-
if app.config['DEVELOPMENT']:
91+
if app.debug:
9292
if request.method == 'GET':
9393
return render_template('auth/widget.html')
9494
email = request.form['email']
@@ -171,7 +171,7 @@ def sign_out():
171171
logout_user()
172172
text = render_template('auth/close-window.html', message='You have signed out.')
173173
response = make_response(text)
174-
if not app.config['DEVELOPMENT']:
174+
if not app.debug:
175175
gitkit.delete_token(response)
176176
return response
177177

app/jekylledit/controllers/base.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from urllib.parse import urlparse
66

77
from flask import Flask, request, url_for
8-
from flask.ext.babel import Babel
8+
from flask_babel import Babel
99
from ..ext.mailgun import Mailgun
1010
from ..ext.normalizeUnicode import normalizeUnicode
1111

@@ -15,7 +15,7 @@
1515

1616

1717
babel = Babel(app)
18-
if not app.config['DEVELOPMENT']:
18+
if not app.debug:
1919
mailgun = Mailgun(app)
2020
else:
2121
mailgun = None
@@ -51,7 +51,7 @@ def mtime(dir, path):
5151

5252
@app.template_global()
5353
def url_for_js(name):
54-
if app.config['DEVELOPMENT']:
54+
if app.debug:
5555
host = urlparse(request.url).hostname
5656
return 'http://%s:9810/compile?id=%s-debug' % (host, name)
5757
return url_for('static', filename='js/{}.js'.format(name))

app/jekylledit/controllers/site.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
import hmac
88

99
from flask import abort, json, jsonify, request, render_template
10-
from flask.ext.cors import cross_origin
11-
from flask.ext.login import current_user, login_required
12-
from flask.ext.principal import Permission
10+
from flask_cors import cross_origin
11+
from flask_login import current_user, login_required
12+
from flask_principal import Permission
1313
from pid import PidFile, PidFileAlreadyLockedError
1414

1515
from ..model import Repository, Roles, Sites
@@ -30,9 +30,10 @@ def commit(repository, filenames):
3030
'commit',
3131
'-m', 'File {} updated'.format(filenames[0]),
3232
])
33-
if not app.config['DEVELOPMENT']:
33+
if not app.debug:
3434
repository.execute(['push'])
3535

36+
3637
def site_lock(f, tries=5, delay=0.2):
3738
@wraps(f)
3839
def decorated_function(**values):
@@ -48,6 +49,7 @@ def decorated_function(**values):
4849
local_delay *= 2
4950
return decorated_function
5051

52+
5153
#site config response
5254
@app.route('/site/<site_id>/config')
5355
@cross_origin()

app/jekylledit/model/auth.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from flask.ext.login import UserMixin
1+
from flask_login import UserMixin
22

33
from .base import JSON, db
44

app/jekylledit/model/base.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import json
22

3-
from flask.ext.migrate import Migrate
4-
from flask.ext.sqlalchemy import SQLAlchemy
3+
from flask_migrate import Migrate
4+
from flask_sqlalchemy import SQLAlchemy
55
from sqlalchemy import MetaData
66
from sqlalchemy.types import TypeDecorator
77

app/jekylledit/settings.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
from os import environ
22

3-
DEBUG = environ.get('FLASK_DEBUG', False)
4-
DEVELOPMENT = environ.get('FLASK_DEVELOPMENT', False)
3+
DEBUG = bool(int(environ.get('FLASK_DEBUG', 0)))
54
PROPAGATE_EXCEPTIONS = True
65
SECRET_KEY = environ['FLASK_SECRET_KEY']
76

8-
if not DEVELOPMENT:
7+
if not DEBUG:
98
GITHUB_SECRET = environ['GITHUB_SECRET']
109
GITKIT_API_KEY = environ['GITKIT_API_KEY']
1110
GITKIT_CLIENT_ID = environ['GITKIT_CLIENT_ID']
@@ -17,8 +16,5 @@
1716
MAILGUN_DOMAIN = environ['MAILGUN_DOMAIN']
1817

1918
SQLALCHEMY_DATABASE_URI = environ['SQLALCHEMY_DATABASE_URI']
20-
if 'SQLALCHEMY_ECHO' in environ:
21-
SQLALCHEMY_ECHO = environ['SQLALCHEMY_ECHO'].lower() == 'true'
22-
else:
23-
SQLALCHEMY_ECHO = DEBUG
19+
SQLALCHEMY_ECHO = bool(int(environ.get('SQLALCHEMY_ECHO', DEBUG)))
2420
SQLALCHEMY_TRACK_MODIFICATIONS = False

app/jekylledit/templates/auth/widget.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
{% endblock title %}
66

77
{% block styles %}
8-
{% if not config['DEVELOPMENT'] %}
8+
{% if not config['DEBUG'] %}
99
<link type="text/css" rel="stylesheet" href="//www.gstatic.com/authtoolkit/css/gitkit.css" />
1010
{% endif %}
1111
{% endblock styles %}
1212

1313
{% block scripts %}
14-
{% if not config['DEVELOPMENT'] %}
14+
{% if not config['DEBUG'] %}
1515
<script type="text/javascript" src="//www.gstatic.com/authtoolkit/js/gitkit.js"></script>
1616
<script type="text/javascript">
1717
window.opener = null;
@@ -25,7 +25,7 @@
2525
{% endblock scripts %}
2626

2727
{% block body %}
28-
{% if not config['DEVELOPMENT'] %}
28+
{% if not config['DEBUG'] %}
2929
<div id="gitkitWidgetDiv"></div>
3030
{% else %}
3131
<form method="POST" action="">

app/requirements.txt

+46-39
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,46 @@
1-
Babel==2.3.4
2-
Flask==0.10.1
3-
Flask-Babel==0.9
4-
Flask-CORS==2.1.2
5-
Flask-Login==0.3.2
6-
Flask-Migrate==1.8.0
7-
Flask-Principal==0.4.0
8-
Flask-SQLAlchemy==2.1
9-
Flask-Script==2.0.5
10-
Flask-WTF==0.12
11-
Jinja2==2.8
12-
Mako==1.0.4
13-
MarkupSafe==0.23
14-
SQLAlchemy==1.0.12
15-
WTForms==2.1
16-
Werkzeug==0.11.9
17-
alembic==0.8.6
18-
blinker==1.4
19-
cffi==1.6.0
20-
cryptography==1.3.1
21-
httplib2==0.9.2
22-
identity-toolkit-python-client==0.1.11
23-
idna==2.1
24-
itsdangerous==0.24
25-
oauth2client==2.0.2
26-
pid==2.0.1
27-
pyOpenSSL==16.0.0
28-
pyasn1==0.1.9
29-
pyasn1-modules==0.0.8
30-
pycparser==2.14
31-
python-editor==1.0
32-
pytz==2016.4
33-
requests==2.10.0
34-
rsa==3.4.2
35-
simplejson==3.8.2
36-
six==1.10.0
37-
speaklater==1.3
38-
uWSGI==2.0.12
39-
python-frontmatter==0.2.1
1+
alembic==0.9.7
2+
asn1crypto==0.24.0
3+
Babel==2.5.3
4+
blinker==1.4
5+
certifi==2018.1.18
6+
cffi==1.11.4
7+
chardet==3.0.4
8+
click==6.7
9+
cryptography==2.1.4
10+
Flask==0.12.2
11+
Flask-Babel==0.11.2
12+
Flask-Cors==3.0.3
13+
Flask-Login==0.4.1
14+
Flask-Migrate==2.1.1
15+
Flask-Principal==0.4.0
16+
Flask-Script==2.0.6
17+
Flask-SQLAlchemy==2.3.2
18+
Flask-WTF==0.14.2
19+
httplib2==0.10.3
20+
identity-toolkit-python-client==0.1.11
21+
idna==2.6
22+
itsdangerous==0.24
23+
Jinja2==2.10
24+
Mako==1.0.7
25+
MarkupSafe==1.0
26+
oauth2client==4.1.2
27+
pid==2.1.1
28+
pkg-resources==0.0.0
29+
pyasn1==0.4.2
30+
pyasn1-modules==0.2.1
31+
pycparser==2.18
32+
pyOpenSSL==17.5.0
33+
python-dateutil==2.6.1
34+
python-editor==1.0.3
35+
python-frontmatter==0.4.2
36+
pytz==2018.3
37+
PyYAML==3.12
38+
requests==2.18.4
39+
rsa==3.4.2
40+
simplejson==3.13.2
41+
six==1.11.0
42+
SQLAlchemy==1.2.2
43+
urllib3==1.22
44+
uWSGI==2.0.16
45+
Werkzeug==0.14.1
46+
WTForms==2.1

0 commit comments

Comments
 (0)