Changeset 14921 in project


Ignore:
Timestamp:
06/06/09 19:05:28 (10 years ago)
Author:
azul
Message:

Add support for other types of views for elements with a given tag. Used currently for image galleries.

File:
1 edited

Legend:

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

    r14100 r14921  
    77
    88(define (show-tags-related env)
    9   (let-from-environment env (db path-in path path-out path-out-real program)
     9  (let-from-environment env (db path-in path path-out program)
    1010    (assert (and 'show-tags-related (string? path-in)))
    1111    (when (file-exists? (svnwiki-make-pathname path-in path))
     
    118118
    119119  if (info.filesFound.length == 0) {
    120     info.div.appendChild(svnwikiJavascript.makeElement('p', document.createTextNode("Ooops, we don't know how to compute the tags related to an empty tag.")))
     120    info.div.appendChild(svnwikiJavascript.makeElement('p', document.createTextNode("Ooops, we don't know how to compute the tags related to an empty tag.")));
    121121    return;
    122122  }
     
    164164
    165165  if (info.filesLoaded < info.filesFound.length) {
    166     var components = String.split(info.filesFound[info.filesLoaded++], "/"); 
     166    var components = String.split(info.filesFound[info.filesLoaded++], "/");
    167167    var last = components.pop(), file = "";
    168168    components.push("xsvnwiki-tags-file/" + last);
     
    185185    info.filesError.push(info.filesFound[info.filesLoaded - 1]);
    186186  svnwikiTagsLoader.relatedUpdate(info);
     187}
     188
     189svnwikiTagsLoader.displayFiles = function () {
     190  document.getElementById('tag-list-files').style.display = 'inline';
     191  // TODO: The list of elements to hide should not be hardcoded here!
     192  document.getElementById('tag-list-images').style.display = 'none';
     193}
     194
     195svnwikiTagsLoader.onLoad = function (data) {
     196  svnwikiJavascript.queryStringInit();
     197  var view = svnwikiJavascript.queryString['view'];
     198  if (!data[view])
     199    return;
     200  data[view]();
    187201}
    188202EOF
     
    207221
    208222(svnwiki-extension-define 'html-body-top 'folksonomy html-body-top)
     223
     224(define (files-actions-links env)
     225  (let-from-environment env (path path-out-real)
     226    (when (and (string=? path "xsvnwiki-tags")
     227               (not (string=? (svnwiki-basename path-out-real) "xsvnwiki-all")))
     228      (let-from-environment env (tags-views)
     229        (unless (stream-null? tags-views)
     230          (svnwiki-file-action-link
     231            env
     232            "javascript: svnwikiTagsLoader.displayFiles();"
     233            "Files")
     234          (stream-for-each
     235            (lambda (data)
     236              (svnwiki-file-action-link
     237                env
     238                (format #f "javascript: ~A" (list-ref data 2))
     239                (list-ref data 1)))
     240            tags-views))))))
     241
     242(svnwiki-extension-define 'files-actions-links 'folksonomy files-actions-links)
     243
     244(define (onload env)
     245  (let-from-environment env (path path-out-real)
     246    (when (and (string=? path "xsvnwiki-tags")
     247               (not (string=? (svnwiki-basename path-out-real) "xsvnwiki-all")))
     248      (let-from-environment env (return tags-views)
     249        (return
     250          (html-stream
     251            (format #f "svnwikiTagsLoader.onLoad({ ~:{~A: function () { ~A; },~}});"
     252                    (stream->list
     253                      (stream-map
     254                        (lambda (data)
     255                          (list (car data) (caddr data)))
     256                        tags-views)))))))))
     257
     258(svnwiki-extension-define 'onload 'folksonomy onload)
Note: See TracChangeset for help on using the changeset viewer.