From 8d0e5132794596c0945f74d56ad815a104c26c4b Mon Sep 17 00:00:00 2001 From: Tadashi MATSUO Date: Sat, 21 Aug 2010 01:38:23 +0900 Subject: [PATCH] Switch ways to parse XML depending on `twittering-service-method'. * twittering-mode.el: Switch ways to parse XML depending on `twittering-service-method'. (twittering-atom-xmltree-to-status-datum): switch ways to parse XML depending on `twittering-service-method'. --- ChangeLog | 5 +++++ twittering-mode.el | 33 ++++++++++++++++++++++----------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 732af2b3..20e2107b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,11 @@ (twittering-generate-format-table): likewise. (twittering-generate-formater-for-first-spec): likewise. + * twittering-mode.el: Switch ways to parse XML depending on + `twittering-service-method'. + (twittering-atom-xmltree-to-status-datum): switch ways to parse + XML depending on `twittering-service-method'. + 2010-08-20 Takashi Masuda * twittering-mode.el: Support StatusNet. diff --git a/twittering-mode.el b/twittering-mode.el index 8ff6b491..d8b40c0b 100644 --- a/twittering-mode.el +++ b/twittering-mode.el @@ -4696,14 +4696,18 @@ BUFFER may be a buffer or the name of an existing buffer." caption)))) (text . ,(twittering-decode-html-entities (car (cddr (assq 'title atom-xml-entry))))) - ,@(progn - (if (string-match "^\\([^ ]+\\) (\\(.*\\))$" author-str) - ;; Twitter - `((user-screen-name . ,(match-string 1 author-str)) - (user-name . ,(match-string 2 author-str))) - ;; StatusNet - `((user-screen-name . ,author-str) - (user-name . "")))) + ,@(cond + ((eq twittering-service-method 'statusnet) + ;; StatusNet + `((user-screen-name . ,author-str) + (user-name . ""))) + ((string-match "^\\([^ ]+\\) (\\(.*\\))$" author-str) + ;; Twitter (default) + `((user-screen-name . ,(match-string 1 author-str)) + (user-name . ,(match-string 2 author-str)))) + (t + '((user-screen-name . "PARSING FAILED!!") + (user-name . "")))) (user-profile-image-url . ,(let* ((link-items (mapcar @@ -4714,9 +4718,16 @@ BUFFER may be a buffer or the name of an existing buffer." (image-urls (mapcar (lambda (item) - (when (or (member '(rel . "image") item) ;; Twitter - (member '(rel . "related") item)) ;; StatusNet - (cdr (assq 'href item)))) + (cond + ((and (eq twittering-service-method 'statusnet) + (member '(rel . "related") item)) + ;; StatusNet + (cdr (assq 'href item))) + ((member '(rel . "image") item) + ;; Twitter (default) + (cdr (assq 'href item))) + (t + nil))) link-items))) (car-safe (remq nil image-urls)))))))