|
@@ -5,7 +5,7 @@ from django.conf import settings
|
5
|
5
|
# TODO: Add whoosh and search
|
6
|
6
|
|
7
|
7
|
import fstools
|
8
|
|
-from pages import messages
|
|
8
|
+from pages import messages, url_page
|
9
|
9
|
import mycreole
|
10
|
10
|
import os
|
11
|
11
|
|
|
@@ -16,8 +16,9 @@ class creol_page(object):
|
16
|
16
|
FOLDER_CONTENT = 'content'
|
17
|
17
|
FILE_NAME = 'page'
|
18
|
18
|
|
19
|
|
- def __init__(self, rel_path) -> None:
|
|
19
|
+ def __init__(self, request, rel_path) -> None:
|
20
|
20
|
self._rel_path = rel_path
|
|
21
|
+ self._request = request
|
21
|
22
|
|
22
|
23
|
def rel_path_is_valid(self):
|
23
|
24
|
return not self.SPLITCHAR in self._rel_path
|
|
@@ -62,11 +63,11 @@ class creol_page(object):
|
62
|
63
|
with open(self.content_file_name, 'w') as fh:
|
63
|
64
|
fh.write(page_txt)
|
64
|
65
|
|
65
|
|
- def render_to_html(self, request):
|
|
66
|
+ def render_to_html(self):
|
66
|
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
|
69
|
else:
|
69
|
|
- messages.unavailable_msg_page(request, self._rel_path)
|
|
70
|
+ messages.unavailable_msg_page(self._request, self._rel_path)
|
70
|
71
|
return ""
|
71
|
72
|
|
72
|
73
|
def render_text(self, request, txt):
|
|
@@ -82,7 +83,7 @@ class creol_page(object):
|
82
|
83
|
except ValueError:
|
83
|
84
|
pass
|
84
|
85
|
|
85
|
|
- params = kwargs.get('').split(",")
|
|
86
|
+ params = kwargs.get('', '').split(",")
|
86
|
87
|
depth = parse_depth(params[0])
|
87
|
88
|
if len(params) == 2:
|
88
|
89
|
startname = params[1]
|
|
@@ -95,15 +96,12 @@ class creol_page(object):
|
95
|
96
|
pathlist = fstools.dirlist(settings.PAGES_ROOT, rekursive=False)
|
96
|
97
|
pathlist.sort()
|
97
|
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
|
102
|
name = contentname[len(self._rel_path)+1:]
|
105
|
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
|
105
|
if len(rv) > 0:
|
108
|
106
|
rv = "<ul>\n" + rv + "</ul>\n"
|
109
|
107
|
return rv
|