Changeset 2312 in project


Ignore:
Timestamp:
11/09/06 03:22:42 (15 years ago)
Author:
azul
Message:

Don't hardcode the list of symbols that extensions can define.

Location:
stream-wiki/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • stream-wiki/trunk/extensions/archives.scm

    r2278 r2312  
    7373              (string->stream *archive-js-code*)))
    7474          (html-stream
    75             ((div id id)
     75            ((div id id class "archive")
    7676             (p "[" ((a href link) "Archive") "]"))
    7777            ((script type "text/javascript" src (make-link-url path-out-real "xsvnwiki-helper/archive/archive.js" #f)))
     
    155155
    156156  var list = makeElement('ul');
     157  list.setAttribute('class', 'archive');
    157158
    158159  for (var i = 0; i < years.length; i++)
     
    166167
    167168          var m =  makeElement('p');
    168           m.appendChild(makeLink(link_target, document.createTextNode(link_text)));
     169          m.setAttribute('class', 'archive');
     170
     171          var link = makeLink(link_target, document.createTextNode(link_text));
     172          link.setAttribute('class', 'archive');
     173
     174          m.appendChild(link);
    169175          m.appendChild(document.createTextNode(' (' +  months[j].getAttribute('files') + ')'));
    170176
  • stream-wiki/trunk/extensions/links.scm

    r2280 r2312  
    1 (define (link-digg-it data)
     1(define (link-digg-it env)
    22  (svnwiki-file-action-link
    3     data
    4     (string-append "http://www.digg.com/submit?phase=2&url=" (data 'static-url) (data 'path))
     3    env
     4    (string-append "http://www.digg.com/submit?phase=2&url=" (env 'static-url) (env 'path))
    55    "Digg it"))
    66
    7 (define (link-reddit data)
     7(define (link-reddit env)
    88  (svnwiki-file-action-link
    9     data
    10     (string-append "http://reddit.com/submit?url=" (data 'static-url) (data 'path))
     9    env
     10    (string-append "http://reddit.com/submit?url=" (env 'static-url) (env 'path))
    1111    "Reddit"))
    1212
    13 (define (link-delicious data)
    14   (let-from-environment data (path-in static-url path)
    15     (html-stream
    16       ((span class "render-bottom" id "delicious")
    17        ((a href (format #f "http://del.icio.us/post?url=~A~A&title=~A"
    18                         static-url
    19                         path
    20                         (let ((title (svn-propget "svnwiki:title" (svnwiki-make-pathname path-in path) "" "" '())))
    21                           (if (and title (not (null? title))) title path))))
    22         "Add to del.icio.us")))))
     13(define (link-delicious env)
     14  (let-from-environment env (path-in static-url path db)
     15    (svnwiki-render-bottom-span
     16      env
     17      (let* ((title-prop (svn-propget "svnwiki:title" (svnwiki-make-pathname path-in path) "" "" '()))
     18             (title (if (and title-prop (not (null? title-prop))) (cadar title-prop) path)))
     19        (html-stream
     20          ((a class "render-bottom-span render-bottom-span-delicious-links"
     21              href (format #f "http://del.icio.us/post?url=~A~A&title=~A" static-url path title)
     22              onclick (format #f "window.open('http://del.icio.us/post?v=4&noui&jump=close&url=~A~A&title=~A', 'delicious','toolbar=no,width=700,height=400'); return false;" static-url path title))
     23           ((img src "http://images.del.icio.us/static/img/delicious.small.gif" border 0))
     24           " Save to del.icio.us"))))))
    2325
    2426(set! *extensions*
    2527  `((digg   (files-actions-links ,link-digg-it))
    26     (delicious (files-render-bottom ,link-delicious))
     28    (delicious (render-bottom-span ,link-delicious))
    2729    (reddit (files-actions-links ,link-reddit))))
  • stream-wiki/trunk/stream-wiki.scm

    r2274 r2312  
    2929    extension-files-actions-links
    3030    extension-toc-header
    31     extension-render-bottom
    32     extension-render-top
     31    extension-data
    3332
    3433    ; Exports for extensions:
     
    8786; name is a symbol with the name for the tag (all in lower).
    8887
    89 (define-record extension name code-span code-break update files-actions-links toc-header render-top render-bottom)
     88(define-record extension name table)
    9089
    9190; Output is an output driver.  See html-driver for an example.
     
    15161515
    15171516(define (alist->extension alist)
    1518   (apply make-extension
    1519          (car alist)
    1520          (map (lambda (sym)
    1521                 (let ((value (assoc (car sym) (cdr alist))))
    1522                   (cadr
    1523                     (if (and value (pair? (cdr value)))
    1524                       value
    1525                       sym))))
    1526               '((code-span #f)
    1527                 (code-break #f)
    1528                 (update #f)
    1529                 (files-actions-links #f)
    1530                 (toc-header #f)
    1531                 (render-top #f)
    1532                 (render-bottom #f)))))
     1517  (make-extension (car alist) (cdr alist)))
     1518
     1519(define (extension-data ext data)
     1520  (let ((value (assoc data (extension-table ext))))
     1521    (and value
     1522         (pair? (cdr value))
     1523         (cadr value))))
     1524
     1525(define extension-code-span (cut extension-data <> 'code-span))
     1526(define extension-code-break (cut extension-data <> 'code-break))
     1527(define extension-update (cut extension-data <> 'update))
     1528(define extension-files-actions-links (cut extension-data <> 'files-actions-links))
     1529(define extension-toc-header (cut extension-data <> 'toc-header))
    15331530
    15341531(define (run-span-extension extension text params info)
Note: See TracChangeset for help on using the changeset viewer.