5 Cent tip for today [ RSS Menu based ]

Featuring the Dragonfly web framework
Locked
newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

5 Cent tip for today [ RSS Menu based ]

Post by newdep »

Oke oke.. i cant stop so here my RSS tilte menu version,
its simple but functional, enjoy and explore...

#!/usr/bin/newlisp
;;
;; RSS Title Slurp - (c) Norman 2004
;; version 3.0 Menu version
;; Linux Console version
;;

(set 'channel '( "title" "pubDate" ))

;;
;; Manual to add --> ( Number Site description link )
;;
(set 'uri '(
("00" "NU.NL " "Algemeen" "http://nu.nl/deeplink_rss2/index.jsp?r=Algemeen")
("01" "NU.NL " "Internet" "http://nu.nl/deeplink_rss2/index.jsp?r=Internet")
("02" "NU.NL " "Economie" "http://nu.nl/deeplink_rss2/index.jsp?r=Economie")
("03" "NU.NL " "Achterklap" "http://nu.nl/deeplink_rss2/index.jsp?r=Achterklap")
("04" "NU.NL " "Sport" "http://nu.nl/deeplink_rss2/index.jsp?r=Sport")
("05" "NU.NL " "Yoshe" "http://nu.nl/deeplink_rss2/index.jsp?r=Yoshe")
("06" "NEWLISP" "News" "http://newlisp.org/rss.cgi?News")
("07" "YAHOO " "Linux" "http://rss.news.yahoo.com/rss/linux")
("08" "YAHOO " "CellPhones" "http://rss.news.yahoo.com/rss/cellphones")
("09" "YAHOO " "Science" "http://rss.news.yahoo.com/rss/science")
("10" "VPRO " "Aanbevolen films deze week in de bioscoop" "http://www.vpro.nl/cinema/binders/rss/index.jsp")
("11" "VPRO " "Aanbevolen films vandaag op televisie (de Cinema.nl selectie)" "http://www.vpro.nl/cinema/includes_tele ... ls=8043634")
("12" "VPRO " "Alle films vandaag op televisie" "http://www.vpro.nl/cinema/includes_tele ... /index.jsp")
("13" "VPRO " "Alle nieuwe berichten" "http://www.vpro.nl/cinema/magazines/rss/index.jsp")
("14" "VPRO " "Nieuwe recensies" "http://www.vpro.nl/cinema/magazines/rss ... newstype=1")
("15" "VPRO " "Nieuwe dvdrecensies" "http://www.vpro.nl/cinema/magazines/rss ... ewstype=11")
("16" "NEWLISP" "Blog Demo Site" "http://newlisp.org/blog/rss.cgi")
))



;;
(define (banner) (println (dotimes ( x 79 ) (print "*")) ))
(define (cls) (println "\027[H\027[2J"))

(until (net-error)
;;
;; Print Menu selection
;;
(cls)
(banner)
(println "** RSS TITLE SLURPER - NODEP 2004")
(banner)
(println)
(dolist (item uri)
(println "[ " (nth 0 item) " ] " (nth 1 item) " -> " (nth 2 item)))
(println)
(banner)
(print "** RSS Feed number: ")

(unless (set 'choice (integer (read-line)))
(begin
(println "** RSS Quited...")
(exit)))

(set 'url (nth 3 (nth choice uri) ))

;;
;; DE-XML
;;
(xml-type-tags nil 'cdata '!-- nil)
(set 'url (xml-parse (get-url url) (+ 1 2 8 16) ))

;;
;; strippp <!-- comments from top...
;;
(until (= (first (nth 0 url)) 'rss ) (pop url))

(set 'rsschannel (nth 2 (nth 0 url)))
(set 'rsschannellen (length rsschannel))

(cls)
(banner)

;;
;; Channel info -> Required CHANNEL elements: title link description
;;
(dolist (x channel)
(if (set 'element (lookup (symbol x) rsschannel))
(println "** RSS Channel " x " -> " element )))

(banner)


;;
;; Seeking for ITEMS in CHANNEL
;;
(dotimes (y rsschannellen)
(if (list? (nth y rsschannel))
(if (= (nth 0 (nth y rsschannel)) 'item )
(println "** RSS Item -> " (lookup 'title (nth y rsschannel))))))

(banner)
(println "** Press <enter> for Menu")
(banner)
(read-line)

)
(exit)
-- (define? (Cornflakes))

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

rss ticker and menu are fantastic! thanks!

Lutz

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

All the scripts are now on http://www.nodep.nl/newlisp
-- (define? (Cornflakes))

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

And here the only newLISP program you ever need to write, and get all the rest from Norman:

Code: Select all

#!/usr/bin/newlisp
#
# get all of Norman's utilities at once
#
# - lutz
#

(set 'page (get-url "http://www.nodep.nl/newlisp/index.html"))
(replace {href="(http://.*lsp)"} page (push $1 links) 0)

(dolist (link links)
 	(set 'file (last (parse link "/")))
      (write-file file (get-url link))
	(println "->" file))


(exit)

;; eof ;;
Lutz

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

hahaha like that one ;-)
-- (define? (Cornflakes))

Locked