Improving tweets view and user profile image methods.

This commit is contained in:
ruidajo 2023-07-27 16:13:05 -05:00
parent 6e69fa5b3a
commit 03355de4f4
8 changed files with 33 additions and 4 deletions

View File

@ -1,4 +1,12 @@
accessing accessing
downloadProfileImage downloadProfileImage
^ self exportProfileImageOn: self folder / 'profile-image', 'jpg' self remoteIsFound
ifTrue: [ ^ self exportProfileImageOn: self folder / 'profile-image', 'jpg' ]
ifFalse: [ | tempFile |
tempFile := (self folder / 'profile-image', 'jpg') asFileReference.
tempFile ensureCreateFile.
tempFile binaryWriteStreamDo: [ :stream |
stream nextPutAll: 'https://mutabit.com/repos.fossil/mutabit/uv/wiki/commons/twitter-user-image-default.jpg' asUrl retrieveContents.
super class inform: 'Exported as: ', String cr, tempFile fullName.
^ self folder / 'profile-image', 'jpg' ]]

View File

@ -3,5 +3,7 @@ profileImageFile
| file | | file |
file := (self folder / 'profile-image', 'jpg'). file := (self folder / 'profile-image', 'jpg').
file exists ifTrue: [ ^ file ]. file exists ifTrue: [ file asFileReference size = 0
ifTrue:[ ^ self downloadProfileImage ].
^ file. ].
^ self downloadProfileImage ^ self downloadProfileImage

View File

@ -2,5 +2,7 @@ accessing
profileImageUrl profileImageUrl
| documentTree | | documentTree |
documentTree := [ self documentTree ] onErrorDo: [ ^ nil ]. self remoteIsFound
ifFalse:[ ^ nil ].
documentTree := self documentTree.
^ profileImageUrl := self class nitterProvider, (((documentTree xpath: '//div[@class="profile-card-info"]//a[@class="profile-card-avatar"]') @ 'href') stringValue copyReplaceAll: '%2F' with: '/') copyWithoutFirst ^ profileImageUrl := self class nitterProvider, (((documentTree xpath: '//div[@class="profile-card-info"]//a[@class="profile-card-avatar"]') @ 'href') stringValue copyReplaceAll: '%2F' with: '/') copyWithoutFirst

View File

@ -0,0 +1,5 @@
accessing
remoteIsFound
^ (ZnClient new url: (self userNameLink asUrl); get; response) isNotFound not

View File

@ -1,5 +1,7 @@
accessing accessing
url url
self remoteIsFound
ifFalse: [ ^ url := nil ].
^ url ifNil: [ | temp | ^ url ifNil: [ | temp |
temp := ((self documentTree xpath: '//div[@class="profile-website"]') // 'a' @@ 'href') first. temp := ((self documentTree xpath: '//div[@class="profile-website"]') // 'a' @@ 'href') first.
temp ifNil: [ ^ url := nil ]. temp ifNil: [ ^ url := nil ].

View File

@ -22,4 +22,5 @@ gtTweetsFor: aView
stencil: [ each asCardElement margin: (BlInsets all: 15) ]. stencil: [ each asCardElement margin: (BlInsets all: 15) ].
container addChild: imageContainer container addChild: imageContainer
]. ].
container asScrollableElement ] container asScrollableElement ];
actionUpdateButtonTooltip: 'Update view'

View File

@ -2,6 +2,11 @@ accessing
asCardElement asCardElement
| aModeLook anEditor textInfoPane buttonsPane webpageButton | | aModeLook anEditor textInfoPane buttonsPane webpageButton |
self remoteIsFound
ifFalse:[ description := 'The user does not exist'.
url := nil.
createdAt := ZTimestamp now. ].
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) ];
editableUnfocused: [ :aWidget | aWidget border: (BlBorder paint: BrGlamorousColors editorBorderColor width: 1) ]; editableUnfocused: [ :aWidget | aWidget border: (BlBorder paint: BrGlamorousColors editorBorderColor width: 1) ];

View File

@ -0,0 +1,4 @@
accessing
remoteIsFound
^ SubclassResponsibility