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 accessing
asCardElement asCardElement
| aModeLook anEditor textInfoPane buttonsPane | | aModeLook anEditor textInfoPane buttonsPane webpageButton |
aModeLook := BrEditorModeAptitude new aModeLook := BrEditorModeAptitude new
editableFocused: [ :aWidget | aWidget border: (BlBorder paint: BrGlamorousColors focusedEditorBorderColor width: 1) ]; editableFocused: [ :aWidget | aWidget border: (BlBorder paint: BrGlamorousColors focusedEditorBorderColor width: 1) ];
@ -11,6 +11,11 @@ asCardElement
aptitude: BrGlamorousRegularEditorAptitude new + aModeLook; aptitude: BrGlamorousRegularEditorAptitude new + aModeLook;
text: self description; text: self description;
vFitContent. 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 textInfoPane := BrVerticalPane new
hMatchParent; hMatchParent;
@ -26,8 +31,9 @@ asCardElement
beLargeSize); beLargeSize);
addChild: (BrLabel new addChild: (BrLabel new
aptitude: BrGlamorousLabelAptitude; aptitude: BrGlamorousLabelAptitude;
text: 'Joined: ' , self createdAtShorted ); text: 'Joined: ' , self createdAtShorted ).
addChild: anEditor. self url ifNotNil: [textInfoPane addChild: webpageButton].
textInfoPane addChild: anEditor.
buttonsPane := BrHorizontalPane new buttonsPane := BrHorizontalPane new
fitContent; fitContent;
cellSpacing: 5; cellSpacing: 5;

View File

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

View File

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

View File

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