| 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))))) |
| 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)))) |