[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[www_shared] branch master updated: fix relative linking
From: |
gnunet |
Subject: |
[www_shared] branch master updated: fix relative linking |
Date: |
Thu, 06 May 2021 19:38:59 +0200 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository www_shared.
The following commit(s) were added to refs/heads/master by this push:
new 543f91c fix relative linking
543f91c is described below
commit 543f91c2566e547d5c50d8e519ab57b10e8dd650
Author: Florian Dold <florian@dold.me>
AuthorDate: Thu May 6 19:36:40 2021 +0200
fix relative linking
---
site.py | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/site.py b/site.py
index 985feb4..260921f 100644
--- a/site.py
+++ b/site.py
@@ -63,26 +63,29 @@ def make_helpers(root, in_file, locale):
+ str(Path(abs_file).relative_to(root /
"template")).rstrip(".j2")
)
- def url_localized(filename):
- return "../" + locale + "/" + filename
+ def url(x):
+ abs_file = Path(in_file).resolve()
+ url = ""
+ current_location = Path(abs_file).relative_to(root / "template")
+ for p in current_location.parts:
+ url += "../"
+ return url + x
def url_static(filename):
- return "../" + filename
+ return url(filename)
def url_dist(filename):
- return "../dist/" + filename
+ return url("dist/" + filename)
+
+ def url_localized(filename):
+ return url(locale + "/" + filename)
def svg_localized(filename):
- lf = filename + "." + locale + ".svg"
- if locale == "en" or not Path(lf).is_file():
- return "../" + filename + ".svg"
+ lf = root / "static" / filename / "." / locale / ".svg"
+ if locale == "en" or not lf.is_file():
+ return url(filename + ".svg")
else:
- return "../" + lf
-
- def url(x):
- # TODO: look at the app root environment variable
- # TODO: check if file exists
- return "../" + x
+ return url(filename + "." + locale + ".svg")
return dict(
self_localized=self_localized,
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [www_shared] branch master updated: fix relative linking,
gnunet <=