Changeset 8676 for lang/gauche/oldtype

Show
Ignore:
Timestamp:
04/02/08 22:06:22 (5 years ago)
Author:
kiyoka
Message:

Some refactoring of ##(timestamp utc) and #(since utc) command.

Location:
lang/gauche/oldtype/trunk/Kahua/oldtype/oldtype
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • lang/gauche/oldtype/trunk/Kahua/oldtype/oldtype/format.scm

    r7811 r8676  
    158158;;          (lineno      . LINENO) 
    159159;;          (latest-rate . NUMBER) 
     160;;          (rev         . COMMIT_REVISION_NUMBER) 
     161;;          (commit-utc  . COMMIT_UTC_SECONDS) 
    160162;;        ) 
    161163;;        (TAG 
     
    200202                                            (car ann-of-line))) 
    201203                                      '((index . 5)))) 
     204                     (rev         (if ann-of-line 
     205                                      (car ann-of-line) 
     206                                      #f)) 
     207                     (info-of-line  (if rev 
     208                                        (assq-ref top rev) 
     209                                        #f)) 
     210                     (commit-utc    (if info-of-line 
     211                                        (assq-ref (assq-ref (car info-of-line) 'date) 'utc) 
     212                                        0)) 
    202213                     (latest-rate (assq-ref line-alist 'index))) 
    203214 
     
    219230                             (committer     . ,(if ann-of-line 
    220231                                                   (assq-ref (cadr ann-of-line) 'user) 
    221                                                    'oldtype))) 
     232                                                   'oldtype)) 
     233                             (rev           . ,rev) 
     234                             (commit-utc    . ,commit-utc) 
     235                             ) 
    222236                            ,@(rec (sxml:content sxml) hctx))) 
    223237                         ((a) 
  • lang/gauche/oldtype/trunk/Kahua/oldtype/oldtype/oldtype.kahua

    r8607 r8676  
    7878;; utility : internal sxml format to highger-order-tag 
    7979(define (sxml->higher-order-tag wikiname sxmls page-src) 
    80   (define _nbsp "\u00a0") 
    81   (define (space->nbsp string) 
    82     (regexp-replace-all #/ / string _nbsp)) 
    8380  (let1 is-w3m (eq? 'w3m (oldtype-user-agent)) 
    8481        (div/ 
     
    109106                                                     (td/ "committer") 
    110107                                                     (td/ (assq-ref param 'committer))) 
     108                                                    (tr/ 
     109                                                     (td/ "commit date") 
     110                                                     (td/ (string-append (oldtype:utc->date-string (assq-ref param 'commit-utc)) 
     111                                                                         (oldtype:space->nbsp (oldtype:utc->ago-string (assq-ref param 'commit-utc)))))) 
     112                                                    (tr/ 
     113                                                     (td/ "commit revision") 
     114                                                     (td/ (assq-ref param 'rev))) 
    111115                                                    (tr/ 
    112116                                                     (td/ "original-src") 
     
    138142                                             ((4)  (oldtype:icon-image 'new4)) 
    139143                                             (else (if is-w3m 
    140                                                        (space->nbsp "  ") 
     144                                                       (oldtype:space->nbsp "  ") 
    141145                                                       (oldtype:icon-image 'new5)))))))) 
    142146                               (_rest 
     
    169173                                                               (type "text") 
    170174                                                               (value (assq-ref param 'orig)))) 
    171                                                       (space->nbsp "  ") 
     175                                                      (oldtype:space->nbsp "  ") 
    172176                                                      (input/ (@/ 
    173177                                                               (type "button") 
     
    192196                                                  (oldtype:icon-image 'ul1)            (node-set (rec arg))))) 
    193197                              ((pre-ul2)     `(,@(span/ 
    194                                                   _nbsp 
     198                                                  (oldtype:space->nbsp " ") 
    195199                                                  (oldtype:icon-image 'ul2)            (node-set (rec arg))))) 
    196200                              ((pre-ul3)     `(,@(span/ 
    197                                                   _nbsp _nbsp 
     201                                                  (oldtype:space->nbsp "  ") 
    198202                                                  (oldtype:icon-image 'ul3)            (node-set (rec arg))))) 
    199203                              ((pre-ol1)     `(,@(span/ 
    200204                                                  (oldtype:icon-image 'ol1)            (node-set (rec arg))))) 
    201205                              ((pre-ol2)     `(,@(span/ 
    202                                                   _nbsp 
     206                                                  (oldtype:space->nbsp " ") 
    203207                                                  (oldtype:icon-image 'ol2)            (node-set (rec arg))))) 
    204208                              ((pre-ol3)     `(,@(span/  
    205                                                   _nbsp _nbsp 
     209                                                  (oldtype:space->nbsp "  ") 
    206210                                                  (oldtype:icon-image 'ol3)            (node-set (rec arg))))) 
    207211                              ((h1)          `(,@(h1/ (@/ (id "h1"))                   (node-set (rec arg))))) 
     
    236240              (cons 
    237241               (if string? 
    238                    (space->nbsp other) 
     242                   (oldtype:space->nbsp other) 
    239243                   other) 
    240244               (rec rest))))))))) 
  • lang/gauche/oldtype/trunk/Kahua/oldtype/oldtype/util.kahua

    r8607 r8676  
    1414(define (oldtype:static-image-path) 
    1515  (string-append "/kahua/" (kahua-worker-type) "/staticimg/")) 
     16 
     17(define (oldtype:space->nbsp string) 
     18  (define _nbsp "\u00a0") 
     19  (regexp-replace-all #/ / string _nbsp)) 
    1620 
    1721 
     
    220224     
    221225 
     226;; 
     227;; Convert utc seconds to "2008-03-20 09:36 PM (+0900)" 
     228;; 
     229(define (oldtype:utc->date-string utc) 
     230  (if utc 
     231      (let1 d (time-utc->date 
     232               (seconds->time 
     233                utc)) 
     234            (string-append (date->string d "~Y-~m-~d ~I:~M ~p (~z)"))) 
     235      "*NoDateInformation*")) 
     236 
     237;; 
     238;; Convert utc seconds to "    (10 seconds ago)" 
     239;; 
     240(define (oldtype:utc->ago-string utc) 
     241  (if utc 
     242      (string-append 
     243       (format "~18,,,' @a" 
     244               (string-append 
     245                "(" 
     246                (how-long-since utc) 
     247                " ago)"))) 
     248      "*NoDateInformation*")) 
     249       
     250 
     251 
    222252(define (oldtype:format-macro expr) 
    223253  (let ((command (car expr)) 
     
    298328      ((timestamp) 
    299329       (if (< 0 len) 
    300            (let* ((_utc    (car arg)) 
    301                   (d (time-utc->date 
    302                       (seconds->time 
    303                        (string->number 
    304                         _utc))))) 
    305              (text/ (string-append (date->string d "~Y-~m-~d ~I:~M ~p (~z)")))) 
     330           (let1 _utc (car arg) 
     331                 (text/ (oldtype:utc->date-string (string->number _utc)))) 
    306332           (p/ "!!Error : No argument ##(timestamp UTC) command"))) 
    307333 
     
    311337           (let1 _utc (car arg) 
    312338                 (text/  
    313                   (format "(~a ago)" 
    314                           (string-append 
    315                            (how-long-since  
    316                             (string->number 
    317                              _utc)))))) 
     339                  (oldtype:space->nbsp 
     340                   (oldtype:utc->ago-string (string->number _utc))))) 
    318341           (p/ "!!Error : No argument ##(since UTC) command"))) 
    319342