RSS Reader in 10 lines of code

Bert Freudenberg bert at impara.de
Tue Oct 4 21:14:05 UTC 2005


Ah, that's from 3.9, for ToolBuilder support.

You could instead just use a Workspace or anything that displays a Text:

Workspace new
     contents: (Text streamContents: [:stream |
         (XMLDOMParser parseDocumentFrom: (HTTPClient httpGet:  
'http://squeaksource.com/feed.rss'))
             tagsNamed: #item do: [:item |
                 #(title bold author italic pubDate normal  
description normal) pairsDo: [:tag :attr |
                     stream withAttribute: (TextEmphasis perform:  
attr) do: [
                         item tagsNamed: tag do: [:element |
                             stream nextPutAll: element  
contentString; space]].
                     attr = #normal ifTrue: [stream cr]]]]);
     openLabel: 'Bert''s Minimal Feed Reader'

Am 04.10.2005 um 20:53 schrieb Jason Rogers:

> OK, so where does the UIManager class come from?  I wanted to play
> with this code snippet but I don't have that installed.  I am running
> 3.8#6665 on Linux.
>
> On 10/4/05, Bert Freudenberg <bert at impara.de> wrote:
>
>>
>> Am 04.10.2005 um 11:45 schrieb Tony Garnock-Jones:
>>
>>
>>> Bert Freudenberg wrote:
>>>
>>>
>>>> If you have Yaxo installed, try this:
>>>>
>>>>
>>>
>>> Yikes! The RSS feed generated isn't well-formed XML!
>>>
>>
>> Doh! Last time I tried the squeak foundation feed was well-formed :(
>>
>> You might try a different feed, though, like http://squeaksource.com/
>> feed.rss
>>
>> This is what it looks like, for those who couldn't try:
>>
>>
>>
>>
>> UIManager default
>>      edit: (Text streamContents: [:stream |
>>          (XMLDOMParser parseDocumentFrom: (HTTPClient httpGet:
>> 'http://squeaksource.com/feed.rss'))
>>              tagsNamed: #item do: [:item |
>>                  #(title bold author italic pubDate normal
>> description normal) pairsDo: [:tag :attr |
>>                      stream withAttribute: (TextEmphasis perform:
>> attr) do: [
>>                          item tagsNamed: tag do: [:element |
>>                              stream nextPutAll: element
>> contentString; space]].
>>                      attr = #normal ifTrue: [stream cr]]]])
>>      label: 'Bert''s Minimal Feed Reader'
>>
>> - Bert -
>>
>>
>>
>>
>>
>>
>>
>>
>>
>
>
> --
> Jason Rogers
>
> "I am crucified with Christ: nevertheless I live; yet not I,
> but Christ liveth in me: and the life which I now live in
> the flesh I live by the faith of the Son of God, who loved
> me, and gave himself for me."
>     Galatians 2:20
>
>

- Bert -




More information about the Squeak-dev mailing list