#!/usr/bin/env zsh # # WebNomad, your slick and static website publisher # (this 'maildir' code is taken from jaromail) # # Copyright (C) 2010-2017 Denis Roio # # This source code is free software; you can redistribute it and/or # modify it under the terms of the GNU Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This source code is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # Please refer to the GNU Public License for more details. # # You should have received a copy of the GNU Public License along with # this source code; if not, write to: # Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # checks if its a maildir # returns 0 (success) if yes # no in all other cases maildircheck() { fn maildircheck $* [[ -r "$1" ]] || { func "Maildir not existing: $1" return 1 } [[ -r "$1/cur" ]] && { return 0 } # Yes is a maildir # shortened test to speedup # && { test -r $1/new } \ # && { test -r $1/tmp } \ error "Not a maildir: $1" return 1 } # short utility to print only mail headers hdr() { [[ -r "$1" ]] || { error "hdr() called on non existing file: $1" return 1 } awk '{ print $0 } /^$/ { exit }' "$1" } # creates the database keeping up-to-date information # on which emails inside the maildir are already published maildb_create() { fn pubdb_create $* [[ -r "$1" ]] && { warning "Maildir database already exists: $1" return 1 } cat <${mail_subj}

From: ${mail_from} - ${mail_date}

EOF # check if it has already html _html=`mu extract "$_path" | awk '/text\/html/ {print $1; exit}'` [[ "$_html" = "" ]] || { mu extract --overwrite --parts="$_html" "$_path" # check if there is an html header to weed out grep '' "$_html".part > /dev/null if [ $? = 0 ]; then awk ' BEGIN { body=0 } / "views/${mdname}.html" EOF for m in ${(f)"$(maildb_list $_db mail_date)"}; do mail_fill "$m" cat <> "views/${mdname}.html" EOF done } mail_atom_render() { fn mail_atom_render $* _db="${mdsrc}.db" req=(mdsrc mdname) freq=($mdsrc $_db) ckreq || return 1 cat < "views/${mdname}.atom.xml" ${TITLE} ${WEB_ROOT}/${mdname}.atom.xml `date --rfc-3339=seconds | sed 's/ /T/'` WebNomad ${DESCRIPTION} http://dyne.org/dyne.png EOF # write out the atom entry for m in ${(f)"$(maildb_list $_db)"}; do mail_fill "$m" eurl="${WEB_ROOT}/${mdname}.msg/${mail_id}.html" cat <> "views/${mdname}.atom.xml" ${mail_subj} ${eurl} ${mail_insert_date} ${mail_subj} ${mail_from} ${eurl} ${mail_subj} From: ${mail_from} ${mail_insert_date} ${eurl} EOF done cat <> "views/${mdname}.atom.xml" EOF }
`date -d"${mail_date}" +"%e %B %Y"` ${mail_from} ${mail_subj}