<=80 chars/line
Signed-off-by: Skylar "The Cobra" Widulski <cobra@vern.cc>
This commit is contained in:
parent
9bbac23645
commit
35a58e6c55
13
meme.scm
13
meme.scm
|
@ -49,6 +49,19 @@
|
|||
((or (equal? path "/")
|
||||
(equal? (car path-components) "page"))
|
||||
(newsfeed-page path))
|
||||
((or (equal? (cdr (last-pair path-components)) "photos")
|
||||
(and (equal? (list-ref
|
||||
path-components
|
||||
(- (length path-components) 3))
|
||||
"photos")
|
||||
(equal? (list-ref
|
||||
path-components
|
||||
(- (length path-components) 2))))
|
||||
(equal? (list-ref
|
||||
path-components
|
||||
(- (length path-components) 2))
|
||||
"photos"))
|
||||
(photos-page path))
|
||||
((equal? (car path-components) "memes")
|
||||
(meme-page path))
|
||||
(else (error-page 404)))))
|
||||
|
|
|
@ -137,7 +137,7 @@
|
|||
|
||||
(define* (next ptr times)
|
||||
(if (= times 0)
|
||||
(car (list-tail (parse-c-struct ptr xml-node) 6))
|
||||
(list-ref (parse-c-struct ptr xml-node) 6)
|
||||
(next (next ptr 0) (- times 1))))
|
||||
(define (child ptr)
|
||||
(cadddr (parse-c-struct ptr xml-node)))
|
||||
|
@ -146,7 +146,7 @@
|
|||
(next (child ptr) 0)
|
||||
(child1 (next (child ptr) 0) (- times 1))))
|
||||
(define (props ptr)
|
||||
(car (list-tail (parse-c-struct ptr xml-node) 13)))
|
||||
(list-ref (parse-c-struct ptr xml-node) 13))
|
||||
(define (name ptr)
|
||||
(pointer->string (caddr (parse-c-struct ptr xml-node))))
|
||||
|
||||
|
@ -157,7 +157,7 @@
|
|||
(define (floatval ptr)
|
||||
(cadddr (parse-c-struct ptr xml-xpath-object)))
|
||||
(define (strval ptr)
|
||||
(car (list-tail (parse-c-struct ptr xml-xpath-object) 4)))
|
||||
(list-ref (parse-c-struct ptr xml-xpath-object) 4))
|
||||
|
||||
(define (dump-xml node body)
|
||||
(define doc (gumbo-libxml-parse
|
||||
|
|
|
@ -25,8 +25,7 @@
|
|||
#:export (error-page
|
||||
newsfeed-page
|
||||
meme-page
|
||||
meme-people-page
|
||||
meme-events-page
|
||||
photos-page
|
||||
proxy-page))
|
||||
|
||||
(define base-url "https://knowyourmeme.com")
|
||||
|
@ -45,8 +44,9 @@
|
|||
"Redirect"))
|
||||
|
||||
(define (error-page code)
|
||||
(values (build-response #:code code
|
||||
#:headers `((content-type . (text/html)))) (error-template code)))
|
||||
(values (build-response
|
||||
#:code code
|
||||
#:headers `((content-type . (text/html)))) (error-template code)))
|
||||
|
||||
(define (newsfeed-page path)
|
||||
(let ((resp "")
|
||||
|
@ -54,9 +54,12 @@
|
|||
(receive (_resp _body) (http-request (string-append base-url path))
|
||||
(set! resp _resp)
|
||||
(set! body _body))
|
||||
(if (equal? (response-code resp) 200)
|
||||
(values good-response (newsfeed-template body))
|
||||
(error-page (response-code resp)))))
|
||||
(cond
|
||||
((equal? (response-code resp) 200)
|
||||
(values good-response (newsfeed-template body)))
|
||||
((and (>= (response-code resp) 300) (<= (response-code resp) 399))
|
||||
(redirect resp (response-code resp)))
|
||||
(else (error-page (response-code resp))))))
|
||||
|
||||
(define (meme-page path)
|
||||
(let ((resp "")
|
||||
|
@ -70,6 +73,18 @@
|
|||
(redirect resp (response-code resp)))
|
||||
(else (error-page (response-code resp))))))
|
||||
|
||||
(define (photos-page path)
|
||||
(let ((resp "")
|
||||
(body ""))
|
||||
(receive (_resp _body) (http-request (string-append base-url path))
|
||||
(set! resp _resp)
|
||||
(set! body _body))
|
||||
(cond ((equal? (response-code resp) 200)
|
||||
(values good-response (photos-template body)))
|
||||
((and (>= (response-code resp) 300) (<= (response-code resp) 399))
|
||||
(redirect resp (response-code resp)))
|
||||
(else (error-page (response-code resp))))))
|
||||
|
||||
(define (proxy-page query)
|
||||
(let ((resp "")
|
||||
(body "")
|
||||
|
@ -86,9 +101,23 @@
|
|||
(receive (_resp _body) (http-request url)
|
||||
(set! resp _resp)
|
||||
(set! body _body))
|
||||
(if (equal? (response-code resp) 200)
|
||||
(values (build-response #:code 200
|
||||
#:headers `((content-type . ,(response-content-type resp))))
|
||||
body)
|
||||
(error-page 404)))
|
||||
(cond
|
||||
((equal? (response-code resp) 200)
|
||||
(values (build-response
|
||||
#:code 200
|
||||
#:headers `((content-type .
|
||||
,(response-content-type resp))))
|
||||
body))
|
||||
((and (>= (response-code resp) 300) (<= (response-code resp) 399))
|
||||
(values (build-response
|
||||
#:code code
|
||||
#:headers `((location . ,(parse-header
|
||||
'location
|
||||
(uri-path
|
||||
(response-location
|
||||
response))))
|
||||
(content-type .
|
||||
,(response-content-type resp))))
|
||||
"Redirect"))
|
||||
(else (error-page 404))))
|
||||
(error-page 400))))
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
get-trending
|
||||
get-newsfeed
|
||||
get-meme
|
||||
get-photos
|
||||
get-sidebar-gallery
|
||||
get-sidebar-trending
|
||||
get-pagination))
|
||||
|
@ -33,32 +34,91 @@
|
|||
|
||||
(define (get-leaderboard body)
|
||||
(list
|
||||
(list (get-xpath-string "/html/body/div[1]/div/div[2]/section[1]/ul/li[1]/article/@id" body #t)
|
||||
(get-xpath-string "/html/body/div[1]/div/div[2]/section[1]/ul/li[1]/article/a/@href" body #t)
|
||||
(get-xpath-string "/html/body/div[1]/div/div[2]/section[1]/ul/li[1]/article/a/img/@src" body #t)
|
||||
(get-xpath-string "/html/body/div[1]/div/div[2]/section[1]/ul/li[1]/article/a/div/div/text()" body #f))
|
||||
(list (get-xpath-string "/html/body/div[1]/div/div[2]/section[1]/ul/li[2]/article/@id" body #t)
|
||||
(get-xpath-string "/html/body/div[1]/div/div[2]/section[1]/ul/li[2]/article/a/@href" body #t)
|
||||
(get-xpath-string "/html/body/div[1]/div/div[2]/section[1]/ul/li[2]/article/a/img/@src" body #t)
|
||||
(get-xpath-string "/html/body/div[1]/div/div[2]/section[1]/ul/li[2]/article/a/div/div/text()" body #f))
|
||||
(list (get-xpath-string "/html/body/div[1]/div/div[2]/section[1]/ul/li[3]/article/@id" body #t)
|
||||
(get-xpath-string "/html/body/div[1]/div/div[2]/section[1]/ul/li[3]/article/a/@href" body #t)
|
||||
(get-xpath-string "/html/body/div[1]/div/div[2]/section[1]/ul/li[3]/article/a/img/@src" body #t)
|
||||
(get-xpath-string "/html/body/div[1]/div/div[2]/section[1]/ul/li[3]/article/a/div/div/text()" body #f))
|
||||
(list (get-xpath-string "/html/body/div[1]/div/div[2]/section[1]/ul/li[4]/article/@id" body #t)
|
||||
(get-xpath-string "/html/body/div[1]/div/div[2]/section[1]/ul/li[4]/article/a/@href" body #t)
|
||||
(get-xpath-string "/html/body/div[1]/div/div[2]/section[1]/ul/li[4]/article/a/img/@src" body #t)
|
||||
(get-xpath-string "/html/body/div[1]/div/div[2]/section[1]/ul/li[4]/article/a/div/div/text()" body #f))))
|
||||
(list
|
||||
(get-xpath-string
|
||||
"/html/body/div[1]/div/div[2]/section[1]/ul/li[1]/article/@id"
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
"/html/body/div[1]/div/div[2]/section[1]/ul/li[1]/article/a/@href"
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
"/html/body/div[1]/div/div[2]/section[1]/ul/li[1]/article/a/img/@src"
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
(string-append
|
||||
"/html/body/div[1]/div/div[2]/section[1]/"
|
||||
"ul/li[1]/article/a/div/div/text()")
|
||||
body #f))
|
||||
(list
|
||||
(get-xpath-string
|
||||
"/html/body/div[1]/div/div[2]/section[1]/ul/li[2]/article/@id"
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
"/html/body/div[1]/div/div[2]/section[1]/ul/li[2]/article/a/@href"
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
"/html/body/div[1]/div/div[2]/section[1]/ul/li[2]/article/a/img/@src"
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
(string-append
|
||||
"/html/body/div[1]/div/div[2]/section[1]"
|
||||
"/ul/li[2]/article/a/div/div/text()")
|
||||
body #f))
|
||||
(list
|
||||
(get-xpath-string
|
||||
"/html/body/div[1]/div/div[2]/section[1]/ul/li[3]/article/@id"
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
"/html/body/div[1]/div/div[2]/section[1]/ul/li[3]/article/a/@href"
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
"/html/body/div[1]/div/div[2]/section[1]/ul/li[3]/article/a/img/@src"
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
(string-append
|
||||
"/html/body/div[1]/div/div[2]/section[1]"
|
||||
"/ul/li[3]/article/a/div/div/text()")
|
||||
body #f))
|
||||
(list
|
||||
(get-xpath-string
|
||||
"/html/body/div[1]/div/div[2]/section[1]/ul/li[4]/article/@id"
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
"/html/body/div[1]/div/div[2]/section[1]/ul/li[4]/article/a/@href"
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
"/html/body/div[1]/div/div[2]/section[1]/ul/li[4]/article/a/img/@src"
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
(string-append
|
||||
"/html/body/div[1]/div/div[2]/section[1]"
|
||||
"/ul/li[4]/article/a/div/div/text()")
|
||||
body #f))))
|
||||
|
||||
(define (get-trending body)
|
||||
(define trending (list ""))
|
||||
(do ((i 1 (1+ i)))
|
||||
((= i (xml-child-element-count (get-xpath-node "/html/body/div[1]/div/div[2]/section[2]" body) 0)) trending)
|
||||
((=
|
||||
i
|
||||
(xml-child-element-count
|
||||
(get-xpath-node "/html/body/div[1]/div/div[2]/section[2]" body) 0))
|
||||
trending)
|
||||
(append!
|
||||
trending
|
||||
(list
|
||||
(list (get-xpath-string (string-append "/html/body/div[1]/div/div[2]/section[2]/a[" (number->string i) "]/@href") body #t)
|
||||
(get-xpath-string (string-append "/html/body/div[1]/div/div[2]/section[2]/a[" (number->string i) "]/text()") body #f))))))
|
||||
(list
|
||||
(get-xpath-string
|
||||
(string-append
|
||||
"/html/body/div[1]/div/div[2]/section[2]/a["
|
||||
(number->string i)
|
||||
"]/@href")
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
(string-append
|
||||
"/html/body/div[1]/div/div[2]/section[2]/a["
|
||||
(number->string i)
|
||||
"]/text()")
|
||||
body #f))))))
|
||||
|
||||
(define (get-newsfeed body)
|
||||
(define newsfeed (list ""))
|
||||
|
@ -67,16 +127,61 @@
|
|||
(append!
|
||||
newsfeed
|
||||
(list
|
||||
(list (get-xpath-string (string-append "/html/body/div[3]/div/div[3]/article[" (number->string i) "]/@id") body #t)
|
||||
(get-xpath-string (string-append "/html/body/div[3]/div/div[3]/article[" (number->string i) "]/div/section/h1/a/@href") body #t)
|
||||
(get-xpath-string (string-append "/html/body/div[3]/div/div[3]/article[" (number->string i) "]/div/section/h1/a/text()") body #f)
|
||||
(get-xpath-string (string-append "/html/body/div[3]/div/div[3]/article[" (number->string i) "]//img/@data-src") body #t)
|
||||
(if (equal? (xml-child-element-count (get-xpath-node (string-append "/html/body/div[3]/div/div[3]/article[" (number->string i) "]/div/section/div[2]") body) 0) 0)
|
||||
"" (get-xpath-string (string-append "/html/body/div[3]/div/div[3]/article[" (number->string i) "]/div/section/div[2]/p/text()") body #f))
|
||||
(get-xpath-string (string-append "/html/body/div[3]/div/div[3]/article[" (number->string i) "]/div/section/p[1]/em/text()") body #f))))))
|
||||
(list
|
||||
(get-xpath-string
|
||||
(string-append
|
||||
"/html/body/div[3]/div/div[3]/article["
|
||||
(number->string i)
|
||||
"]/@id")
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
(string-append
|
||||
"/html/body/div[3]/div/div[3]/article["
|
||||
(number->string i)
|
||||
"]/div/section/h1/a/@href")
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
(string-append
|
||||
"/html/body/div[3]/div/div[3]/article["
|
||||
(number->string i)
|
||||
"]/div/section/h1/a/text()")
|
||||
body #f)
|
||||
(get-xpath-string
|
||||
(string-append
|
||||
"/html/body/div[3]/div/div[3]/article["
|
||||
(number->string i)
|
||||
"]//img/@data-src")
|
||||
body #t)
|
||||
(if
|
||||
(equal?
|
||||
(xml-child-element-count
|
||||
(get-xpath-node
|
||||
(string-append
|
||||
"/html/body/div[3]/div/div[3]/article["
|
||||
(number->string i)
|
||||
"]/div/section/div[2]")
|
||||
body)
|
||||
0)
|
||||
0)
|
||||
""
|
||||
(get-xpath-string
|
||||
(string-append
|
||||
"/html/body/div[3]/div/div[3]/article["
|
||||
(number->string i)
|
||||
"]/div/section/div[2]/p/text()")
|
||||
body #f))
|
||||
(get-xpath-string
|
||||
(string-append
|
||||
"/html/body/div[3]/div/div[3]/article["
|
||||
(number->string i)
|
||||
"]/div/section/p[1]/em/text()")
|
||||
body #f))))))
|
||||
|
||||
(define (get-meme body)
|
||||
(define bodycopy (get-xpath-node "/html/body/div[3]/div/article//section[@class=\"bodycopy\"]" body))
|
||||
(define bodycopy
|
||||
(get-xpath-node
|
||||
"/html/body/div[3]/div/article//section[@class=\"bodycopy\"]"
|
||||
body))
|
||||
(define chld (child1 bodycopy 0))
|
||||
(define chld1 %null-pointer)
|
||||
(define chld2 %null-pointer)
|
||||
|
@ -121,11 +226,9 @@
|
|||
(cond
|
||||
((and (equal? (name chld1) "a")
|
||||
(equal? (name (child chld1)) "img"))
|
||||
(set! chld2
|
||||
(car (list-tail
|
||||
(parse-c-struct
|
||||
(child chld1)
|
||||
xml-node) 11)))
|
||||
(set! chld2 (list-ref (parse-c-struct (child chld1)
|
||||
xml-node)
|
||||
11))
|
||||
(while (not (null-pointer? chld2))
|
||||
(cond
|
||||
((equal? (name chld2) "data-src")
|
||||
|
@ -137,11 +240,9 @@
|
|||
(proxy
|
||||
(pointer->string
|
||||
(xml-node-list-get-string
|
||||
(car (list-tail
|
||||
(parse-c-struct
|
||||
chld2
|
||||
xml-node)
|
||||
8))
|
||||
(list-ref
|
||||
(parse-c-struct chld2 xml-node)
|
||||
8)
|
||||
(child chld2)
|
||||
1)))
|
||||
"\" />")))
|
||||
|
@ -151,67 +252,207 @@
|
|||
(append! lst (cdr lst1))))
|
||||
(set! chld (next chld 0)))
|
||||
(append
|
||||
(list (get-xpath-string "/html/body/div[3]/div/article/header/section/h1/text()" body #f)
|
||||
(get-xpath-string "/html/body/div[3]/div/article/header/a/img/@src" body #t)
|
||||
(dump-xpath-xml "/html/body/div[3]/div/article/header/section/div/h5" body)
|
||||
(dump-xpath-xml "/html/body/div[3]/div/article/header/section/div/footer/p[1]" body)
|
||||
(dump-xpath-xml "/html/body/div[3]/div/article/header/section/div/footer/p[2]" body))
|
||||
(list
|
||||
(get-xpath-string
|
||||
"/html/body/div[3]/div/article/header/section/h1/text()" body #f)
|
||||
(get-xpath-string
|
||||
"/html/body/div[3]/div/article/header/a/img/@src" body #t)
|
||||
(dump-xpath-xml
|
||||
"/html/body/div[3]/div/article/header/section/div/h5" body)
|
||||
(dump-xpath-xml
|
||||
"/html/body/div[3]/div/article/header/section/div/footer/p[1]" body)
|
||||
(dump-xpath-xml
|
||||
"/html/body/div[3]/div/article/header/section/div/footer/p[2]" body))
|
||||
(cdr lst)))
|
||||
|
||||
(define (get-photos body)
|
||||
(list))
|
||||
|
||||
(define (get-sidebar-gallery body)
|
||||
(define gallery (list ""))
|
||||
(do ((i 1 (+ i 2)))
|
||||
((>= i (- (xml-child-element-count (get-xpath-node "/html/body/div[3]/aside" body) 0) 1)) gallery)
|
||||
((>=
|
||||
i
|
||||
(- (xml-child-element-count
|
||||
(get-xpath-node "/html/body/div[3]/aside" body) 0)
|
||||
1))
|
||||
gallery)
|
||||
(append!
|
||||
gallery
|
||||
(list
|
||||
(list (get-xpath-string (string-append "/html/body/div[3]/aside/div[" (number->string i) "]/h3/text()") body #f)
|
||||
|
||||
(get-xpath-string (string-append "/html/body/div[3]/aside/div[" (number->string i) "]/table/tbody/tr[1]/td[1]/a/@href") body #t)
|
||||
(get-xpath-string (string-append "/html/body/div[3]/aside/div[" (number->string i) "]/table/tbody/tr[1]/td[1]/a/img/@alt") body #t)
|
||||
(get-xpath-string (string-append "/html/body/div[3]/aside/div[" (number->string i) "]/table/tbody/tr[1]/td[1]/a/img/@data-src") body #t)
|
||||
(get-xpath-string (string-append "/html/body/div[3]/aside/div[" (number->string i) "]/table/tbody/tr[1]/td[1]/h4/a/text()") body #f)
|
||||
(list
|
||||
(get-xpath-string
|
||||
(string-append
|
||||
"/html/body/div[3]/aside/div["
|
||||
(number->string i)
|
||||
"]/h3/text()")
|
||||
body #f)
|
||||
|
||||
(get-xpath-string (string-append "/html/body/div[3]/aside/div[" (number->string i) "]/table/tbody/tr[1]/td[2]/a/@href") body #t)
|
||||
(get-xpath-string (string-append "/html/body/div[3]/aside/div[" (number->string i) "]/table/tbody/tr[1]/td[2]/a/img/@alt") body #t)
|
||||
(get-xpath-string (string-append "/html/body/div[3]/aside/div[" (number->string i) "]/table/tbody/tr[1]/td[2]/a/img/@data-src") body #t)
|
||||
(get-xpath-string (string-append "/html/body/div[3]/aside/div[" (number->string i) "]/table/tbody/tr[1]/td[2]/h4/a/text()") body #f)
|
||||
|
||||
(get-xpath-string (string-append "/html/body/div[3]/aside/div[" (number->string i) "]/table/tbody/tr[2]/td[1]/a/@href") body #t)
|
||||
(get-xpath-string (string-append "/html/body/div[3]/aside/div[" (number->string i) "]/table/tbody/tr[2]/td[1]/a/img/@alt") body #t)
|
||||
(get-xpath-string (string-append "/html/body/div[3]/aside/div[" (number->string i) "]/table/tbody/tr[2]/td[1]/a/img/@data-src") body #t)
|
||||
(get-xpath-string (string-append "/html/body/div[3]/aside/div[" (number->string i) "]/table/tbody/tr[2]/td[1]/h4/a/text()") body #f)
|
||||
(get-xpath-string
|
||||
(string-append
|
||||
"/html/body/div[3]/aside/div["
|
||||
(number->string i)
|
||||
"]/table/tbody/tr[1]/td[1]/a/@href")
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
(string-append
|
||||
"/html/body/div[3]/aside/div["
|
||||
(number->string i)
|
||||
"]/table/tbody/tr[1]/td[1]/a/img/@alt")
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
(string-append
|
||||
"/html/body/div[3]/aside/div["
|
||||
(number->string i)
|
||||
"]/table/tbody/tr[1]/td[1]/a/img/@data-src")
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
(string-append
|
||||
"/html/body/div[3]/aside/div["
|
||||
(number->string i)
|
||||
"]/table/tbody/tr[1]/td[1]/h4/a/text()")
|
||||
body #f)
|
||||
|
||||
(get-xpath-string (string-append "/html/body/div[3]/aside/div[" (number->string i) "]/table/tbody/tr[2]/td[2]/a/@href") body #t)
|
||||
(get-xpath-string (string-append "/html/body/div[3]/aside/div[" (number->string i) "]/table/tbody/tr[2]/td[2]/a/img/@alt") body #t)
|
||||
(get-xpath-string (string-append "/html/body/div[3]/aside/div[" (number->string i) "]/table/tbody/tr[2]/td[2]/a/img/@data-src") body #t)
|
||||
(get-xpath-string (string-append "/html/body/div[3]/aside/div[" (number->string i) "]/table/tbody/tr[2]/td[2]/h4/a/text()") body #f))))))
|
||||
|
||||
(get-xpath-string
|
||||
(string-append
|
||||
"/html/body/div[3]/aside/div["
|
||||
(number->string i)
|
||||
"]/table/tbody/tr[1]/td[2]/a/@href")
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
(string-append
|
||||
"/html/body/div[3]/aside/div["
|
||||
(number->string i)
|
||||
"]/table/tbody/tr[1]/td[2]/a/img/@alt")
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
(string-append
|
||||
"/html/body/div[3]/aside/div["
|
||||
(number->string i)
|
||||
"]/table/tbody/tr[1]/td[2]/a/img/@data-src")
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
(string-append
|
||||
"/html/body/div[3]/aside/div["
|
||||
(number->string i)
|
||||
"]/table/tbody/tr[1]/td[2]/h4/a/text()")
|
||||
body #f)
|
||||
|
||||
|
||||
(get-xpath-string
|
||||
(string-append
|
||||
"/html/body/div[3]/aside/div["
|
||||
(number->string i)
|
||||
"]/table/tbody/tr[2]/td[1]/a/@href")
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
(string-append
|
||||
"/html/body/div[3]/aside/div["
|
||||
(number->string i)
|
||||
"]/table/tbody/tr[2]/td[1]/a/img/@alt")
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
(string-append
|
||||
"/html/body/div[3]/aside/div["
|
||||
(number->string i)
|
||||
"]/table/tbody/tr[2]/td[1]/a/img/@data-src")
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
(string-append
|
||||
"/html/body/div[3]/aside/div["
|
||||
(number->string i)
|
||||
"]/table/tbody/tr[2]/td[1]/h4/a/text()")
|
||||
body #f)
|
||||
|
||||
|
||||
(get-xpath-string
|
||||
(string-append
|
||||
"/html/body/div[3]/aside/div["
|
||||
(number->string i)
|
||||
"]/table/tbody/tr[2]/td[2]/a/@href")
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
(string-append
|
||||
"/html/body/div[3]/aside/div["
|
||||
(number->string i)
|
||||
"]/table/tbody/tr[2]/td[2]/a/img/@alt")
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
(string-append
|
||||
"/html/body/div[3]/aside/div["
|
||||
(number->string i)
|
||||
"]/table/tbody/tr[2]/td[2]/a/img/@data-src")
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
(string-append
|
||||
"/html/body/div[3]/aside/div["
|
||||
(number->string i)
|
||||
"]/table/tbody/tr[2]/td[2]/h4/a/text()")
|
||||
body #f))))))
|
||||
|
||||
(define (get-sidebar-trending body)
|
||||
(list
|
||||
(get-xpath-string "/html/body/div[3]/aside/div[4]/h3/a/@href" body #t)
|
||||
(get-xpath-string "/html/body/div[3]/aside/div[4]/h3/a/text()" body #f)
|
||||
|
||||
(get-xpath-string "/html/body/div[3]/aside/div[4]/table/tbody/tr[1]/td[1]/a/@href" body #t)
|
||||
(get-xpath-string "/html/body/div[3]/aside/div[4]/table/tbody/tr[1]/td[1]/a/img/@data-src" body #t)
|
||||
(get-xpath-string "/html/body/div[3]/aside/div[4]/table/tbody/tr[1]/td[2]/a/@href" body #t)
|
||||
(get-xpath-string "/html/body/div[3]/aside/div[4]/table/tbody/tr[1]/td[2]/a/img/@data-src" body #t)
|
||||
(get-xpath-string "/html/body/div[3]/aside/div[4]/table/tbody/tr[1]/td[3]/a/@href" body #t)
|
||||
(get-xpath-string "/html/body/div[3]/aside/div[4]/table/tbody/tr[1]/td[3]/a/img/@data-src" body #t)
|
||||
(get-xpath-string
|
||||
"/html/body/div[3]/aside/div[4]/table/tbody/tr[1]/td[1]/a/@href"
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
"/html/body/div[3]/aside/div[4]/table/tbody/tr[1]/td[1]/a/img/@data-src"
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
"/html/body/div[3]/aside/div[4]/table/tbody/tr[1]/td[2]/a/@href"
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
"/html/body/div[3]/aside/div[4]/table/tbody/tr[1]/td[2]/a/img/@data-src"
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
"/html/body/div[3]/aside/div[4]/table/tbody/tr[1]/td[3]/a/@href"
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
"/html/body/div[3]/aside/div[4]/table/tbody/tr[1]/td[3]/a/img/@data-src"
|
||||
body #t)
|
||||
|
||||
(get-xpath-string "/html/body/div[3]/aside/div[4]/table/tbody/tr[2]/td[1]/a/@href" body #t)
|
||||
(get-xpath-string "/html/body/div[3]/aside/div[4]/table/tbody/tr[2]/td[1]/a/img/@data-src" body #t)
|
||||
(get-xpath-string "/html/body/div[3]/aside/div[4]/table/tbody/tr[2]/td[2]/a/@href" body #t)
|
||||
(get-xpath-string "/html/body/div[3]/aside/div[4]/table/tbody/tr[2]/td[2]/a/img/@data-src" body #t)
|
||||
(get-xpath-string "/html/body/div[3]/aside/div[4]/table/tbody/tr[2]/td[3]/a/@href" body #t)
|
||||
(get-xpath-string "/html/body/div[3]/aside/div[4]/table/tbody/tr[2]/td[3]/a/img/@data-src" body #t)
|
||||
(get-xpath-string
|
||||
"/html/body/div[3]/aside/div[4]/table/tbody/tr[2]/td[1]/a/@href"
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
"/html/body/div[3]/aside/div[4]/table/tbody/tr[2]/td[1]/a/img/@data-src"
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
"/html/body/div[3]/aside/div[4]/table/tbody/tr[2]/td[2]/a/@href"
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
"/html/body/div[3]/aside/div[4]/table/tbody/tr[2]/td[2]/a/img/@data-src"
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
"/html/body/div[3]/aside/div[4]/table/tbody/tr[2]/td[3]/a/@href"
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
"/html/body/div[3]/aside/div[4]/table/tbody/tr[2]/td[3]/a/img/@data-src"
|
||||
body #t)
|
||||
|
||||
(get-xpath-string "/html/body/div[3]/aside/div[4]/table/tbody/tr[3]/td[1]/a/@href" body #t)
|
||||
(get-xpath-string "/html/body/div[3]/aside/div[4]/table/tbody/tr[3]/td[1]/a/img/@data-src" body #t)
|
||||
(get-xpath-string "/html/body/div[3]/aside/div[4]/table/tbody/tr[3]/td[2]/a/@href" body #t)
|
||||
(get-xpath-string "/html/body/div[3]/aside/div[4]/table/tbody/tr[3]/td[2]/a/img/@data-src" body #t)
|
||||
(get-xpath-string "/html/body/div[3]/aside/div[4]/table/tbody/tr[3]/td[3]/a/@href" body #t)
|
||||
(get-xpath-string "/html/body/div[3]/aside/div[4]/table/tbody/tr[3]/td[3]/a/img/@data-src" body #t)))
|
||||
(get-xpath-string
|
||||
"/html/body/div[3]/aside/div[4]/table/tbody/tr[3]/td[1]/a/@href"
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
"/html/body/div[3]/aside/div[4]/table/tbody/tr[3]/td[1]/a/img/@data-src"
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
"/html/body/div[3]/aside/div[4]/table/tbody/tr[3]/td[2]/a/@href"
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
"/html/body/div[3]/aside/div[4]/table/tbody/tr[3]/td[2]/a/img/@data-src"
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
"/html/body/div[3]/aside/div[4]/table/tbody/tr[3]/td[3]/a/@href"
|
||||
body #t)
|
||||
(get-xpath-string
|
||||
"/html/body/div[3]/aside/div[4]/table/tbody/tr[3]/td[3]/a/img/@data-src"
|
||||
body #t)))
|
||||
|
||||
(define (get-pagination body)
|
||||
(dump-xpath-xml "/html/body/div[3]/div/div[4]/div" body))
|
||||
|
|
|
@ -155,8 +155,8 @@
|
|||
(h1 ,(caddr l))
|
||||
(img (@ (src ,(proxy (cadddr l)))
|
||||
(alt ,(caddr l))))
|
||||
(p ,(car (list-tail l 4)))
|
||||
(i ,(car (list-tail l 5))))))
|
||||
(p ,(list-ref l 4))
|
||||
(i ,(list-ref l 5)))))
|
||||
(cdr newsfeed))))
|
||||
|
||||
(define (meme-as-sxml meme)
|
||||
|
@ -167,10 +167,12 @@
|
|||
(div (@ (class "subdiv"))
|
||||
,(html->shtml (caddr meme))
|
||||
,(html->shtml (cadddr meme))
|
||||
,(html->shtml (car (list-tail meme 4)))))
|
||||
,(html->shtml (list-ref meme 4))))
|
||||
(div (@ (class "box meme-body"))
|
||||
,(map (lambda (s)
|
||||
(html->shtml (string-replace-substring s "https://knowyourmeme.com" "")))
|
||||
(html->shtml
|
||||
(string-replace-substring
|
||||
s "https://knowyourmeme.com" "")))
|
||||
(list-tail meme 5)))))
|
||||
|
||||
(define (sidebar-gallery-as-sxml sidebar-gallery)
|
||||
|
@ -181,25 +183,25 @@
|
|||
(tr (td (a (@ (href ,(kym->local (cadr l))))
|
||||
(img (@ (src ,(proxy (cadddr l)))
|
||||
(alt ,(caddr l))))
|
||||
(p (b ,(car (list-tail l 4))))))
|
||||
(td (a (@ (href ,(kym->local (car (list-tail l 5)))))
|
||||
(p (b ,(list-ref l 4)))))
|
||||
(td (a (@ (href ,(kym->local (list-ref l 5))))
|
||||
(img (@ (src
|
||||
,(proxy
|
||||
(car (list-tail l 7))))
|
||||
(alt ,(car (list-tail l 6)))))
|
||||
(p (b ,(car (list-tail l 8)))))))
|
||||
(tr (td (a (@ (href ,(kym->local (car (list-tail l 9)))))
|
||||
(list-ref l 7)))
|
||||
(alt ,(list-ref l 6))))
|
||||
(p (b ,(list-ref l 8))))))
|
||||
(tr (td (a (@ (href ,(kym->local (list-ref l 9))))
|
||||
(img (@ (src
|
||||
,(proxy
|
||||
(car (list-tail l 11))))
|
||||
(alt ,(car (list-tail l 10)))))
|
||||
(p (b ,(car (list-tail l 12))))))
|
||||
(td (a (@ (href ,(kym->local (car (list-tail l 13)))))
|
||||
(list-ref l 11)))
|
||||
(alt ,(list-ref l 10))))
|
||||
(p (b ,(list-ref l 12)))))
|
||||
(td (a (@ (href ,(kym->local (list-ref l 13))))
|
||||
(img (@ (src
|
||||
,(proxy
|
||||
(car (list-tail l 15))))
|
||||
(alt ,(car (list-tail l 14)))))
|
||||
(p (b ,(car (list-tail l 16))))))))))
|
||||
(list-ref l 15)))
|
||||
(alt ,(list-ref l 14))))
|
||||
(p (b ,(list-ref l 16)))))))))
|
||||
(cdr sidebar-gallery)))
|
||||
|
||||
(define (sidebar-trending-as-sxml sidebar-trending)
|
||||
|
@ -209,40 +211,49 @@
|
|||
(table (@ (class "trending-images"))
|
||||
(tr (td (a (@ (href ,(kym->local (caddr sidebar-trending))))
|
||||
(img (@ (src ,(proxy (cadddr sidebar-trending)))))))
|
||||
(td (a (@ (href ,(kym->local (car (list-tail sidebar-trending 4)))))
|
||||
(td (a (@ (href
|
||||
,(kym->local (list-ref sidebar-trending 4))))
|
||||
(img (@ (src
|
||||
,(proxy
|
||||
(car (list-tail sidebar-trending 5))))))))
|
||||
(td (a (@ (href ,(kym->local (car (list-tail sidebar-trending 6)))))
|
||||
(list-ref sidebar-trending 5)))))))
|
||||
(td (a (@ (href
|
||||
,(kym->local (list-ref sidebar-trending 6))))
|
||||
(img (@ (src
|
||||
,(proxy
|
||||
(car (list-tail sidebar-trending 7)))))))))
|
||||
(tr (td (a (@ (href ,(kym->local (car (list-tail sidebar-trending 8)))))
|
||||
(list-ref sidebar-trending 7))))))))
|
||||
(tr (td (a (@ (href
|
||||
,(kym->local (list-ref sidebar-trending 8))))
|
||||
(img (@ (src
|
||||
,(proxy
|
||||
(car (list-tail sidebar-trending 9))))))))
|
||||
(td (a (@ (href ,(kym->local (car (list-tail sidebar-trending 10)))))
|
||||
(list-ref sidebar-trending 9)))))))
|
||||
(td (a (@ (href
|
||||
,(kym->local (list-ref sidebar-trending 10))))
|
||||
(img (@ (src
|
||||
,(proxy
|
||||
(car (list-tail sidebar-trending 11))))))))
|
||||
(td (a (@ (href ,(kym->local (car (list-tail sidebar-trending 12)))))
|
||||
(list-ref sidebar-trending 11)))))))
|
||||
(td (a (@ (href
|
||||
,(kym->local (list-ref sidebar-trending 12))))
|
||||
(img (@ (src
|
||||
,(proxy
|
||||
(car
|
||||
(list-tail sidebar-trending 13)))))))))
|
||||
(tr (td (a (@ (href ,(kym->local (car (list-tail sidebar-trending 14)))))
|
||||
(tr (td (a (@ (href
|
||||
,(kym->local (list-ref sidebar-trending 14))))
|
||||
(img (@ (src
|
||||
,(proxy
|
||||
(car (list-tail sidebar-trending 15))))))))
|
||||
(td (a (@ (href ,(kym->local (car (list-tail sidebar-trending 16)))))
|
||||
(list-ref sidebar-trending 15)))))))
|
||||
(td (a (@ (href
|
||||
,(kym->local (list-ref sidebar-trending 16))))
|
||||
(img (@ (src
|
||||
,(proxy
|
||||
(car (list-tail sidebar-trending 17))))))))
|
||||
(td (a (@ (href ,(kym->local (car (list-tail sidebar-trending 18)))))
|
||||
(list-ref sidebar-trending 17)))))))
|
||||
(td (a (@ (href
|
||||
,(kym->local (list-ref sidebar-trending 18))))
|
||||
(img (@ (src
|
||||
,(proxy
|
||||
(car
|
||||
(list-tail sidebar-trending 19))))))))))))
|
||||
(list-tail sidebar-trending
|
||||
19))))))))))))
|
||||
|
||||
(define (pagination-as-sxml pagination)
|
||||
`(div (@ (class "pagination box"))
|
||||
|
@ -281,3 +292,11 @@
|
|||
,heading
|
||||
,(meme-as-sxml (get-meme body))
|
||||
,footer))))
|
||||
|
||||
(define (photos-template body)
|
||||
(shtml->html
|
||||
`(html ,(html-head "MeMe")
|
||||
(body
|
||||
,heading
|
||||
,(photos-as-sxml (get-photos body))
|
||||
,footer))))
|
||||
|
|
Loading…
Reference in New Issue