Browse Source

creole macro changed and improved. Help added

master
Dirk Alders 3 months ago
parent
commit
f8cbb6ee4d
2 changed files with 16 additions and 8 deletions
  1. 3
    2
      pages/help.py
  2. 13
    6
      pages/page.py

+ 3
- 2
pages/help.py View File

22
 CREOLE += mycreole.render_simple("""
22
 CREOLE += mycreole.render_simple("""
23
 = Piki Markup
23
 = Piki Markup
24
 | {{{[[rel_path_to_page|Name]]}}} | will result in a Link to the given wiki page. |
24
 | {{{[[rel_path_to_page|Name]]}}} | will result in a Link to the given wiki page. |
25
-| {{{<<subpages>>}}} | will result in a list of all subpages below the current page. |
25
+| {{{<<subpages>>}}}              | will result in a list of all subpages below the current page. |
26
 | {{{<<subpages=N,startswith>>}}} | will result in a list of subpages below the current page.\
26
 | {{{<<subpages=N,startswith>>}}} | will result in a list of subpages below the current page.\
27
                                     N will reduce the depth of the subpages to N. \
27
                                     N will reduce the depth of the subpages to N. \
28
-                                    startswith  will reduce the hits to all pages starting with the given string. 
28
+                                    startswith  will reduce the hits to all pages starting with the given string. \
29
                                     You can give one or both Parameters. |
29
                                     You can give one or both Parameters. |
30
+| {{{<<allpages>>}}}              | will result in a last of all pages. You can use [N,startswith] as with subpages. |
30
 """)
31
 """)
31
 
32
 
32
 ACCESS = mycreole.render_simple(_("""
33
 ACCESS = mycreole.render_simple(_("""

+ 13
- 6
pages/page.py View File

1
 from django.conf import settings
1
 from django.conf import settings
2
 
2
 
3
-# TODO: PRIO: BugFix if subpages filter is used without parameters
4
 # TODO: PRIO: Add wildcards for subpages filter
3
 # TODO: PRIO: Add wildcards for subpages filter
5
 # TODO: Add whoosh and search
4
 # TODO: Add whoosh and search
6
 
5
 
105
                 depth = 9999
104
                 depth = 9999
106
         #
105
         #
107
         rv = ""
106
         rv = ""
108
-        pathlist = fstools.dirlist(settings.PAGES_ROOT, rekursive=False)
109
-        pathlist.sort()
110
-        for path in pathlist:
111
-            contentname = self.__folder_content_filter__(os.path.basename(path))
107
+        # create a rel_path list
108
+        pathlist = [self.__folder_content_filter__(os.path.basename(path)) for path in fstools.dirlist(settings.PAGES_ROOT, rekursive=False)]
109
+        # sort basename
110
+        pathlist.sort(key=os.path.basename)
111
+
112
+        last_char = None
113
+        for contentname in pathlist:
112
             #
114
             #
113
             if (contentname.startswith(self._rel_path) or allpages) and contentname != self._rel_path:
115
             if (contentname.startswith(self._rel_path) or allpages) and contentname != self._rel_path:
114
                 if allpages:
116
                 if allpages:
116
                 else:
118
                 else:
117
                     name = contentname[len(self._rel_path)+1:]
119
                     name = contentname[len(self._rel_path)+1:]
118
                 if name.count('/') < depth and name.startswith(startname):
120
                 if name.count('/') < depth and name.startswith(startname):
121
+                    if last_char != os.path.basename(name)[0].upper():
122
+                        last_char = os.path.basename(name)[0].upper()
123
+                        if last_char is not None:
124
+                            rv += "</ul>\n"
125
+                        rv += f'<h3>{last_char}</h3>\n<ul>\n'
119
                     rv += f'  <li><a href="{url_page(self._request, contentname)}">{name}</a></li>\n'
126
                     rv += f'  <li><a href="{url_page(self._request, contentname)}">{name}</a></li>\n'
120
         if len(rv) > 0:
127
         if len(rv) > 0:
121
-            rv = "<ul>\n" + rv + "</ul>\n"
128
+            rv += "</ul>\n"
122
         return rv
129
         return rv

Loading…
Cancel
Save