Commit 0b0f035d authored by berumuron's avatar berumuron
Browse files

imp: Show finale URLs instead of files path

When building the website, it is better to know the URL of the article
or the page instead of its path. Indeed, it's easier to find the path
because it is on the same computer. Also, the path is displayed if the
URL is set to `filesystem` in development.
parent bc9410d0
......@@ -144,6 +144,10 @@ class Page:
def slug(self):
return self.meta["PAGE_SLUG"]
def url(self):
site_url = self.meta.get("SITE_URL", "")
return f"{site_url}{self.slug()}.html"
def content(self):
return self.meta["PAGE_CONTENT"]
......@@ -255,7 +259,7 @@ def main(environment):
# And write the file
with open(output_filepath, "w") as output_file:
print(f"Written page: file://{os.path.abspath(output_filepath)}")
print(f"Written page: {page.url()}")
# Check that a ./static folder exists and copy its content under the ./site
# folder
......@@ -297,7 +301,7 @@ def main(environment):
output_filepath = os.path.join(output_path, f"{article.slug()}.html")
with open(output_filepath, "w") as output_file:
print(f"Written article: file://{os.path.abspath(output_filepath)}")
print(f"Written article: {article.url()}")
# Write the page with the list of articles if blog template exists
blog_template_filepath = os.path.join("templates", "blog.html")
......@@ -309,7 +313,7 @@ def main(environment):
blog_output_filepath = os.path.join(output_path, f"blog.html")
with open(blog_output_filepath, "w") as output_file:
print(f"Written page: file://{os.path.abspath(blog_output_filepath)}")
print(f"Written page: {configuration['SITE_URL']}blog.html")
# Just create some variables so it's easier to manipulate after
site_url = configuration["SITE_URL"]
......@@ -355,7 +359,7 @@ def main(environment):
feed_filepath = os.path.join(feed_dirpath, "all.atom.xml")
print(f"Written feed: file://{os.path.abspath(feed_filepath)}")
print(f"Written feed: {configuration['SITE_URL']}feeds/all.atom.xml")
if __name__ == "__main__":
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment