gnunet-svn
[Top][All Lists]
Advanced

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

[www_shared] branch master updated: news goes inside template dir


From: gnunet
Subject: [www_shared] branch master updated: news goes inside template dir
Date: Thu, 06 May 2021 16:03:17 +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 d92f6d3  news goes inside template dir
d92f6d3 is described below

commit d92f6d37ed9fc605b517aafe614618369209a665
Author: Florian Dold <florian@dold.me>
AuthorDate: Thu May 6 16:00:49 2021 +0200

    news goes inside template dir
---
 site.py     | 53 ++++++++++-------------------------------------------
 textproc.py |  4 ++--
 2 files changed, 12 insertions(+), 45 deletions(-)

diff --git a/site.py b/site.py
index 035d178..f52f028 100644
--- a/site.py
+++ b/site.py
@@ -37,7 +37,7 @@ from inc.fileproc import copy_files, copy_tree
 from inc.make_rss import *
 
 class SiteGenerator:
-    def __init__(self, debug):
+    def __init__(self, debug=0):
         self.debug = debug
 
     def load_config(self, name="www.yml"):
@@ -79,13 +79,7 @@ class SiteGenerator:
         make_rss(directory, conf, env)
 
     def run_localized(self, root, conf, env, locale, tr):
-        abs_cwd = Path(".").resolve()
-        # root = "../" + root
-        if self.debug > 1:
-            _ = Path(".")
-            q = list(_.glob("**/*.j2"))
-            print(q)
-        abs_cwd = Path(".").resolve()
+        abs_cwd = Path(root).resolve()
 
         for in_file in Path(".").glob(root + "/*.j2"):
             in_file = str(in_file)
@@ -102,33 +96,20 @@ class SiteGenerator:
                 abs_file = Path(in_file).resolve()
                 baseurl = os.environ.get("BASEURL")
                 if relative or not baseurl:
-                    if root == "news":
-                        return "../../" + other_locale + "/news/" + 
in_file.replace(
-                           root + '/', '').rstrip(".j2")
-                    else:
-                        return "../" + other_locale + "/" + in_file.replace(
-                           root + '/', '').rstrip(".j2")
+                    return "../" + other_locale + "/" + in_file.replace(
+                       root + '/', '').rstrip(".j2")
                 else:
                     return baseurl + other_locale + "/" + 
str(Path(abs_file).relative_to(abs_cwd)).rstrip(".j2")
 
 
             def url_localized(filename):
-                if root == "news":
-                    return "../../" + locale + "/" + filename
-                else:
-                    return "../" + locale + "/" + filename
+                return "../" + locale + "/" + filename
 
             def url_static(filename):
-                if root == "news":
-                    return "../../static/" + filename
-                else:
-                    return "../static/" + filename
+                return "../static/" + filename
 
             def url_dist(filename):
-                if root == "news":
-                    return "../../dist/" + filename
-                else:
-                    return "../dist/" + filename
+                return "../dist/" + filename
 
             def svg_localized(filename):
                 lf = filename + "." + locale + ".svg"
@@ -140,10 +121,6 @@ class SiteGenerator:
             def url(x):
                 # TODO: look at the app root environment variable
                 # TODO: check if file exists
-                #if root == "news":
-                #    return "../" + "../" + x
-                #else:
-                #    return "../" + x
                 return "../" + x
 
             content = tmpl.render(lang=locale,
@@ -161,19 +138,12 @@ class SiteGenerator:
                                     svg_localized=svg_localized,
                                     filename=name + "." + ext)
 
-            if root == "news":
-                out_name = "./rendered/" + locale + "/" + root + "/" + 
in_file.replace(
-                    root + '/', '').rstrip(".j2")
-            else:
-                out_name = "./rendered/" + locale + "/" + in_file.replace(
-                    root + '/', '').rstrip(".j2")
+            out_name = "./rendered/" + locale + "/" + in_file.replace(
+                root + '/', '').rstrip(".j2")
 
             outdir = Path("rendered")
 
-            if root == "news":
-                langdir = outdir / locale / root
-            else:
-                langdir = outdir / locale
+            langdir = outdir / locale
 
             try:
                 langdir.mkdir(parents=True, exist_ok=True)
@@ -190,19 +160,16 @@ class SiteGenerator:
 
 
     def run(self, root, conf, env):
-        # root = "../" + root
         if self.debug > 1:
             _ = Path(".")
             q = list(_.glob("**/*.j2"))
             print(q)
 
-        # for l in glob.glob("locale/*/"):
         # https://bugs.python.org/issue22276
         for l in list(x for x in Path(".").glob("locale/*/") if x.is_dir()):
             l = str(PurePath(l).name)
             if self.debug > 1:
                 print(l)
-            # locale = os.path.basename(l[:-1])
             locale = l
 
             try:
diff --git a/textproc.py b/textproc.py
index 30370ac..ef44bf1 100644
--- a/textproc.py
+++ b/textproc.py
@@ -53,7 +53,7 @@ def cut_text(filename, count):
 
 
 def cut_news_text(filename, count):
-    return cut_text("news/" + filename + ".j2", count)
+    return cut_text("template/news/" + filename + ".j2", count)
 
 
 # TODO: replace id='...' with frontier so that we can
@@ -71,7 +71,7 @@ def cut_by_frontier(filename):
 
 
 def cut_article(filename, conf, lang):
-    return cut_all("news/" + filename + ".j2", conf, lang)
+    return cut_all("template/news/" + filename + ".j2", conf, lang)
 
 def cut_all(filename, conf, lang):
     with open(filename) as html:

-- 
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]