Update usage of pathclass.

This commit is contained in:
voussoir 2021-12-07 23:12:02 -08:00
parent c1bc7ead18
commit 0261f7ebdd
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB
2 changed files with 6 additions and 6 deletions

View file

@ -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)

View file

@ -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: