Skip to content

Commit

Permalink
Modernize.
Browse files Browse the repository at this point in the history
  • Loading branch information
keosak committed Feb 13, 2018
1 parent df31c28 commit b6db696
Show file tree
Hide file tree
Showing 18 changed files with 106 additions and 284 deletions.
79 changes: 0 additions & 79 deletions activate

This file was deleted.

21 changes: 10 additions & 11 deletions app/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
FROM debian:8
FROM debian:9
ENV DEBIAN_FRONTEND noninteractive

ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
ENV VIRTUAL_ENV=/usr/local
ENV FLASK_APP=/usr/local/src/jekylledit/jekylledit/__init__.py
WORKDIR /usr/local/src/jekylledit
EXPOSE 8000

RUN apt-get -qq update && apt-get -qq -y --no-install-recommends install \
Expand All @@ -16,15 +20,10 @@ RUN apt-get -qq update && apt-get -qq -y --no-install-recommends install \
rsync \
ssh

COPY requirements.txt /venv/requirements.txt
RUN python3 -m venv /venv \
&& /venv/bin/pip install -r /venv/requirements.txt \
&& /venv/bin/pip freeze > /venv/requirements-freezed.txt
COPY requirements.txt /tmp/requirements.txt
RUN python3 -m venv /usr/local \
&& /usr/local/bin/pip install -r /tmp/requirements.txt

RUN git config --global push.default matching

COPY . /venv/app

ARG VERSION
ARG SETUP_MODE
RUN /venv/app/setup.sh $VERSION $SETUP_MODE
COPY jekylledit /usr/local/src/jekylledit/jekylledit
27 changes: 0 additions & 27 deletions app/jekylledit/__main__.py

This file was deleted.

10 changes: 5 additions & 5 deletions app/jekylledit/controllers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

from flask import Blueprint, _request_ctx_stack, abort, jsonify, make_response, \
redirect, render_template, request, url_for
from flask.ext.login import LoginManager, current_user, login_user, logout_user
from flask.ext.principal import Identity, Permission, PermissionDenied, Principal
from flask_login import LoginManager, current_user, login_user, logout_user
from flask_principal import Identity, Permission, PermissionDenied, Principal
from ..ext.identitytoolkit import Gitkit
from itsdangerous import URLSafeTimedSerializer

