From dc39bccf756014ba5c4a1bb422bc9baed63b8a8e Mon Sep 17 00:00:00 2001
From: neodarz <neodarz@neodarz.net>
Date: Sat, 25 May 2019 23:40:31 +0200
Subject: Move absolutify_links function to external file

---
 pyblog | 17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)

(limited to 'pyblog')

diff --git a/pyblog b/pyblog
index b625f1c7..2f87d0eb 100755
--- a/pyblog
+++ b/pyblog
@@ -638,21 +638,6 @@ def rewrite_title():
                             indexmd.write(line)
 
 
-def absolutify_links(soup, baseurl):
-    """Make links in an article absolute.
-
-    Parameters
-    ----------
-    soup : bs4.BeautifulSoup
-    baseurl : str
-
-    """
-    for tag in soup.find_all(lambda tag: tag.has_attr("href")):
-        tag["href"] = urllib.parse.urljoin(baseurl, tag["href"])
-    for tag in soup.find_all(lambda tag: tag.has_attr("src")):
-        tag["src"] = urllib.parse.urljoin(baseurl, tag["src"])
-
-
 def generate_index_and_feed():
     """Generate index.html and feeds (atom and rss)."""
     # pylint: disable=too-many-statements,attribute-defined-outside-init,invalid-name
@@ -753,7 +738,7 @@ def generate_index_and_feed():
                     for script_tag in article.find_all("script"):
                         tags_to_remove.append(script_tag)
                     # make internal links absolute
-                    absolutify_links(article, entry_url)
+                    utils.absolutify_links(article, entry_url)
                     # remove marked tags
                     for tag in tags_to_remove:
                         tag.extract()
-- 
cgit v1.2.1