Compare commits
No commits in common. "3ec8def5c2b4aa2d11193376351bbd214494347f" and "c08a6a84fbcd231440385b841ca38628995836de" have entirely different histories.
3ec8def5c2
...
c08a6a84fb
8 changed files with 9 additions and 40 deletions
2
info.rkt
2
info.rkt
|
|
@ -1,3 +1,3 @@
|
|||
#lang info
|
||||
|
||||
(define build-deps '("rackunit-lib" "web-server-lib" "http-easy-lib" "html-writing" "json-pointer" "typed-ini-lib" "memo" "net-cookies-lib" "db" "sequence-tools-lib"))
|
||||
(define build-deps '("rackunit-lib" "web-server-lib" "http-easy-lib" "html-parsing" "html-writing" "json-pointer" "typed-ini-lib" "memo" "net-cookies-lib" "db" "sequence-tools-lib"))
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
title "File:Rainbow Flag1.svg"
|
||||
imageinfo
|
||||
((: timestamp "2025-03-10T07:24:50Z"
|
||||
user "DogeMcMeow"))
|
||||
user "DogeMcMeow"))
|
||||
fileusage
|
||||
((: pageid 191
|
||||
ns 0
|
||||
|
|
|
|||
|
|
@ -5,8 +5,7 @@
|
|||
racket/string
|
||||
"pure-utils.rkt"
|
||||
"url-utils.rkt"
|
||||
"xexpr-utils.rkt"
|
||||
(for-syntax racket/base syntax/parse))
|
||||
"xexpr-utils.rkt")
|
||||
|
||||
(provide
|
||||
preprocess-html-wiki
|
||||
|
|
@ -73,18 +72,7 @@
|
|||
(div (@ (class "reviews"))
|
||||
(header "GameSpot Expert Reviews"))
|
||||
(div (@ (data-test-ampersand) (class "mw-collapsible-content"))
|
||||
(& ndash))
|
||||
(div (img (@ (loading "lazy") (width "80") (height "80") (data-test-size "small")))
|
||||
(img (@ (loading "lazy") (width "500") (height "80") (data-test-size "wide")))
|
||||
(img (@ (loading "lazy") (width "500") (height "500") (data-test-size "large"))))))))
|
||||
|
||||
(define-syntax match?
|
||||
(syntax-parser
|
||||
[(_ datum:id pattern)
|
||||
#'(match datum [pattern #t] [_ #f])]))
|
||||
|
||||
(define (image-dimension-small-enough? x)
|
||||
(and (number? x) (x . <= . 200)))
|
||||
(& ndash))))))
|
||||
|
||||
(define (updater wikiname #:strict-proxy? [strict-proxy? #f])
|
||||
;; precompute wikiurl regex for efficency
|
||||
|
|
@ -183,15 +171,6 @@
|
|||
(curry u
|
||||
(λ (v) (dict-has-key? v 'data-src))
|
||||
(λ (v) (alist-overwrite v 'src (dict-ref v 'data-src))))
|
||||
; remove loading=lazy for images small enough in either dimension
|
||||
(curry u
|
||||
(λ (v) (match? v (list-no-order
|
||||
(list 'loading "lazy")
|
||||
(or
|
||||
(list 'height (app string->number (? image-dimension-small-enough?)))
|
||||
(list 'width (app string->number (? image-dimension-small-enough?))))
|
||||
_ ...)))
|
||||
(λ (v) (dict-remove v 'loading)))
|
||||
; don't use srcset - TODO: use srcset?
|
||||
(λ (v) (dict-remove v 'srcset))))
|
||||
|
||||
|
|
@ -366,16 +345,6 @@
|
|||
(check-equal? ((query-selector (λ (t a c) (dict-has-key? a 'data-test-ampersand)) transformed))
|
||||
'(div (@ (data-test-ampersand) (class "mw-collapsible-content"))
|
||||
(& ndash)))
|
||||
; check that loading=lazy is retained on large images
|
||||
(check-equal? ((query-selector (λ (t a c) (match? a (list-no-order '(data-test-size "small")
|
||||
_ ...))) transformed))
|
||||
'(img (@ (width "80") (height "80") (data-test-size "small"))))
|
||||
(check-equal? ((query-selector (λ (t a c) (match? a (list-no-order '(data-test-size "wide")
|
||||
_ ...))) transformed))
|
||||
'(img (@ (width "500") (height "80") (data-test-size "wide"))))
|
||||
(check-equal? ((query-selector (λ (t a c) (match? a (list-no-order '(data-test-size "large")
|
||||
_ ...))) transformed))
|
||||
'(img (@ (loading "lazy") (width "500") (height "500") (data-test-size "large"))))
|
||||
; benchmark
|
||||
(when (file-exists? "../storage/Frog.html")
|
||||
(with-input-from-file "../storage/Frog.html"
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
racket/string
|
||||
json
|
||||
(prefix-in easy: net/http-easy)
|
||||
"../lib/html-parsing/main.rkt"
|
||||
html-parsing
|
||||
html-writing
|
||||
web-server/http
|
||||
web-server/http/bindings
|
||||
|
|
|
|||
|
|
@ -607,7 +607,7 @@
|
|||
(require racket/generator
|
||||
racket/list
|
||||
net/http-easy
|
||||
"../lib/html-parsing/main.rkt"
|
||||
html-parsing
|
||||
"../lib/xexpr-utils.rkt")
|
||||
(define r (get "https://www.niwanetwork.org/members/"))
|
||||
(define x (html->xexp (bytes->string/utf-8 (response-body r))))
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
racket/string
|
||||
memo
|
||||
net/http-easy
|
||||
"../lib/html-parsing/main.rkt"
|
||||
html-parsing
|
||||
"../lib/pure-utils.rkt"
|
||||
"../lib/syntax.rkt"
|
||||
"../lib/url-utils.rkt"
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
(require racket/string
|
||||
(prefix-in easy: net/http-easy)
|
||||
; html libs
|
||||
"../lib/html-parsing/main.rkt"
|
||||
html-parsing
|
||||
html-writing
|
||||
; web server libs
|
||||
net/url
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
(require racket/list
|
||||
racket/string
|
||||
; html libs
|
||||
"../lib/html-parsing/main.rkt"
|
||||
html-parsing
|
||||
html-writing
|
||||
; web server libs
|
||||
net/url
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue