Tools for generating the Volumetric Regimes book https://volumetricregimes.xyz/ (wiki-to-print, using Paged.js)
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
2.5 KiB
72 lines
2.5 KiB
import flask
|
|
import urllib, json
|
|
import os
|
|
from update import *
|
|
|
|
# To add: server feedback (logging + capacity) using socket io in Flask
|
|
# https://towardsdatascience.com/how-to-add-on-screen-logging-to-your-flask-application-and-deploy-it-on-aws-elastic-beanstalk-aa55907730f
|
|
|
|
# Create the application.
|
|
APP = flask.Flask(__name__)
|
|
|
|
# ---
|
|
|
|
PROJECT_NAME = 'volumetric-regimes'
|
|
DIR_PATH = '.' # without trailing slash
|
|
PORTNUMBER = 5522
|
|
WIKI = 'https://possiblebodies.constantvzw.org/book' # remove tail slash '/'
|
|
PAGENAME = 'Unfolded'
|
|
STYLESHEET_PAD = 'volumetric-regimes.css'
|
|
STYLESHEET = 'print.css'
|
|
|
|
# ---
|
|
|
|
|
|
def download_stylesheet():
|
|
# using etherpump
|
|
os.system(f'{ DIR_PATH }/venv/bin/etherpump gettext { STYLESHEET_PAD } > { DIR_PATH }/static/css/{ STYLESHEET }')
|
|
|
|
@APP.route('/', methods=['GET'])
|
|
def pad():
|
|
if not os.path.exists(f'{ DIR_PATH }/static/Unfolded.html'):
|
|
download_stylesheet() # download the stylesheet pad
|
|
publication_unfolded = update_material_now(PAGENAME, WIKI) # download the latest version of the page
|
|
with open(f'{ DIR_PATH }/static/Unfolded.html', 'w') as out:
|
|
out.write(publication_unfolded) # save the html (without <head>) to file
|
|
else:
|
|
publication_unfolded = open(f'{ DIR_PATH }/static/Unfolded.html', 'r').read()
|
|
|
|
return flask.render_template('index.html', title=PROJECT_NAME)
|
|
|
|
@APP.route('/notes/', methods=['GET'])
|
|
def notes():
|
|
return flask.render_template('notes.html')
|
|
|
|
@APP.route('/update/', methods=['GET', 'POST'])
|
|
def update():
|
|
publication_unfolded = update_material_now(PAGENAME, WIKI) # download the latest version of the page
|
|
save(publication_unfolded, 'Unfolded') # save the html to file (without <head>) to file
|
|
|
|
return flask.render_template('index.html', title=PROJECT_NAME)
|
|
|
|
@APP.route('/pagedjs/', methods=['GET', 'POST'])
|
|
def pagedjs():
|
|
download_stylesheet() # download the stylesheet pad
|
|
publication_unfolded = open(f'{ DIR_PATH }/static/Unfolded.html', 'r').read()
|
|
|
|
return flask.render_template('pagedjs.html', publication_unfolded=publication_unfolded)
|
|
|
|
@APP.route('/inspect/', methods=['GET', 'POST'])
|
|
def inspect():
|
|
download_stylesheet() # download the stylesheet pad
|
|
publication_unfolded = open(f'{ DIR_PATH }/static/Unfolded.html', 'r').read()
|
|
|
|
return flask.render_template('inspect.html', publication_unfolded=publication_unfolded)
|
|
|
|
@APP.route('/stylesheet/', methods=['GET'])
|
|
def stylesheet():
|
|
return flask.render_template('stylesheet.html')
|
|
|
|
if __name__ == '__main__':
|
|
APP.debug=True
|
|
APP.run(port=f'{ PORTNUMBER }')
|
|
|