gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[www_shared] branch master updated: check internal links for validity


From: gnunet
Subject: [www_shared] branch master updated: check internal links for validity
Date: Sun, 09 May 2021 19:23:34 +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 ebed74a  check internal links for validity
ebed74a is described below

commit ebed74abfc2c3acb1c12df6c5b4453c6da227027
Author: Florian Dold <florian@dold.me>
AuthorDate: Sun May 9 19:20:53 2021 +0200

    check internal links for validity
---
 sitegen/site.py | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/sitegen/site.py b/sitegen/site.py
index 2220eac..1767a2a 100644
--- a/sitegen/site.py
+++ b/sitegen/site.py
@@ -90,8 +90,30 @@ def make_helpers(root, in_file, locale):
                 + str(Path(abs_file).relative_to(root / 
"template")).rstrip(".j2")
             )
 
-    def url(x):
+    def url(x, virtual=False):
         abs_file = Path(in_file).resolve()
+
+        def check_exists():
+            if virtual:
+                return True
+            if Path(root / "static" / x).exists():
+                return True
+            if Path(root / "template" / (x + ".j2")).exists():
+                return True
+            if Path(root / "template" / (x + ".j2")).exists():
+                return True
+            slashpos = x.find("/")
+            if slashpos < 0:
+                return False
+            rest = x[slashpos+1:]
+            # Heuristic search for translated file
+            if Path(root / "template" / (rest + ".j2")).exists():
+                return True
+            return False
+
+        if not check_exists():
+            raise FileNotFoundError("can't find " + x)
+
         url = ""
         current_location = Path(abs_file).relative_to(root / "template")
         for p in current_location.parts:

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]