picowiki

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/picowiki.git/
Log | Files | Refs

rss.l (3668B)


      1 (de readChanges (F)
      2    (let L NIL
      3       (in F
      4          (until (eof)
      5             (match '("\"" @D "\"" " "
      6                      "\"" @T "\"" " "
      7                      "\"" @N "\"" " "
      8                      "\"" @P "\"" " "
      9                      @V " "
     10                      "\"" @C "\"" ) (line) )
     11             (push 'L (mapcar pack (list @D @T @N @P @V @C))) ) )
     12       L ) )
     13             
     14 (de renderChanges (Page)
     15    (<div> '((class . "page changes"))
     16       (<h1> NIL
     17          (if (= "Changes" Page)
     18             (ht:Prin Page)
     19             (ht:Prin "'" Page "' changes") ) )
     20       (let F (pageFile "Changes")
     21          (ifn (info F)
     22             (<p> NIL "No changes have been made yet.")
     23             (let L (readChanges F)
     24                (for D (group (if (= "Changes" Page)
     25                                 L
     26                                 (filter '((X) (= Page (cadddr X))) L) ) )
     27                   (<p> NIL
     28                      (ht:Prin (httpDate2 (strDat (car D))))
     29                      (<ul> NIL
     30                         (for C (cdr D)
     31                            (let (@T (car C)
     32                                    @N (cadr C)
     33                                    @P (caddr C)
     34                                    @V (cadddr C)
     35                                    @C (car (cddddr C)) )
     36                               (<li> NIL
     37                                  (ht:Prin @T)
     38                                  " " (<ilink> @P)
     39                                  " " (ht:Prin @V)
     40                                  ": " (ht:Prin @C)
     41                                  " -- " (<ilink> @N) ) ) ) ) ) ) ) ) ) ) )
     42 
     43 (de httpDate2 (Dat Tim)
     44    (let D (date Dat)
     45       (pack
     46          (day Dat *Day) ", "
     47          (pad 2 (caddr D)) " "
     48          (get *Mon (cadr D)) " "
     49          (car D)
     50          (when Tim " ")
     51          (when Tim (tim$ Tim T))
     52          (when Tim " GMT") ) ) )
     53 
     54 (de rssItem (@D I)
     55    (when (match '(@T @N @P @V @C) I)
     56       (setq @T (car @T))
     57       (setq @N (car @N))
     58       (setq @P (car @P))
     59       (setq @V (car @V))
     60       (setq @C (car @C))
     61       (<xml> item
     62          (<xml> title
     63             (xprin (httpDate2 (strDat @D)) " " @P " " @V ": " @C
     64                (when @N (pack " -- " @N)) ) )
     65          (<xml> pubDate (xprin (httpDate2 (strDat @D) ($tim @T))))
     66          (<xml> link
     67             (xprin "http://" *Host "/picoWiki/" (ht:Fmt (pageUrl @P 'view))) ) ) ) )
     68 
     69 # "2008-10-08" "16:04:09" "Tomas Hlavaty" "picoWiki" 1 "created"
     70 #  date time who page version comment
     71 
     72 (de rss (Ttl Desc Pg)
     73    (httpHead "text/xml; charset=utf-8" 0)
     74    (ht:Out *Chunked
     75       ##(xml? T)
     76       (<xml> NIL
     77          (<xml> rss version "0.92"
     78             (<xml> channel
     79                (<xml> title NIL Ttl)
     80                (<xml> link (xprin "http://" *Host "/picoWiki/Changes"))
     81                (<xml> description NIL Desc)
     82 
     83                (let F (pageFile "Changes")
     84                   (when (info F)
     85                      (let L (readChanges F)
     86                         (for D (group L)                    # by date
     87                            (for DD (by caddr group (cdr D)) # by page
     88                               (let N (length DD)
     89                                  (link
     90                                     (rssItem (car D)
     91                                        (if (< 1 N)
     92                                           (list
     93                                              (caar DD)
     94                                              NIL
     95                                              (car (cddar DD))
     96                                              (cadr (cddar DD))
     97                                              (pack N " changes") )
     98                                           (car DD) ) ) ) ) ) ) ) ) ) ) ) ) ) )
     99