Improving modularization with the new NitterUser object.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2022-01-02 14:27:58 -05:00
parent 15db771f80
commit 321ddc8e71
13 changed files with 51 additions and 14 deletions

View File

@ -0,0 +1,6 @@
accessing
createdAt
^ createdAt ifNil: [| joinDateString |
joinDateString := ((self documentTree xpath: '//div[@class="profile-joindate"]/span/@title') stringValue).
createdAt := (ZTimestampFormat fromString:'4:05 PM - 03 Feb 2001') parse: joinDateString.
]

View File

@ -0,0 +1,3 @@
accessing
description
^ description ifNil: [description := (self documentTree xpath: '//div[@class="profile-bio"]') stringValue]

View File

@ -0,0 +1,3 @@
operation
documentTree
^ (XMLDOMParser on: self userNameLink asUrl retrieveContents) parseDocument

View File

@ -0,0 +1,3 @@
accessing
name
^ name ifNil: [ name := ((self rssFeed requiredItems title) splitOn: '/') first ]

View File

@ -0,0 +1,3 @@
accessing
profileImageUrl
^ profileImageUrl ifNil: [ (self rssFeed xmlDocument xpath: '//image/url') stringValue copyReplaceAll: '%2F' with: '/' ]

View File

@ -0,0 +1,4 @@
accessing
rssFeed
^ RSSTools createRSSFeedFor: self userNameLink , '/rss'

View File

@ -0,0 +1,3 @@
accessing
userName: userNameString
userName := userNameString.

View File

@ -0,0 +1,4 @@
accessing
userNameLink
^ 'https://nitter.net/' , self userName

View File

@ -0,0 +1,11 @@
{
"commentStamp" : "",
"super" : "TwitterUser",
"category" : "Datanalitica-Datanalitica",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "NitterUser",
"type" : "normal"
}

View File

@ -1,3 +1,3 @@
accessing
createdAtShorted
^ self createdAt asString copyFrom: 1 to: 7
^ self createdAt asString copyFrom: 1 to: 10

View File

@ -1,14 +1,10 @@
accessing
fromNitterProfile: userNameString
| nitterProfileLink rssFeed title nitterDocTree joinDateString |
nitterProfileLink := 'https://nitter.net/', userNameString.
rssFeed := RSSTools createRSSFeedFor: nitterProfileLink, '/rss'.
title := rssFeed requiredItems title.
name := (title splitOn: '/') first trimmed.
"Tecnically we could just do 'userName' = 'userNameString'. But we want to capture also how it is expressed in the RSS."
userName := ((title splitOn: '/') second trimmed) allButFirst. "Taking out the '@' sign."
profileImageUrl := (rssFeed xmlDocument xpath: '//image/url') stringValue copyReplaceAll: '%2F' with: '/'.
nitterDocTree := (XMLDOMParser on: nitterProfileLink asUrl retrieveContents) parseDocument.
description := (nitterDocTree xpath: '//div[@class="profile-bio"]') stringValue.
joinDateString := ((nitterDocTree xpath: '//div[@class="profile-joindate"]/span/@title') stringValue).
createdAt := (ZTimestampFormat fromString:'4:05 PM - 03 Feb 2001') parse: joinDateString.
| nitterUser joinDateString |
nitterUser := NitterUser new userName: userNameString.
name := nitterUser name.
userName := NitterUser new userName: userNameString.
"((title splitOn: '/') second trimmed) allButFirst." "<--This should go to a test."
profileImageUrl := nitterUser profileImageUrl.
description := nitterUser description.
createdAt := nitterUser createdAt.

View File

@ -14,7 +14,8 @@
"metrics",
"tweets",
"createdAt",
"groups"
"groups",
"url"
],
"name" : "TwitterUser",
"type" : "normal"