From 155a277f26ca68b00f1899e5f584d09b11373d35 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Sun, 12 Feb 2023 23:51:48 +1300 Subject: [PATCH] indie wikis: add Wapopedia/Drawn To Life --- lib/syntax.rkt | 10 +++++----- src/extwiki-generic.rkt | 17 +++++++++++------ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/lib/syntax.rkt b/lib/syntax.rkt index 1793905..10267dd 100644 --- a/lib/syntax.rkt +++ b/lib/syntax.rkt @@ -60,11 +60,11 @@ (if (null? rest) `(cond ,@els) `(cond - ,@els - [#t - (let ,(for/list ([var vars]) - (cdr var)) - ,(transform-cond/var rest))])))) + ,@els + [#t + (let* ,(for/list ([var vars]) + (cdr var)) + ,(transform-cond/var rest))])))) ;; the syntax definitions and their tests go below here diff --git a/src/extwiki-generic.rkt b/src/extwiki-generic.rkt index a6abc33..fe30b14 100644 --- a/src/extwiki-generic.rkt +++ b/src/extwiki-generic.rkt @@ -20,6 +20,7 @@ (define wikis '(((gallowmere) "MediEvil Wiki" "https://medievil.wiki/w/Main_Page" #f #f) ((fallout) "Fallout Wiki" "https://fallout.wiki/wiki/Fallout_Wiki" #f "https://fallout.wiki/api.php") + ((drawntolife) "Wapopedia" "https://drawntolife.wiki/en/Main_Page" #f "https://drawntolife.wiki/w/api.php") )) (define wikis-hash (make-hash)) @@ -58,8 +59,10 @@ [(not logo) (values #f '("Data table must have a \"Logo\" column"))] [(null? logo) (values #f '("Logo table column must have a link"))] (var href (get-attribute 'href (bits->attributes (car (hash-ref table 'logo))))) - [(not href) (values #f '("Logo table column must have a link"))] - [#t (values href null)])) + (var src (get-attribute 'src (bits->attributes (car (hash-ref table 'logo))))) + (var true-src (or href src)) + [(not true-src) (values #f '("Logo table column must have a link"))] + [#t (values true-src null)])) (define (get-api-endpoint wiki) (define main-page (third wiki)) @@ -77,7 +80,7 @@ (or override (match main-page [(regexp #rx"/$") (string-append main-page "Special:Search")] - [(regexp #rx"^(.*/w[^./]*/)" (list _ wiki-prefix)) (string-append wiki-prefix "Special:Search")] + [(regexp #rx"^(.*/(?:en|w[^./]*)/)" (list _ wiki-prefix)) (string-append wiki-prefix "Special:Search")] [_ (error 'get-search-page "unknown url format: ~a" main-page)]))) (define/memoize (get-redirect-content wikiname) #:hash hash @@ -109,8 +112,10 @@ ,@body (p "This wiki's core community has wholly migrated away from Fandom. You should " (a (@ (href ,go)) "go to " ,display-name " now!"))) - (div (@ (class "niwa__right")) - (img (@ (class "niwa__logo") (src ,logo))))) + ,(if logo + `(div (@ (class "niwa__right")) + (img (@ (class "niwa__logo") (src ,logo)))) + "")) ,(if (pair? links) `(p (@ (class "niwa__feedback")) ,@(add-between links " / ")) @@ -122,4 +127,4 @@ "")))] [#t #f])) (module+ test - ((get-redirect-content "gallowmere") "Gallowmere Historia")) + (check-not-false ((get-redirect-content "gallowmere") "MediEvil Wiki")))