Преглед на файлове

creole macro changed and improved. Help added

master
Dirk Alders преди 3 месеца
родител
ревизия
f8cbb6ee4d
променени са 2 файла, в които са добавени 16 реда и са изтрити 8 реда
  1. 3
    2
      pages/help.py
  2. 13
    6
      pages/page.py

+ 3
- 2
pages/help.py Целия файл

@@ -22,11 +22,12 @@ CREOLE = mycreole.mycreole_help_pagecontent()
22 22
 CREOLE += mycreole.render_simple("""
23 23
 = Piki Markup
24 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 26
 | {{{<<subpages=N,startswith>>}}} | will result in a list of subpages below the current page.\
27 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 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 33
 ACCESS = mycreole.render_simple(_("""

+ 13
- 6
pages/page.py Целия файл

@@ -1,6 +1,5 @@
1 1
 from django.conf import settings
2 2
 
3
-# TODO: PRIO: BugFix if subpages filter is used without parameters
4 3
 # TODO: PRIO: Add wildcards for subpages filter
5 4
 # TODO: Add whoosh and search
6 5
 
@@ -105,10 +104,13 @@ class creol_page(object):
105 104
                 depth = 9999
106 105
         #
107 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 115
             if (contentname.startswith(self._rel_path) or allpages) and contentname != self._rel_path:
114 116
                 if allpages:
@@ -116,7 +118,12 @@ class creol_page(object):
116 118
                 else:
117 119
                     name = contentname[len(self._rel_path)+1:]
118 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 126
                     rv += f'  <li><a href="{url_page(self._request, contentname)}">{name}</a></li>\n'
120 127
         if len(rv) > 0:
121
-            rv = "<ul>\n" + rv + "</ul>\n"
128
+            rv += "</ul>\n"
122 129
         return rv

Loading…
Отказ
Запис