import codecs
import os
import config.env as env
css_md_content = ""
with codecs.open(env.css_md_path, encoding=env.encoding, mode="r") as css:
css_md_content = css.read()
css_index_content = ""
with codecs.open(env.css_index_path, encoding=env.encoding, mode="r") as css:
css_index_content = css.read()
html_header = (
"""
"""
)
html_footer = """
"""
style_basic = """
@media (prefers-color-scheme: dark) {
/* this is the github markdown dark background */
html { background-color: #0d1117; }
}
body {
width: 92%; max-width: 40em; margin: auto;
font-size: 1.2rem; line-height: 1.5; padding-bottom: 3em;}
code { font-family: "DejaVu Sans Mono", Consolas, monospace; }
pre { overflow: auto; }
math, .LaTeX { font-size: 1.1em; }
div.figure .caption { padding: 0em 1em 1em; font-size: 0.8em; }
ul li { list-style-type: disc; }
li p { margin: 0.5em 0; }
#TOC { border: 1px solid lightgray; padding: 0.5em; margin-bottom: 1em;}
#TOC li { list-style: circle; }
#TOC > ul { margin-bottom: 0px }
@media (min-width: 102em) {
body { position: relative; }
#TOC { display: block; position: absolute; left: -50%; top: 5em; max-width: 46%; width: 45%; }
}
"""
style_document_add = """
@media (max-width: 101em) {
#TOC { display: none; }
}
.topmenu { font-size: 1em; color: lightgrey; }
.topmenu a { color: lightgrey; }
"""
style_index = """
ul.file-listing a { text-decoration: none; }
ul.file-listing ul.file-listing { padding-left: 1.5em; }
ul li.dir-entry {
list-style-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAApElEQVQ4je3UsQqBYRTG8Z9SMpjsrsAdYMI1WNyDhdnKriiD1U3YXML3SWE3uAgDX+lF8iqlPPX01qnn/55OncMvqYMUSeA1KjHAFKUH9S7GMcDkSb2Jk/vOQ2/QhzKq2F/fd52/ftzCBKZYYRnhA2ohcIb6m+PJdJv9A//AT4GND4BZtp0BBxgiFwG8zY7QgyIWLsv96gCE3uKIHeYoRDT1ZZ0BsR1JIXdX8A8AAAAASUVORK5CYII=');
}
ul li.file-entry{
list-style-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAA00lEQVQ4jcXUQUqCURSG4Qc0bKaUiKsIhEbazMBhOHILES3EUYIGtpBwlDODhhFCTqQdtIYGf5H+eOVeFP4P3ul7L4fzHbZziQme9jDEqYhU8IkervbwjecYaRPziIeXuIuRNvESKRQjjRV+4f6XN8xQPkQ4wO0Ga9QPEeazKER4gi6uA3T9zy1KeCZb8McAY1RThCkpRtjAh2yJd/EuG0txPzy68BxT4RM2RS1FWEZH+IS1UUoRpuQ1JPw7sDfCDcnTx0rWrJ1pYSTckDwPuNgU/ADJ7ku1B60bXwAAAABJRU5ErkJggg==');
}
@media (prefers-color-scheme: dark) {
ul li.dir-entry {
list-style-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAmklEQVR42mMYOuD////hQHwViK+g4SNALEeygVDDeLGIxwBxJzkGXsEh7gzEb0DyBPA1IC4BaRAGYh0gvgOiycAsUItdgHgKiDEdiPcC8Qoy8F0gtkY3cAYQ25ARj3C9VDJw1MBRA20pMNAWynaFGVgKxPVAzEi6gQi9QNwBxPkgQU4gng/N3FdIxDeA+AUQ3wbi2UDMzjDoAQBZ7/p98kNklQAAAABJRU5ErkJggg==');
}
ul li.file-entry{
list-style-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAwElEQVR42tzUAQbCUBzH8UebAsqadI0I1ICNAAl0haSDBIo2toMkUEARIBkF6QZdYX0R/ug9m0kMH/zhy+/hqSzLpD5CJAZLNKC+kUcdN4zgGbyw1UXl0cUBygQp5iJqDO5zBpWMlg0+sfg4YwerTHCKmfCAWzyod/xL0IaPQMOHVSToIESksUFTBCvwhh1ckWpc4FRrchsxEo0YrSJBC0N4GgPUfjX5BNf0wY4R5DTBHbYMSj2sEeW0wnt6yGYAAAiM90EeJ53sAAAAAElFTkSuQmCC');
}
}
"""
#markdown_css_link= """"""
def show_nested_files(files):
subdirectory_files = files[1]
text = ''
for nested in subdirectory_files:
if type(nested) is str:
text += f'
{os.path.basename(nested)}'
reportable_dirs = [item + '\\' for item in []]
if any([directory in nested for directory in reportable_dirs]):
text += f' [report]'
text += '
'
elif type(nested) is tuple:
path = nested[0]
text += '
' + os.path.basename(path) + '
'
text += show_nested_files(nested)
text = '
' + text + '
'
return text
def index(files):
text = ""
text += "Server Index"
text += ''.format(style_basic + style_index)
text += """""".format(style_basic + style_index)
text += ""
text += '
Testing documentation for Dipal:
'
text += "
Directory contents
"
text += show_nested_files(files)
text += ''
return text
def render_file_entry(nested):
filename = os.path.basename(nested)
link = f'{filename}'
report_link = f' [report]' if 'compiled\\' in nested else ''
return f'