Changeset 18162 in project


Ignore:
Timestamp:
05/23/10 12:22:19 (9 years ago)
Author:
azul
Message:

release

Location:
release/3/svnwiki-archives/tags/1.1
Files:
1 edited
2 copied

Legend:

Unmodified
Added
Removed
  • release/3/svnwiki-archives/tags/1.1/svnwiki-archives.scm

    r12533 r18162  
    44
    55(declare (export))
    6 (use svnwiki-extensions-support stream-ext srfi-40 html-stream svn-post-commit-hooks orders format-modular srfi-1 orders svn-client)
     6(use svnwiki-extensions-support stream-ext srfi-40 html-stream svn-post-commit-hooks format-modular srfi-1 orders svn-client)
    77
    88(define (get-archive-path-startup env)
     
    4040                ((script type "text/javascript" src (format #f "~A/xsvnwiki-helper/archive/archive" static-url)))
    4141                ((script type "text/javascript")
    42                  (format #f "<!--~%if (typeof(showArchive) == 'function') { loadXml ('~A', function (x) { showArchive(x, '~A', '~A'); }); }~%-->" (make-link-url path-out-real (format #f "~A/xsvnwiki-archive/files.xml" real-path) #f) id link)))))
     42                 (format #f "<!--~%if (typeof(showArchive) == 'function') { svnwikiJavascript.loadXml ('~A', function (x) { showArchive(x, '~A', '~A'); }); }~%-->" (make-link-url path-out-real (format #f "~A/xsvnwiki-archive/files.xml" real-path) #f) id link)))))
    4343          (html-stream
    4444            ((div id "archive")
     
    4646      stream-null)))
    4747
    48 (define *archive-js-code* #<<EOF
    49 // We use this to avoid the GC from collecting objects from loadXml before
    50 // they have actually loaded their documents and processed them:
    51 
    52 var requests = new Array();
    53 
    54 function loadXml (href, process)
    55 {
    56   var xmlDoc;
    57   var len = requests.length;
    58 
    59   if (document.implementation && document.implementation.createDocument)
    60     {
    61       xmlDoc = document.implementation.createDocument("", "", null);
    62       xmlDoc.onload = function () { removeRequest(xmlDoc); process(xmlDoc) };
    63     }
    64   else if (window.ActiveXObject)
    65     {
    66       xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    67       xmlDoc.onreadystatechange = function () { if (xmlDoc.readyState == 4) { removeRequest(xmlDoc); process(xmlDoc); } };
    68     }
    69   else
    70     {
    71       alert('Your browser can\'t handle this script');
    72       return;
    73     }
    74 
    75   requests.push(xmlDoc);
    76   xmlDoc.load(href);
    77 }
    78 
    79 function removeRequest (element)
    80 {
    81   var rd, wr;
    82   for (rd = 0, wr = 0; rd < requests.length; rd ++)
    83     if (requests[rd] != element)
    84       requests[wr ++] = requests[rd];
    85   while (wr < requests.len)
    86     requests.pop();
    87 }
    88 
    89 function cleanContent (element)
    90 {
    91   while (element.hasChildNodes())
    92     element.removeChild(element.firstChild);
    93 }
    94 
    95 function makeLink ( target, content )
    96 {
    97   var link = makeElement('A', content);
    98   link.setAttribute('href', target);
    99   return link;
    100 }
    101 
    102 function makeElement (type, content)
    103 {
    104   var elem = document.createElement(type);
    105   if (content)
    106     elem.appendChild(content);
    107   return elem;
    108 }
    109 
     48(define (archive-js-code env)
     49#<<EOF
    11050function showArchive (xmlDoc, obj, prefix)
    11151{
     
    11555    return;
    11656
    117   var content = document.getElementById(obj)
    118   cleanContent(content)
    119 
    120   var list = makeElement('ul');
     57  var content = svnwikiJavascript.cleanContent(document.getElementById(obj));
     58
     59  var list = svnwikiJavascript.makeElement('ul');
    12160  list.setAttribute('class', 'archive');
    12261
     
    12766      for (var j = 0; j < months.length; j ++)
    12867        {
     68          var m =  svnwikiJavascript.makeElement('p');
     69          m.setAttribute('class', 'archive');
     70
    12971          var link_text = years[i].getAttribute('name') + '-' + months[j].getAttribute('name');
    13072          var link_target = prefix + "/" + years[i].getAttribute('name') + '-' + months[j].getAttribute('name');
    13173
    132           var m =  makeElement('p');
    133           m.setAttribute('class', 'archive');
    134 
    135           var link = makeLink(link_target, document.createTextNode(link_text));
     74          var link = svnwikiJavascript.makeLink(link_target, document.createTextNode(link_text));
    13675          link.setAttribute('class', 'archive');
    13776
     
    13978          m.appendChild(document.createTextNode(' (' +  months[j].getAttribute('files') + ')'));
    14079
    141           list.appendChild(makeElement('li',  m));
     80          list.appendChild(svnwikiJavascript.makeElement('li',  m));
    14281        }
    14382    }
     
    322261      (get-props-parents-first "svnarchive:ignore" path-in (svnwiki-make-pathname path (car entry)) #f)))
    323262
    324 (define (archive-start-update-notify env)
    325   (let-from-environment env (path-out)
    326     (unless (directory? (svnwiki-make-pathname path-out "xsvnwiki-helper"))
    327       (create-directory (svnwiki-make-pathname path-out "xsvnwiki-helper")))
    328     (unless (directory? (svnwiki-make-pathname (list path-out "xsvnwiki-helper") "archive"))
    329       (create-directory (svnwiki-make-pathname (list path-out "xsvnwiki-helper") "archive")))
    330     (write-file-with-tmp
    331       (svnwiki-make-pathname (list "xsvnwiki-helper" "archive") "archive")
    332       "text/javascript"
    333       path-out
    334       (string->stream *archive-js-code*))))
    335 
    336263(svnwiki-extension-define 'update-notify 'archive archive-update)
    337 (svnwiki-extension-define 'start-update-notify 'archive archive-start-update-notify)
     264(svnwiki-extension-define 'javascript 'archive archive-js-code)
    338265(svnwiki-extension-define 'code-break 'archive archive-toc-links)
Note: See TracChangeset for help on using the changeset viewer.