Changeset 250:ef4aab45811b
- Timestamp:
- 2007-08-12 16:58:51
(1 year ago)
- Author:
- Stefan Schwarzer <sschwarzer@sschwarzer.net>
- branch:
- default
- Message:
Change semantics when clicking on a directory link. This no longer
opens a two-pane frameset for the clicked directory. Instead, the
directories are displayed in the left frame with a dir level so that
the contained items in the clicked directory are visible.
If the user selects to see "all" directory levels, Websourcebrowser
now determines the actual dir levels setting and sets the
corresponding query parameter accordingly. The intended side effect is
that the user can decrease the nesting level one by one since the
actual level (and one less) is displayed in the options header.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r246 |
r250 |
|
| 180 | 180 | # avoiding information disclosure (double dot attack) |
|---|
| 181 | 181 | self.emit_data(http_status=httplib.BAD_REQUEST) |
|---|
| | 182 | # defaults |
|---|
| 182 | 183 | use_header_and_footer = True |
|---|
| | 184 | h1_class = "File" |
|---|
| 183 | 185 | if not os.path.exists(path): |
|---|
| 184 | 186 | self.emit_data(http_status=httplib.NOT_FOUND) |
|---|
| … | … | |
| 202 | 204 | # emit the frame |
|---|
| 203 | 205 | html = converter.dir_to_html(path, params) |
|---|
| | 206 | h1_class = "Dir" |
|---|
| 204 | 207 | elif self.is_image_path(path): |
|---|
| 205 | 208 | html = converter.image_to_html(url) |
|---|
| … | … | |
| 217 | 220 | title = urllib.unquote(title) |
|---|
| 218 | 221 | self.emit_data(html, title=title, mtime=os.path.getmtime(path), |
|---|
| | 222 | h1_class=h1_class, |
|---|
| 219 | 223 | use_header_and_footer=use_header_and_footer) |
|---|
| 220 | 224 | |
|---|
| r233 |
r250 |
|
| 189 | 189 | path = os.path.normpath(path) |
|---|
| 190 | 190 | start_level = dir_level(path) |
|---|
| | 191 | items = list(itertools.ifilterfalse(_ignore_item, |
|---|
| | 192 | walk(path, params['dir_levels']))) |
|---|
| | 193 | actual_dir_level = max([dir_level(item) for item in items]) - start_level |
|---|
| | 194 | params['dir_levels'] = actual_dir_level |
|---|
| 191 | 195 | html_parts = [] |
|---|
| 192 | 196 | add_html = html_parts.append |
|---|
| … | … | |
| 200 | 204 | add_html(u'<tr><td><span class="Options">' |
|---|
| 201 | 205 | u'<a href="%s" target="_top">up</a></span></td></tr>' % parent_url) |
|---|
| 202 | | for item in itertools.ifilterfalse(_ignore_item, |
|---|
| 203 | | walk(path, params['dir_levels'])): |
|---|
| | 206 | for item in items: |
|---|
| 204 | 207 | # HTML for spacing |
|---|
| 205 | 208 | spacing = (u'<span class="Indent">' + |
|---|
| … | … | |
| 212 | 215 | link_text = cgi.escape(coding.decode(os.path.basename(item))) |
|---|
| 213 | 216 | if os.access(item, os.R_OK): |
|---|
| 214 | | url = urlpath.to_url(config.root, item) |
|---|
| 215 | 217 | if os.path.isdir(item): |
|---|
| 216 | | params['frames'] = "yes" |
|---|
| | 218 | params['frames'] = "no" |
|---|
| | 219 | params['dir_levels'] = \ |
|---|
| | 220 | max(actual_dir_level, dir_level(item) - start_level + 1) |
|---|
| | 221 | url = urlpath.to_url(config.root, path) |
|---|
| 217 | 222 | url = session.default_session.add_to_url(url, params) |
|---|
| 218 | | target = "_top" |
|---|
| | 223 | anchor = urlpath.to_url(config.root, item)[1:].\ |
|---|
| | 224 | replace("/", "___") |
|---|
| | 225 | url = "%s#%s" % (url, anchor) |
|---|
| | 226 | target = config.DIR_WINDOW_TARGET |
|---|
| 219 | 227 | else: |
|---|
| 220 | 228 | params['frames'] = "no" |
|---|
| | 229 | url = urlpath.to_url(config.root, item) |
|---|
| | 230 | url = session.default_session.add_to_url(url, params) |
|---|
| 221 | 231 | target = config.SOURCE_WINDOW_TARGET |
|---|
| 222 | 232 | link = u'<a href="%s" target="%s">%s</a>' % (url, target, link_text) |
|---|
| | 233 | # add an anchor in order to jump to directories |
|---|
| | 234 | if os.path.isdir(item): |
|---|
| | 235 | link = u'<a name="%s">%s</a>' % (anchor, link) |
|---|
| 223 | 236 | else: |
|---|
| 224 | 237 | # not really a link |
|---|
| r222 |
r250 |
|
| 2 | 2 | h1 { margin: 0px; display: block; padding: 5px; font-size: 120%; |
|---|
| 3 | 3 | position: fixed; top: 0px; left: 0px; width: 100%; z-index: 2; } |
|---|
| 4 | | h1.Path { background-color: #9090ff ; } |
|---|
| | 4 | h1.Dir { position: relative; } |
|---|
| | 5 | h1.Dir, h1.File { background-color: #9090ff ; } |
|---|
| | 6 | h1.Error, .Error { background-color: #ff9090; } |
|---|
| 5 | 7 | h1.Other { background-color: #90ff90; } |
|---|
| 6 | | h1.Error, .Error { background-color: #ff9090; } |
|---|
| 7 | 8 | .Main { margin: 0.8em; padding-bottom: 1ex; |
|---|
| 8 | 9 | position: absolute; top: 2.5em; z-index: 1; } |
|---|