From dd655260b416029d18dfca15c6c4fdcf660019da Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Thu, 31 Mar 2022 20:49:30 -0500 Subject: [PATCH] Implementing tweets navigation in the NitterUser. --- .../NitterUser.class/instance/getMessages.st | 10 ++++++++++ .../Tweet.class/instance/fromNitterRssItem..st | 9 +++++++++ .../TwitterUser.class/instance/asCardElement.st | 2 +- .../TwitterUser.class/instance/tweets.st | 2 +- 4 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 Datanalitica.package/NitterUser.class/instance/getMessages.st create mode 100644 Datanalitica.package/Tweet.class/instance/fromNitterRssItem..st diff --git a/Datanalitica.package/NitterUser.class/instance/getMessages.st b/Datanalitica.package/NitterUser.class/instance/getMessages.st new file mode 100644 index 0000000..71f2715 --- /dev/null +++ b/Datanalitica.package/NitterUser.class/instance/getMessages.st @@ -0,0 +1,10 @@ +accessing +getMessages + | lastTweetsRaw lastTweets | + lastTweetsRaw := self rssFeed xmlDocument xpath: '//item'. + lastTweets := TweetsCollection new. + lastTweetsRaw do: [ :rssTweet | + lastTweets add: ((Tweet new fromNitterRssItem: rssTweet )) + ]. + ^ lastTweets + \ No newline at end of file diff --git a/Datanalitica.package/Tweet.class/instance/fromNitterRssItem..st b/Datanalitica.package/Tweet.class/instance/fromNitterRssItem..st new file mode 100644 index 0000000..7abd0a3 --- /dev/null +++ b/Datanalitica.package/Tweet.class/instance/fromNitterRssItem..st @@ -0,0 +1,9 @@ +accessing +fromNitterRssItem: xmlItem + | author | + author := (xmlItem xpath: 'dc:creator') stringValue allButFirst. + user := NitterUser new + userName: author . + created := (xmlItem xpath: 'pubDate') stringValue. + text := (XMLHTMLParser on: (xmlItem xpath: 'description') stringValue) parseDocument stringValue. + id := ((xmlItem xpath: 'guid') stringValue splitOn: '/') last copyReplaceAll: '#m' with: '' \ No newline at end of file diff --git a/Datanalitica.package/TwitterUser.class/instance/asCardElement.st b/Datanalitica.package/TwitterUser.class/instance/asCardElement.st index ea35173..787b8c3 100644 --- a/Datanalitica.package/TwitterUser.class/instance/asCardElement.st +++ b/Datanalitica.package/TwitterUser.class/instance/asCardElement.st @@ -41,7 +41,7 @@ asCardElement BrButton new aptitude: BrGlamorousButtonWithLabelAptitude new; label: 'Tweets'; - action: [ :e | e phlow spawnObject: self tweets ]. + action: [ :e | e phlow spawnObject: self getMessages ]. BrButton new aptitude: BrGlamorousButtonWithLabelAptitude new; label: 'Web view'; diff --git a/Datanalitica.package/TwitterUser.class/instance/tweets.st b/Datanalitica.package/TwitterUser.class/instance/tweets.st index f460912..7f01686 100644 --- a/Datanalitica.package/TwitterUser.class/instance/tweets.st +++ b/Datanalitica.package/TwitterUser.class/instance/tweets.st @@ -1,3 +1,3 @@ accessing tweets - ^ tweets ifNil: [ self tweets: self getMessages ] \ No newline at end of file + ^ tweets ifNil: [ tweets := OrderedCollection new ] \ No newline at end of file