new front page layout

This commit is contained in:
gauthiier 2017-06-29 17:25:19 +02:00
parent 40ec5db009
commit d818035d16
3 changed files with 37 additions and 7 deletions

View File

@ -25,8 +25,25 @@ table td {
padding: 1em;
}
table td h1 {
bborder: 1px red solid;
margin-top: 0.4em;
margin-bottom: 0.2em;
}
table td p {
bborder: 1px red solid;
margin-top: 0.1em;
margin-bottom: 0.4em;
}
table tr {
text-align: center;
}
table td img {
width: 20em;
width: 100%;
border: 2px grey ridge;
}

View File

@ -3,8 +3,10 @@
<td>
[[text_md]]
</td>
</tr>
<tr>
<td>
[[link_md]]
[[link_md]]
</td>
</tr>
</table>

21
gen.py
View File

@ -26,7 +26,13 @@ def translate(txt, dirname):
print('error opening <table> file. aborting...');
sys.exit(0);
[text, link] = txt.split('- - -');
href = None
sections = txt.count('- - -');
if sections == 1:
[text, link] = txt.split('- - -');
elif sections == 2:
[text, link, href] = txt.split('- - -');
text_md = markdown.markdown(text);
link_md = markdown.markdown(link);
@ -34,7 +40,11 @@ def translate(txt, dirname):
link_md = link_md.replace('data/', dirname + '/');
out = table.read().replace('[[text_md]]', text_md);
return out.replace('[[link_md]]', link_md);
out = out.replace('[[link_md]]', link_md);
if href:
href = href.replace('data/', dirname + '/');
out = "<a " + href + ">" + out + "</a>";
return out
def escape_date(dirname):
return re.sub('^20\d{2}?.', '', dirname)
@ -63,7 +73,8 @@ def index_content(dir_name, data_dir, index_txt, desc_txt, template):
# desc_txt is a markdown file containing description
# for the project - no layout applied to it, only md
if desc_txt:
desc_md = None
if os.path.isfile(desc_txt):
try:
desc_file = open(desc_txt, 'r+');
desc_md = markdown.markdown(desc_file.read());
@ -76,8 +87,8 @@ def index_content(dir_name, data_dir, index_txt, desc_txt, template):
# index_txt is a json file containing one thing:
# an array of files names or glob patterns
if index_txt:
content_index = None
if os.path.isfile(index_txt):
try:
index_file = open(index_txt, 'r+');
content_index = json.loads(index_file.read());