Improving modularization with the new NitterUser object.
This commit is contained in:
parent
15db771f80
commit
321ddc8e71
0
Datanalitica.package/NitterUser.class/README.md
Normal file
0
Datanalitica.package/NitterUser.class/README.md
Normal 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.
|
||||
]
|
@ -0,0 +1,3 @@
|
||||
accessing
|
||||
description
|
||||
^ description ifNil: [description := (self documentTree xpath: '//div[@class="profile-bio"]') stringValue]
|
@ -0,0 +1,3 @@
|
||||
operation
|
||||
documentTree
|
||||
^ (XMLDOMParser on: self userNameLink asUrl retrieveContents) parseDocument
|
3
Datanalitica.package/NitterUser.class/instance/name.st
Normal file
3
Datanalitica.package/NitterUser.class/instance/name.st
Normal file
@ -0,0 +1,3 @@
|
||||
accessing
|
||||
name
|
||||
^ name ifNil: [ name := ((self rssFeed requiredItems title) splitOn: '/') first ]
|
@ -0,0 +1,3 @@
|
||||
accessing
|
||||
profileImageUrl
|
||||
^ profileImageUrl ifNil: [ (self rssFeed xmlDocument xpath: '//image/url') stringValue copyReplaceAll: '%2F' with: '/' ]
|
@ -0,0 +1,4 @@
|
||||
accessing
|
||||
rssFeed
|
||||
|
||||
^ RSSTools createRSSFeedFor: self userNameLink , '/rss'
|
@ -0,0 +1,3 @@
|
||||
accessing
|
||||
userName: userNameString
|
||||
userName := userNameString.
|
@ -0,0 +1,4 @@
|
||||
accessing
|
||||
userNameLink
|
||||
|
||||
^ 'https://nitter.net/' , self userName
|
11
Datanalitica.package/NitterUser.class/properties.json
Normal file
11
Datanalitica.package/NitterUser.class/properties.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"commentStamp" : "",
|
||||
"super" : "TwitterUser",
|
||||
"category" : "Datanalitica-Datanalitica",
|
||||
"classinstvars" : [ ],
|
||||
"pools" : [ ],
|
||||
"classvars" : [ ],
|
||||
"instvars" : [ ],
|
||||
"name" : "NitterUser",
|
||||
"type" : "normal"
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
accessing
|
||||
createdAtShorted
|
||||
^ self createdAt asString copyFrom: 1 to: 7
|
||||
^ self createdAt asString copyFrom: 1 to: 10
|
@ -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.
|
@ -14,7 +14,8 @@
|
||||
"metrics",
|
||||
"tweets",
|
||||
"createdAt",
|
||||
"groups"
|
||||
"groups",
|
||||
"url"
|
||||
],
|
||||
"name" : "TwitterUser",
|
||||
"type" : "normal"
|
||||
|
Loading…
Reference in New Issue
Block a user