Attachment 'navibar.patch'
Download 1 --- moin-1.8.2/MoinMoin/theme/__init__.py 2009-01-06 19:30:29.000000000 -0500
2 +++ moin-1.8.2.modif/MoinMoin/theme/__init__.py 2009-03-05 18:09:52.358208036 -0500
3 @@ -407,6 +407,60 @@
4 """ Return maximum length for shortened page names """
5 return 25
6
7 + def navibarDefaultLinks(self):
8 + """ Returns list of default links to be displayed in the navibar
9 +
10 + Result also contains the class to be used.
11 + This method uses self.request.cfg.navi_bar and 'wikilink' by default,
12 + but could be overridden in the theme.
13 +
14 + @rtype: tuple
15 + @return: CSS class name to be used, list of links
16 + """
17 + if self.request.cfg.navi_bar:
18 + return ('wikilink', self.request.cfg.navi_bar)
19 + return ('wikilink', [])
20 +
21 + def navibarUserLinks(self):
22 + """ Returns list of user's quicklinks to be displayed in the navibar
23 +
24 + Result also contains the class to be used.
25 + This method uses self.request.user.getQuickLinks() and 'userlink' by default,
26 + but could be overridden in the theme.
27 +
28 + @rtype: tuple
29 + @return: CSS class name to be used, list of links
30 + """
31 + return ('userlink', self.request.user.getQuickLinks())
32 +
33 + def navibarSisterLinks(self):
34 + """ Returns list of links to sistersites to be displayed in the navibar
35 +
36 + Result also contains the class to be used.
37 + This method uses self.request.cfg.sistersites and 'sisterwiki' by default,
38 + but could be overridden in the theme.
39 +
40 + @rtype: tuple
41 + @return: CSS class name to be used, list of tuples: (sistername, sisterurl)
42 + """
43 + if self.request.cfg.sistersites:
44 + return ('sisterwiki', self.request.cfg.sistersites)
45 + return ('sisterwiki', [])
46 +
47 + def navibarExtraLinks(self):
48 + """ Returns list of additional links to be displayed in the navibar
49 +
50 + Result also contains the class to be used.
51 + This method returns empty list and 'extralink' by default,
52 + but could be overridden in the theme. This could be used to generate automatic
53 + list of additional links to be put in navibar. For example for generating some
54 + additional quicklinks for some users (or, for example, only for logged users)
55 +
56 + @rtype: tuple
57 + @return: CSS class name to be used, list of links
58 + """
59 + return ('extralink', [])
60 +
61 def navibar(self, d):
62 """ Assemble the navibar
63
64 @@ -420,27 +474,46 @@
65 item = u'<li class="%s">%s</li>'
66 current = d['page_name']
67
68 - # Process config navi_bar
69 - if request.cfg.navi_bar:
70 - for text in request.cfg.navi_bar:
71 - pagename, link = self.splitNavilink(text)
72 + # Add default navibar links.
73 +
74 + add_cls, add_links = self.navibarDefaultLinks()
75 +
76 + for text in add_links:
77 + pagename, link = self.splitNavilink(text)
78 + if pagename == current:
79 + cls = add_cls + ' current'
80 + else:
81 + cls = add_cls
82 + items.append(item % (cls, link))
83 + found[pagename] = 1
84 +
85 + # Add some additional links, eliminating duplicates.
86 +
87 + add_cls, add_links = self.navibarExtraLinks()
88 +
89 + for text in add_links:
90 + # Split text without localization, user knows what he wants
91 + pagename, link = self.splitNavilink(text)
92 + if not pagename in found:
93 if pagename == current:
94 - cls = 'wikilink current'
95 + cls = add_cls + ' current'
96 else:
97 - cls = 'wikilink'
98 + cls = add_cls
99 items.append(item % (cls, link))
100 found[pagename] = 1
101
102 # Add user links to wiki links, eliminating duplicates.
103 - userlinks = request.user.getQuickLinks()
104 - for text in userlinks:
105 +
106 + add_cls, add_links = self.navibarUserLinks()
107 +
108 + for text in add_links:
109 # Split text without localization, user knows what he wants
110 pagename, link = self.splitNavilink(text, localize=0)
111 if not pagename in found:
112 if pagename == current:
113 - cls = 'userlink current'
114 + cls = add_cls + ' current'
115 else:
116 - cls = 'userlink'
117 + cls = add_cls
118 items.append(item % (cls, link))
119 found[pagename] = 1
120
121 @@ -451,11 +524,13 @@
122 link = d['page'].link_to(request, title)
123 cls = 'current'
124 items.append(item % (cls, link))
125 -
126 +
127 + add_cls, sister_links = self.navibarSisterLinks()
128 +
129 # Add sister pages.
130 - for sistername, sisterurl in request.cfg.sistersites:
131 + for sistername, sisterurl in sister_links:
132 if sistername == request.cfg.interwikiname: # it is THIS wiki
133 - cls = 'sisterwiki current'
134 + cls = add_cls + ' current'
135 items.append(item % (cls, sistername))
136 else:
137 # TODO optimize performance
138 @@ -464,7 +539,7 @@
139 data = cache.content()
140 sisterpages = data['sisterpages']
141 if current in sisterpages:
142 - cls = 'sisterwiki'
143 + cls = add_cls
144 url = sisterpages[current]
145 link = request.formatter.url(1, url) + \
146 request.formatter.text(sistername) +\
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.