Update usage of pathclass.
This commit is contained in:
parent
c1bc7ead18
commit
0261f7ebdd
2 changed files with 6 additions and 6 deletions
|
@ -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
|
/writing/screenshot.png which doesn't exist. So this function turns all
|
||||||
relative links into absolute links starting from /writing.
|
relative links into absolute links starting from /writing.
|
||||||
'''
|
'''
|
||||||
folder = pathclass.Path(md_file.parent, force_sep='/')
|
folder = pathclass.Path(md_file.parent)
|
||||||
writing_rootdir = pathclass.Path(WRITING_ROOTDIR, force_sep='/')
|
writing_rootdir = pathclass.Path(WRITING_ROOTDIR)
|
||||||
def fixby(tagname, attribute):
|
def fixby(tagname, attribute):
|
||||||
links = soup.find_all(tagname)
|
links = soup.find_all(tagname)
|
||||||
for link in links:
|
for link in links:
|
||||||
|
@ -168,7 +168,7 @@ def soup_adjust_relative_links(soup, md_file, repo_path):
|
||||||
if href.startswith('#'):
|
if href.startswith('#'):
|
||||||
continue
|
continue
|
||||||
href = folder.join(href)
|
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/'):
|
if not href.startswith('/writing/'):
|
||||||
raise ValueError('Somethings wrong with', href)
|
raise ValueError('Somethings wrong with', href)
|
||||||
link[attribute] = href
|
link[attribute] = href
|
||||||
|
@ -184,12 +184,12 @@ class Article:
|
||||||
def __init__(self, md_file):
|
def __init__(self, md_file):
|
||||||
self.md_file = pathclass.Path(md_file)
|
self.md_file = pathclass.Path(md_file)
|
||||||
self.html_file = self.md_file.replace_extension('html')
|
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.date = git_file_published_date(self.md_file)
|
||||||
self.edited = git_file_edited_date(self.md_file)
|
self.edited = git_file_edited_date(self.md_file)
|
||||||
|
|
||||||
repo_path = git_repo_for_file(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}'
|
github_history = f'https://github.com/voussoir/voussoir.net/commits/master/{relative_path}'
|
||||||
|
|
||||||
commits = git_file_commit_history(self.md_file)
|
commits = git_file_commit_history(self.md_file)
|
||||||
|
|
|
@ -713,7 +713,7 @@ def markdown_flask(core_filename, port, *args, **kwargs):
|
||||||
site = flask.Flask(__name__)
|
site = flask.Flask(__name__)
|
||||||
image_cache = {}
|
image_cache = {}
|
||||||
kwargs['image_cache'] = 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:
|
if core_filename.is_dir:
|
||||||
cwd = core_filename
|
cwd = core_filename
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue