Changeset 4673

Show
Ignore:
Timestamp:
10/30/08 09:36:06 (2 months ago)
Author:
Blackhex
Message:

ScreenshotsPlugin:

  • Fixed uploaded file name problem on Windows.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • screenshotsplugin/0.11/tracscreenshots/core.py

    r4364 r4673  
    112112        if match: 
    113113            return True 
    114         match = re.match(r'''^/screenshots/(\d+)$''', req.path_info) 
     114        match = re.match(r'''^/screenshots/(\d+)($|/$)''', req.path_info) 
    115115        if match: 
    116116            req.args['action'] = 'get-file' 
     
    654654        if size == 0: 
    655655            raise TracError('Can\'t upload empty file.') 
    656         filename = os.path.basename(image.filename).decode('utf-8') 
     656 
     657        # Try to normalize the filename to unicode NFC if we can. 
     658        # Files uploaded from OS X might be in NFD. 
     659        self.log.debug('input filename: %s', (image.filename,)) 
     660        filename = unicodedata.normalize('NFC', to_unicode(image.filename, 
     661          'utf-8')) 
     662        filename = filename.replace('\\', '/').replace(':', '/') 
     663        filename = os.path.basename(filename) 
     664        self.log.debug('output filename: %s', (filename,)) 
    657665 
    658666        # Check correct file type. 
  • screenshotsplugin/0.11/tracscreenshots/templates/screenshot-add.html

    r4344 r4673  
    22<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:py="http://genshi.edgewall.org/"> 
    33  <xi:include href="layout.html"/> 
     4  <xi:include href="macros.html"/> 
    45  <head> 
    56    <title>Screenshots</title> 
  • screenshotsplugin/0.11/tracscreenshots/templates/screenshot.html

    r4344 r4673  
    22<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:py="http://genshi.edgewall.org/"> 
    33  <xi:include href="layout.html"/> 
     4  <xi:include href="macros.html"/> 
    45  <head> 
    56    <title>Screenshots</title> 
  • screenshotsplugin/0.11/tracscreenshots/templates/screenshots.html

    r4344 r4673  
    22<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:py="http://genshi.edgewall.org/"> 
    33  <xi:include href="layout.html"/> 
     4  <xi:include href="macros.html"/> 
    45  <head> 
    56    <title>Screenshots</title> 
  • screenshotsplugin/0.11/tracscreenshots/templates/screenshots-matrix-view.html

    r4359 r4673  
    11<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
    22<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:py="http://genshi.edgewall.org/"> 
    3   <div class="images"> 
    4     <table> 
    5       <tbody> 
    6         <py:for each="row in screenshots.matrix"> 
    7           <tr> 
    8             <py:for each="image in row"> 
    9               <td> 
    10                 <py:choose> 
    11                   <div py:when="image.id != -1" class="image" style="width: ${screenshots.width}px; height: ${screenshots.height}px"> 
    12                     <?python 
    13                       frame_aspect = float(screenshots['width']) / float(screenshots['height']) 
    14                       image_aspect = float(image['width']) / float(image['height']) 
    15                       if frame_aspect < image_aspect: 
    16                           image_width = screenshots['width'] 
    17                           image_height = int(screenshots['width'] / image_aspect + 0.5) 
    18                       else: 
    19                           image_width = int(screenshots['height'] * image_aspect + 0.5) 
    20                           image_height = screenshots['height'] 
    21                     ?> 
    22                     <a href="${href.screenshots(image.id)}" title="${image.id}" style="line-height: ${screenshots.height - 4}px"> 
    23                       <img src="${href.screenshots(image.id)}?width=${image_width};height=${image_height};format=raw" 
    24                         alt="${image.description}"/> 
    25                     </a> 
     3  <head> 
     4    <title>Screenshots - Matrix View</title> 
     5  </head> 
     6  <body> 
     7    <div class="images"> 
     8      <table> 
     9        <tbody> 
     10          <py:for each="row in screenshots.matrix"> 
     11            <tr> 
     12              <py:for each="image in row"> 
     13                <td> 
     14                  <py:choose> 
     15                    <div py:when="image.id != -1" class="image" style="width: ${screenshots.width}px; height: ${screenshots.height}px"> 
     16                      <?python 
     17                        frame_aspect = float(screenshots['width']) / float(screenshots['height']) 
     18                        image_aspect = float(image['width']) / float(image['height']) 
     19                        if frame_aspect < image_aspect: 
     20                            image_width = screenshots['width'] 
     21                            image_height = int(screenshots['width'] / image_aspect + 0.5) 
     22                        else: 
     23                            image_width = int(screenshots['height'] * image_aspect + 0.5) 
     24                            image_height = screenshots['height'] 
     25                      ?> 
     26                      <a href="${href.screenshots(image.id)}" title="${image.id}" style="line-height: ${screenshots.height - 4}px"> 
     27                        <img src="${href.screenshots(image.id, width = image_width, height = image_height, format = 'raw')}" 
     28                          alt="${image.description}"/> 
     29                      </a> 
     30                    </div> 
     31                    <div py:otherwise="" class="image noimage" style="width: ${screenshots.width}px; height: ${screenshots.height}px"> 
     32                      &nbsp; 
     33                    </div> 
     34                  </py:choose> 
     35                <div class="name">${image.name or '&nbsp;'}</div> 
     36                  <div py:if="'SCREENSHOTS_ADMIN' in perm" class="controls"> 
     37                    <py:choose> 
     38                      <py:when test="image.id != -1"> 
     39                        <a href="${href.screenshots()}?action=edit;id=${image.id};index=${screenshots.index}">Edit</a> 
     40                        <a href="${href.screenshots()}?action=delete;id=${image.id};index=${screenshots.index}">Delete</a> 
     41                      </py:when> 
     42                      <py:otherwise> 
     43                        &nbsp; 
     44                      </py:otherwise> 
     45                    </py:choose> 
    2646                  </div> 
    27                   <div py:otherwise="" class="image noimage" style="width: ${screenshots.width}px; height: ${screenshots.height}px"> 
    28                     &nbsp; 
    29                   </div> 
    30                 </py:choose> 
    31                <div class="name">${image.name or '&nbsp;'}</div> 
    32                 <div py:if="'SCREENSHOTS_ADMIN' in perm" class="controls"> 
    33                   <py:choose> 
    34                     <py:when test="image.id != -1"> 
    35                       <a href="${href.screenshots()}?action=edit;id=${image.id};index=${screenshots.index}">Edit</a> 
    36                       <a href="${href.screenshots()}?action=delete;id=${image.id};index=${screenshots.index}">Delete</a> 
    37                     </py:when> 
    38                     <py:otherwise> 
    39                       &nbsp; 
    40                     </py:otherwise> 
    41                   </py:choose> 
    42                 </div> 
    43               </td> 
    44             </py:for> 
    45           </tr> 
    46         </py:for> 
    47       </tbody> 
    48     </table> 
    49   </div> 
     47                </td> 
     48              </py:for> 
     49            </tr> 
     50          </py:for> 
     51        </tbody> 
     52      </table> 
     53    </div> 
    5054 
    51   <div class="controls"> 
    52     <div class="position">Page ${screenshots.page}/${screenshots.page_count}</div> 
    53     &larr; 
    54     <py:choose> 
    55       <py:when test="screenshots.prev_index != -1"> 
    56         <a href="${href.screenshots()}?index=0">First Page</a> 
    57       </py:when> 
    58       <py:otherwise> 
    59         First Page 
    60       </py:otherwise> 
    61     </py:choose> 
    62    
    63     <py:choose> 
    64       <py:when test="screenshots.prev_index != -1"> 
    65         <a href="${href.screenshots()}?index=${screenshots.prev_index}">Previous Page</a> 
    66       </py:when> 
    67       <py:otherwise> 
    68         Previous Page 
    69       </py:otherwise> 
    70     </py:choose> 
    71    
    72     <span> 
    73       <form class="goto" method="get" action="${href.screenshots()}"> 
    74         <input type="input" name="page" value="${screenshots.page or '1'}" onkeypress="return checkNumber(event)"/> 
    75         <input type="submit" value="Go"></input> 
    76       </form> 
    77     </span> 
    78    
    79     <py:choose> 
    80       <py:when test="screenshots.next_index != -1"> 
    81         <a href="${href.screenshots()}?index=${screenshots.next_index}">Next Page</a> 
    82       </py:when> 
    83       <py:otherwise> 
    84         Next Page 
    85       </py:otherwise> 
    86     </py:choose> 
    87    
    88     <py:choose> 
    89       <py:when test="screenshots.next_index != -1"> 
    90         <a href="${href.screenshots()}?index=${screenshots.screenshot_count - 1}">Last Page</a> 
    91       </py:when> 
    92       <py:otherwise> 
    93         Last Page 
    94       </py:otherwise> 
    95     </py:choose> 
    96     &rarr; 
    97  
    98   </div
     55    <div class="controls"> 
     56      <div class="position">Page ${screenshots.page}/${screenshots.page_count}</div> 
     57      &larr; 
     58      <py:choose> 
     59        <py:when test="screenshots.prev_index != -1"> 
     60          <a href="${href.screenshots()}?index=0">First Page</a> 
     61        </py:when> 
     62        <py:otherwise> 
     63          First Page 
     64        </py:otherwise> 
     65      </py:choose> 
     66     
     67      <py:choose> 
     68        <py:when test="screenshots.prev_index != -1"> 
     69          <a href="${href.screenshots()}?index=${screenshots.prev_index}">Previous Page</a> 
     70        </py:when> 
     71        <py:otherwise> 
     72          Previous Page 
     73        </py:otherwise> 
     74      </py:choose> 
     75     
     76      <span> 
     77        <form class="goto" method="get" action="${href.screenshots()}"> 
     78          <input type="input" name="page" value="${screenshots.page or '1'}" onkeypress="return checkNumber(event)"/> 
     79          <input type="submit" value="Go"></input> 
     80        </form> 
     81      </span> 
     82     
     83      <py:choose> 
     84        <py:when test="screenshots.next_index != -1"> 
     85          <a href="${href.screenshots()}?index=${screenshots.next_index}">Next Page</a> 
     86        </py:when> 
     87        <py:otherwise> 
     88          Next Page 
     89        </py:otherwise> 
     90      </py:choose> 
     91     
     92      <py:choose> 
     93        <py:when test="screenshots.next_index != -1"> 
     94          <a href="${href.screenshots()}?index=${screenshots.screenshot_count - 1}">Last Page</a> 
     95        </py:when> 
     96        <py:otherwise> 
     97          Last Page 
     98        </py:otherwise> 
     99      </py:choose> 
     100      &rarr; 
     101    </div> 
     102  </body
    99103</html>