diff options
author | Zhiming Wang <zmwangx@gmail.com> | 2015-07-17 12:31:06 -0700 |
---|---|---|
committer | Zhiming Wang <zmwangx@gmail.com> | 2015-07-17 12:31:06 -0700 |
commit | effd834bd74c3b6a25ebaf59adcab6bd6d29cbdc (patch) | |
tree | 8d73b5f8a552383ff7da55659ed3e50679463001 /pyblog | |
parent | e37944f4a78ba4d2695eeec75b25b1c20aeef933 (diff) | |
download | my_new_personal_website-effd834bd74c3b6a25ebaf59adcab6bd6d29cbdc.tar.xz my_new_personal_website-effd834bd74c3b6a25ebaf59adcab6bd6d29cbdc.zip |
index.html TOC: use <table> instead of <ul>
For better formatting.
The following screenshots illustrate the difference:
* https://i.imgur.com/ZfkUpBG.png
* https://i.imgur.com/S6cRK00.png
I also reduced the indentation on the left of each year's index from 2em
to 1em.
Diffstat (limited to 'pyblog')
-rwxr-xr-x | pyblog | 22 |
1 files changed, 17 insertions, 5 deletions
@@ -292,19 +292,31 @@ def generate_index(feed): tocbuff.write('<div class="indextoc" id="toc">') year = 10000 # will be larger than the latest year for quite a while # recall that entries are in reverse chronological order + table_opened = False for entry in feed.entries: date = entry.updated_datetime if date.year < year: + # close the previous table if there is one + if table_opened: + tocbuff.write(u'</table>\n') # write a new <h2 class="toc"> tag with the smaller year year = date.year tocbuff.write(u'\n<h2 class="toc" id="{0}">{0}</h2>\n\n'.format(year)) - - # write a new <li> entry (<ul>) in Markdown, in the format: - # * <time class="tocdate" datetime="2015-05-05T00:06:04-0700">May 5</time> - # [Blah blah](/blog/2015-05-04-blah-blah.html) + tocbuff.write(u'<table>\n') + table_opened = True + + # write a new table row entry in Markdown, in the format: + # + # <tr> + # <td class="date"><time class="tocdate" datetime="2015-05-05T00:06:04-0700">May 5</time></td> + # <td class="title">[Blah blah](/blog/2015-05-04-blah-blah.html)</td> + # </tr> monthday = date.strftime("%b %d") - tocbuff.write(u'* <time class="tocdate" datetime="%s">%s</time> [%s](%s)\n' % + tocbuff.write(u'<tr><td class="date"><time class="tocdate" datetime="%s">%s</time></td>' + '<td class="title">[%s](%s)</td></tr>\n' % (date.isoformat(), monthday, entry.title_text, entry.relpath)) + if table_opened: + tocbuff.write(u'</table>\n') tocbuff.write('</div>') # create tempfile with index.md and the TOC concatenated, and generate index.html from that |