Changeset 21126

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

Added monthly index feature to blog-list page.

Location:
lang/gauche/oldtype/trunk
Files:
3 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") 
  • lang/gauche/oldtype/trunk/Kahua/oldtype/oldtype/version.kahua

    r20400 r21126  
    77 
    88;;--------------------------------------------------------- 
    9 (define *oldtype-version* "0.3.4") 
     9(define *oldtype-version* "0.3.5") 
  • lang/gauche/oldtype/trunk/command/blog

    r20548 r21126  
    3939             (for-each 
    4040              (lambda (line) 
    41                 (if (#/##\(comment\)/ line) 
     41                (if (and (#/##\(comment\)/ line) (not (#/^[!]/ line))) 
    4242                    (print (string-append "comment please => [[" (oldtype:otpath->wikiname filename) "]]")) 
    4343                    (print line))) 
     
    4747      (newline)))) 
    4848 
    49 ;; 
    50 ;; test pattern: 
    51 ;;   (thumbnail-filter '("line 1" 
    52 ;;                       "line 2" 
    53 ;;                       "line 3" 
    54 ;;                       "line 4" 
    55 ;;                       "##(amazon 4873113482)       ##(img-s ../img/abc.jpg)" 
    56 ;;                       "! ##(youtube 4873113482)    ##(img-m ../img/abc.jpg)" 
    57 ;;                       )) 
    58 ;; result: 
    59 ;;  "##(img-s ../img/abc.jpg)  ##(amazon-s 4873113482) " 
    60 ;;  
    61 (define (thumbnail-filter str-list) 
    62   (let1 ret '() 
    63         (for-each 
    64          (lambda (line) 
    65            (when (not (#/^!/ line)) 
    66              (regexp-replace-all 
    67               #/##\((img|img-s|img-m|youtube|youtube-s|youtube-m|amazon|amazon-s|amazon-m)[ ]+([^\)]+)\)/ 
    68               line 
    69               (lambda (m) 
    70                 (push! ret (list 
    71                             (rxmatch-substring m 1) 
    72                             (rxmatch-substring m 2))))))) 
    73          str-list) 
    74         (string-join 
    75          (map 
    76           (lambda (x) 
    77             (let1 command-pair (string-split (car x) #\-) 
    78                   (string-append 
    79                    "##(" (car command-pair) "-s " (cadr x) ") "))) 
    80           (reverse ret))))) 
    8149 
    82  
    83 (define (output-blog-list save-filename entrylist) 
     50(define (output-blog-list save-filename group-entries) 
    8451  (with-output-to-file save-filename 
    8552    (lambda () 
     53      (print "  Past blog entries. ") 
    8654      (for-each 
    87        (lambda (filename) 
    88          (with-input-from-file (string-append (oldtype:editpath) "/" filename) 
    89            (lambda () 
    90              (when (#/[.][0-9]+/ filename) 
    91                (display 
    92                 (string-append "- [[" (oldtype:otpath->wikiname filename) "]]")) 
    93                (let* ((lst (port->string-list (current-input-port))) 
    94                       (image-line (thumbnail-filter lst))) 
    95                  (print (car lst)) ;; first line 
    96                  (when (< 0 (string-length image-line)) 
    97                    (print image-line))))))) 
    98        entrylist)))) 
     55       (lambda (group) 
     56         (let ((month_year (car group)) 
     57               (entries    (cdr group))) 
     58           (print  
     59            (string-append "* [[!" (oldtype:user-local) ".blog." #?=month_year "]]")) 
     60           (for-each 
     61            (lambda (filename) 
     62              (with-input-from-file (string-append (oldtype:editpath) "/" filename) 
     63                (lambda () 
     64                  (when (#/[.][0-9]+/ #?=filename) 
     65                    (display 
     66                     (string-append "-   [[" (oldtype:otpath->wikiname filename) "]]")) 
     67                    (let* ((lst (port->string-list (current-input-port))) 
     68                           (image-line (oldtype:thumbnail-filter lst))) 
     69                      (print (car lst)) ;; first line 
     70                      (when (< 0 (string-length image-line)) 
     71                        (print image-line))))))) 
     72            (reverse (sort entries))))) 
     73       group-entries)))) 
    9974 
    10075 
     
    10681               "") 
    10782  (output-blog-list (string-append ot-blog ".list.ot") 
    108                     (ot-blog-entrylist)) 
     83                    (sort  
     84                     (oldtype:grouping-blog-entries 
     85                      (ot-blog-entrylist)) 
     86                     (lambda (x y) (string>? (car x) (car y))))) 
     87 
    10988  (for-each 
    11089   (lambda (x) 
     
    11897   (oldtype:grouping-blog-entries 
    11998    (ot-blog-entrylist))) 
    120  
     99   
    121100  (exit 0))