Ticket #591: make-egg-index.patch

File make-egg-index.patch, 5.6 KB (added by sjamaan, 13 years ago)

Don't hide invalid eggs but flag them as invalid in the HTML output

  • scripts/make-egg-index.scm

    diff --git a/scripts/make-egg-index.scm b/scripts/make-egg-index.scm
    index 27df8d3..6d2afa8 100644
    a b  
    3838    (macros "Macros and meta-syntax")
    3939    (misc "Miscellaneous")
    4040    (hell "Concurrency and parallelism")
    41     (uncategorized "Uncategorized")
     41    (uncategorized "Uncategorized or invalid category")
    4242    (obsolete "Unsupported or redundant") ) )
    4343
    4444(define (d fstr . args)
     
    145145        (p "Generated with Chicken " ,(chicken-version))))
    146146
    147147(define (emit-egg-information eggs)
    148   (append-map
    149    (match-lambda
    150      ((cat catname)
    151       (let ((eggs (append-map
    152                    make-egg-entry
    153                    (sort
    154                     (filter (lambda (info)
    155                               (and (eq? cat (cadr (or (assq 'category (cdr info))
    156                                                       '(#f uncategorized))))
    157                                    (not (assq 'hidden (cdr info)))))
    158                             eggs)
    159                     (lambda (e1 e2)
    160                       (string<? (symbol->string (car e1)) (symbol->string (car e2))))))))
    161         (if (null? eggs)
    162             '()
    163             (begin
    164               (d "category: ~a" catname)
    165               `((a (@ (name ,cat)))
    166                 (h3 (a (@ (href "#category-list"))
    167                        ,catname))
    168                 (table
    169                  (tr (th "Name") (th "Description") (th "License") (th "Author") (th "Maintainer") (th "Version"))
    170                  ,@eggs)))))))
    171    +categories+))
     148  (let ((catnames (map car +categories+)))
     149    (append-map
     150     (match-lambda
     151      ((cat catname)
     152       (let ((eggs (append-map
     153                    make-egg-entry
     154                    (sort
     155                     (filter (lambda (info)
     156                               (let* ((egg-cat (assq 'category (cdr info)))
     157                                      (catname (or (and egg-cat
     158                                                        (memq (cadr egg-cat)
     159                                                              catnames)
     160                                                        (cadr egg-cat))
     161                                                   'uncategorized)))
     162                                 (and (eq? cat catname)
     163                                      (not (assq 'hidden (cdr info))))))
     164                             eggs)
     165                     (lambda (e1 e2)
     166                       (string<? (symbol->string (car e1)) (symbol->string (car e2))))))))
     167         (if (null? eggs)
     168             '()
     169             (begin
     170               (d "category: ~a" catname)
     171               `((a (@ (name ,cat)))
     172                 (h3 (a (@ (href "#category-list"))
     173                        ,catname))
     174                 (table
     175                  (tr (th "Name") (th "Description") (th "License") (th "Author") (th "Maintainer") (th "Version"))
     176                  ,@eggs)))))))
     177     +categories+)))
    172178
    173179(define (make-egg-entry egg)
    174180  (call/cc
     
    178184             (else def)))
    179185     (define (check pred x p)
    180186       (cond ((pred x) x)
    181              (else
    182               (warning "extension has .meta entry of incorrect type and will not be listed" (car egg) p x)
    183               (return '()))))
     187             (else `(span (em (@ (class "meta-file-error"))
     188                              "Invalid meta-file property '" ,p "'")
     189                          " " (& "mdash")
     190                          " please contact this egg's author!"))))
    184191     (d "  ~a   ~a" (car egg) (prop 'version "HEAD" any?))
    185192     `((tr (td (a (@ (href ,(sprintf "http://wiki.call-cc.org/eggref/~a/~a" *major-version* (car egg))))
    186193                  ,(symbol->string (car egg))))
     
    191198           (td ,(prop 'version "" version?)))))))
    192199
    193200;; Names are either raw HTML, or [[user name]] denoting a wiki link.
    194 (define (linkify-names str)
     201(define (linkify-names sxml)
    195202  ;; Call MATCHED on (sub)matches and DID-NOT-MATCH on non-matches in STR,
    196203  ;; and collect into a list.
    197204  (define (transform irx str matched did-not-match)
     
    210217              (let ((m (irregex-search irx str i end)))
    211218                (if (not m)
    212219                    (finish i acc)
    213                     (let* ((end (irregex-match-end m 0))
     220                    (let* ((end (irregex-match-end-index m 0))
    214221                           (acc (kons i m acc)))
    215222                      (lp end acc))))))))
    216     (let ((irregex-match-start-index irregex-match-start)) ;; upcoming API change in irregex 0.7
    217       (irregex-fold irx
    218                     (lambda (i m s)
    219                       (cons (matched (irregex-match-substring m 1))
    220                             (cons (did-not-match
    221                                    (substring str i (irregex-match-start-index m 0)))
    222                                   s)))
    223                     '()
    224                     str
    225                     (lambda (i s)
    226                       (reverse (cons (did-not-match (substring str i))
    227                                      s))))))
    228   (transform
    229    +link-regexp+
    230    str
    231    (lambda (name)  ;; wiki username
    232      `(a (@ (href ,(string-append "http://wiki.call-cc.org/users/"
    233                                   (string-substitute " " "-" name 'global))))
    234          ,name))
    235    (lambda (x)     ;; raw HTML chunk
    236      `(literal ,x))))
     223    (irregex-fold irx
     224                  (lambda (i m s)
     225                    (cons (matched (irregex-match-substring m 1))
     226                          (cons (did-not-match
     227                                 (substring str i (irregex-match-start-index m 0)))
     228                                s)))
     229                  '()
     230                  str
     231                  (lambda (i s)
     232                    (reverse (cons (did-not-match (substring str i))
     233                                   s)))))
     234  (if (string? sxml)
     235      (transform
     236        +link-regexp+
     237        sxml
     238        (lambda (name)  ;; wiki username
     239          `(a (@ (href ,(string-append "http://wiki.call-cc.org/users/"
     240                                       (irregex-replace/all " " name "-"))))
     241              ,name))
     242        (lambda (x)     ;; raw HTML chunk
     243         `(literal ,x)))
     244      sxml))
    237245
    238246(define name?
    239247  (disjoin string? symbol?))