Changeset 14996 in project


Ignore:
Timestamp:
06/14/09 22:00:10 (10 years ago)
Author:
azul
Message:

Preserve tag and size elements in query string in links in the gallery of a given tag and also in the Prev/Next? links. Also, use svnwiki-with-tmp-file so that previously generated images won't be regenerated unless needed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/3/svnwiki-image/trunk/svnwiki-image.scm

    r14955 r14996  
    6868  if (!found)
    6969    return;
     70  var size = '';
     71  svnwikiJavascript.queryStringInit();
     72  if (svnwikiJavascript.queryString['size'])
     73    size += '&size=' + svnwikiJavascript.queryString['size'][0];
    7074  if (prev)
    71     svnwikiImage.addTagLinksOne(ul, linkTags, prev, '⇩ Previous in tag: ' + tag, tag);
    72   svnwikiImage.addTagLinksOne(ul, linkTags, tag, 'Tag: ' + tag, tag);
     75    svnwikiImage.addTagLinksOne(ul, linkTags + '/' + prev + '?tag=' + tag + size, '⇩ Previous in tag: ' + tag);
     76  svnwikiImage.addTagLinksOne(ul, linkTags + '/' + tag + '?view=image' + size, 'Tag: ' + tag);
    7377  if (next)
    74     svnwikiImage.addTagLinksOne(ul, linkTags, next, 'Next in tag: ' + tag + ' ⇹', tag);
    75 }
    76 
    77 svnwikiImage.addTagLinksOne = function (ul, linkTags, target, linkName, tagName) {
    78   ul.appendChild(svnwikiJavascript.makeElement('li', svnwikiJavascript.makeLink(linkTags + '/' + target + '?tag=' + tagName, document.createTextNode(linkName))));
     78    svnwikiImage.addTagLinksOne(ul, linkTags + '/' + next + '?tag=' + tag + size, 'Next in tag: ' + tag + ' ⇹');
     79}
     80
     81svnwikiImage.addTagLinksOne = function (ul, target, linkName) {
     82  ul.appendChild(svnwikiJavascript.makeElement('li', svnwikiJavascript.makeLink(target, document.createTextNode(linkName))));
    7983}
    8084
     
    8488  // from initializeImageView.
    8589  svnwikiJavascript.queryStringInit();
    86   var size = parseInt(svnwikiJavascript.queryString['size']);
     90  if (!svnwikiJavascript.queryString['size'])
     91    return;
     92  var size = parseInt(svnwikiJavascript.queryString['size'][0]);
    8793  if (isNaN(size))
    8894    return;
     
    152158
    153159svnwikiImage.updateImagesDisplay = function() {
     160  svnwikiJavascript.queryStringInit();
     161  var size = svnwikiJavascript.queryString['size'];
    154162  document.getElementById('tag-list-images').style.display = 'inline'
    155163  var container = document.getElementById('tag-list-images').getElementsByTagName('ul')[1];
    156164  svnwikiJavascript.cleanContent(container)
    157   for (i = 0; i < svnwikiImage.imagesList.length; i ++) {
     165  for (var i = 0; i < svnwikiImage.imagesList.length; i ++) {
    158166    url = svnwikiImage.imagesList[i][0];
    159167    name = svnwikiImage.imagesList[i][1];
    160168    var img = svnwikiJavascript.makeElement('img');
    161169    img.setAttribute('src', url + '-' + svnwikiImage.imageSizes[svnwikiImage.currentImageSize]);
    162     if (svnwikiImage.currentTag)
    163       url += '?tag=' + svnwikiImage.currentTag;
     170    separator = '?'
     171    if (svnwikiImage.currentTag) {
     172      url += separator + 'tag=' + svnwikiImage.currentTag;
     173      separator = '&';
     174    } 
     175    if (size) {
     176      url += separator + 'size=' + svnwikiJavascript.queryString['size'][0];
     177      separator = '&';
     178    }
    164179    container.appendChild(svnwikiJavascript.makeElement('li', svnwikiJavascript.makeLink(url, img)));
    165180  }
     
    319334        (for-each
    320335          (lambda (size)
    321             (svnwiki-report-progress env "Image render generate: ~A: ~A by ~A pixels~%" path (car size) (cadr size))
    322             (system
    323               (format #f "anytopnm ~A | pnmscale -xysize ~A ~A | pnmto~A >~A"
    324                       (svnwiki-path-escape (svnwiki-make-pathname path-in path))
    325                       (car size)
    326                       (cadr size)
    327                       subtype
    328                       (svnwiki-path-escape
    329                         (svnwiki-make-pathname
    330                           path-out
    331                           (format #f "~A-~A" path (max (car size) (cadr size)))
    332                           subtype)))))
     336            (svnwiki-with-tmp-file
     337              (format #f "~A-~A" path (apply max size))
     338              (format #f "image/~A" subtype)
     339              path-out
     340              (lambda (path-out-real)
     341                (svnwiki-report-progress env "Image render generate: ~A: ~A by ~A pixels~%" path (car size) (cadr size))
     342                (system
     343                  (format #f "anytopnm ~A | pnmscale -xysize ~A ~A | pnmto~A >~A"
     344                          (svnwiki-path-escape (svnwiki-make-pathname path-in path))
     345                          (car size)
     346                          (cadr size)
     347                          subtype
     348                          (svnwiki-path-escape path-out-real))))))
    333349          (svnwiki-image-sizes size-x size-y))))))
    334350
Note: See TracChangeset for help on using the changeset viewer.