Attachment 'explorer-moin1v9.patch'
Download 1 --- explorer-1v8.py 2008-10-13 13:22:36.000000000 +0200
2 +++ explorer-1v9.py 2009-12-28 22:02:13.968750000 +0100
3 @@ -8,8 +8,12 @@
4
5 from MoinMoin.theme import ThemeBase
6 from MoinMoin import version
7 +from MoinMoin.logfile import editlog
8
9 is_moin_1_6 = version.release.startswith('1.6')
10 +is_moin_1_7 = version.release.startswith('1.7')
11 +is_moin_1_8 = version.release.startswith('1.8')
12 +is_moin_1_9 = version.release.startswith('1.9')
13
14 # Debugging
15 # import pdb, time
16 @@ -19,7 +23,7 @@
17 from MoinMoin.action import AttachFile
18 from MoinMoin import i18n, wikiutil, version
19 from MoinMoin.Page import Page
20 -
21 +
22 name = 'explorer'
23
24
25 @@ -152,10 +156,14 @@
26 """
27 ThemeBase.__init__(self, request)
28 # Get the cookie
29 - if is_moin_1_6: # Moin 1.6
30 + if is_moin_1_6:
31 self.cookie = request.parse_cookie()
32 - else: # Moin 1.7
33 + elif is_moin_1_7 or is_moin_1_8:
34 self.cookie = request.cookie
35 + elif is_moin_1_9:
36 + self.cookie = request.cookies
37 + else:
38 + raise NotImplementedError("Moin version " + str(version.release) + " is not supported yet")
39 # Add them especific icons
40 self.icons.update(self.icons_update)
41 # Get module name of the theme
42 @@ -163,7 +171,12 @@
43 cfg = self.cfg
44 # Determine if theme should be displayed in site mode or desktop mode
45 # Default: desktop mode <=> request is from localhost
46 - self.site_mode = getattr(cfg, '%s_site_mode' % module_name, not request.http_host.startswith('localhost'))
47 + if is_moin_1_6 or is_moin_1_7 or is_moin_1_8:
48 + self.site_mode = getattr(cfg, '%s_site_mode' % module_name, not request.http_host.startswith('localhost'))
49 + elif is_moin_1_9:
50 + self.site_mode = getattr(cfg, '%s_site_mode' % module_name, not request.host.startswith('localhost'))
51 + else:
52 + raise NotImplementedError("Moin version " + str(version.release) + " is not supported yet")
53 # Get admin configured toolbars
54 self.toolbar_lists = getattr(cfg, '%s_toolbars' % module_name, self.toolbar_lists)
55 # Get admin configured toolbars position
56 @@ -201,14 +214,26 @@
57
58 # Apply setings from cookie
59 if self.cookie:
60 - if self.cookie.has_key('%s_hide_sidebar' % module_name):
61 - self.sidebar_width = "0px"
62 - elif self.cookie.has_key('%s_sidebar_width' % module_name):
63 - self.sidebar_width = self.cookie['%s_sidebar_width' % module_name].value
64 - if self.cookie.has_key('%s_main_height' % module_name):
65 - main_height = self.cookie['%s_main_height' % module_name].value
66 - if self.cookie.has_key('%s_page_content_height' % module_name):
67 - page_content_height = self.cookie['%s_page_content_height' % module_name].value
68 + if is_moin_1_6 or is_moin_1_7 or is_moin_1_8:
69 + if self.cookie.has_key('%s_hide_sidebar' % module_name):
70 + self.sidebar_width = "0px"
71 + elif self.cookie.has_key('%s_sidebar_width' % module_name):
72 + self.sidebar_width = self.cookie['%s_sidebar_width' % module_name].value
73 + if self.cookie.has_key('%s_main_height' % module_name):
74 + main_height = self.cookie['%s_main_height' % module_name].value
75 + if self.cookie.has_key('%s_page_content_height' % module_name):
76 + page_content_height = self.cookie['%s_page_content_height' % module_name].value
77 + elif is_moin_1_9:
78 + if self.cookie.has_key('%s_hide_sidebar' % module_name):
79 + self.sidebar_width = "0px"
80 + elif self.cookie.has_key('%s_sidebar_width' % module_name):
81 + self.sidebar_width = self.request.cookies.get('%s_sidebar_width' % module_name)
82 + if self.cookie.has_key('%s_main_height' % module_name):
83 + main_height = self.request.cookies.get('%s_main_height' % module_name)
84 + if self.cookie.has_key('%s_page_content_height' % module_name):
85 + page_content_height = self.request.cookies.get('%s_page_content_height' % module_name)
86 + else:
87 + raise NotImplementedError("Moin version " + str(version.release) + " is not supported yet")
88
89 is_ltr = self.i18n.getDirection(self.request.lang) == "ltr"
90
91 @@ -414,7 +439,7 @@
92 toolbar.append('<li>%s</li>' % self.make_iconlink("userprefs", d))
93 else:
94 toolbar.append('<li>%s</li>' % self.make_iconlink(icon, d))
95 - else: # Moin 1.7
96 + elif is_moin_1_7 or is_moin_1_8 or is_moin_1_9:
97 if request.user.valid:
98 if request.user.auth_method in request.cfg.auth_can_logout:
99 toolbar.append('<li class="ib_selected">%s</li>' % self.make_iconlink("logout", d))
100 @@ -425,6 +450,8 @@
101 toolbar.append('<li>%s</li>' % self.make_iconlink('login direct', d))
102 else:
103 toolbar.append('<li>%s</li>' % self.make_iconlink(icon, d))
104 + else:
105 + raise NotImplementedError("Moin version " + str(version.release) + " is not supported yet")
106 elif icon == "quicklink" and request.user.valid:
107 # Only display for logged in users
108 toolbar.append('<li%s>%s</li>' % [('', self.make_iconlink(icon, d)), (' class="ib_selected"', self.make_iconlink("quickunlink", d))][request.user.isQuickLinkedTo([self.page_name])])
109 @@ -665,10 +692,12 @@
110 # On categories remove the key string identifying a category (default 'Category')
111 if match_object.lastindex:
112 self.display_name = match_object.group(1).lstrip()
113 - else: # Moin 1.7
114 + elif is_moin_1_7 or is_moin_1_8 or is_moin_1_9:
115 # Extract the key of the category to be dispalyed only
116 if match_object.groupdict().has_key('key'):
117 self.display_name = match_object.groupdict()['key'].lstrip()
118 + else:
119 + raise NotImplementedError("Moin version " + str(version.release) + " is not supported yet")
120 else:
121 self.type = 1 # page
122
123 @@ -825,7 +854,12 @@
124 self.log_pos = self.cache[0]
125 self.total_size = self.cache[1]
126 self.summary_html = self.cache[2]
127 - elog = self.request.editlog
128 + if is_moin_1_6 or is_moin_1_7 or is_moin_1_8:
129 + elog = self.request.editlog
130 + elif is_moin_1_9:
131 + elog = editlog.EditLog(self.request)
132 + else:
133 + raise NotImplementedError("Moin version " + str(version.release) + " is not supported yet")
134 old_pos = self.log_pos
135 new_pos, items = elog.news(old_pos)
136 if self.request.action == 'refresh':
137 @@ -873,8 +907,13 @@
138 self.add_page(page_name)
139 # print '>>>>>> Finish Build WikiTree: ', time.clock()
140 self.finalize_touched()
141 -
142 - self.log_pos, items = self.request.editlog.news(None) # ToDo: Optimize. Only need end position
143 + if is_moin_1_6 or is_moin_1_7 or is_moin_1_8:
144 + elog = self.request.editlog
145 + elif is_moin_1_9:
146 + elog = editlog.EditLog(self.request)
147 + else:
148 + raise NotImplementedError("Moin version " + str(version.release) + " is not supported yet")
149 + self.log_pos, items = elog.news(None) # ToDo: Optimize. Only need end position
150 self.cache = self.build_cache_data()
151 self.request.cfg.cache.meta.putItem(self.request, u'', u'wiki_tree', self.cache)
152 self.write_disk_cache(self.cache)
153 @@ -960,8 +999,8 @@
154 attachments = {}
155 for file in files:
156 fsize = float(self.os.stat(self.os.path.join(attach_dir,file).encode(self.config.charset))[6])
157 - get_url = self.AttachFile.getAttachUrl(page_name, file, self.request, escaped=1)
158 - attachments[file] = [fsize, get_url]
159 + get_url = self.AttachFile.getAttachUrl(page_name, file, self.request)
160 + attachments[file] = [fsize, self.wikiutil.escape(get_url, 1)]
161 return attachments
162
163
164 @@ -1141,10 +1180,15 @@
165 self.userid = request.user.id
166 self.acl_caching = getattr(request.cfg, 'wiki_tree_acl_caching', True)
167 # Get the cookie of the request
168 - if is_moin_1_6: # Moin 1.6
169 + if is_moin_1_6:
170 self.cookie = request.parse_cookie()
171 - else: # Moin 1.7
172 + elif is_moin_1_7 or is_moin_1_8:
173 self.cookie = request.cookie
174 + elif is_moin_1_9:
175 + self.cookie = request.cookies
176 + else:
177 + raise NotImplementedError("Moin version " + str(version.release) + " is not supported yet")
178 +
179 if not self.cookie:
180 self.cookie = self.Cookie.SimpleCookie()
181
182 @@ -1153,8 +1197,15 @@
183
184 self.expand_subtree = ''
185 if self.cookie.has_key('expand_subtree'):
186 - self.expand_subtree = self.cookie['expand_subtree'].value
187 - self.cookie[self.expand_subtree] = 1
188 + if is_moin_1_6 or is_moin_1_7 or is_moin_1_8:
189 + self.expand_subtree = self.cookie['expand_subtree'].value
190 + self.cookie[self.expand_subtree] = 1
191 + elif is_moin_1_9:
192 + self.expand_subtree = self.request.cookies.get('expand_subtree')
193 + self.request.set_cookie('expand_subtree', value=1)
194 + else:
195 + raise NotImplementedError("Moin version " + str(version.release) + " is not supported yet")
196 +
197 return self.subtree_html(self.root)
198
199
200 @@ -1240,7 +1291,12 @@
201 is_path_to_root = False
202 for parent_name in node.parents:
203 if self.expand_parents(parent_name, path):
204 - self.cookie[id] = 'X'
205 + if is_moin_1_6 or is_moin_1_7 or is_moin_1_8:
206 + self.cookie[id] = 'X'
207 + elif is_moin_1_9:
208 + self.request.set_cookie(id, value='X')
209 + else:
210 + raise NotImplementedError("Moin version " + str(version.release) + " is not supported yet")
211 is_path_to_root = True
212 break
213 return is_path_to_root
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.