1
0
Fork 0

another checkpoint, off to party

This commit is contained in:
Andy Wingo 2008-02-22 19:28:46 +01:00
parent 77509e4d3f
commit bdc98f612b
6 changed files with 25 additions and 6 deletions

View file

@ -77,6 +77,8 @@
(cons (car in) (pclose p out)))))))) (cons (car in) (pclose p out))))))))
(define (wordpress->sxml text) (define (wordpress->sxml text)
(catch 'parser-error
(lambda ()
(let ((sxml (cadr (with-input-from-string (string-append "<div>" text "</div>") (let ((sxml (cadr (with-input-from-string (string-append "<div>" text "</div>")
xml->sxml)))) xml->sxml))))
(pre-post-order (pre-post-order
@ -87,3 +89,8 @@
(cons tag body)))) (cons tag body))))
(*text* . ,(lambda (tag text) (*text* . ,(lambda (tag text)
text)))))) text))))))
(lambda (key . args)
`(pre "parse error: "
,(with-output-to-string (lambda () (write args)))
"\n"
,text))))

View file

@ -181,7 +181,13 @@
(define page-new-comment not-implemented) (define page-new-comment not-implemented)
(define page-delete-comment not-implemented) (define page-delete-comment not-implemented)
(define page-delete-post not-implemented) (define page-delete-post not-implemented)
(define page-index not-implemented)
(define (page-index request index)
(rcons* request
'title "my bloggidy blog"
'body (map (lambda (post)
(show-post post #f))
(take-max (assq-ref index 'posts) 10))))
(define (page-show-post request index year month day post) (define (page-show-post request index year month day post)
(let ((slug (make-post-key year month day post))) (let ((slug (make-post-key year month day post)))

View file

@ -150,8 +150,8 @@
(define (post-sxml-n-comments post) (define (post-sxml-n-comments post)
`(div (@ (class "feedback")) `(div (@ (class "feedback"))
(a (@ (href ,(string-append *public-url-base* "/archives/" (a (@ (href ,(string-append *public-url-base* "archives/"
(assq-ref post 'encoded-name) (url:decode (assq-ref post 'key))
"#comments"))) "#comments")))
"(" ,(post-n-comments post) ")"))) "(" ,(post-n-comments post) ")")))

View file

@ -58,6 +58,6 @@
(a (@ ,(href "")) "wingolog")) (a (@ ,(href "")) "wingolog"))
,(make-navbar) ,(make-navbar)
(div (@ (id "content")) (div (@ (id "content"))
,@(rref request 'body '(p "what"))) ,@(rref request 'body '((p "what"))))
(div (@ (id "footer")) (div (@ (id "footer"))
"powered by sxml"))))) "powered by sxml")))))

View file

@ -29,6 +29,7 @@
#:use-module (srfi srfi-1) #:use-module (srfi srfi-1)
#:export (expanduser match-lines dbg unwind-protect dbg dsu-sort #:export (expanduser match-lines dbg unwind-protect dbg dsu-sort
hash-push! list-has-length? list-head-match mapn hash-push! list-has-length? list-head-match mapn
take-max
list-intersperse with-backtrace define-memoized)) list-intersperse with-backtrace define-memoized))
(define (expanduser path) (define (expanduser path)
@ -66,6 +67,11 @@
(let ((handle (hash-create-handle! h key '()))) (let ((handle (hash-create-handle! h key '())))
(set-cdr! handle (cons value (cdr handle))))) (set-cdr! handle (cons value (cdr handle)))))
(define (take-max list n)
(if (or (null? list) (zero? n))
'()
(cons (car list) (take-max (cdr list) (1- n)))))
(define (list-has-length? list len) (define (list-has-length? list len)
(cond (cond
((zero? len) (null? list)) ((zero? len) (null? list))

View file

@ -38,7 +38,7 @@ def post_comments(post):
sql = ('select comment_ID, comment_author, comment_author_email,' sql = ('select comment_ID, comment_author, comment_author_email,'
' comment_author_url, comment_author_IP,' ' comment_author_url, comment_author_IP,'
' comment_date, comment_date_gmt, comment_content, comment_approved' ' comment_date, comment_date_gmt, comment_content, comment_approved'
' from wp_comments where comment_post_ID=%s') ' from wp_comments where comment_post_ID=%s where comment_approved!=\'spam\'')
cur.execute(sql, (post['id'],)) cur.execute(sql, (post['id'],))
keys = ('id', 'author', 'author_email', 'author_url', 'author_ip', keys = ('id', 'author', 'author_email', 'author_url', 'author_ip',
'date', 'date-gmt', 'content', 'approved') 'date', 'date-gmt', 'content', 'approved')
@ -70,7 +70,7 @@ def write_comment(comment, dir):
def make_post_key(post): def make_post_key(post):
d = post['date'] d = post['date']
pre = '%d/%02d/%02d/%s' % (d.year, d.month, d.day, post['name']) pre = '%d/%02d/%02d/%s' % (d.year, d.month, d.day, post['name'])
return urllib.quote(pre, '') return urllib.quote(pre, '').tolower()
def write_post(post, categories, comments): def write_post(post, categories, comments):
def make_metadata(): def make_metadata():