From 55bdc78582c07ab47401fe0988722da6f0934acb Mon Sep 17 00:00:00 2001 From: likho Date: Sat, 19 Mar 2022 22:10:56 -0700 Subject: [PATCH] adjust css for subfolder --- microblog.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/microblog.py b/microblog.py index 11528af..f89a0b9 100644 --- a/microblog.py +++ b/microblog.py @@ -139,7 +139,7 @@ class Paginator: pass def toc(self, n=None, page=None): #style 1 - if self.TOTAL_PAGES < 1 or (n == None and page == None): + if self.TOTAL_PAGES < 1 or (n == None or page == None): return "[no pages]" # For page 'n' do not create an anchor tag fmt = "[%i]" #(self.subdir, page, page number) @@ -184,6 +184,17 @@ if __name__ == "__main__": email = sys.argv[3] if (argc >= 4) else None return template, content, email + # change the path of css for pages in a separate dir from index + def adjust_css(template): + # in order + x = template.find("./style.css") + y = template.find("./timeline.css") + chars = [char for char in template] + chars.insert(x, '.') + y += 1 + chars.insert(y, '.') + return "".join(chars) + def main(): template, content, email = get_args() tl, tc = make_timeline(content, email) @@ -194,13 +205,13 @@ if __name__ == "__main__": html = f.read() #print(html % (count, "\n".join(tcl), "\n\n".join(tl))) count = len(tl) - posts_per_page = 5 + posts_per_page = 20 pagectrl = Paginator(count, posts_per_page) if count <= posts_per_page: print(pagectrl.paginate(html, tcl, timeline)) else: latest = tl[:posts_per_page] print(pagectrl.singlepage(html, tcl, latest)) - pagectrl.paginate(html, tcl, tl) + pagectrl.paginate(adjust_css(html), tcl, tl) main()