ADDED user/crc/rancid/Makefile Index: user/crc/rancid/Makefile =================================================================== --- user/crc/rancid/Makefile +++ user/crc/rancid/Makefile @@ -0,0 +1,18 @@ +# Set this to the retro root directory +# +# You should have at least a 'retro' binary, the 'retroImage', and +# 'library' directory there +# +# Note that while you can run Rancid under the Python VM, we need +# the C VM for building (at present) + +RX = ~/code/rx + +default: + @cp $(RX)/retroImage . + @ln -s $(RX)/library . + $(RX)/retro --with rancid.rx --with casket.rx --shrink + @rm library + +clean: + @rm -f retroImage ADDED user/crc/rancid/casket.rx Index: user/crc/rancid/casket.rx =================================================================== --- user/crc/rancid/casket.rx +++ user/crc/rancid/casket.rx @@ -0,0 +1,94 @@ +( casket ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) +chain: casket' +{{ + variable :options +---reveal--- + : KiB ( n-n ) 1024 * ; + : casket:path ( -$ ) @memory 8 KiB - ; + : casket:options ( -$ ) @:options ; + : casket:buffer ( -$ ) @memory 16 KiB - ; + : casket:root ( -$ ) "./" ; + : casket:url ( -$ ) "http://domain.com/path/to/cgi" ; + : getRequest ( -$ ) + casket:path dup "PATH_INFO" getEnv + dup 1+ '/ ^strings'findChar 1+ !:options ; +}} + ( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) + : Content-type: ( "- ) + "Content-type: " getToken ^strings'append "\n\n" ^strings'append + keepString .data ` puts ; immediate + ( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) + {{ + : withBase ( n$q-$ ) [ swap ] dip base &do preserve ; + : char ( $-$ ) + @+ [ 'n = ] [ drop cr ] when + [ '' = ] [ drop '" putc ] when + [ '[ = ] [ 27 putc putc ] when + putc ; + : obj ( $-$ ) + @+ [ 'd = ] [ drop [ decimal putn ] withBase ] when + [ 'o = ] [ drop [ octal putn ] withBase ] when + [ 'x = ] [ drop [ hex putn ] withBase ] when + [ 'c = ] [ drop swap putc ] when + [ 's = ] [ drop &puts dip ] when + [ 'q = ] [ drop &do dip ] when + [ 'u = ] [ drop casket:url puts ] when + putc ; + : complex ( $-n ) + repeat + @+ 0; + dup '\ = [ drop char 0 ] ifTrue + dup '% = [ drop obj 0 ] ifTrue + putc + again ; + ---reveal--- + : tputs complex drop ; + }} + ( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) + {{ + create buffer ( -a ) + 16 1024 * allot + : casket:templates ( -$ ) casket:root "templates/" ^strings'append ; + ---reveal--- + : withTemplate ( $- ) + buffer 0 16 1024 * fill + casket:templates ^strings'prepend buffer swap ^files'slurp drop + buffer tputs ; + }} + +: /404 + Content-type: text/html + "

404

" tputs cr bye ; +: / + Content-type: text/html + "

casket

