;; lj.el --- LiveJournal meets SXEmacs -*- Emacs-Lisp -*-
-;; Copyright (C) 2008 - 2011 Steve Youngs
+;; Copyright (C) 2008 - 2014 Steve Youngs
;; Author: Steve Youngs <steve@sxemacs.org>
;; Maintainer: Steve Youngs <steve@sxemacs.org>
;; plus the first letter or two of the next tag you wanna use
;; after the last inserted tag.
;;
-;;; Twitter: (broken, don't use)
-;;
-;; This is currently broken because twitter turned off Basic Auth
-;;
-;; You can optionally post the subject header of your blog entry as
-;; a status update to Twitter, along with a URL to the entry on
-;; livejournal.com. To do so, you must set...
-;;
-;; `lj-twitter-flag'
-;; `lj-twitter-username'
-;; `lj-twitter-password'
-;;
-;; The down side to this is that your twitter username and password
-;; are stored in clear text. I'll work on a way to make that safer
-;; later.
-;;
;; Have fun with it!
;;; Todo:
;; choose different qotd's after one has been selected. Also, be
;; able to view older qotd's.
;;
-;; o Rewrite the twitter code to use OAuth.
;;
;;; Bugs:
;;
;;; Version:
-(defconst lj-version 1.30
+(defconst lj-version 1.31
"Version number of SXEmacs/LJ.")
;;; Code:
:link '(url-link "http://www.livejournal.com/")
:group 'hypermedia)
-(defgroup lj-twitter nil
- "LiveJournal meets Twitter"
- :prefix "lj-twitter-"
- :link '(url-link "http://www.livejournal.com/")
- :link '(url-link "http://twitter.com/")
- :group 'lj)
-
(defun lj-customise-faces ()
"Customise the lj.el faces."
(interactive)
"The default LJ userpic keyword.")
;; See mpd.el in the same repo as lj.el
-(defvar **mpd-var-Title* nil)
-(defvar **mpd-var-Artist* nil)
-(defun lj-music-mpd ()
- "Return the current song title/artist from mpd."
- (let ((song (if **mpd-var-Title*
- (format "%s --- [%s]"
- **mpd-var-Title*
- **mpd-var-Artist*)
- "The Sounds of Silence --- [Marcel Marceau]")))
- song))
-
-(defcustom lj-music (and (featurep 'mpd) #'lj-music-mpd)
+(defcustom lj-music (and (featurep 'mpd) #'mpd-now-playing)
"*A function to retrieve current song for LJ music header.
This function should return a formatted string, or nil."
:type 'function
:type 'hook
:group 'lj)
-(defcustom lj-twitter-flag nil
- "*Non-nil means to update your twitter status.
-
-The subject header and a URL to the last blog entry is posted to
-twitter as a status update if this is set."
- :type 'boolean
- :group 'lj-twitter)
-
-(defcustom lj-twitter-username (user-login-name)
- "*Your twitter username."
- :type 'string
- :group 'lj-twitter)
-
-;;; FIXME: Can we store this in something OTHER than plain text. Do
-;;; we even need it at all with OAuth?
-(defcustom lj-twitter-password "secret"
- "*Your twitter password."
- :type 'string
- :group 'lj-twitter)
-
(defconst lj-clientversion
(concat (when (featurep 'sxemacs) "S")
"XEmacs-"
(btime (apply #'encode-btime (lj-parse-time-string timestr))))
(btime-to-time btime)))
-(defun lj-twitter-compress-url (url)
+(defun lj-compress-url (url)
"Compress URL using tinyurl.com."
(with-temp-buffer
(mm-url-insert
(lj-hexify-string url t)))
(buffer-string)))
-(defun lj-twitter-sentinel (process status)
- "Sentinel for `lj-twitter-update-status' PROCESS STATUS."
- (if (equal status "finished\n")
- (message "Sending to Twitter...done")
- (message "Sending to Twitter...failed: %s"
- (substring status 0 (1- (length status))))))
-
-;;; FIXME: Twitter no longer supports Basic Auth, so must rewrite this
-;;; using OAuth.
-(defun lj-twitter-update-status (user pass status url)
- "Update twitter status.
-
-Argument USER is your twitter username.
-Argument PASS is your twitter password.
-Argument STATUS is the subject header from your LJ post.
-Argument URL is the URL to the post on livejournal.com."
- (let* ((userpass (format "%s:%s" user pass))
- (turl (lj-twitter-compress-url url))
- (twit (concat "status="
- (lj-hexify-string
- (concat status " See: " turl) t)))
- (twiturl "http://twitter.com/statuses/update.json")
- proc)
- (if (<= (length twit) 147) ; twitter's max + "status="
- (progn
- (setq proc
- (apply #'start-process
- "LJcurl" nil "curl"
- (list "-u" userpass
- "-d" twit
- "-s" twiturl
- "-H" "X-Twitter-Client: SXEmacs_LJ"
- "-H" (format "X-Twitter-Client-Version: %s"
- lj-version)
- "-H" (concat
- "X-Twitter-Client-URL: "
- "http://www.sxemacs.org/~steve/lj/lj.xml")
- "-d" "source=lj.el")))
- (set-process-sentinel proc #'lj-twitter-sentinel))
- (warn "LJ subject too long for Twitter"))))
-
(defun lj-check-limits (bodlen sublen taglen muslen loclen)
"Make sure we don't exceed any LJ size limits.
(lj-archive-post (lj-header-content "fcc")))
(and lj-bcc-address
(lj-send-bcc subject security tags comm mood music location body))
-;;; FIXME: twitter updates are broken, needs OAuth
-;; (and lj-twitter-flag
-;; (lj-twitter-update-status lj-twitter-username lj-twitter-password
-;; subject lj-last-url))
;; If there is a itemid don't delete the draft because it is our
;; archive copy
(when (zerop (length itemid))