From 9229d4dd08c59ee9ade1a77698bff487f63e5906 Mon Sep 17 00:00:00 2001 From: cage Date: Wed, 24 Jun 2020 19:42:05 +0200 Subject: [PATCH] - added support for signature. --- etc/shared.conf | 4 +++- src/message-rendering-utils.lisp | 4 ++++ src/package.lisp | 4 +++- src/software-configuration.lisp | 14 ++++++++++++++ src/ui-goodies.lisp | 32 ++++++++++++++++++++------------ 5 files changed, 44 insertions(+), 14 deletions(-) diff --git a/etc/shared.conf b/etc/shared.conf index 98144a8..5c7d31c 100644 --- a/etc/shared.conf +++ b/etc/shared.conf @@ -77,11 +77,13 @@ color-regexp = "_[^_]+_" #ffff00 underline color-regexp = "/[^/]+/" #ffff00 italic -color-regexp = "⯀" green bold +color-regexp = "⯀" green bold color-regexp = "The poll has expired" #ff00ff bold +# the signature file path relative to $HOME +# signature-file = ".signature" # you can filter off users using regexp diff --git a/src/message-rendering-utils.lisp b/src/message-rendering-utils.lisp index 8804cfb..1634232 100644 --- a/src/message-rendering-utils.lisp +++ b/src/message-rendering-utils.lisp @@ -274,3 +274,7 @@ (format stream "~%~a~%" (_ "A single choice allowed"))) (when expiredp (format stream "~%~a~%" (_ "The poll has expired")))))))) + +(defun signature () + (when-let ((signature-file (swconf:signature-file-path))) + (format nil "-- ~%~a" (fs:slurp-file signature-file)))) diff --git a/src/package.lisp b/src/package.lisp index 5019849..2617f10 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -949,6 +949,7 @@ :parse :load-config-file :external-editor + :signature-file-path :vote-vertical-bar :crypted-mark-value :quick-help-header-colors @@ -1612,7 +1613,8 @@ :status-attachments->text :message-original->text-body :message-original->text-header - :poll->text)) + :poll->text + :signature)) (defpackage :thread-window (:use diff --git a/src/software-configuration.lisp b/src/software-configuration.lisp index 2d6412b..65b56d1 100644 --- a/src/software-configuration.lisp +++ b/src/software-configuration.lisp @@ -351,6 +351,7 @@ locked unlocked account + signature-file main-window thread-window message-window @@ -430,8 +431,21 @@ (defparameter *allowed-attachment-type* '("unknown" "image" "gifv" "video" "audio")) +(define-constant +default-signature-filename+ ".signature" :test #'string=) + ;;;; interface +(defun signature-file-path () + "Returns the filepath of the signature file, the $HOME is prepended." + (let* ((signature-file (or (access:accesses *software-configuration* + +key-signature-file+) + +default-signature-filename+)) + (signature-path (fs:cat-parent-dir (fs:home-dir) + signature-file))) + (if (fs:file-exists-p signature-path) + signature-path + nil))) + (defun vote-vertical-bar () (or (access:accesses *software-configuration* +key-vote-vertical-bar+) diff --git a/src/ui-goodies.lisp b/src/ui-goodies.lisp index b966373..d308223 100644 --- a/src/ui-goodies.lisp +++ b/src/ui-goodies.lisp @@ -835,18 +835,26 @@ Force the checking for new message in the thread the selected message belong." (loop for line in quoted-lines do (format stream "~a~%" line)))))) (add-body () - (let ((temp-file (fs:temporary-file)) - (reference-open-file (get-universal-time))) - (prepare-reply-body temp-file) - (croatoan:end-screen) - (os-utils:open-with-editor temp-file) - (when (and (> (fs:file-size temp-file) - 0) - (> (fs:get-stat-mtime temp-file) - reference-open-file)) - (let ((body (fs:slurp-file temp-file))) - (setf (sending-message:body *message-to-send*) body) - (add-subject)))))) + (let ((temp-file (fs:temporary-file)) + (signature (message-rendering-utils:signature))) + (when signature + (with-open-file (stream + temp-file + :direction :output + :element-type 'character + :if-exists :supersede) + (write-sequence signature stream))) + (let ((reference-open-file (get-universal-time))) + (prepare-reply-body temp-file) + (croatoan:end-screen) + (os-utils:open-with-editor temp-file) + (when (and (> (fs:file-size temp-file) + 0) + (> (fs:get-stat-mtime temp-file) + reference-open-file)) + (let ((body (fs:slurp-file temp-file))) + (setf (sending-message:body *message-to-send*) body) + (add-subject))))))) (add-body))) (defun reply-message ()