" tputs cr bye ; + +: doBeforeDispatch ; + +: dispatch + doBeforeDispatch + getRequest 1+ + [ @+ [ 0 <> ] [ '/ <> ] bi and ] while 1- 0 swap ! + casket:path find [ @d->xt do ] [ drop /404 ] if bye ; + +{{ + create bit 5 allot + : extract ( $c-$a ) drop @+ bit ! @+ bit 1+ ! bit ; + : render ( $c-$n ) + dup '+ = [ drop 32 ] ifTrue + dup 13 = [ drop 32 ] ifTrue + dup 10 = [ drop 32 ] ifTrue + dup '% = [ extract hex toNumber decimal ] ifTrue ; + : ( $-$ ) repeat @+ 0; render ^buffer'add again ; +---reveal--- + : decode ( $- ) casket:buffer ^buffer'set drop ; +}} + +: serve: ( """- ) + getToken dup + "/" ^strings'prepend header + compiler on + keepString .data getToken drop + ` Content-type: ` puts ` ; &.word reclass ; + +;chain ADDED user/crc/rancid/rancid.rx Index: user/crc/rancid/rancid.rx =================================================================== --- user/crc/rancid/rancid.rx +++ user/crc/rancid/rancid.rx @@ -0,0 +1,80 @@ +( rancid, an irc log browser ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) +with casket' + +( support code ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) +: LOGS ( -$ ) casket:root "logs/" ^strings'append ; + +: commonHeader ( - ) + Content-type: text/html + "header.html" withTemplate ; + +: commonFooter ( - ) + "footer.html" withTemplate ; + +: navbar + casket:options tempString + dup ', swap 2 + ! + dup ', swap 5 + ! + "20" ^strings'prepend "script.erx" withTemplate ; + +( paths ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) +{{ + 2 elements content lines + + : clean ( $- ) + withLength + [ dup @ 10 13 within [ 999 swap &! sip ] ifTrue 1+ ] times drop ; + + : getLine ( $-$ ) + 999 ^strings'splitAtChar drop lines ++ ; + + : loadSourceData ( $- ) + here swap ^files'slurp here !content heap +! 32 , 0 , + @content clean ; + + : countLines ( $- ) + [ getLine dup 1 <> ] while drop ; + + : prepare ( $- ) + 0 !lines heap [ loadSourceData @content countLines ] preserve lines -- ; + + : display ( $- ) + "" puts + 32 ^strings'splitAtChar "%s" puts + 32 ^strings'splitAtChar 1+ ^strings'chop ^strings'chop "%s%s" puts + "\n" puts ; + + : dumpLines ( - ) + @lines [ @content ^files'readLine display ] times ; +---reveal--- + : /log ( - ) + commonHeader + navbar + LOGS casket:options ^strings'append + heap [ + dup keepString [ prepare ] dip + ^files':R ^files'open !content + "\n" puts + dumpLines + "\n
\n" puts + @content ^files'close drop + ] preserve + commonFooter ; +}} + +: /css + Content-type: text/css + "rancid.css" withTemplate ; + +: /index + commonHeader + "default.erx" withTemplate + commonFooter ; + +( Casket Configuration ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) +[ /index ] is / +[ ( -$ ) "/path/to/rancid/" ] is casket:root +[ ( -$ ) "http://url/to/rancid" ] is casket:url +&dispatch is boot + +.s save bye ADDED user/crc/rancid/templates/default.erx Index: user/crc/rancid/templates/default.erx =================================================================== --- user/crc/rancid/templates/default.erx +++ user/crc/rancid/templates/default.erx @@ -0,0 +1,90 @@ +

The Retro project has logs of conversation in the #retro irc channel on irc.freenode.net going + back to 2006. This is a small web app to allow viewing them in a nicer fashion.

+ +

To get started, select a date from the calendar below. These logs are updated hourly. For direct + linking, use this URL, replacing the yy.mm.dd with the date you wish to link to: +
%u/log/yy.mm.dd

+ + ADDED user/crc/rancid/templates/footer.html Index: user/crc/rancid/templates/footer.html =================================================================== --- user/crc/rancid/templates/footer.html +++ user/crc/rancid/templates/footer.html @@ -0,0 +1,4 @@ +
+

Rancid is © 2011 by Charles Childers

+ + ADDED user/crc/rancid/templates/header.html Index: user/crc/rancid/templates/header.html =================================================================== --- user/crc/rancid/templates/header.html +++ user/crc/rancid/templates/header.html @@ -0,0 +1,81 @@ + + + + + Rancid: An IRC Log Viewer + + + + +

Rancid

ADDED user/crc/rancid/templates/rancid.css Index: user/crc/rancid/templates/rancid.css =================================================================== --- user/crc/rancid/templates/rancid.css +++ user/crc/rancid/templates/rancid.css @@ -0,0 +1,199 @@ +body { + font: 100% sans-serif; + background: #ffffff; + color: black; + margin: 2em; + padding: 0em 2em; } + +p.topic-title { + font-weight: bold; } + +table.docinfo { + text-align: left; + margin: 2em 0em; } + +a[href] { + color: #436976; + background-color: transparent; } + +a.toc-backref { + text-decoration: none; } + +h1 a[href] { + color: #003a6b; + text-decoration: none; + background-color: transparent; } + +a.strong { + font-weight: bold; } + +img { + margin: 0; + border: 0; } + +p { + margin: 0.5em 0 1em 0; + line-height: 1.5em; } + +p a:visited { + color: purple; + background-color: transparent; } + +p a:active { + color: red; + background-color: transparent; } + +a:hover { + text-decoration: none; } + +p img { + border: 0; + margin: 0; } + +p.rubric { + font-weight: bold; + font-style: italic; } + +h1.title { + color: #003a6b; + font-size: 250%; + margin-bottom: 0em; } + +h2.subtitle { + color: #003a6b; + border-bottom: 0px; } + +h1, h2, h3, h4, h5, h6 { + color: #555; + background-color: transparent; + margin: 0em; + padding-top: 0.5em; } + +h1 { + font-size: 160%; + margin-bottom: 0.5em; + border-bottom: 2px solid #aaa; } + +h2 { + font-size: 140%; + margin-bottom: 0.5em; + border-bottom: 1px solid #aaa; } + +h3 { + font-size: 130%; + margin-bottom: 0.5em; } + +h4 { + font-size: 110%; + font-weight: bold; + margin-bottom: 0.5em; } + +h5 { + font-size: 105%; + font-weight: bold; + margin-bottom: 0.5em; } + +h6 { + font-size: 100%; + font-weight: bold; + margin-bottom: 0.5em; } + +dt { + font-style: italic; } + +dd { + margin-bottom: 1.5em; } + +div.admonition, div.note, div.tip, div.caution, div.important { + margin: 2em 2em; + padding: 0em 1em; + border-top: 1px solid #aaa; + border-left: 1px solid #aaa; + border-bottom: 2px solid #555; + border-right: 2px solid #555; } + +div.important { + background: transparent url('../images/important.png') 10px 2px no-repeat; } + +div.caution { + background: transparent url('../images/caution.png') 10px 2px no-repeat; } + +div.note { + background: transparent url('../images/note.png') 10px 2px no-repeat; } + +div.tip { + background: transparent url('../images/tip.png') 10px 2px no-repeat; } + +div.admonition-example { + background: transparent url('../images/tip.png') 10px 2px no-repeat; } + +div.admonition-critical-example { + background: transparent url('../images/important.png') 10px 2px no-repeat; } + +p.admonition-title { + font-weight: bold; + border-bottom: 1px solid #aaa; + padding-left: 30px; } + +table.docutils { + text-align: left; + border: 1px solid gray; + border-collapse: collapse; + width: 100%; + margin: 1.5em 0em; } + +table.docutils caption { + font-style: italic; } + +table.docutils td, table.docutils th { + padding: 0.25em 0.5em; } + +table.docutils th { + background-color: #dddddd; } + +div.sidebar { + width: 33%; + float: right; + margin: 0em 2em; + padding: 0em 1em; + border-top: 1px solid #aaa; + border-left: 1px solid #aaa; + border-bottom: 2px solid #555; + border-right: 2px solid #555; } + +p.sidebar-title { + margin-bottom: 0em; + color: #003a6b; + border-bottom: 1px solid #aaa; + font-weight: bold; } + +p.sidebar-subtitle { + margin-top: 0em; + font-style: italic; + color: #003a6b; } + +pre.literal-block { + margin-left: 1em; + margin-right: 1em; + background: #dddddd; } + +ol.simple, ul.simple { + margin-bottom: 1em } + +ol.arabic { + list-style: decimal } + +ol.loweralpha { + list-style: lower-alpha } + +ol.upperalpha { + list-style: upper-alpha } + +ol.lowerroman { + list-style: lower-roman } + +ol.upperroman { + list-style: upper-roman } + +td.label { + width: 8%; } ADDED user/crc/rancid/templates/script.erx Index: user/crc/rancid/templates/script.erx =================================================================== --- user/crc/rancid/templates/script.erx +++ user/crc/rancid/templates/script.erx @@ -0,0 +1,39 @@ +
+ +