Nitter: Improving tweets preview, metadata and collections management.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2022-04-01 19:34:30 -05:00
parent e5e8fea29d
commit 032e6fd7da
11 changed files with 39 additions and 5 deletions

View File

@ -1,8 +1,13 @@
accessing accessing
getMessages getMessages
| lastTweetsRaw lastTweets | | lastTweetsRaw customQuery lastTweets |
lastTweetsRaw := self rssFeed xmlDocument xpath: '//item'. lastTweetsRaw := self rssFeed xmlDocument xpath: '//item'.
lastTweets := TweetsCollection new. lastTweets := TweetsCollection new.
customQuery := Dictionary new
at: 'parameters' put: self;
at: 'date' put: DateAndTime now;
yourself.
lastTweets query: customQuery.
lastTweetsRaw do: [ :rssTweet | lastTweetsRaw do: [ :rssTweet |
lastTweets add: ((Tweet new fromNitterRssItem: rssTweet )) lastTweets add: ((Tweet new fromNitterRssItem: rssTweet ))
]. ].

View File

@ -9,7 +9,7 @@ asCardElement
anEditor := BrEditor new anEditor := BrEditor new
aptitude: BrGlamorousRegularEditorAptitude new + aModeLook; aptitude: BrGlamorousRegularEditorAptitude new + aModeLook;
text: self text; text: self textPreview;
vFitContent. vFitContent.
textInfoPane := BrVerticalPane new textInfoPane := BrVerticalPane new

View File

@ -5,5 +5,5 @@ fromNitterRssItem: xmlItem
user := NitterUser new user := NitterUser new
userName: author . userName: author .
created := (xmlItem xpath: 'pubDate') stringValue. created := (xmlItem xpath: 'pubDate') stringValue.
text := (XMLHTMLParser on: (xmlItem xpath: 'description') stringValue) parseDocument stringValue. text := (xmlItem xpath: 'description') stringValue.
id := ((xmlItem xpath: 'guid') stringValue splitOn: '/') last copyReplaceAll: '#m' with: '' id := ((xmlItem xpath: 'guid') stringValue splitOn: '/') last copyReplaceAll: '#m' with: ''

View File

@ -2,4 +2,4 @@ accessing
printOn: aStream printOn: aStream
super printOn: aStream. super printOn: aStream.
aStream aStream
nextPutAll: '( ',self text ,' )' nextPutAll: '( ',self textPreview ,' )'

View File

@ -0,0 +1,6 @@
accessing
textPreview
"I'm a utility method to improve the way text is rendered accordin to if it comes from
Nitter or Twitter."
^ (XMLHTMLParser on: self text) parseDocument stringValue

View File

@ -0,0 +1,3 @@
accessing
dataStore
^ (FileLocator userData / 'Socialmetrica') ensureCreateDirectory

View File

@ -0,0 +1,6 @@
accessing
query: aDictionary
"The dictionary has two keys: the query parameter(s) itself
and the date when the query was executed.
Such information is used to store/serialize query results outside of the image."
query := aDictionary

View File

@ -0,0 +1,3 @@
accessing
query
^ query

View File

@ -0,0 +1,3 @@
accessing
queryParameters
^ self query at: 'parameters'

View File

@ -0,0 +1,7 @@
accessing
store
| localFolder parameters |
parameters := self queryParameters .
parameters class = NitterUser ifFalse: [ ^ self ].
^ localFolder := (self dataStore / parameters userName) ensureCreateDirectory.

View File

@ -6,7 +6,8 @@
"pools" : [ ], "pools" : [ ],
"classvars" : [ ], "classvars" : [ ],
"instvars" : [ "instvars" : [
"tweets" "tweets",
"query"
], ],
"name" : "TweetsCollection", "name" : "TweetsCollection",
"type" : "normal" "type" : "normal"