creole macro changed and improved. Help added

This commit is contained in:
Dirk Alders 2024-10-07 21:21:47 +02:00
parent 4116e36e7c
commit f8cbb6ee4d
2 changed files with 16 additions and 8 deletions

View File

@ -25,8 +25,9 @@ CREOLE += mycreole.render_simple("""
| {{{<<subpages>>}}} | will result in a list of all subpages below the current page. |
| {{{<<subpages=N,startswith>>}}} | will result in a list of subpages below the current page.\
N will reduce the depth of the subpages to N. \
startswith will reduce the hits to all pages starting with the given string.
startswith will reduce the hits to all pages starting with the given string. \
You can give one or both Parameters. |
| {{{<<allpages>>}}} | will result in a last of all pages. You can use [N,startswith] as with subpages. |
""")
ACCESS = mycreole.render_simple(_("""

View File

@ -1,6 +1,5 @@
from django.conf import settings
# TODO: PRIO: BugFix if subpages filter is used without parameters
# TODO: PRIO: Add wildcards for subpages filter
# TODO: Add whoosh and search
@ -105,10 +104,13 @@ class creol_page(object):
depth = 9999
#
rv = ""
pathlist = fstools.dirlist(settings.PAGES_ROOT, rekursive=False)
pathlist.sort()
for path in pathlist:
contentname = self.__folder_content_filter__(os.path.basename(path))
# create a rel_path list
pathlist = [self.__folder_content_filter__(os.path.basename(path)) for path in fstools.dirlist(settings.PAGES_ROOT, rekursive=False)]
# sort basename
pathlist.sort(key=os.path.basename)
last_char = None
for contentname in pathlist:
#
if (contentname.startswith(self._rel_path) or allpages) and contentname != self._rel_path:
if allpages:
@ -116,7 +118,12 @@ class creol_page(object):
else:
name = contentname[len(self._rel_path)+1:]
if name.count('/') < depth and name.startswith(startname):
if last_char != os.path.basename(name)[0].upper():
last_char = os.path.basename(name)[0].upper()
if last_char is not None:
rv += "</ul>\n"
rv += f'<h3>{last_char}</h3>\n<ul>\n'
rv += f' <li><a href="{url_page(self._request, contentname)}">{name}</a></li>\n'
if len(rv) > 0:
rv = "<ul>\n" + rv + "</ul>\n"
rv += "</ul>\n"
return rv