commit 59cdf8ca26ef171f75e61bddc950428325b447af
parent e36cf4e7b55bede9bb755610d1cd590710fabb1a
Author: Jaromil <jaromil@dyne.org>
Date: Wed, 12 Dec 2012 13:39:35 +0100
fixed attachment mechanism
introduced a new Applications.txt config file to match mime/types
tested only on gnu/linux, should use open /Applications on mac/osx...
Diffstat:
5 files changed, 37 insertions(+), 21 deletions(-)
diff --git a/install.sh b/install.sh
@@ -97,6 +97,21 @@ else
error "Existing configuration $WORKDIR/Filters.txt skipped"
fi
+if ! [ -r $WORKDIR/Applications.txt ]; then
+ cat <<EOF > $WORKDIR/Applications.txt
+# Example configuration to match mime/type to applications
+# each line should start with a mime/type and then indicate an executable
+
+# Example:
+# application/rtf oowriter
+
+EOF
+ act "Default helper applications settings created"
+else
+ error "Existing configuration $WORKDIR/Applications.txt skipped"
+fi
+
+
if ! [ -r $WORKDIR/Mutt.txt ]; then
cat <<EOF > $WORKDIR/Mutt.txt
# Mutt specific customizations
diff --git a/src/jaro b/src/jaro
@@ -566,6 +566,7 @@ main()
edit) CLEANEXIT=0; edit_file ${PARAM} ;;
open) CLEANEXIT=0; open_folder ${PARAM} ;;
+ preview) CLEANEXIT=0; preview_file ${PARAM} ;;
backup) backup ${PARAM} ;;
rmdupes) rmdupes ${PARAM} ;;
diff --git a/src/zlibs/addressbook b/src/zlibs/addressbook
@@ -49,6 +49,7 @@ EOF
chmod 600 $WORKDIR/addressbook
return 0
}
+
insert_address() {
_email="$1"; _name="$2";
func "insert address: $_name <$_email>"
@@ -81,6 +82,7 @@ EOF
{ test $? != 0 } && {
func "address not found or error occurred" }
}
+
search_name() {
func "search_name from $list like $1"
cat <<EOF | ${SQL} -column -batch ${addressbook}
@@ -89,6 +91,7 @@ SELECT * FROM $list
WHERE name LIKE "%${1}%";
EOF
}
+
search_email() {
func "search addressbook $list for $1"
cat <<EOF | ${SQL} -column -batch ${addressbook}
@@ -98,7 +101,6 @@ WHERE email LIKE "%${1}%";
EOF
}
-
lookup_email() {
func "lookup email id from $list where $1"
cat <<EOF | ${SQL} -column -batch ${addressbook}
@@ -109,9 +111,7 @@ EOF
complete() {
func "complete from $list: ${PARAM[1]}"
-
act "Searching for \"${PARAM[1]}\" in $list"
-
matches="${matches}\n`search_name ${PARAM[1]}`"
# mutt query requires something like this
@@ -125,20 +125,14 @@ complete() {
}
printf "\n" }'
}
+
isknown() {
func "is known in $list: (string from stdin)"
-
head="`${WORKDIR}/bin/fetchaddr -x From: -a`"
-
-
email="${head[(ws:,:)1]}"
-
exitcode=1
-
lookup="`lookup_email ${email}`"
-
{ test "$lookup" != "" } && { exitcode=0 }
-
act "Email <$email> found in $list with id $lookup"
}
@@ -198,10 +192,8 @@ learn() {
forget() {
func "forget sender from mail in stdin"
-
act "Expecting mail from stdin pipe"
head="`${WORKDIR}/bin/fetchaddr -x From:`"
-
# forget the email part of the parsed head
remove_address "${head[(ws:,:)1]}"
}
@@ -249,7 +241,6 @@ import_macosx() {
unlink $tmp
lock ${addressbook}
-
new=0; dupes=0;
for a in ${(f)addresses}; do
_email=`echo $a | cut -d'|' -f1`
@@ -262,12 +253,12 @@ import_macosx() {
done
unlock ${addressbook}
-
notice "Operation completed"
act "$new new addresses imported"
act "$dupes duplicate addresses skipped"
return 0
}
+
# import addresbook email from VCard
import_vcard() {
act "import VCard from file: ${PARAM[1]}"
diff --git a/src/zlibs/filters b/src/zlibs/filters
@@ -68,7 +68,6 @@ set query_command = "$WORKDIR/bin/jaro -q complete '%s'"
macro index,pager a "<pipe-message>$WORKDIR/bin/jaro -l whitelist -q learn sender<enter>" "add to whitelist everyone in the message"
macro index,pager A "<pipe-message>$WORKDIR/bin/jaro -l whitelist -q learn all<enter>" "add all addresses in whitelist"
macro index,pager z "<pipe-message>$WORKDIR/bin/jaro -l blacklist -q learn sender<enter>" "add sender to blacklist"
-macro index,pager Z "<pipe-message>$WORKDIR/bin/jaro -l blacklist -q forget sender<enter>" "remove sender from blacklist"
# mailboxes in order of priority
source $MUTTDIR/mboxes
@@ -90,16 +89,26 @@ EOF
# MUTT MAILCAP
-wwwtext=w3m
-{ command -v lynx > /dev/null } && { wwwtext=lynx }
-{ command -v elinks > /dev/null } && { wwwtext=elinks }
-cat <<EOF > $MUTTDIR/mailcap
+ wwwtext=w3m
+ { command -v lynx > /dev/null } && { wwwtext=lynx }
+ { command -v elinks > /dev/null } && { wwwtext=elinks }
+ cat <<EOF > $MUTTDIR/mailcap
text/html; ${wwwtext} -dump %s; nametemplate=%s.html; copiousoutput
-application/*; a=${WORKDIR}/tmp && f=\`basename %s\` && rm -f \$a/\$f && cp %s \$a/\$f && jaro preview \$a/\$f
text/plain; iconv -f iso-8859-1 -t utf-8; test=charset=%{charset} \
&& test x`echo \"$charset\" | tr a-z A-Z` = xISO-8859-1; copiousoutput
text/plain; cat %s
EOF
+ apptypes=`cat ${WORKDIR}/Applications.txt`
+ for t in ${(f)apptypes}; do
+ eval `print $t | awk '
+ { print "_type=" $1 "; _app=" $2 ";" }'`
+ cat <<EOF >> $MUTTDIR/mailcap
+${_type}; a=${WORKDIR}/tmp && f=\`basename %s\` && rm -f \$a/\$f && cp %s \$a/\$f && ${_app} \$a/\$f
+EOF
+ done
+ cat <<EOF >> $MUTTDIR/mailcap
+application/*; a=${WORKDIR}/tmp && f=\`basename %s\` && rm -f \$a/\$f && cp %s \$a/\$f && jaro preview \$a/\$f
+EOF
# this one is empty and sources files in temp when necessary
touch $MUTTDIR/password
diff --git a/src/zlibs/helpers b/src/zlibs/helpers
@@ -124,7 +124,7 @@ open_folder() {
##############
## Open a File
-open_file() {
+preview_file() {
case $OS in
GNU)
sensible-browser ${=PARAM} &