Expand All @@ -20,7 +20,7 @@
blueprint = Blueprint('auth', __name__)
login_manager = LoginManager(app)
principal = Principal(app, use_sessions=False, skip_static=True)
if not app.config['DEVELOPMENT']:
if not app.debug:
gitkit = Gitkit(app, {
'widget': 'auth.widget',
'sign_in_success': 'auth.sign_in_success',
Expand Down Expand Up @@ -88,7 +88,7 @@ def permission_denied(exc):

@blueprint.route('/widget', methods={'GET', 'POST'})
def widget():
if app.config['DEVELOPMENT']:
if app.debug:
if request.method == 'GET':
return render_template('auth/widget.html')
email = request.form['email']
Expand Down Expand Up @@ -171,7 +171,7 @@ def sign_out():
logout_user()
text = render_template('auth/close-window.html', message='You have signed out.')
response = make_response(text)
if not app.config['DEVELOPMENT']:
if not app.debug:
gitkit.delete_token(response)
return response

Expand Down
6 changes: 3 additions & 3 deletions app/jekylledit/controllers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from urllib.parse import urlparse

from flask import Flask, request, url_for
from flask.ext.babel import Babel
from flask_babel import Babel
from ..ext.mailgun import Mailgun
from ..ext.normalizeUnicode import normalizeUnicode

Expand All @@ -15,7 +15,7 @@


babel = Babel(app)
if not app.config['DEVELOPMENT']:
if not app.debug:
mailgun = Mailgun(app)
else:
mailgun = None
Expand Down Expand Up @@ -51,7 +51,7 @@ def mtime(dir, path):

@app.template_global()
def url_for_js(name):
if app.config['DEVELOPMENT']:
if app.debug:
host = urlparse(request.url).hostname
return 'http://%s:9810/compile?id=%s-debug' % (host, name)
return url_for('static', filename='js/{}.js'.format(name))
10 changes: 6 additions & 4 deletions app/jekylledit/controllers/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import hmac

from flask import abort, json, jsonify, request, render_template
from flask.ext.cors import cross_origin
from flask.ext.login import current_user, login_required
from flask.ext.principal import Permission
from flask_cors import cross_origin
from flask_login import current_user, login_required
from flask_principal import Permission
from pid import PidFile, PidFileAlreadyLockedError

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


def site_lock(f, tries=5, delay=0.2):
@wraps(f)
def decorated_function(**values):
Expand All @@ -48,6 +49,7 @@ def decorated_function(**values):
local_delay *= 2
return decorated_function


#site config response
@app.route('/site/<site_id>/config')
@cross_origin()
Expand Down
2 changes: 1 addition & 1 deletion app/jekylledit/model/auth.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flask.ext.login import UserMixin
from flask_login import UserMixin

from .base import JSON, db

Expand Down
4 changes: 2 additions & 2 deletions app/jekylledit/model/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json

from flask.ext.migrate import Migrate
from flask.ext.sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import MetaData
from sqlalchemy.types import TypeDecorator

Expand Down
10 changes: 3 additions & 7 deletions app/jekylledit/settings.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from os import environ

DEBUG = environ.get('FLASK_DEBUG', False)
DEVELOPMENT = environ.get('FLASK_DEVELOPMENT', False)
DEBUG = bool(int(environ.get('FLASK_DEBUG', 0)))
PROPAGATE_EXCEPTIONS = True
SECRET_KEY = environ['FLASK_SECRET_KEY']

if not DEVELOPMENT:
if not DEBUG:
GITHUB_SECRET = environ['GITHUB_SECRET']
GITKIT_API_KEY = environ['GITKIT_API_KEY']
GITKIT_CLIENT_ID = environ['GITKIT_CLIENT_ID']
Expand All @@ -17,8 +16,5 @@
MAILGUN_DOMAIN = environ['MAILGUN_DOMAIN']

SQLALCHEMY_DATABASE_URI = environ['SQLALCHEMY_DATABASE_URI']
if 'SQLALCHEMY_ECHO' in environ:
SQLALCHEMY_ECHO = environ['SQLALCHEMY_ECHO'].lower() == 'true'
else:
SQLALCHEMY_ECHO = DEBUG
SQLALCHEMY_ECHO = bool(int(environ.get('SQLALCHEMY_ECHO', DEBUG)))
SQLALCHEMY_TRACK_MODIFICATIONS = False
6 changes: 3 additions & 3 deletions app/jekylledit/templates/auth/widget.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
{% endblock title %}

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

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

{% block body %}
{% if not config['DEVELOPMENT'] %}
{% if not config['DEBUG'] %}
<div id="gitkitWidgetDiv"></div>
{% else %}
<form method="POST" action="">
Expand Down
85 changes: 46 additions & 39 deletions app/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,39 +1,46 @@
Babel==2.3.4
Flask==0.10.1
Flask-Babel==0.9
Flask-CORS==2.1.2
Flask-Login==0.3.2
Flask-Migrate==1.8.0
Flask-Principal==0.4.0
Flask-SQLAlchemy==2.1
Flask-Script==2.0.5
Flask-WTF==0.12
Jinja2==2.8
Mako==1.0.4
MarkupSafe==0.23
SQLAlchemy==1.0.12
WTForms==2.1
Werkzeug==0.11.9
alembic==0.8.6
blinker==1.4
cffi==1.6.0
cryptography==1.3.1
httplib2==0.9.2
identity-toolkit-python-client==0.1.11
idna==2.1
itsdangerous==0.24
oauth2client==2.0.2
pid==2.0.1
pyOpenSSL==16.0.0
pyasn1==0.1.9
pyasn1-modules==0.0.8
pycparser==2.14
python-editor==1.0
pytz==2016.4
requests==2.10.0
rsa==3.4.2
simplejson==3.8.2
six==1.10.0
speaklater==1.3
uWSGI==2.0.12
python-frontmatter==0.2.1
alembic==0.9.7
asn1crypto==0.24.0
Babel==2.5.3
blinker==1.4
certifi==2018.1.18
cffi==1.11.4
chardet==3.0.4
click==6.7
cryptography==2.1.4
Flask==0.12.2
Flask-Babel==0.11.2
Flask-Cors==3.0.3
Flask-Login==0.4.1
Flask-Migrate==2.1.1
Flask-Principal==0.4.0
Flask-Script==2.0.6
Flask-SQLAlchemy==2.3.2
Flask-WTF==0.14.2
httplib2==0.10.3
identity-toolkit-python-client==0.1.11
idna==2.6
itsdangerous==0.24
Jinja2==2.10
Mako==1.0.7
MarkupSafe==1.0
oauth2client==4.1.2
pid==2.1.1
pkg-resources==0.0.0
pyasn1==0.4.2
pyasn1-modules==0.2.1
pycparser==2.18
pyOpenSSL==17.5.0
python-dateutil==2.6.1
python-editor==1.0.3
python-frontmatter==0.4.2
pytz==2018.3
PyYAML==3.12
requests==2.18.4
rsa==3.4.2
simplejson==3.13.2
six==1.11.0
SQLAlchemy==1.2.2
urllib3==1.22
uWSGI==2.0.16
Werkzeug==0.14.1
WTForms==2.1
Loading

0 comments on commit b6db696

Please sign in to comment.