Code review: Modularization.
This commit is contained in:
parent
65c36e924c
commit
bc168c4f0a
@ -1,4 +1,4 @@
|
||||
accessing
|
||||
getMessages
|
||||
self getLocalMessages ifNil: [ self getRemoteMessages ].
|
||||
self getLocalMessages ifNil: [ self getRemoteMessagesFromRss ].
|
||||
^ self tweets
|
@ -1,5 +1,5 @@
|
||||
accessing
|
||||
getRemoteMessages
|
||||
getRemoteMessagesFromRss
|
||||
|
||||
| customQuery lastTweetsRaw lastTweets |
|
||||
lastTweetsRaw := self rssFeed xmlDocument xpath: '//item'.
|
@ -0,0 +1,5 @@
|
||||
accessing
|
||||
lastTweetsFromHtml
|
||||
|
||||
^ (self documentTree xpath: '//div[@class="timeline-item "]')
|
||||
asOrderedCollection collect: [ :xmlElement | xmlElement postCopy ]
|
@ -3,33 +3,35 @@ numberOfURLsForLoadingTweets: number
|
||||
|
||||
| collectionURLs count asURLs urlAndTweets |
|
||||
number = 1 ifTrue: [ ^ self ].
|
||||
|
||||
|
||||
urlAndTweets := OrderedDictionary new.
|
||||
collectionURLs := { self userNameLink .}asOrderedCollection.
|
||||
|
||||
urlAndTweets
|
||||
at: 'tweets'
|
||||
put: ((self documentTree xpath: '//div[@class="timeline-item "]')asOrderedCollection collect: [ :xmlElement | xmlElement postCopy]).
|
||||
|
||||
collectionURLs := { self userNameLink } asOrderedCollection.
|
||||
|
||||
urlAndTweets at: 'tweets' put: self lastTweetsFromHtml.
|
||||
|
||||
count := 1.
|
||||
(number-count) timesRepeat: [ | tempDoc docTree urlString |
|
||||
tempDoc := XMLHTMLParser parse:
|
||||
(collectionURLs at: count) asUrl retrieveContents.
|
||||
|
||||
urlString := (self userNameLink,
|
||||
((tempDoc xPath: '//a[.="Load more"]') @ 'href') stringValue).
|
||||
number - count timesRepeat: [
|
||||
| tempDoc docTree urlString |
|
||||
tempDoc := XMLHTMLParser parse:
|
||||
(collectionURLs at: count) asUrl retrieveContents.
|
||||
|
||||
urlString := self userNameLink
|
||||
,
|
||||
((tempDoc xPath: '//a[.="Load more"]') @ 'href')
|
||||
stringValue.
|
||||
docTree := XMLHTMLParser parse: urlString asUrl retrieveContents.
|
||||
collectionURLs
|
||||
add: urlString.
|
||||
|
||||
urlAndTweets
|
||||
at: 'tweets-', (urlString splitOn: 'cursor=') second
|
||||
put: ((docTree xpath: '//div[@class="timeline-item "]')asOrderedCollection
|
||||
collect: [ :xmlElement | xmlElement postCopy ]).
|
||||
count := count+1 ].
|
||||
|
||||
collectionURLs add: urlString.
|
||||
|
||||
urlAndTweets
|
||||
at: 'tweets-' , (urlString splitOn: 'cursor=') second
|
||||
put:
|
||||
((docTree xpath: '//div[@class="timeline-item "]')
|
||||
asOrderedCollection collect: [ :xmlElement |
|
||||
xmlElement postCopy ]).
|
||||
count := count + 1 ].
|
||||
|
||||
asURLs := collectionURLs collect: [ :string | string asUrl ].
|
||||
|
||||
|
||||
urlAndTweets at: 'urls' put: asURLs.
|
||||
|
||||
^ urlAndTweets.
|
||||
|
||||
^ urlAndTweets
|
Loading…
Reference in New Issue
Block a user