From f8cbb6ee4d712eccb96a28bf6932c15e07c12a88 Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Mon, 7 Oct 2024 21:21:47 +0200 Subject: [PATCH] creole macro changed and improved. Help added --- pages/help.py | 5 +++-- pages/page.py | 19 +++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/pages/help.py b/pages/help.py index e67b0ec..e49d25b 100644 --- a/pages/help.py +++ b/pages/help.py @@ -22,11 +22,12 @@ CREOLE = mycreole.mycreole_help_pagecontent() CREOLE += mycreole.render_simple(""" = Piki Markup | {{{[[rel_path_to_page|Name]]}}} | will result in a Link to the given wiki page. | -| {{{<>}}} | will result in a list of all subpages below the current page. | +| {{{<>}}} | will result in a list of all subpages below the current page. | | {{{<>}}} | 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. | +| {{{<>}}} | will result in a last of all pages. You can use [N,startswith] as with subpages. | """) ACCESS = mycreole.render_simple(_(""" diff --git a/pages/page.py b/pages/page.py index cfb8fb1..28280dd 100644 --- a/pages/page.py +++ b/pages/page.py @@ -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 += "\n" + rv += f'

{last_char}

\n
    \n' rv += f'
  • {name}
  • \n' if len(rv) > 0: - rv = "
      \n" + rv + "
    \n" + rv += "
\n" return rv