From 638dd67cef98201847be8161daafab5208ca1bd6 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Wed, 9 Nov 2022 19:42:17 -0800 Subject: [PATCH] Let atomify take argument web_root. --- etiquette/objects.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/etiquette/objects.py b/etiquette/objects.py index d85de8f..e4e25ed 100644 --- a/etiquette/objects.py +++ b/etiquette/objects.py @@ -433,7 +433,8 @@ class Album(ObjectBase, GroupableMixin): for photo in photos: photo.add_tag(tag) - def atomify(self) -> bs4.BeautifulSoup: + def atomify(self, web_root='') -> bs4.BeautifulSoup: + web_root = web_root.rstrip('/') soup = bs4.BeautifulSoup('', 'xml') entry = soup.new_tag('entry') soup.append(entry) @@ -449,7 +450,7 @@ class Album(ObjectBase, GroupableMixin): link = soup.new_tag('link') link['rel'] = 'alternate' link['type'] = 'text/html' - link['href'] = f'/album/{self.id}' + link['href'] = f'{web_root}/album/{self.id}' entry.append(link) published = soup.new_tag('published') @@ -991,7 +992,8 @@ class Photo(ObjectBase): return tag - def atomify(self) -> bs4.BeautifulSoup: + def atomify(self, web_root='') -> bs4.BeautifulSoup: + web_root = web_root.rstrip('/') soup = bs4.BeautifulSoup('', 'xml') entry = soup.new_tag('entry') soup.append(entry) @@ -1007,7 +1009,7 @@ class Photo(ObjectBase): link = soup.new_tag('link') link['rel'] = 'alternate' link['type'] = 'text/html' - link['href'] = f'/photo/{self.id}' + link['href'] = f'{web_root}/photo/{self.id}' entry.append(link) published = soup.new_tag('published') @@ -1015,7 +1017,7 @@ class Photo(ObjectBase): entry.append(published) content = soup.new_tag('content') - content.string = bs4.CData(f'') + content.string = bs4.CData(f'') entry.append(content) typ = soup.new_tag('etiquette:type')