simplification changes in the webinterface: not saving extra html files (not needed in the flask application, they were doubled with the flask templates renderings)
This commit is contained in:
parent
c12598b715
commit
af9336e47c
@ -1,3 +1,2 @@
|
||||
flask
|
||||
etherpump
|
||||
weasyprint
|
||||
|
@ -1,214 +0,0 @@
|
||||
/* CSS for Paged.js interface – v0.2 */
|
||||
|
||||
/* Change the look */
|
||||
:root {
|
||||
--color-background: whitesmoke;
|
||||
--color-pageSheet: #cfcfcf;
|
||||
--color-pageBox: violet;
|
||||
--color-paper: white;
|
||||
--color-marginBox: transparent;
|
||||
--pagedjs-crop-color: black;
|
||||
--pagedjs-crop-shadow: white;
|
||||
--pagedjs-crop-stroke: 1px;
|
||||
}
|
||||
|
||||
/* To define how the book look on the screen: */
|
||||
@media screen {
|
||||
|
||||
/* adding this here from main.css to style the div#nav */
|
||||
div#nav{
|
||||
position: fixed;
|
||||
width: calc(100% - 2em);
|
||||
margin: 1em;
|
||||
text-align: right;
|
||||
left: 0;
|
||||
top: 0;
|
||||
z-index: 999;
|
||||
}
|
||||
div#nav a#home,
|
||||
div#nav a#notes{
|
||||
float: left;
|
||||
padding: 0.25em 0.125em;
|
||||
}
|
||||
div#nav div#loading{
|
||||
display: none;
|
||||
margin: 0.35em 0;
|
||||
color: black;
|
||||
clear: both;
|
||||
float: right;
|
||||
background-color: white;
|
||||
padding: 0.5em 1em;
|
||||
border-radius: 5px;
|
||||
opacity: 0;
|
||||
animation: fade 2s infinite linear;
|
||||
}
|
||||
@keyframes fade {
|
||||
0%,100% { opacity: 0 }
|
||||
50% { opacity: 1 }
|
||||
}
|
||||
|
||||
|
||||
body {
|
||||
background-color: var(--color-background);
|
||||
}
|
||||
|
||||
.pagedjs_pages {
|
||||
display: flex;
|
||||
width: calc(var(--pagedjs-width) * 2);
|
||||
flex: 0;
|
||||
flex-wrap: wrap;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.pagedjs_page {
|
||||
background-color: var(--color-paper);
|
||||
box-shadow: 0 0 0 1px var(--color-pageSheet);
|
||||
margin: 0;
|
||||
flex-shrink: 0;
|
||||
flex-grow: 0;
|
||||
margin-top: 10mm;
|
||||
}
|
||||
|
||||
.pagedjs_first_page {
|
||||
margin-left: var(--pagedjs-width);
|
||||
}
|
||||
|
||||
.pagedjs_page:last-of-type {
|
||||
margin-bottom: 10mm;
|
||||
}
|
||||
|
||||
.pagedjs_pagebox{
|
||||
box-shadow: 0 0 0 1px var(--color-pageBox);
|
||||
}
|
||||
|
||||
.pagedjs_left_page{
|
||||
z-index: 20;
|
||||
width: calc(var(--pagedjs-bleed-left) + var(--pagedjs-pagebox-width))!important;
|
||||
}
|
||||
|
||||
.pagedjs_left_page .pagedjs_bleed-right .pagedjs_marks-crop {
|
||||
border-color: transparent;
|
||||
}
|
||||
|
||||
.pagedjs_left_page .pagedjs_bleed-right .pagedjs_marks-middle{
|
||||
width: 0;
|
||||
}
|
||||
|
||||
.pagedjs_right_page{
|
||||
z-index: 10;
|
||||
position: relative;
|
||||
left: calc(var(--pagedjs-bleed-left)*-1);
|
||||
}
|
||||
|
||||
/* show the margin-box */
|
||||
|
||||
.pagedjs_margin-top-left-corner-holder,
|
||||
.pagedjs_margin-top,
|
||||
.pagedjs_margin-top-left,
|
||||
.pagedjs_margin-top-center,
|
||||
.pagedjs_margin-top-right,
|
||||
.pagedjs_margin-top-right-corner-holder,
|
||||
.pagedjs_margin-bottom-left-corner-holder,
|
||||
.pagedjs_margin-bottom,
|
||||
.pagedjs_margin-bottom-left,
|
||||
.pagedjs_margin-bottom-center,
|
||||
.pagedjs_margin-bottom-right,
|
||||
.pagedjs_margin-bottom-right-corner-holder,
|
||||
.pagedjs_margin-right,
|
||||
.pagedjs_margin-right-top,
|
||||
.pagedjs_margin-right-middle,
|
||||
.pagedjs_margin-right-bottom,
|
||||
.pagedjs_margin-left,
|
||||
.pagedjs_margin-left-top,
|
||||
.pagedjs_margin-left-middle,
|
||||
.pagedjs_margin-left-bottom {
|
||||
box-shadow: 0 0 0 1px inset var(--color-marginBox);
|
||||
}
|
||||
|
||||
/* uncomment this part for recto/verso book : ------------------------------------ */
|
||||
/*
|
||||
|
||||
.pagedjs_pages {
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.pagedjs_first_page {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.pagedjs_page {
|
||||
margin: 0 auto;
|
||||
margin-top: 10mm;
|
||||
}
|
||||
|
||||
.pagedjs_left_page{
|
||||
width: calc(var(--pagedjs-bleed-left) + var(--pagedjs-pagebox-width) + var(--pagedjs-bleed-left))!important;
|
||||
}
|
||||
|
||||
.pagedjs_left_page .pagedjs_bleed-right .pagedjs_marks-crop{
|
||||
border-color: var(--pagedjs-crop-color);
|
||||
}
|
||||
|
||||
.pagedjs_left_page .pagedjs_bleed-right .pagedjs_marks-middle{
|
||||
width: var(--pagedjs-cross-size)!important;
|
||||
}
|
||||
|
||||
.pagedjs_right_page{
|
||||
left: 0;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
/* uncomment this par to see the baseline : -------------------------------------------*/
|
||||
|
||||
/*
|
||||
.pagedjs_pagebox {
|
||||
--pagedjs-baseline: 22px;
|
||||
--pagedjs-baseline-position: 5px;
|
||||
--pagedjs-baseline-color: cyan;
|
||||
background: linear-gradient(transparent 0%, transparent calc(var(--pagedjs-baseline) - 1px), var(--pagedjs-baseline-color) calc(var(--pagedjs-baseline) - 1px), var(--pagedjs-baseline-color) var(--pagedjs-baseline)), transparent;
|
||||
background-size: 100% var(--pagedjs-baseline);
|
||||
background-repeat: repeat-y;
|
||||
background-position-y: var(--pagedjs-baseline-position);
|
||||
} */
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------------------*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Marks (to delete when merge in paged.js) */
|
||||
|
||||
.pagedjs_marks-crop{
|
||||
z-index: 999999999999;
|
||||
|
||||
}
|
||||
|
||||
.pagedjs_bleed-top .pagedjs_marks-crop,
|
||||
.pagedjs_bleed-bottom .pagedjs_marks-crop{
|
||||
box-shadow: 1px 0px 0px 0px var(--pagedjs-crop-shadow);
|
||||
}
|
||||
|
||||
.pagedjs_bleed-top .pagedjs_marks-crop:last-child,
|
||||
.pagedjs_bleed-bottom .pagedjs_marks-crop:last-child{
|
||||
box-shadow: -1px 0px 0px 0px var(--pagedjs-crop-shadow);
|
||||
}
|
||||
|
||||
.pagedjs_bleed-left .pagedjs_marks-crop,
|
||||
.pagedjs_bleed-right .pagedjs_marks-crop{
|
||||
box-shadow: 0px 1px 0px 0px var(--pagedjs-crop-shadow);
|
||||
}
|
||||
|
||||
.pagedjs_bleed-left .pagedjs_marks-crop:last-child,
|
||||
.pagedjs_bleed-right .pagedjs_marks-crop:last-child{
|
||||
box-shadow: 0px -1px 0px 0px var(--pagedjs-crop-shadow);
|
||||
}
|
@ -7,7 +7,7 @@ import jinja2
|
||||
|
||||
STATIC_FOLDER_PATH = './static' # without trailing slash
|
||||
PUBLIC_STATIC_FOLDER_PATH = '/static' # without trailing slash
|
||||
WRAPPING_TEMPLATES_DIR = './wrapping-templates'
|
||||
TEMPLATES_DIR = None
|
||||
|
||||
# This uses a low quality copy of all the images
|
||||
# (using a folder with the name "images-small",
|
||||
@ -180,17 +180,18 @@ def parse_page(pagename, wiki):
|
||||
|
||||
return html
|
||||
|
||||
def save(html, pagename, publication_unfolded):
|
||||
def save(html, pagename):
|
||||
"""
|
||||
html = string (HTML)
|
||||
pagename = string
|
||||
"""
|
||||
if html:
|
||||
if __name__ == "__main__":
|
||||
# command-line
|
||||
|
||||
# save final page that will be used with PagedJS
|
||||
template_file = open(f'{ STATIC_FOLDER_PATH }/{ WRAPPING_TEMPLATES_DIR }/template.html').read()
|
||||
template_file = open(f'{ STATIC_FOLDER_PATH }/{ TEMPLATES_DIR }/template.html').read()
|
||||
template = jinja2.Template(template_file)
|
||||
html = template.render(publication_unfolded=publication_unfolded, title=pagename)
|
||||
html = template.render(publication_unfolded=html, title=pagename)
|
||||
|
||||
html_file = f'{ STATIC_FOLDER_PATH }/{ pagename }.html'
|
||||
print('Saving HTML:', html_file)
|
||||
@ -198,10 +199,10 @@ def save(html, pagename, publication_unfolded):
|
||||
out.write(html)
|
||||
out.close()
|
||||
|
||||
# save extra html page for debugging
|
||||
template_file = open(f'{ STATIC_FOLDER_PATH }/{ WRAPPING_TEMPLATES_DIR }/template.inspect.html').read()
|
||||
# save extra html page for debugging (CLI only)
|
||||
template_file = open(f'{ STATIC_FOLDER_PATH }/{ TEMPLATES_DIR }/template.inspect.html').read()
|
||||
template = jinja2.Template(template_file)
|
||||
html = template.render(publication_unfolded=publication_unfolded, title=pagename)
|
||||
html = template.render(publication_unfolded=html, title=pagename)
|
||||
|
||||
html_file = f'{ STATIC_FOLDER_PATH }/{ pagename }.inspect.html'
|
||||
print('Saving HTML:', html_file)
|
||||
@ -209,6 +210,12 @@ def save(html, pagename, publication_unfolded):
|
||||
out.write(html)
|
||||
out.close()
|
||||
|
||||
else:
|
||||
# Flask application
|
||||
|
||||
with open(f'{ STATIC_FOLDER_PATH }/Unfolded.html', 'w') as out:
|
||||
out.write(html) # save the html to a file (without <head>)
|
||||
|
||||
def update_material_now(pagename, wiki):
|
||||
"""
|
||||
pagename = string
|
||||
@ -226,5 +233,5 @@ if __name__ == "__main__":
|
||||
pagename = 'Unfolded'
|
||||
|
||||
publication_unfolded = update_material_now(pagename, wiki) # download the latest version of the page
|
||||
save(publication_unfolded, pagename, publication_unfolded) # save the page to file
|
||||
save(publication_unfolded, pagename) # save the page to file
|
||||
|
||||
|
@ -22,51 +22,50 @@ STYLESHEET = 'print.css'
|
||||
# ---
|
||||
|
||||
|
||||
def download(STYLESHEET):
|
||||
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
|
||||
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('flask/index.html', title=PROJECT_NAME)
|
||||
return flask.render_template('index.html', title=PROJECT_NAME)
|
||||
|
||||
@APP.route('/notes/', methods=['GET'])
|
||||
def notes():
|
||||
return flask.render_template('flask/notes.html')
|
||||
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
|
||||
with open(f'{ DIR_PATH }/static/Unfolded.html', 'w') as out:
|
||||
out.write(publication_unfolded) # save the html (without <head>) to file
|
||||
save(publication_unfolded, 'Unfolded') # save the html to file (without <head>) to file
|
||||
|
||||
return flask.render_template('flask/index.html', title=PROJECT_NAME)
|
||||
return flask.render_template('index.html', title=PROJECT_NAME)
|
||||
|
||||
@APP.route('/pagedjs/', methods=['GET', 'POST'])
|
||||
def pagedjs():
|
||||
download(STYLESHEET) # download the stylesheet pad
|
||||
download_stylesheet() # download the stylesheet pad
|
||||
publication_unfolded = open(f'{ DIR_PATH }/static/Unfolded.html', 'r').read()
|
||||
|
||||
return flask.render_template('flask/pagedjs.html', publication_unfolded=publication_unfolded, STYLESHEET=STYLESHEET)
|
||||
return flask.render_template('pagedjs.html', publication_unfolded=publication_unfolded)
|
||||
|
||||
@APP.route('/inspect/', methods=['GET', 'POST'])
|
||||
def inspect():
|
||||
download(STYLESHEET) # download the stylesheet pad
|
||||
download_stylesheet() # download the stylesheet pad
|
||||
publication_unfolded = open(f'{ DIR_PATH }/static/Unfolded.html', 'r').read()
|
||||
|
||||
return flask.render_template('flask/inspect.html', publication_unfolded=publication_unfolded, STYLESHEET=STYLESHEET)
|
||||
return flask.render_template('inspect.html', publication_unfolded=publication_unfolded)
|
||||
|
||||
@APP.route('/stylesheet/', methods=['GET'])
|
||||
def stylesheet():
|
||||
return flask.render_template('flask/stylesheet.html')
|
||||
return flask.render_template('stylesheet.html')
|
||||
|
||||
if __name__ == '__main__':
|
||||
APP.debug=True
|
||||
|
Loading…
Reference in New Issue
Block a user