diff options
author | neodarz <neodarz@neodarz.net> | 2017-06-20 19:12:18 +0200 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2017-06-20 19:12:18 +0200 |
commit | c20f7b3cedc878d90416cd3bf72f03d08ec1909c (patch) | |
tree | e259388914070c2f3d2597c423854127a2ab3721 /pyblog | |
parent | 6dbdf013628321f9996efe4a90eaa03b8a8875a4 (diff) | |
download | my_new_personal_website-c20f7b3cedc878d90416cd3bf72f03d08ec1909c.tar.xz my_new_personal_website-c20f7b3cedc878d90416cd3bf72f03d08ec1909c.zip |
Fix list order
Diffstat (limited to '')
-rwxr-xr-x | pyblog | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -309,7 +309,7 @@ def generate_menu(): # Generate the string who contain the links of the menu htmly_website_page = "<ul>" - for name in os.listdir(os.path.join(BUILDDIR, "website")): + for name in sorted(os.listdir(os.path.join(BUILDDIR, "website"))): if name != "Documents": htmly_website_page += "<a href='/website/"+name+"' class='lia'><li><span class='left-lia'></span><span class='center-lia'>"+name.split('.html')[0]+"</span><span class='right-lia'></span></li></a>" htmly_website_page += "</ul>" @@ -348,7 +348,7 @@ def generate_submenu(): # Generate the string who contain the links of the menu htmly_website_page = "<ul>" htmly_website_page += "<a href='/website/bts-sio.html' class='sublia'><li><span class='subleft-lia'></span><span class='subcenter-lia'>bts-sio</span><span class='subright-lia'></span></li></a>" - for name in os.listdir(os.path.join(BUILDDIR, "website/Documents")): + for name in sorted(os.listdir(os.path.join(BUILDDIR, "website/Documents"))): if name != "Situation1" and name != "Situation2": htmly_website_page += "<a href='/website/Documents/"+name+"' class='sublia'><li><span class='subleft-lia'></span><span class='subcenter-lia'>"+name.split('.html')[0]+"</span><span class='subright-lia'></span></li></a>" htmly_website_page += "</ul>" @@ -676,7 +676,7 @@ def generate_notes_list(): 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 name in os.listdir(os.path.join(BUILDDIR, "notes")): + for name in list(reversed(sorted(os.listdir(os.path.join(BUILDDIR, "notes"))))): if re.match(r"^[0-9]{4}-[0-9]{2}-[0-9]{2}.*\.html", name): htmlpath = os.path.join(BUILDDIR, "notes", name) #tentry = AtomEntry() @@ -684,7 +684,6 @@ def generate_notes_list(): try: with open(htmlpath, encoding="utf-8") as htmlfile: soup = bs4.BeautifulSoup(htmlfile.read(), "lxml") - # generate atom entry #entry.author = copy.deepcopy(feed.author) # assume it's always the same author #entry_url = urllib.parse.urljoin(BLOG_HOME, "blog/%s" % name) @@ -701,7 +700,7 @@ def generate_notes_list(): post_date = soup.find("meta", attrs={"name": "date"})["content"] updated_datetime = dateutil.parser.parse(post_date) - date = updated_datetime + date = updated_datetime if date.year < year: # close the previous table if there is one if table_opened: |