Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: [REBOL]

From: greggirwin:mindspring at: 6-Jul-2002 20:22

Hi Joanna, << Another question.. ... Has anyone made REBOL script that could parse Slashdot news headers and view them on small window? All info (including links to files) are on http://slashdot.org/code.shtml There is no example on REBOL. IMHO it woud make an nice example how REBOL/VIEW can be used. I looked those header files and they surely look quite easy to parse, it would make nice and short view demo. >> Here's a real quick, hackety-hack version that might be useful as a starting point for something nicer. The item-rules can actually be generated programmatically from the object spec without much difficulty as well, but for just this small number of fields this isn't bad. Beware strange names due to scavenged code. Anyone think this is worth improving? If we did, it could (as Joanna said) be a good showcase piece for the SlashDot crowd to give them a reason to look into REBOL. (WWW - Watch for Word Wrap) --Gregg REBOL [ Title: "Slashdot Header Viewer" Author: "Gregg Irwin" Email: [greggirwin--acm--org] Date: 6-Jul-2002 ] story: make object! [ title: url: time: author: department: topic: comments: section: image: none ] data: read http://slashdot.org/slashdot.xml stories: copy [] cur-story: make story [] parser: make object! [ item-rules: [ [thru <title> copy text to </title>] (cur-story/title: text) | [thru <url> copy text to </url>] (cur-story/url: to url! text) | [thru <time> copy text to </time>] (cur-story/time: to date! text) | [thru <author> copy text to </author>] (cur-story/author: text) | [thru <department> copy text to </department>] (cur-story/department: text) | [thru <topic> copy text to </topic>] (cur-story/topic: text) | [thru <comments> copy text to </comments>] (cur-story/comments: text) | [thru <section> copy text to </section>] (cur-story/section: text) | [thru <image> copy text to </image>] (cur-story/image: text) ] story-rule: [ [thru <story> copy text to </story>] ( parse text [some item-rules] append stories cur-story cur-story: make story [] ) ] get-stories: does [ parse data [some story-rule to end] ] ] lwide: 385 num-items-visible: 4 cnt: 0 parser/get-stories subface: layout/offset [ origin 0 space 0x0 t1: h2 lwide black snow [browse item/url] t2: text lwide black ivory - 32 t3: text lwide black ivory - 32 ] 0x0 view layout compose [ space 2x2 lst: list (as-pair 385 (subface/size/y * num-items-visible)) [ origin 0 space 0x0 box subface/size ] supply [ count: count + cnt face/pane: none if pick stories count [ item: pick stories count ; don't move it face/pane: subface t1/text: item/title t2/text: rejoin ["Posted by " item/author " on " item/time/date at item/time/time] t3/text: rejoin ["From the " item/department " dept. (" item/comments " comments)"] ] ] return sld: scroller (as-pair 16 (subface/size/y * num-items-visible)) [ c: max 0 to-integer value * subtract length? stories num-items-visible if c <> cnt [cnt: c show lst] ] ]