|
35 | 35 | (define (do-it xs) |
36 | 36 | (for/list ([x xs]) |
37 | 37 | (match x |
38 | | - [`(div ((class ,classes)) |
39 | | - (img ((src ,url) ,attrs ...)) |
| 38 | + [`(div ([class ,classes]) |
| 39 | + (img ([src ,url] ,attrs ...)) |
40 | 40 | ,content ...) |
41 | 41 | #:when (and (regexp-match #px"\\bfigure\\b" classes) |
42 | 42 | (not (url-host (string->url url)))) |
43 | 43 | (let ([sizes-attr (assq 'sizes attrs)]) |
44 | 44 | `(div ([class ,classes]) |
45 | | - (img (,@(make-responsive url (cond [sizes-attr => second] |
| 45 | + (img ([class "img-responsive"] ; Bootstrap class |
| 46 | + ,@(make-responsive url (cond [sizes-attr => second] |
46 | 47 | [#t #f])) |
47 | 48 | ,@(if sizes-attr |
48 | 49 | (remove sizes-attr attrs) |
|
77 | 78 | (when magick-available? |
78 | 79 | (test-equal? "Element-specific custom sizes attribute" |
79 | 80 | (responsive-images |
80 | | - '((div ((class "figure")) |
81 | | - (img ((src "/img/1x1.gif") |
82 | | - (sizes "some-custom-size-spec")))))) |
| 81 | + '((div ([class "figure"]) |
| 82 | + (img ([src "/img/1x1.gif"] |
| 83 | + [sizes "some-custom-size-spec"]))))) |
83 | 84 | '((div ((class "figure")) |
84 | | - (img ((src "/img/1x1.gif") |
85 | | - (srcset "/img/1x1.gif 2w") |
86 | | - (sizes "some-custom-size-spec")))))) |
| 85 | + (img ([class "img-responsive"] |
| 86 | + [src "/img/1x1.gif"] |
| 87 | + [srcset "/img/1x1.gif 2w"] |
| 88 | + [sizes "some-custom-size-spec"]))))) |
87 | 89 | (test-equal? "Image bigger than maximum size" |
88 | 90 | (responsive-images |
89 | | - '((div ((class "figure pull-right")) |
90 | | - (img ((src "/img/1300px-image.gif") (alt ""))) |
91 | | - (p ((class "caption")) "some text")))) |
| 91 | + '((div ([class "figure pull-right"]) |
| 92 | + (img ([src "/img/1300px-image.gif"] (alt ""))) |
| 93 | + (p ([class "caption"]) "some text")))) |
92 | 94 | `((div ((class "figure pull-right")) |
93 | | - (img ((src "/img/resized/600/1300px-image.gif") |
94 | | - (srcset |
| 95 | + (img ([class "img-responsive"] |
| 96 | + [src "/img/resized/600/1300px-image.gif"] |
| 97 | + [srcset |
95 | 98 | ,(string-join |
96 | 99 | (for/list ([s (current-image-sizes)]) |
97 | 100 | (format "/img/resized/~a/1300px-image.gif ~aw" s s)) |
98 | | - ", ")) |
99 | | - (sizes "(max-width: 1300px) 100vw, 1300px") |
| 101 | + ", ")] |
| 102 | + [sizes "(max-width: 1300px) 100vw, 1300px"] |
100 | 103 | (alt ""))) |
101 | 104 | (p ((class "caption")) "some text")))) |
102 | 105 | (test-equal? "Image smaller than biggest size but bigger than smallest size" |
|
105 | 108 | (img ((src "/img/800px-image.gif") (alt ""))) |
106 | 109 | (p ((class "caption")) "some text")))) |
107 | 110 | `((div ((class "figure")) |
108 | | - (img ((src ,(format "/img/resized/~a/800px-image.gif" |
| 111 | + (img ([class "img-responsive"] |
| 112 | + (src ,(format "/img/resized/~a/800px-image.gif" |
109 | 113 | (current-image-default-size))) |
110 | 114 | (srcset |
111 | 115 | ,(string-append |
|
123 | 127 | (img ((src "/img/600px-image.gif") (alt ""))) |
124 | 128 | (p ((class "caption")) "some text")))) |
125 | 129 | '((div ((class "figure")) |
126 | | - (img ((src "/img/600px-image.gif") |
| 130 | + (img ([class "img-responsive"] |
| 131 | + (src "/img/600px-image.gif") |
127 | 132 | (srcset "/img/resized/320/600px-image.gif 320w, /img/600px-image.gif 600w") |
128 | 133 | (sizes "(max-width: 600px) 100vw, 600px") |
129 | 134 | (alt ""))) |
|
134 | 139 | (img ((src "/img/1x1.gif") (alt ""))) ; Tiny image |
135 | 140 | (p ((class "caption")) "some text")))) |
136 | 141 | '((div ((class "figure")) |
137 | | - (img ((src "/img/1x1.gif") |
| 142 | + (img ([class "img-responsive"] |
| 143 | + (src "/img/1x1.gif") |
138 | 144 | (srcset "/img/1x1.gif 2w") |
139 | 145 | (sizes "(max-width: 2px) 100vw, 2px") |
140 | 146 | (alt ""))) |
|
250 | 256 | "&hide_thread=true")))) |
251 | 257 | (define js (call/input-url oembed-url get-pure-port read-json)) |
252 | 258 | (define html ('html js)) |
| 259 | + |
253 | 260 | (cond [html (~>> (with-input-from-string html read-html-as-xexprs) |
254 | 261 | (append '(div ([class "embed-tweet"]))))] |
255 | 262 | [else x])] |
|
0 commit comments