Browse Source

BugFix: Macro subpages - links corrected and fix if no parameters given

master
Dirk Alders 2 months ago
parent
commit
9d8641ac31
1 changed files with 10 additions and 12 deletions
  1. 10
    12
      pages/page.py

+ 10
- 12
pages/page.py View File

5
 # TODO: Add whoosh and search
5
 # TODO: Add whoosh and search
6
 
6
 
7
 import fstools
7
 import fstools
8
-from pages import messages
8
+from pages import messages, url_page
9
 import mycreole
9
 import mycreole
10
 import os
10
 import os
11
 
11
 
16
     FOLDER_CONTENT = 'content'
16
     FOLDER_CONTENT = 'content'
17
     FILE_NAME = 'page'
17
     FILE_NAME = 'page'
18
 
18
 
19
-    def __init__(self, rel_path) -> None:
19
+    def __init__(self, request, rel_path) -> None:
20
         self._rel_path = rel_path
20
         self._rel_path = rel_path
21
+        self._request = request
21
 
22
 
22
     def rel_path_is_valid(self):
23
     def rel_path_is_valid(self):
23
         return not self.SPLITCHAR in self._rel_path
24
         return not self.SPLITCHAR in self._rel_path
62
         with open(self.content_file_name, 'w') as fh:
63
         with open(self.content_file_name, 'w') as fh:
63
             fh.write(page_txt)
64
             fh.write(page_txt)
64
 
65
 
65
-    def render_to_html(self, request):
66
+    def render_to_html(self):
66
         if self.is_available():
67
         if self.is_available():
67
-            return self.render_text(request, self.raw_page_src)
68
+            return self.render_text(self._request, self.raw_page_src)
68
         else:
69
         else:
69
-            messages.unavailable_msg_page(request, self._rel_path)
70
+            messages.unavailable_msg_page(self._request, self._rel_path)
70
             return ""
71
             return ""
71
 
72
 
72
     def render_text(self, request, txt):
73
     def render_text(self, request, txt):
82
             except ValueError:
83
             except ValueError:
83
                 pass
84
                 pass
84
 
85
 
85
-        params = kwargs.get('').split(",")
86
+        params = kwargs.get('', '').split(",")
86
         depth = parse_depth(params[0])
87
         depth = parse_depth(params[0])
87
         if len(params) == 2:
88
         if len(params) == 2:
88
             startname = params[1]
89
             startname = params[1]
95
         pathlist = fstools.dirlist(settings.PAGES_ROOT, rekursive=False)
96
         pathlist = fstools.dirlist(settings.PAGES_ROOT, rekursive=False)
96
         pathlist.sort()
97
         pathlist.sort()
97
         for path in pathlist:
98
         for path in pathlist:
98
-            dirname = os.path.basename(path)
99
-            contentname = self.__folder_content_filter__(dirname)
99
+            contentname = self.__folder_content_filter__(os.path.basename(path))
100
             #
100
             #
101
-            my_dirname = self.__content_folder_filter__(self._rel_path)
102
-            #
103
-            if dirname.startswith(my_dirname) and dirname != my_dirname:
101
+            if contentname.startswith(self._rel_path) and contentname != self._rel_path:
104
                 name = contentname[len(self._rel_path)+1:]
102
                 name = contentname[len(self._rel_path)+1:]
105
                 if name.count('/') <= depth and name.startswith(startname):
103
                 if name.count('/') <= depth and name.startswith(startname):
106
-                    rv += f'  <li><a href="{contentname}">{name}</a></li>\n'
104
+                    rv += f'  <li><a href="{url_page(self._request, contentname)}">{name}</a></li>\n'
107
         if len(rv) > 0:
105
         if len(rv) > 0:
108
             rv = "<ul>\n" + rv + "</ul>\n"
106
             rv = "<ul>\n" + rv + "</ul>\n"
109
         return rv
107
         return rv

Loading…
Cancel
Save