|
@@ -29,9 +29,15 @@ class creol_page(object):
|
29
|
29
|
def attachment_path(self):
|
30
|
30
|
return os.path.join(self.content_folder_name, self.FOLDER_ATTACHMENTS)
|
31
|
31
|
|
|
32
|
+ def __content_folder_filter__(self, folder):
|
|
33
|
+ return folder.replace('/', '::')
|
|
34
|
+
|
|
35
|
+ def __folder_content_filter__(self, folder):
|
|
36
|
+ return folder.replace('::', '/')
|
|
37
|
+
|
32
|
38
|
@property
|
33
|
39
|
def content_folder_name(self):
|
34
|
|
- return self._rel_path.replace('/', '::')
|
|
40
|
+ return self.__content_folder_filter__(self._rel_path)
|
35
|
41
|
|
36
|
42
|
@property
|
37
|
43
|
def content_file_name(self):
|
|
@@ -54,7 +60,46 @@ class creol_page(object):
|
54
|
60
|
|
55
|
61
|
def render_to_html(self, request):
|
56
|
62
|
if self.is_available():
|
57
|
|
- return mycreole.render(request, self.raw_page_src, self.attachment_path, "next_anchor")
|
|
63
|
+ return self.render_text(request, self.raw_page_src)
|
58
|
64
|
else:
|
59
|
65
|
messages.unavailable_msg_page(request, self._rel_path)
|
60
|
66
|
return ""
|
|
67
|
+
|
|
68
|
+ def render_text(self, request, txt):
|
|
69
|
+ macros = {
|
|
70
|
+ "subpages": self.macro_subpages
|
|
71
|
+ }
|
|
72
|
+ return mycreole.render(request, txt, self.attachment_path, "next_anchor", macros=macros)
|
|
73
|
+
|
|
74
|
+ def macro_subpages(self, *args, **kwargs):
|
|
75
|
+ def parse_depth(s: str):
|
|
76
|
+ try:
|
|
77
|
+ return int(s)
|
|
78
|
+ except ValueError:
|
|
79
|
+ pass
|
|
80
|
+
|
|
81
|
+ params = kwargs.get('').split(",")
|
|
82
|
+ depth = parse_depth(params[0])
|
|
83
|
+ if len(params) == 2:
|
|
84
|
+ startname = params[1]
|
|
85
|
+ elif depth is None:
|
|
86
|
+ startname = params[0]
|
|
87
|
+ if depth is None:
|
|
88
|
+ depth = 9999
|
|
89
|
+ #
|
|
90
|
+ rv = ""
|
|
91
|
+ pathlist = fstools.dirlist(settings.PAGES_ROOT, rekursive=False)
|
|
92
|
+ pathlist.sort()
|
|
93
|
+ for path in pathlist:
|
|
94
|
+ dirname = os.path.basename(path)
|
|
95
|
+ contentname = self.__folder_content_filter__(dirname)
|
|
96
|
+ #
|
|
97
|
+ my_dirname = self.__content_folder_filter__(self._rel_path)
|
|
98
|
+ #
|
|
99
|
+ if dirname.startswith(my_dirname) and dirname != my_dirname:
|
|
100
|
+ name = contentname[len(self._rel_path)+1:]
|
|
101
|
+ if name.count('/') <= depth and name.startswith(startname):
|
|
102
|
+ rv += f' <li><a href="{contentname}">{name}</a></li>\n'
|
|
103
|
+ if len(rv) > 0:
|
|
104
|
+ rv = "<ul>\n" + rv + "</ul>\n"
|
|
105
|
+ return rv
|