Improving Nitter data extraction and rendering.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2022-01-02 19:01:09 -05:00
parent 321ddc8e71
commit f6b14c086d
5 changed files with 20 additions and 17 deletions

View File

@ -0,0 +1,4 @@
accessing
url
^ url ifNil: [
url := ((self documentTree xpath: '//div[@class="profile-website"]') // 'a' @@ 'href') first asUrl]

View File

@ -1,6 +1,6 @@
accessing
asCardElement
| aModeLook anEditor textInfoPane buttonsPane |
| aModeLook anEditor textInfoPane buttonsPane webpageButton |
aModeLook := BrEditorModeAptitude new
editableFocused: [ :aWidget | aWidget border: (BlBorder paint: BrGlamorousColors focusedEditorBorderColor width: 1) ];
@ -12,6 +12,11 @@ asCardElement
text: self description;
vFitContent.
webpageButton := BrButton new
aptitude: BrGlamorousButtonWithLabelAptitude new;
label: (self url asString copyReplaceAll: self url scheme, '://' with: '') allButLast;
action: [ WebBrowser openOn: self url asString ].
textInfoPane := BrVerticalPane new
hMatchParent;
vFitContent;
@ -26,8 +31,9 @@ asCardElement
beLargeSize);
addChild: (BrLabel new
aptitude: BrGlamorousLabelAptitude;
text: 'Joined: ' , self createdAtShorted );
addChild: anEditor.
text: 'Joined: ' , self createdAtShorted ).
self url ifNotNil: [textInfoPane addChild: webpageButton].
textInfoPane addChild: anEditor.
buttonsPane := BrHorizontalPane new
fitContent;
cellSpacing: 5;

View File

@ -3,7 +3,7 @@ fromNitterProfile: userNameString
| nitterUser joinDateString |
nitterUser := NitterUser new userName: userNameString.
name := nitterUser name.
userName := NitterUser new userName: userNameString.
userName := nitterUser userName.
"((title splitOn: '/') second trimmed) allButFirst." "<--This should go to a test."
profileImageUrl := nitterUser profileImageUrl.
description := nitterUser description.

View File

@ -1,17 +1,7 @@
accessing
profileImage
| response |
response := ZnClient new url: (self profileImageUrl); get; response.
response contentType = ZnMimeType imageJpeg
ifTrue: [ | imageTemp |
imageTemp := [ JPEGReadWriter gtFromBuffer: response contents ].
^ BlUrlImageElement url: self profileImageUrl
"The previous version has something like
imageTemp on: Error do: [ ^ GtABContact new avatar ].
^ imageTemp value asElement
].
response contentType = ZnMimeType imagePng
ifTrue: [ | imageTemp |
imageTemp := [ PNGReadWriter gtFromBuffer: response contents ].
imageTemp on: Error do: [ ^ GtABContact new avatar ].
^ imageTemp value asElement
].
^ BlElement new background: Color gray
Should a generic avatar be reimplemented?"

View File

@ -0,0 +1,3 @@
accessing
url
^ url