Changeset 250:ef4aab45811b

Show
Ignore:
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
  • browser.py

    r246 r250  
    180180            #  avoiding information disclosure (double dot attack) 
    181181            self.emit_data(http_status=httplib.BAD_REQUEST) 
     182        # defaults 
    182183        use_header_and_footer = True 
     184        h1_class = "File" 
    183185        if not os.path.exists(path): 
    184186            self.emit_data(http_status=httplib.NOT_FOUND) 
     
    202204                # emit the frame 
    203205                html = converter.dir_to_html(path, params) 
     206                h1_class = "Dir" 
    204207        elif self.is_image_path(path): 
    205208            html = converter.image_to_html(url) 
     
    217220        title = urllib.unquote(title) 
    218221        self.emit_data(html, title=title, mtime=os.path.getmtime(path), 
     222                       h1_class=h1_class, 
    219223                       use_header_and_footer=use_header_and_footer) 
    220224 
  • converter.py

    r233 r250  
    189189    path = os.path.normpath(path) 
    190190    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 
    191195    html_parts = [] 
    192196    add_html = html_parts.append 
     
    200204        add_html(u'<tr><td><span class="Options">' 
    201205          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: 
    204207        # HTML for spacing 
    205208        spacing = (u'<span class="Indent">' + 
     
    212215        link_text = cgi.escape(coding.decode(os.path.basename(item))) 
    213216        if os.access(item, os.R_OK): 
    214             url = urlpath.to_url(config.root, item) 
    215217            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) 
    217222                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 
    219227            else: 
    220228                params['frames'] = "no" 
     229                url = urlpath.to_url(config.root, item) 
     230                url = session.default_session.add_to_url(url, params) 
    221231                target = config.SOURCE_WINDOW_TARGET 
    222232            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) 
    223236        else: 
    224237            # not really a link 
  • websourcebrowser.css

    r222 r250  
    22h1 { margin: 0px; display: block; padding: 5px; font-size: 120%; 
    33     position: fixed; top: 0px; left: 0px; width: 100%; z-index: 2; } 
    4 h1.Path { background-color: #9090ff ; } 
     4h1.Dir { position: relative; } 
     5h1.Dir, h1.File { background-color: #9090ff ; } 
     6h1.Error, .Error { background-color: #ff9090; } 
    57h1.Other { background-color: #90ff90; } 
    6 h1.Error, .Error { background-color: #ff9090; } 
    78.Main { margin: 0.8em; padding-bottom: 1ex; 
    89        position: absolute; top: 2.5em; z-index: 1; }