|
@@ -6,15 +6,77 @@ Website for Craftbroec RR stuff
|
|
|
import os
|
|
|
import hashlib
|
|
|
import hmac
|
|
|
-from subprocess import call
|
|
|
+import subprocess
|
|
|
+import shutil
|
|
|
|
|
|
-from flask import jsonify, abort, request
|
|
|
+from flask import jsonify, abort, request, send_from_directory
|
|
|
from app import app
|
|
|
|
|
|
|
|
|
@app.route('/')
|
|
|
def index():
|
|
|
"""Show index page"""
|
|
|
+ return send_from_directory('static', 'index.html')
|
|
|
+
|
|
|
+
|
|
|
+@app.route("/tutorial")
|
|
|
+@app.route("/tutorial/book")
|
|
|
+def tutorial_book():
|
|
|
+ """Display book"""
|
|
|
+ return send_from_directory('static', 'tutorial/book.pdf')
|
|
|
+
|
|
|
+
|
|
|
+@app.route("/tutorial/article")
|
|
|
+def tutorial_article():
|
|
|
+ """Display book"""
|
|
|
+ return send_from_directory('static', 'tutorial/article.pdf')
|
|
|
+
|
|
|
+
|
|
|
+@app.route("/tutorial/dist")
|
|
|
+def tutorial_dist():
|
|
|
+ """Display book"""
|
|
|
+ return send_from_directory('static', 'tutorial/dist.pdf')
|
|
|
+
|
|
|
+
|
|
|
+@app.route("/tutorial.png")
|
|
|
+def tutorial_dist_png():
|
|
|
+ """Display book"""
|
|
|
+ return send_from_directory('static', 'tutorial/dist.png')
|
|
|
+
|
|
|
+
|
|
|
+@app.route('/typeset', methods=['GET', 'POST'])
|
|
|
+def typeset():
|
|
|
+ """Show index page"""
|
|
|
+ working_dir = os.getcwd()
|
|
|
+ if os.path.basename(working_dir) == 'rr':
|
|
|
+ os.chdir('rr_tutorial')
|
|
|
+
|
|
|
+ book_toc_size = os.path.getsize('master_book.toc')
|
|
|
+ article_toc_size = os.path.getsize('master_article.toc')
|
|
|
+ dist_toc_size = os.path.getsize('master_dist.toc')
|
|
|
+
|
|
|
+ subprocess.check_output(['xelatex', '-halt-on-error', 'master_book.tex'])
|
|
|
+ subprocess.check_output(['xelatex', '-halt-on-error', 'master_article.tex'])
|
|
|
+ subprocess.check_output(['./set.sh'])
|
|
|
+
|
|
|
+ if book_toc_size != os.path.getsize('master_book.toc'):
|
|
|
+ subprocess.check_output(['xelatex', '-halt-on-error', 'master_book.tex'])
|
|
|
+
|
|
|
+ if article_toc_size != os.path.getsize('master_article.toc'):
|
|
|
+ subprocess.check_output(['xelatex', '-halt-on-error', 'master_article.tex'])
|
|
|
+
|
|
|
+ if dist_toc_size != os.path.getsize('master_dist.toc'):
|
|
|
+ subprocess.check_output(['./set.sh'])
|
|
|
+
|
|
|
+
|
|
|
+ shutil.copyfile('master_book.pdf', '../app/static/tutorial/book.pdf')
|
|
|
+ shutil.copyfile('master_article.pdf', '../app/static/tutorial/article.pdf')
|
|
|
+ shutil.copyfile('master_dist.pdf', '../app/static/tutorial/dist.pdf')
|
|
|
+
|
|
|
+ subprocess.check_output(['./convert.sh'])
|
|
|
+ shutil.copyfile('master_dist.png', '../app/static/tutorial/dist.png')
|
|
|
+
|
|
|
+ os.chdir(working_dir)
|
|
|
return jsonify(True)
|
|
|
|
|
|
|
|
@@ -27,6 +89,7 @@ def deploy():
|
|
|
if len(signature) < 2 or not hmac.compare_digest(signature, digest):
|
|
|
abort(400, 'Invalid signature')
|
|
|
|
|
|
- call(['git', 'pull'])
|
|
|
- call(['touch', 'flask.wsgi'])
|
|
|
+ subprocess.call(['pipenv', 'sync'])
|
|
|
+ subprocess.call(['git', 'pull'])
|
|
|
+ subprocess.call(['touch', 'flask.wsgi'])
|
|
|
return jsonify(True)
|