Use -n and -o args like Planet Venus
This commit is contained in:
parent
11b20cb003
commit
7123a0f71f
|
@ -55,22 +55,30 @@
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(define (refresh-cache)
|
(define (refresh-cache all?)
|
||||||
(for-each (lambda (feed)
|
(for-each (lambda (feed)
|
||||||
|
(let ((new? (not (feed-cached? feed cache-directory))))
|
||||||
|
(when (or all? new?)
|
||||||
(disp "Refreshing " (feed-url feed))
|
(disp "Refreshing " (feed-url feed))
|
||||||
(planet-refresh-feed feed cache-directory))
|
(planet-refresh-feed feed cache-directory))))
|
||||||
feeds))
|
feeds))
|
||||||
|
|
||||||
(define (generate-from-cache)
|
(define (generate-from-cache)
|
||||||
(disp "Writing index.html")
|
(disp "Writing www/index.html")
|
||||||
(write-html-file "index.html" (front-page)))
|
(write-html-file "www/index.html" (front-page)))
|
||||||
|
|
||||||
|
(define (only-command-line-arg? arg)
|
||||||
|
(and (= 1 (length (command-args)))
|
||||||
|
(string=? arg (first (command-args)))))
|
||||||
|
|
||||||
(define (main)
|
(define (main)
|
||||||
(cond ((null? (command-args))
|
(cond ((null? (command-args))
|
||||||
(refresh-cache)
|
(refresh-cache #t)
|
||||||
(generate-from-cache))
|
(generate-from-cache))
|
||||||
((and (= 1 (length (command-args)))
|
((only-command-line-arg? "-n")
|
||||||
(string=? "-n" (first (command-args))))
|
(refresh-cache #f)
|
||||||
|
(generate-from-cache))
|
||||||
|
((only-command-line-arg? "-o")
|
||||||
(generate-from-cache))
|
(generate-from-cache))
|
||||||
(else
|
(else
|
||||||
(error "Usage: ./planet-scheme [-n]"))))
|
(error "Usage: ./planet-scheme [-n]"))))
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
feed-id
|
feed-id
|
||||||
feed-title
|
feed-title
|
||||||
feed-url
|
feed-url
|
||||||
|
feed-cache-file
|
||||||
|
feed-cached?
|
||||||
entry-author
|
entry-author
|
||||||
entry-title
|
entry-title
|
||||||
entry-content-xhtml
|
entry-content-xhtml
|
||||||
|
@ -109,6 +111,9 @@
|
||||||
(define (feed-cache-file feed cache-directory)
|
(define (feed-cache-file feed cache-directory)
|
||||||
(path-append cache-directory (string-append (feed-id feed) ".xml")))
|
(path-append cache-directory (string-append (feed-id feed) ".xml")))
|
||||||
|
|
||||||
|
(define (feed-cached? feed cache-directory)
|
||||||
|
(file-exists? (feed-cache-file feed cache-directory)))
|
||||||
|
|
||||||
(define (planet-refresh-feed feed cache-directory)
|
(define (planet-refresh-feed feed cache-directory)
|
||||||
(let ((cache-file (feed-cache-file feed cache-directory)))
|
(let ((cache-file (feed-cache-file feed cache-directory)))
|
||||||
(create-directory cache-directory)
|
(create-directory cache-directory)
|
||||||
|
|
Loading…
Reference in New Issue