[squeak-dev] The Trunk: Collections-ct.1010.mcz
commits at source.squeak.org
commits at source.squeak.org
Wed May 4 19:06:25 UTC 2022
Christoph Thiede uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ct.1010.mcz
==================== Summary ====================
Name: Collections-ct.1010
Author: ct
Time: 4 May 2022, 9:05:51.60725 pm
UUID: cdc1e77e-7428-4749-a97f-e1f8aaef3d29
Ancestors: Collections-mt.1009, Collections-ct.949
Merges Collections-ct.949 (support for data URIs to HtmlReadWriter).
=============== Diff against Collections-mt.1009 ===============
Item was changed:
----- Method: HtmlReadWriter>>httpGetImage: (in category 'private') -----
httpGetImage: url
"To not add a direct dependency to WebClient, provide this hook for getting am image from an HTTP url. Maybe we can have this via an AppRegistry at some point. Maybe extend WebBrowser."
+
-
(url beginsWith: 'code://') ifTrue: [
"Same support for Smalltalk expressions as in TextURL >> #actOnClickFor:."
^ ([Compiler evaluate: (url allButFirst: 7)] ifError: [nil])
ifNotNil: [:object | object isForm ifTrue: [object] ifFalse: [nil]]].
+ (url beginsWith: 'data:') ifTrue: [ | data mediaType separator |
+ separator := url indexOf: $, ifAbsent: [^ nil].
+ mediaType := url copyFrom: 6 to: separator - 1.
+ data := url allButFirst: separator.
+ data := (mediaType endsWith: ';base64')
+ ifTrue: [
+ mediaType := mediaType allButLast: 7.
+ [Base64MimeConverter mimeDecodeToBytes: data readStream] ifError: [nil]]
+ ifFalse: [data asByteArray readStream].
+ ^ [ImageReadWriter formFromStream: data] ifError: [nil]].
+
^ (Smalltalk classNamed: 'WebClient') ifNotNil: [:client |
([client httpGet: url] ifError: [nil]) ifNotNil: [:response |
response code = 200 ifFalse: [nil] ifTrue: [
[Form fromBinaryStream: response content asByteArray readStream]
ifError: [nil]]]]!
More information about the Squeak-dev
mailing list
|