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 accessing
createdAtShorted createdAtShorted
^ self createdAt asString copyFrom: 1 to: 7 ^ self createdAt asString copyFrom: 1 to: 10

View File

@ -1,14 +1,10 @@
accessing accessing
fromNitterProfile: userNameString fromNitterProfile: userNameString
| nitterProfileLink rssFeed title nitterDocTree joinDateString | | nitterUser joinDateString |
nitterProfileLink := 'https://nitter.net/', userNameString. nitterUser := NitterUser new userName: userNameString.
rssFeed := RSSTools createRSSFeedFor: nitterProfileLink, '/rss'. name := nitterUser name.
title := rssFeed requiredItems title. userName := NitterUser new userName: userNameString.
name := (title splitOn: '/') first trimmed. "((title splitOn: '/') second trimmed) allButFirst." "<--This should go to a test."
"Tecnically we could just do 'userName' = 'userNameString'. But we want to capture also how it is expressed in the RSS." profileImageUrl := nitterUser profileImageUrl.
userName := ((title splitOn: '/') second trimmed) allButFirst. "Taking out the '@' sign." description := nitterUser description.
profileImageUrl := (rssFeed xmlDocument xpath: '//image/url') stringValue copyReplaceAll: '%2F' with: '/'. createdAt := nitterUser createdAt.
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.

View File

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