Skip to content

Commit

Permalink
Switch ways to parse XML depending on `twittering-service-method'.
Browse files Browse the repository at this point in the history
* 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'.
  • Loading branch information
cvmat committed Aug 20, 2010
1 parent 50200d6 commit 8d0e513
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Expand Up @@ -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 <masutaka@nifty.com>

* twittering-mode.el: Support StatusNet.
Expand Down
33 changes: 22 additions & 11 deletions twittering-mode.el
Expand Up @@ -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
Expand All @@ -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)))))))

Expand Down

0 comments on commit 8d0e513

Please sign in to comment.