adding booklet.py

main
mb 2 years ago
parent 010f0e232a
commit 9f72fb2430

@ -1 +1,68 @@
print("hello!") from glob import glob
import os
# https://devdocs.io/python~3.9/library/glob#glob.glob
files = glob("content/**", recursive=True)
print(files)
print("---------")
for file in files:
#print(file)
if file.endswith(".md"):
print("===========")
print(file)
html_file = file.replace(".md", ".html")
pandoc_cmd = "pandoc -f markdown -t html " + file + " -o " + html_file
print(pandoc_cmd)
# pandoc_cmd = f"pandoc -f markdown -t html { file } -o { html_file }"
#os.system(pandoc_cmd)
print("html file saved!")
# ---------------
# We find all the HTML files,
# read the content,
# and then collect all that content into a variable called "all_html"
html_files = glob("content/**", recursive=True)
print("---------")
all_html = ""
for html_file in html_files:
if html_file.endswith(".html"):
print(html_file)
# open the html file and read the content
html = open(html_file).read()
# add this content to all_html
all_html = all_html + html
print("----------")
print(all_html)
template = f"""<!DOCTYPE html>
<html>
<head>
<script src="paged.js/paged.polyfill.js"></script>
<link href="paged.js/pagedjs.css" rel="stylesheet" type="text/css">
<link href="print.css" rel="stylesheet" type="text/css" media="print">
</head>
<body>
{ all_html }
</body>
</html>
"""
output = open("booklet.html", "w")
output.write(template)
# Now open this page in the browser, remember: paged.js needs to be accessed through a webserver.
# To run a webserver locally, you can use:
# cd SI20/booklet/
# python3 -m http.server
# localhost:8000/booklet.html

File diff suppressed because it is too large Load Diff

@ -0,0 +1,214 @@
/* 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);
}
Loading…
Cancel
Save