[Upgrade to latest ljupdate clinton@unknownlamer.org**20071115134034] { hunk ./site-lisp/lj-acct.el 201 - (make-directory dir parents)) + (make-directory directory parents)) hunk ./site-lisp/lj-compose.el 108 - ;; The current time - (time (split-string (format-time-string "%Y:%m:%d:%H:%M") "[:]")) + ;; The current time -- or use the specified time if it exists + (time-field (lj-compose-fetch-field "Time")) + (timestamp (if (eq nil time-field) + () + (date-to-time (concat time-field " " (cadr (current-time-zone)))))) + + (time (split-string (format-time-string "%Y:%m:%d:%H:%M" timestamp) "[:]")) hunk ./site-lisp/lj-compose.el 126 - (request (list '("mode" . "postevent") - '("auth_method" . "challenge") + (request (list '("auth_method" . "challenge") hunk ./site-lisp/lj-compose.el 137 - + (let ((itemid (lj-compose-fetch-field "Itemid"))) + (if itemid + (progn (add-to-list 'request (cons "itemid" itemid)) + (add-to-list 'request '("mode" . "editevent"))) + (add-to-list 'request '("mode" . "postevent")))) hunk ./site-lisp/lj-compose.el 213 - (set-buffer buf) ; return to the *LiveJournal* buffer + (set-buffer buf) ; return to the *LiveJournal* buffer hunk ./site-lisp/lj-compose.el 325 - (kbd "C-c C-f ") ; (kbd "C-c C-f ") + (kbd "C-c C-f ") ; (kbd "C-c C-f ") hunk ./site-lisp/lj-custom.el 42 - :link '(url-link "http://www.livejournal.com/community/ljupdate/")) + :link '(url-link "http://community.livejournal.com/ljupdate/")) hunk ./site-lisp/lj-edit.el 37 -(require 'ljupdate) -(require 'lj-compose) - hunk ./site-lisp/lj-edit.el 41 +(require 'lj-compose) hunk ./site-lisp/lj-edit.el 50 -(defun lj-edit-post (edit-itemid) +(defun lj-edit-post (&optional edit-itemid) hunk ./site-lisp/lj-edit.el 52 - (message (concat "Editing id: " edit-itemid)) + (message (if edit-itemid + (concat "Editing id: " edit-itemid) + "Editing last post.")) hunk ./site-lisp/lj-edit.el 56 - "www.livejournal.com")) - (edit-username (or lj-last-username lj-default-username "")) - (edit-request (list '("mode" . "getevents") - '("auth_method" . "challenge") - '("ver" . "1") - '("selecttype" . "one") - ))) - (add-to-list 'edit-request (cons "itemid" edit-itemid)) - (setq edit-challenge (lj-getchallenge edit-server)) - (if (string= edit-username "") - (setq edit-username (read-from-minibuffer (format "Username @%s: " edit-server)))) + "www.livejournal.com")) + (edit-username (or lj-last-username lj-default-username "")) + (edit-request (list '("mode" . "getevents") + '("auth_method" . "challenge") + '("ver" . "1") + '("selecttype" . "one") + (cons "itemid" (if edit-itemid + edit-itemid + "-1")) + )) + (edit-challenge (lj-getchallenge edit-server))) + (when (string= edit-username "") + (setq edit-username (read-from-minibuffer (format "Username @%s: " edit-server)))) + (add-to-list 'edit-request (cons "user" edit-username)) hunk ./site-lisp/lj-edit.el 72 - (cons "auth_response" - (lj-md5 (concat edit-challenge (lj-password edit-server edit-username))))) - (add-to-list 'edit-request (cons "user" lj-last-username)) + (cons "auth_response" + (lj-md5 (concat edit-challenge (lj-password edit-server edit-username))))) hunk ./site-lisp/lj-edit.el 77 - ;; (lj-list-props response) - (if (not (eq (get-buffer "*LiveJournal*") nil)) - (kill-buffer (get-buffer "*LiveJournal*"))) - (lj-compose) - (goto-char (- 1 (lj-compose-find-separator))) - (lj-add-props edit-response edit-server edit-username) - (goto-char (+ 1 (lj-compose-find-separator))) - (insert (replace-regexp-in-string "\r" "" (lj-html-decode-string (gethash "events_1_event" edit-response)))))))) + ;; (lj-list-props response) + (if (not (eq (get-buffer "*LiveJournal*") nil)) + (kill-buffer (get-buffer "*LiveJournal*"))) + (lj-compose) + (goto-char (- 1 (lj-compose-find-separator))) + (lj-add-props edit-response edit-server edit-username) + (goto-char (+ 1 (lj-compose-find-separator))) + (insert (replace-regexp-in-string "\r" "" (lj-html-decode-string (gethash "events_1_event" edit-response)))) + )))(delete-windows-on "lj-list")) hunk ./site-lisp/lj-edit.el 96 - (progn - (let ((prop_name (gethash (concat "prop_" (number-to-string n) "_name") response)) - (prop_value (gethash (concat "prop_" (number-to-string n) "_value") response))) - (cond ((string= prop_name "current_mood") (lj-add-prop "Mood" prop_value)) - ((string= prop_name "current_music") (lj-add-prop "Music" prop_value)) - ((string= prop_name "taglist") (lj-add-prop "Tags" prop_value)) - ((string= prop_name "picture_keyword") (lj-add-prop "Picture" prop_value)) - ((string= prop_name "picture_keyword") (lj-add-prop "Picture" prop_value)) - ((and (string= prop_name "opt_nocomments") (string= prop_value "1")) - (lj-add-prop "Allow-Comments" "no")) - ((and (string= prop_name "opt_noemail") (string= prop_value "1")) - (lj-add-prop "Receive-Mail-Notification" "no")) - )) - (lj-add-props-helper response (- n 1))))) + (progn + (let ((prop_name (gethash (concat "prop_" (number-to-string n) "_name") response)) + (prop_value (gethash (concat "prop_" (number-to-string n) "_value") response))) + (cond ((string= prop_name "current_mood") (lj-add-prop "Mood" prop_value)) + ((string= prop_name "current_music") (lj-add-prop "Music" prop_value)) + ((string= prop_name "taglist") (lj-add-prop "Tags" prop_value)) + ((string= prop_name "picture_keyword") (lj-add-prop "Picture" prop_value)) + ((string= prop_name "picture_keyword") (lj-add-prop "Picture" prop_value)) + ((and (string= prop_name "opt_nocomments") (string= prop_value "1")) + (lj-add-prop "Allow-Comments" "no")) + ((and (string= prop_name "opt_noemail") (string= prop_value "1")) + (lj-add-prop "Receive-Mail-Notification" "no")) + )) + (lj-add-props-helper response (- n 1))))) hunk ./site-lisp/lj-edit.el 111 -(defun lj-add-props (response edit-server edit-username) +(defun lj-add-props (response edit-server edit-username) hunk ./site-lisp/lj-edit.el 122 - (let* ((access (gethash "events_1_security" response)) - (allowmask (gethash "events_1_allowmask" response))) - (if (stringp access) - (cond ((string-match "public" access) - (lj-add-prop "Access" "public")) - ((string-match "private" access) - (lj-add-prop "Access" "private")) - ((string-match "usemask" access) - (if (eq (truncate (log (string-to-number allowmask) 2)) 0) - (lj-add-prop "Access" "friends") - (lj-add-prop "Access" (car (rassoc (truncate (log (string-to-number allowmask) 2)) (lj-user-get edit-server edit-username :friends-groups))))))))) + (let* ((access (gethash "events_1_security" response)) + (allowmask (gethash "events_1_allowmask" response))) + (if (stringp access) + (cond ((string-match "public" access) + (lj-add-prop "Access" "public")) + ((string-match "private" access) + (lj-add-prop "Access" "private")) + ((string-match "usemask" access) + (if (eq (truncate (log (string-to-number allowmask) 2)) 0) + (lj-add-prop "Access" "friends") + (lj-add-prop "Access" (car (rassoc (truncate (log (string-to-number allowmask) 2)) (lj-user-get edit-server edit-username :friends-groups))))))))) hunk ./site-lisp/lj-edit.el 135 -(defun lj-edit-submit () - "Submit this entry to the server." - (interactive) - (let* ((buf (current-buffer)) - ;; The text of the entry. - (event (lj-compose-prepare-body)) +;; (defun lj-edit-submit () +;; "Submit this entry to the server." +;; (interactive) +;; (let* ((buf (current-buffer)) +;; ;; The text of the entry. +;; (event (lj-compose-prepare-body)) hunk ./site-lisp/lj-edit.el 142 - ;; Some convenience variables for oft-used headers - (server (lj-compose-fetch-field "Server")) - (user (lj-compose-fetch-field "User")) - (itemid (lj-compose-fetch-field "Itemid")) - ;; The current time -- or use the specified time if it exists - (time (lj-compose-fetch-field "Time")) - (timestamp (if (eq nil time) - () - (date-to-time (concat time " " (cadr (current-time-zone)))))) - - (time (split-string (format-time-string "%Y:%m:%d:%H:%M" timestamp) "[:]")) - (year (pop time)) - (month (pop time)) - (day (pop time)) - (hour (pop time)) - (minute (pop time)) +;; ;; Some convenience variables for oft-used headers +;; (server (lj-compose-fetch-field "Server")) +;; (user (lj-compose-fetch-field "User")) +;; (itemid (lj-compose-fetch-field "Itemid")) +;; ;; The current time -- or use the specified time if it exists +;; (time (lj-compose-fetch-field "Time")) +;; (timestamp (if (eq nil time) +;; () +;; (date-to-time (concat time " " (cadr (current-time-zone)))))) hunk ./site-lisp/lj-edit.el 152 - ;; LJ Authentication information - challenge +;; (time (split-string (format-time-string "%Y:%m:%d:%H:%M" timestamp) "[:]")) +;; (year (pop time)) +;; (month (pop time)) +;; (day (pop time)) +;; (hour (pop time)) +;; (minute (pop time)) hunk ./site-lisp/lj-edit.el 159 - ;; The actual request packet, and the response we receive from - ;; the server. - (request (list '("mode" . "editevent") - '("auth_method" . "challenge") - '("ver" . "1") - (cons "itemid" itemid) - (cons "year" year) - (cons "mon" month) - (cons "day" day) - (cons "hour" hour) - (cons "min" minute) - (cons "event" event)))) +;; ;; LJ Authentication information +;; challenge hunk ./site-lisp/lj-edit.el 162 - ;; Build up the request packet. - (add-to-list 'request (cons "user" user)) +;; ;; The actual request packet, and the response we receive from +;; ;; the server. +;; (request (list '("mode" . "editevent") +;; '("auth_method" . "challenge") +;; '("ver" . "1") +;; (cons "itemid" itemid) +;; (cons "year" year) +;; (cons "mon" month) +;; (cons "day" day) +;; (cons "hour" hour) +;; (cons "min" minute) +;; (cons "event" event)))) hunk ./site-lisp/lj-edit.el 175 - (let ((subject (lj-compose-fetch-field "Subject"))) - (when subject - (add-to-list 'request (cons "subject" subject)))) - ;; FIXME: use moodid if available - (let ((mood (lj-compose-fetch-field "Mood"))) - (when mood - (add-to-list 'request (cons "prop_current_mood" mood)))) +;; ;; Build up the request packet. +;; (add-to-list 'request (cons "user" user)) hunk ./site-lisp/lj-edit.el 178 - (let ((tags (lj-compose-fetch-field "Tags"))) - (when tags - (add-to-list 'request (cons "prop_taglist" tags)))) +;; (let ((subject (lj-compose-fetch-field "Subject"))) +;; (when subject +;; (add-to-list 'request (cons "subject" subject)))) +;; ;; FIXME: use moodid if available +;; (let ((mood (lj-compose-fetch-field "Mood"))) +;; (when mood +;; (add-to-list 'request (cons "prop_current_mood" mood)))) hunk ./site-lisp/lj-edit.el 186 - (let ((music (lj-compose-fetch-field "Music"))) - (when music - (add-to-list 'request (cons "prop_current_music" music)))) +;; (let ((tags (lj-compose-fetch-field "Tags"))) +;; (when tags +;; (add-to-list 'request (cons "prop_taglist" tags)))) hunk ./site-lisp/lj-edit.el 190 - (let ((community (lj-compose-fetch-field "Community"))) - (when community - (add-to-list 'request (cons "usejournal" community)))) +;; (let ((music (lj-compose-fetch-field "Music"))) +;; (when music +;; (add-to-list 'request (cons "prop_current_music" music)))) hunk ./site-lisp/lj-edit.el 194 - (let ((picture (lj-compose-fetch-field "Picture"))) - (when picture - (add-to-list 'request (cons "prop_picture_keyword" picture)))) +;; (let ((community (lj-compose-fetch-field "Community"))) +;; (when community +;; (add-to-list 'request (cons "usejournal" community)))) hunk ./site-lisp/lj-edit.el 198 - (let ((comments (lj-compose-fetch-field "Allow-Comments"))) - (when (and comments (string-match "[Nn][Oo]" comments)) - (add-to-list 'request '("prop_opt_nocomments" . "1")))) +;; (let ((picture (lj-compose-fetch-field "Picture"))) +;; (when picture +;; (add-to-list 'request (cons "prop_picture_keyword" picture)))) hunk ./site-lisp/lj-edit.el 202 - (let ((email (lj-compose-fetch-field "Receive-Mail-Notification"))) - (when (and email (string-match "[Nn][Oo]" email)) - (add-to-list 'request '("prop_opt_noemail" . "1")))) +;; (let ((comments (lj-compose-fetch-field "Allow-Comments"))) +;; (when (and comments (string-match "[Nn][Oo]" comments)) +;; (add-to-list 'request '("prop_opt_nocomments" . "1")))) hunk ./site-lisp/lj-edit.el 206 - (let* ((access (lj-compose-fetch-field "Access")) - (friends-group-number - (cdr (assoc access (lj-user-get server user :friends-groups))))) - (if (stringp access) - (cond ((string-match "public" access) - (add-to-list 'request '("security" . "public"))) - ((string-match "private" access) - (add-to-list 'request '("security" . "private"))) - ((string-match "friends" access) - (add-to-list 'request '("allowmask" . "1")) - (add-to-list 'request '("security" . "usemask"))) - (friends-group-number - (add-to-list 'request (cons "allowmask" - (lj-exp2 friends-group-number))) - (add-to-list 'request '("security" . "usemask"))) - (t - (warn "Unable to understand Access: %s; presuming private.") - (add-to-list 'request '("security" . "private")))) - (add-to-list 'request '("security" . "public")))) +;; (let ((email (lj-compose-fetch-field "Receive-Mail-Notification"))) +;; (when (and email (string-match "[Nn][Oo]" email)) +;; (add-to-list 'request '("prop_opt_noemail" . "1")))) hunk ./site-lisp/lj-edit.el 210 - ;; Actually talk to the LJ server. - (message "Connecting to `%s' as `%s'. Please wait." server user) - (setq challenge (lj-getchallenge server)) +;; (let* ((access (lj-compose-fetch-field "Access")) +;; (friends-group-number +;; (cdr (assoc access (lj-user-get server user :friends-groups))))) +;; (if (stringp access) +;; (cond ((string-match "public" access) +;; (add-to-list 'request '("security" . "public"))) +;; ((string-match "private" access) +;; (add-to-list 'request '("security" . "private"))) +;; ((string-match "friends" access) +;; (add-to-list 'request '("allowmask" . "1")) +;; (add-to-list 'request '("security" . "usemask"))) +;; (friends-group-number +;; (add-to-list 'request (cons "allowmask" +;; (lj-exp2 friends-group-number))) +;; (add-to-list 'request '("security" . "usemask"))) +;; (t +;; (warn "Unable to understand Access: %s; presuming private.") +;; (add-to-list 'request '("security" . "private")))) +;; (add-to-list 'request '("security" . "public")))) hunk ./site-lisp/lj-edit.el 230 - (add-to-list 'request (cons "auth_challenge" challenge)) - (add-to-list 'request - (cons "auth_response" - (lj-md5 (concat challenge (lj-password server user))))) +;; ;; Actually talk to the LJ server. +;; (message "Connecting to `%s' as `%s'. Please wait." server user) +;; (setq challenge (lj-getchallenge server)) hunk ./site-lisp/lj-edit.el 234 - (message "Submitting to `%s' as `%s'. Please wait." server user) +;; (add-to-list 'request (cons "auth_challenge" challenge)) +;; (add-to-list 'request +;; (cons "auth_response" +;; (lj-md5 (concat challenge (lj-password server user))))) hunk ./site-lisp/lj-edit.el 239 - (let ((response (lj-protocol-send-request server request))) - (set-buffer buf) ; return to the *LiveJournal* buffer - (if (and (hash-table-p response) - (string= (gethash "success" response) "OK")) - (progn - (set-buffer-modified-p nil) - (message "Successfully posted as %s." (gethash "url" response)) - t) - (let ((errmsg (gethash "errmsg" response))) - (if errmsg - (message "Posting to %s failed: %s" server errmsg) - (message "Posting to %s failed!" server))) - nil)))) +;; (message "Submitting to `%s' as `%s'. Please wait." server user) hunk ./site-lisp/lj-edit.el 241 -(defun lj-html-decode-string (in_string) +;; (let ((response (lj-protocol-send-request server request))) +;; (set-buffer buf) ; return to the *LiveJournal* buffer +;; (if (and (hash-table-p response) +;; (string= (gethash "success" response) "OK")) +;; (progn +;; (set-buffer-modified-p nil) +;; (message "Successfully posted as %s." (gethash "url" response)) +;; t) +;; (let ((errmsg (gethash "errmsg" response))) +;; (if errmsg +;; (message "Posting to %s failed: %s" server errmsg) +;; (message "Posting to %s failed!" server))) +;; nil)))) + +(defun lj-html-decode-string (string) hunk ./site-lisp/lj-edit.el 257 - (let ((in_string (replace-regexp-in-string "%\\([0-9A-F]\\{2\\}\\)" (lambda (my_match) (char-to-string (string-to-number (substring my_match 1) 16))) in_string))) - (replace-regexp-in-string "+" " " in_string))) + (let ((string (replace-regexp-in-string "%\\([0-9A-F]\\{2\\}\\)" (lambda (match) (char-to-string (string-to-number (substring match 1) 16))) string))) + (replace-regexp-in-string "+" " " string))) hunk ./site-lisp/lj-edit.el 263 - (progn - (insert (gethash (concat "prop_" (number-to-string n) "_name") response)) - (insert "\t") - (insert (gethash (concat "prop_" (number-to-string n) "_value") response)) - (insert "\n") - (lj-list-props response (- n 1))))) - + (progn + (insert (gethash (concat "prop_" (number-to-string n) "_name") response)) + (insert "\t") + (insert (gethash (concat "prop_" (number-to-string n) "_value") response)) + (insert "\n") + (lj-list-props response (- n 1))))) + hunk ./site-lisp/lj-edit.el 272 - (event_subject (concat event_string "_subject")) - (event_time (concat event_string "_eventtime")) - (event_itemid_string (concat event_string "_itemid")) - (event_itemid (gethash event_itemid_string hash)) - (button_start -1) - (button_end -1) - (which_event n)) + (event_subject (concat event_string "_subject")) + (event_time (concat event_string "_eventtime")) + (event_itemid_string (concat event_string "_itemid")) + (event_itemid (gethash event_itemid_string hash)) + (button_start -1) + (button_end -1) + (which_event n)) hunk ./site-lisp/lj-edit.el 280 - (progn - (insert-button (concat (gethash event_time hash) " - " - (if (gethash event_subject hash) - (gethash event_subject hash) - "(no subject)")) 'action (lambda (event) (lj-edit-post event_itemid))) - (insert "\n"); - (lj-insert-entry-into-entry-list hash (+ n 1)))))) + (progn + (insert-button (concat (gethash event_time hash) " - " + (if (gethash event_subject hash) + (gethash event_subject hash) + "(no subject)")) 'action (lambda (event) (lj-edit-post event_itemid))) + (insert "\n") + (lj-insert-entry-into-entry-list hash (+ n 1)))))) hunk ./site-lisp/lj-edit.el 290 - "www.livejournal.com")) - (username (or lj-last-username lj-default-username "")) - (request (list '("mode" . "getevents") - '("auth_method" . "challenge") - '("ver" . "1") - '("selecttype" . "lastn") - ))) - (setq challenge (lj-getchallenge server)) - (if (string= username "") - (setq username (read-from-minibuffer (format "Username @%s: " server)))) - (add-to-list 'request (cons "howmany" (number-to-string n))) + "www.livejournal.com")) + (username (or lj-last-username lj-default-username "")) + (request (list '("mode" . "getevents") + '("auth_method" . "challenge") + '("ver" . "1") + '("selecttype" . "lastn") + (cons "howmany" (number-to-string n)))) + (challenge (lj-getchallenge server))) + (when (string= username "") + (setq username (read-from-minibuffer (format "Username @%s: " server)))) + (add-to-list 'request (cons "user" username)) hunk ./site-lisp/lj-edit.el 305 - (add-to-list 'request (cons "user" lj-last-username)) hunk ./site-lisp/lj-edit.el 307 - (set-buffer "lj-list") - (lj-insert-entry-into-entry-list response 1) - (print-help-return-message))))) + (set-buffer "lj-list") + (lj-insert-entry-into-entry-list response 1) + (print-help-return-message))))) hunk ./site-lisp/lj-edit.el 316 +;;;###autoload +(defalias 'lj-edit-last 'lj-edit-post) + +(provide 'lj-edit) + hunk ./site-lisp/lj-edit.el 322 + +;;; lj-edit.el ends here + }