Show
Ignore:
Timestamp:
10/11/08 16:57:22 (3 months ago)
Author:
kiyoka
Message:

Added monthly index feature to blog-list page.

Files:
1 modified

Legend:

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

    r20419 r21126  
    5656          oldtype:utc->ago-string 
    5757          oldtype:grouping-blog-entries 
     58          oldtype:thumbnail-filter 
    5859          pretty-print-sexp)) 
    5960(select-module oldtype.util) 
     
    307308 
    308309 
     310;; 
     311;; test pattern: 
     312;;   (thumbnail-filter '("line 1" 
     313;;                       "line 2" 
     314;;                       "line 3" 
     315;;                       "line 4" 
     316;;                       "##(amazon 4873113482)       ##(img-s ../img/abc.jpg)" 
     317;;                       "! ##(youtube 4873113482)    ##(img-m ../img/abc.jpg)" 
     318;;                       )) 
     319;; result: 
     320;;  "##(img-s ../img/abc.jpg)  ##(amazon-s 4873113482) " 
     321;;  
     322(define (oldtype:thumbnail-filter str-list) 
     323  (let1 ret '() 
     324        (for-each 
     325         (lambda (line) 
     326           (when (not (#/^[!]/ line)) 
     327             (regexp-replace-all 
     328              #/##\((img|img-s|img-m|youtube|youtube-s|youtube-m|amazon|amazon-s|amazon-m)[ ]+([^\)]+)\)/ 
     329              line 
     330              (lambda (m) 
     331                (push! ret (list 
     332                            (rxmatch-substring m 1) 
     333                            (rxmatch-substring m 2))))))) 
     334         str-list) 
     335        (string-join 
     336         (map 
     337          (lambda (x) 
     338            (let1 command-pair (string-split (car x) #\-) 
     339                  (string-append 
     340                   "##(" (car command-pair) "-s " (cadr x) ") "))) 
     341          (reverse ret))))) 
     342 
     343 
    309344(provide "oldtype/util")