diff --git a/Socialmetrica.package/NitterUser.class/instance/downloadProfileImage.st b/Socialmetrica.package/NitterUser.class/instance/downloadProfileImage.st index af43576..e58b6fb 100644 --- a/Socialmetrica.package/NitterUser.class/instance/downloadProfileImage.st +++ b/Socialmetrica.package/NitterUser.class/instance/downloadProfileImage.st @@ -1,4 +1,12 @@ accessing downloadProfileImage - ^ self exportProfileImageOn: self folder / 'profile-image', 'jpg' \ No newline at end of file + 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' ]] \ No newline at end of file diff --git a/Socialmetrica.package/NitterUser.class/instance/profileImageFile.st b/Socialmetrica.package/NitterUser.class/instance/profileImageFile.st index de10300..ee76e7c 100644 --- a/Socialmetrica.package/NitterUser.class/instance/profileImageFile.st +++ b/Socialmetrica.package/NitterUser.class/instance/profileImageFile.st @@ -3,5 +3,7 @@ profileImageFile | file | file := (self folder / 'profile-image', 'jpg'). - file exists ifTrue: [ ^ file ]. + file exists ifTrue: [ file asFileReference size = 0 + ifTrue:[ ^ self downloadProfileImage ]. + ^ file. ]. ^ self downloadProfileImage \ No newline at end of file diff --git a/Socialmetrica.package/NitterUser.class/instance/profileImageUrl.st b/Socialmetrica.package/NitterUser.class/instance/profileImageUrl.st index 77735ea..0e77597 100644 --- a/Socialmetrica.package/NitterUser.class/instance/profileImageUrl.st +++ b/Socialmetrica.package/NitterUser.class/instance/profileImageUrl.st @@ -2,5 +2,7 @@ accessing profileImageUrl | 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 \ No newline at end of file diff --git a/Socialmetrica.package/NitterUser.class/instance/remoteIsFound.st b/Socialmetrica.package/NitterUser.class/instance/remoteIsFound.st new file mode 100644 index 0000000..d6e9883 --- /dev/null +++ b/Socialmetrica.package/NitterUser.class/instance/remoteIsFound.st @@ -0,0 +1,5 @@ +accessing +remoteIsFound + + ^ (ZnClient new url: (self userNameLink asUrl); get; response) isNotFound not + \ No newline at end of file diff --git a/Socialmetrica.package/NitterUser.class/instance/url.st b/Socialmetrica.package/NitterUser.class/instance/url.st index 56e984d..fbe89a7 100644 --- a/Socialmetrica.package/NitterUser.class/instance/url.st +++ b/Socialmetrica.package/NitterUser.class/instance/url.st @@ -1,5 +1,7 @@ accessing url + self remoteIsFound + ifFalse: [ ^ url := nil ]. ^ url ifNil: [ | temp | temp := ((self documentTree xpath: '//div[@class="profile-website"]') // 'a' @@ 'href') first. temp ifNil: [ ^ url := nil ]. diff --git a/Socialmetrica.package/TweetsCollection.class/instance/gtTweetsFor..st b/Socialmetrica.package/TweetsCollection.class/instance/gtTweetsFor..st index 10d7568..e8efd2a 100644 --- a/Socialmetrica.package/TweetsCollection.class/instance/gtTweetsFor..st +++ b/Socialmetrica.package/TweetsCollection.class/instance/gtTweetsFor..st @@ -22,4 +22,5 @@ gtTweetsFor: aView stencil: [ each asCardElement margin: (BlInsets all: 15) ]. container addChild: imageContainer ]. - container asScrollableElement ] \ No newline at end of file + container asScrollableElement ]; + actionUpdateButtonTooltip: 'Update view' \ No newline at end of file diff --git a/Socialmetrica.package/TwitterUser.class/instance/asCardElement.st b/Socialmetrica.package/TwitterUser.class/instance/asCardElement.st index ebb5864..929caad 100644 --- a/Socialmetrica.package/TwitterUser.class/instance/asCardElement.st +++ b/Socialmetrica.package/TwitterUser.class/instance/asCardElement.st @@ -2,6 +2,11 @@ accessing asCardElement | aModeLook anEditor textInfoPane buttonsPane webpageButton | + self remoteIsFound + ifFalse:[ description := 'The user does not exist'. + url := nil. + createdAt := ZTimestamp now. ]. + aModeLook := BrEditorModeAptitude new editableFocused: [ :aWidget | aWidget border: (BlBorder paint: BrGlamorousColors focusedEditorBorderColor width: 1) ]; editableUnfocused: [ :aWidget | aWidget border: (BlBorder paint: BrGlamorousColors editorBorderColor width: 1) ]; diff --git a/Socialmetrica.package/TwitterUser.class/instance/remoteIsFound.st b/Socialmetrica.package/TwitterUser.class/instance/remoteIsFound.st new file mode 100644 index 0000000..621e494 --- /dev/null +++ b/Socialmetrica.package/TwitterUser.class/instance/remoteIsFound.st @@ -0,0 +1,4 @@ +accessing +remoteIsFound + + ^ SubclassResponsibility \ No newline at end of file