From e68048797483a3e5cc5e1dc114a80a7af8fecbb9 Mon Sep 17 00:00:00 2001 From: Zhiming Wang Date: Sun, 26 Jul 2015 21:58:01 -0700 Subject: tons of logic and performance improvements The main aim is a more logical DOM structure and more performant CSS. --- pyblog | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'pyblog') diff --git a/pyblog b/pyblog index 0cba605a..8f8e19d0 100755 --- a/pyblog +++ b/pyblog @@ -289,7 +289,7 @@ def generate_index(feed): # generate TOC tocbuff = io.StringIO() - tocbuff.write('
') + tocbuff.write('
') year = 10000 # will be larger than the latest year for quite a while # recall that entries are in reverse chronological order table_opened = False @@ -299,21 +299,21 @@ def generate_index(feed): # close the previous table if there is one if table_opened: tocbuff.write(u'\n') - # write a new

tag with the smaller year + # write a new

tag with the smaller year year = date.year - tocbuff.write(u'\n

{0}

\n\n'.format(year)) - tocbuff.write(u'\n') + tocbuff.write(u'\n

{0}

\n\n'.format(year)) + tocbuff.write(u'
\n') table_opened = True # write a new table row entry in Markdown, in the format: # # - # - # + # + # # monthday = date.strftime("%b %d") - tocbuff.write(u'' - '\n' % + tocbuff.write(u'' + '\n' % (date.isoformat(), monthday, entry.title_text, entry.relpath)) if table_opened: tocbuff.write(u'
[Blah blah](/blog/2015-05-04-blah-blah.html)[Blah blah](/blog/2015-05-04-blah-blah.html)
[%s](%s)
[%s](%s)
\n') @@ -395,8 +395,8 @@ def generate_sitemap(feed): updated = None with open(fullpath, encoding="utf-8") as htmlobj: soup = bs4.BeautifulSoup(htmlobj.read(), "lxml") - if soup.article.footer is not None: - updated_tag = soup.article.footer.find(attrs={"class": "updated"}) + if soup.footer is not None: + updated_tag = soup.footer.find(attrs={"class": "updated"}) if updated_tag is not None: updated = dateutil.parser.parse(updated_tag.text) sitemap.append(make_sitemap_url_element(link, updated, "monthly", 0.9)) @@ -518,8 +518,6 @@ def generate_index_and_feed(): article = soup.article if article.header is not None: tags_to_remove.append(article.header) - if article.footer is not None: - tags_to_remove.append(article.footer) # mark line numbers for removal for line_number_span in article.find_all("span", attrs={"class": "line-number"}): -- cgit v1.2.1