New signature feature and self-promotion.
authorSteve Youngs <steve@sxemacs.org>
Sat, 25 Jun 2011 06:23:59 +0000 (16:23 +1000)
committerSteve Youngs <steve@sxemacs.org>
Sat, 25 Jun 2011 06:23:59 +0000 (16:23 +1000)
This patchset brings some shameless self-promotion by adding a byline to
the bottom of a post: "Posted via: SXEmacs/LJ (version string)".  It is in
a fairly small font and out of the way so should be reasonably
inconspicuous, but you can turn it off if you want to with...

  (setq lj-self-promote nil)

There's a new user variable, `lj-signature', the value of which is
inserted at the bottom of the post buffer if it is non-nil.  It is
inserted verbatim, so making it pretty (HTML formatting) is up to the
user.

     * lj.el (lj-byline): New.  Nothing wrong with a bit of
self-advertising, I reckon. ;-)

     * lj.el (lj-self-promote): New.  When non-nil tell the world that
     you use sexy software.

     * lj.el (lj-post): Optionally add the byline.

     * lj.el (lj-preview): Include byline in preview.

     * lj.el (lj-validate): Ditto.

     * lj.el (lj-signature): New.  Lets you include a sig at the bottom
     of a post.

     * lj.el (lj-generate-new-buffer): Insert the signature if it is set.

     * lj.el (lj-version): Bump.

Signed-off-by: Steve Youngs <steve@sxemacs.org>
lj.el

diff --git a/lj.el b/lj.el
index ae6459f..d05e0fa 100644 (file)
--- a/lj.el
+++ b/lj.el
@@ -1,13 +1,13 @@
 ;; lj.el --- LiveJournal meets SXEmacs   -*- Emacs-Lisp -*-
 
-;; Copyright (C) 2008, 2009 Steve Youngs
+;; Copyright (C) 2008 - 2011 Steve Youngs
 
 ;; Author:     Steve Youngs <steve@sxemacs.org>
 ;; Maintainer: Steve Youngs <steve@sxemacs.org>
 ;; Created:    <2008-06-15>
 ;; Based On:   jwz-lj.el by Jamie Zawinski <jwz@jwz.org>
 ;; Keywords:   blog, lj, livejournal
-;; Homepage:   <http://www.sxemacs.org/~steve/lj/lj.el>
+;; Homepage:   <http://www.sxemacs.org/lj.el>
 
 ;; This file is part of SLH (Steve's Lisp Hacks).
 
 ;;    certain.  As for GNU/Emacs... absolutely no idea, but I'd doubt
 ;;    that this is anywhere near compatible.
 ;;
-;;; History:
-;; 
-;;    See the tla logs
-;;
 
 ;;; Version:
-(defconst lj-version 1.25
+(defconst lj-version 1.26
   "Version number of SXEmacs/LJ.")
 
 ;;; Code:
   (interactive)
   (customize-group "lj"))
 
+(defcustom lj-self-promote t
+  "When non-nil, a \"Posted via...\" byline is added to a post.
+
+The text is a single line in small print (8pt) right justified at the
+very end of your post.  It should be quite inconspicuous, but you are
+welcome to turn this off if you are too bashful to let the world know
+what software you use."
+  :type 'boolean
+  :group 'lj)
+
 (defcustom lj-user-id (user-login-name)
   "*Your LJ user ID."
   :type 'string
   :group 'lj)
 
+(defcustom lj-signature nil
+  "A signature to add to the bottom of a post.
+
+This is analogous to an email signature.  Set this any HTML marked up
+text you like, or something that returns such.  Remember to use valid
+XHTML 1.0 Transitional if you plan to validate before posting."
+  :type 'sexp
+  :group 'lj)
+
 (defcustom lj-cookie-flavour 'auto
   "*The default cookie flavour \(browser\) to search for cookies."
   :type '(choice
@@ -1776,6 +1791,8 @@ The filenames are of the format... `ljp-YYYYMMDDHHMM'."
   (set-extent-property
    (insert-face "</head>\n" 'default) 'invisible t)
   (insert lj-header-separator "\n")
+  (when lj-signature
+    (save-excursion (insert "\n\n" lj-signature)))
   (lj-mode))
 
 (defun lj-goto-subject (&optional nocreate)
@@ -2318,6 +2335,18 @@ it is submitted.  Do not expect anything fancy."
                              nil t)
       (replace-match "<h3>Writer's Block Answer</h3>" t))))
 
+(defconst lj-byline
+  (format (concat "<br />"
+                 "<p style=\"text-align:right;font-family:verdana,"
+                 "helvetica,sans-serif;font-size:8pt;\">"
+                 "Posted via: <a href=\"http://www.sxemacs.org/lj.el\""
+                 " title=\"Download SXEmacs/LJ\">"
+                 "SXEmacs/LJ</a> (%s)</p>")
+         lj-clientversion)
+  "A client by-line to add to bottom of a post.
+
+It is also included when validating or previewing a post.")
+
 (defun lj-validate ()
   "Check the markup in a LJ post.
 
@@ -2339,6 +2368,8 @@ Transitional."
         (save-restriction
           (narrow-to-region (point) (point-max))
           (buffer-string))))
+      (and lj-self-promote
+          (insert lj-byline))
       (insert lj-validate-footer)
       (lj-ljtags-to-html)
       (write-region (point-min) (point-max) vf))
@@ -2407,6 +2438,8 @@ it should give you a rough idea."
         (save-restriction
           (narrow-to-region (point) (point-max))
           (buffer-string))))
+      (and lj-self-promote
+          (insert lj-byline))
       (insert "\n</div>")
       (insert lj-validate-footer)
       (lj-ljtags-to-html)
@@ -2586,7 +2619,11 @@ With two prefix args, also set a \"date out of order\" flag."
   (run-hooks 'lj-before-post-hook)
   (let ((subject (lj-header-content "subject"))
        (body (and (lj-goto-body)
-                  (buffer-substring-no-properties (point) (point-max))))
+                  (if lj-self-promote
+                      (concat 
+                       (buffer-substring-no-properties (point) (point-max))
+                       lj-byline)
+                    (buffer-substring-no-properties (point) (point-max)))))
        (user lj-user-id)
        (security (lj-header-content "security"))
        (tags (lj-header-content "tags"))