From 84591efdccced452b6d7381181fd2d29c0d9e84c Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Sun, 8 Jan 2023 08:17:02 -0500 Subject: [PATCH] Moving functionality from VideoWeb. --- src/MiniDocs/BrAsyncFileWidget.extension.st | 23 +++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/MiniDocs/BrAsyncFileWidget.extension.st diff --git a/src/MiniDocs/BrAsyncFileWidget.extension.st b/src/MiniDocs/BrAsyncFileWidget.extension.st new file mode 100644 index 0000000..5d6dd0f --- /dev/null +++ b/src/MiniDocs/BrAsyncFileWidget.extension.st @@ -0,0 +1,23 @@ +Extension { #name : #BrAsyncFileWidget } + +{ #category : #'*MiniDocs' } +BrAsyncFileWidget >> url: aUrl [ + + | realUrl imageUrl | + realUrl := aUrl asZnUrl. + + realUrl scheme = #file ifTrue: [ + ^ self file: realUrl asFileReference ]. + imageUrl := realUrl. + realUrl host = 'www.youtube.com' ifTrue: [ | video | + video := LeRawYoutubeReferenceInfo fromYoutubeStringUrl: realUrl asString. + imageUrl := (video rawData at: 'thumbnail_url') asUrl. + ]. + + self stencil: [ + (SkiaImage fromForm: + (Form fromBase64String: imageUrl retrieveContents base64Encoded)) + asElement constraintsDo: [ :c | + c horizontal matchParent. + c vertical matchParent ] ] +]