File tree 2 files changed +36
-36
lines changed
2 files changed +36
-36
lines changed Original file line number Diff line number Diff line change @@ -194,6 +194,40 @@ def get_pagename_prefixes(filter=[]):
194
194
return pagename_prefixes
195
195
196
196
197
+ def get_breadcrumbs (pagepath ):
198
+ if not pagepath or len (pagepath )< 1 :
199
+ return []
200
+ # strip trailing slashes
201
+ pagepath = pagepath .rstrip ("/" )
202
+ parents = []
203
+ crumbs = []
204
+ for e in split_path (pagepath ):
205
+ parents .append (e )
206
+ crumbs .append (
207
+ (
208
+ get_pagename (e ),
209
+ join_path (parents ),
210
+ )
211
+ )
212
+ return crumbs
213
+
214
+
215
+ def upsert_pagecrumbs (pagepath ):
216
+ """
217
+ adds the given pagepath to the page specific crumbs "pagecrumbs" stored in the session
218
+ """
219
+ if pagepath is None or pagepath == "/" :
220
+ return
221
+ if "pagecrumbs" not in session :
222
+ session ["pagecrumbs" ] = []
223
+ else :
224
+ session ["pagecrumbs" ] = list (filter (lambda x : x .lower () != pagepath .lower (), session ["pagecrumbs" ]))
225
+
226
+ # add the pagepath to the tail of the list of pagecrumbs
227
+ session ["pagecrumbs" ] = session ["pagecrumbs" ][- 7 :] + [pagepath ]
228
+ # flask.session: modifications on mutable structures are not picked up automatically
229
+ session .modified = True
230
+
197
231
198
232
def patchset2urlmap (patchset , rev_b , rev_a = None ):
199
233
url_map = {}
Original file line number Diff line number Diff line change 40
40
get_pagename ,
41
41
get_pagename_prefixes ,
42
42
patchset2urlmap ,
43
+ get_breadcrumbs ,
44
+ upsert_pagecrumbs ,
43
45
)
44
46
from otterwiki .auth import has_permission , current_user
45
47
from otterwiki .plugins import chain_hooks
55
57
PIL .Image .Resampling = PIL .Image
56
58
57
59
58
- def get_breadcrumbs (pagepath ):
59
- if not pagepath or len (pagepath )< 1 :
60
- return []
61
- # strip trailing slashes
62
- pagepath = pagepath .rstrip ("/" )
63
- parents = []
64
- crumbs = []
65
- for e in split_path (pagepath ):
66
- parents .append (e )
67
- crumbs .append (
68
- (
69
- get_pagename (e ),
70
- join_path (parents ),
71
- )
72
- )
73
- return crumbs
74
-
75
-
76
- def upsert_pagecrumbs (pagepath ):
77
- if pagepath is None or pagepath == "/" :
78
- return
79
- if "pagecrumbs" not in session :
80
- session ["pagecrumbs" ] = []
81
- else :
82
- session ["pagecrumbs" ] = list (filter (lambda x : x .lower () != pagepath .lower (), session ["pagecrumbs" ]))
83
-
84
- # add the pagepath to the tail of the list of pagecrumbs
85
- session ["pagecrumbs" ] = session ["pagecrumbs" ][- 7 :] + [pagepath ]
86
- # flask.session: modifications on mutable structures are not picked up automatically
87
- session .modified = True
88
-
89
60
class PageIndex :
90
61
def __init__ (self , path = None ):
91
62
'''
@@ -274,11 +245,6 @@ def get(self):
274
245
return log
275
246
276
247
def render (self ):
277
- """revert_form.
278
-
279
- :param revision:
280
- :param message:
281
- """
282
248
if not has_permission ("READ" ):
283
249
abort (403 )
284
250
log = self .get ()
You can’t perform that action at this time.
0 commit comments