fn conf_enable_mdir { mdir=`{pwd} listbase=$conf_wd listname=`{basename `{ basename -d $listbase}} conf_enable_app mdir dirfilter=$dirfilter' /mbox\/?$/d;' } fn mdir_init { showmonth=`{echo $req_path | sed 's/.*[0-9][0-9][0-9][0-9]\/([A-Z][a-z][^\/]+).*/\1/'} showyear=`{echo $req_path | sed 's/.*\/([0-9][0-9][0-9][0-9])\/.*/\1/'} handler_body_main='mdir_index' if (~ $req_path $listbase[0-9][0-9][0-9][0-9]/[A-Z][a-z]*/[0-9]*) { handler_body_main='message_display' } if not if (~ $req_path $listbase[0-9][0-9][0-9][0-9]/[A-Z][a-z]*) { handler_body_main='month_display' } if not if(~ $req_path $listbase[0-9][0-9][0-9][0-9]*) { handler_body_main='year_display' } } fn message_display { message=`{basename $req_path} echo '

'$listname' - '$showyear' - ' echo ''$showmonth' -' echo 'this message ' approx=`{echo $"message | sed 's/(...).*/\1/' } neighbors=`{ls -p $mdir/mbox/$approx^*} prevmsg=`{echo $neighbors | tr '\012' ' ' | sed -n 's/.* ([^ ]+) '$message'.*/\1/p'} nextmsg=`{echo $neighbors | tr '\012' ' ' | sed -n 's/.*'$message' ([^ ]+).*/\1/p'} echo '

' if (~ $#prevmsg 1 || ~ $#nextmsg 1) { echo '[ ' } if (~ $#prevmsg 1) { echo 'previous' } if (~ $#prevmsg 1 && ~ $#nextmsg 1) { echo ' , ' } if (~ $#nextmsg 1) { echo 'next' } if (~ $#prevmsg 1 || ~ $#nextmsg 1) { echo ' ]' } echo '

' awk ' /^Subject:/ && (headersdone == 0) { subject=$0 } /^From:/ && (headersdone == 0) { from=$0; gsub(//, "\\>", from); } /^Date:/ && (headersdone == 0) { date=$0 } /^$/ && (headersdone==0) { print "

" subject "

"; print from; print date; headersdone=1 }
  (headersdone == 1) { exit }
  ' $mdir/mbox/$message | sed 's/([^ @.]+)\@[^ @]+\.[^@ $][a-zA-Z]+/\1@[REDACTED]/g;' 

	cat $mdir/mbox/$message | {
		boundary=undef;
		while (line=`{read}) {
			if (~ $line Content-Type*multipart*) { # flag mimeshit boundary
										multipart=1
				boundary=`{echo $line | sed 's/^.*boundary=//; s/[  ].*$//'}
										if (test -z $boundary) { boundary=undef; } # fucking header wrap
			}
						if (~ $multipart 1) {
										if (~ $boundary undef) { # desperately try to identify a boundary
					boundary=`{echo $line | sed 's/^.*boundary=//; s/[        ].*$//'}
			 }
			}

			if (~ $"line '') { # note end of header section
				endheaders = 1;
			}

			if (~ $boundary undef ) { # no boundary, headers over:  print message
				if (~ $endheaders 1) {
					echo $line
				}
			}
			if not { # boundaries: print only text/plain
				if (~ $line --$boundary) { # boundary found, toggle state
					if (~ $inboundary 1) { 
						inboundary=0
					}
					if not {
						inboundary=1
					}
				}
				if (~ $inboundary 1) { # we're in a text/plain part, print it
					if (~ $textpart 1) {
						echo $line
					}
				}
				if (~ $line Content-Type*text*plain*) { # note advent of text/plain part
					if (~ $inboundary 1) {
						echo found text part
						textpart=1
					}
				}
			}
		}
	}

  echo '
' } fn mdir_index { echo '

' $listname '

' echo '' } fn year_display { echo '

'$listname' - '$showyear'

' echo '' } fn month_display { echo '

'$listname' - '$showyear' - '$showmonth'

' echo '' }