From 0261f7ebdd6d2e15282916b87f896327171eb12c Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Tue, 7 Dec 2021 23:12:02 -0800 Subject: [PATCH] Update usage of pathclass. --- voussoir.net/writing/generate_site.py | 10 +++++----- voussoir.net/writing/vmarkdown.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/voussoir.net/writing/generate_site.py b/voussoir.net/writing/generate_site.py index 59f3852..ad443e9 100644 --- a/voussoir.net/writing/generate_site.py +++ b/voussoir.net/writing/generate_site.py @@ -155,8 +155,8 @@ def soup_adjust_relative_links(soup, md_file, repo_path): /writing/screenshot.png which doesn't exist. So this function turns all relative links into absolute links starting from /writing. ''' - folder = pathclass.Path(md_file.parent, force_sep='/') - writing_rootdir = pathclass.Path(WRITING_ROOTDIR, force_sep='/') + folder = pathclass.Path(md_file.parent) + writing_rootdir = pathclass.Path(WRITING_ROOTDIR) def fixby(tagname, attribute): links = soup.find_all(tagname) for link in links: @@ -168,7 +168,7 @@ def soup_adjust_relative_links(soup, md_file, repo_path): if href.startswith('#'): continue href = folder.join(href) - href = '/' + href.relative_to(writing_rootdir.parent, simple=True) + href = '/' + href.relative_to(writing_rootdir.parent, simple=True).replace('\\', '/') if not href.startswith('/writing/'): raise ValueError('Somethings wrong with', href) link[attribute] = href @@ -184,12 +184,12 @@ class Article: def __init__(self, md_file): self.md_file = pathclass.Path(md_file) self.html_file = self.md_file.replace_extension('html') - self.web_path = self.md_file.parent.relative_to(WRITING_ROOTDIR, simple=True) + self.web_path = self.md_file.parent.relative_to(WRITING_ROOTDIR, simple=True).replace('\\', '/') self.date = git_file_published_date(self.md_file) self.edited = git_file_edited_date(self.md_file) repo_path = git_repo_for_file(self.md_file) - relative_path = self.md_file.relative_to(repo_path, simple=True) + relative_path = self.md_file.relative_to(repo_path, simple=True).replace('\\', '/') github_history = f'https://github.com/voussoir/voussoir.net/commits/master/{relative_path}' commits = git_file_commit_history(self.md_file) diff --git a/voussoir.net/writing/vmarkdown.py b/voussoir.net/writing/vmarkdown.py index 321c7ea..2704c0f 100644 --- a/voussoir.net/writing/vmarkdown.py +++ b/voussoir.net/writing/vmarkdown.py @@ -713,7 +713,7 @@ def markdown_flask(core_filename, port, *args, **kwargs): site = flask.Flask(__name__) image_cache = {} kwargs['image_cache'] = image_cache - core_filename = pathclass.Path(core_filename, force_sep='/') + core_filename = pathclass.Path(core_filename) if core_filename.is_dir: cwd = core_filename else: