Show
Ignore:
Timestamp:
06/05/08 00:42:23 (5 years ago)
Author:
kiyoka
Message:

Changed aggregation logic of blog entries.

Files:
1 modified

Legend:

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

    r13023 r13242  
    3939  (use text.parse) 
    4040  (use file.util) 
     41  (use util.list) 
    4142  (use oldtype.pasttime) 
    4243  (export oldtype:otpath->wikiname 
     
    5556          oldtype:utc->date-string 
    5657          oldtype:utc->ago-string 
     58          oldtype:grouping-blog-entries 
    5759          pretty-print-sexp)) 
    5860(select-module oldtype.util) 
     
    253255      "*NoDateInformation*")) 
    254256 
     257;; 
     258;; grouping blog entry list by month 
     259;; 
     260;; arg: 
     261;;   ("kiyoka.2008_10_01.ot" "kiyoka.2008_10_03.ot" ...) 
     262;;  
     263;; result: 
     264;;   ( 
     265;;     (YEAR_MONTH LIST-OF-ENTRY) 
     266;;     (2008_10 ("kiyoka.2008_10_01.ot" "kiyoka.2008_10_03.ot" ...)) 
     267;;     (2008_11 ("kiyoka.2008_11_02.ot" "kiyoka.2008_11_03.ot" ...)) 
     268;;   ) 
     269;; 
     270(define (oldtype:grouping-blog-entries entrylist) 
     271  (define (check-format str) 
     272    (#/^[^.]+[.][0-9]+_[0-9]+_[0-9]+/ str)) 
     273 
     274  (let ((valid-entries 
     275         (filter 
     276          (lambda (name) 
     277            (check-format name)) 
     278          entrylist)) 
     279        (ht (make-hash-table 'string=?))) 
     280    (for-each 
     281     (lambda (name) 
     282       (let* ((lst (string-split name #/[._]/)) 
     283              (str (string-append (second lst)  ;; year 
     284                                  "_" 
     285                                  (third  lst)) ;; month 
     286                   )) 
     287         (hash-table-push! ht 
     288                           str 
     289                           name))) 
     290     valid-entries) 
     291    (hash-table->alist ht))) 
     292 
    255293 
    256294(provide "oldtype/util")