[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Patches for sb-atom and sb-atom-hash



I made two small changes to sb-atom and sb-atom-hash:

* Deal with atom feeds which do not have an "alternate" link
  element. While this is not according to the atom standard, there are
  feeds who do not have it (e.g. planet.emacsen.org). The patch simply
  takes the first link in this case.

* While the atom-hash shimbun is for feeds with published content, I
  think it should also be able to deal with feeds who just publish a
  summary (just like rss-hash can also deal with feeds who only have a
  description).

The patch for sb-atom and sb-atom-hash is attached to this mail.

Regards,
David
Index: sb-atom.el
===================================================================
RCS file: /storage/cvsroot/emacs-w3m/shimbun/sb-atom.el,v
retrieving revision 1.4
diff -u -r1.4 sb-atom.el
--- sb-atom.el	17 Oct 2007 11:15:58 -0000	1.4
+++ sb-atom.el	10 Dec 2008 22:35:32 -0000
@@ -81,6 +81,11 @@
 				  "alternate")
 		     (throw 'url (shimbun-atom-attribute-value
 				  (intern (concat atom-ns "href")) link)))))))
+	  (unless url
+	    (setq url (shimbun-atom-attribute-value
+		       (intern (concat atom-ns "href"))
+		       (car (shimbun-rss-find-el
+			     (intern (concat atom-ns "link")) entry)))))
 	  (when url
 	    (let* ((date (or (shimbun-rss-get-date shimbun url)
 			     (shimbun-rss-node-text atom-ns 'modified entry)
Index: sb-atom-hash.el
===================================================================
RCS file: /storage/cvsroot/emacs-w3m/shimbun/sb-atom-hash.el,v
retrieving revision 1.4
diff -u -r1.4 sb-atom-hash.el
--- sb-atom-hash.el	17 Oct 2007 11:15:58 -0000	1.4
+++ sb-atom-hash.el	10 Dec 2008 22:35:32 -0000
@@ -93,6 +93,11 @@
 				    "alternate")
 		       (throw 'url (shimbun-atom-attribute-value
 				    (intern (concat atom-ns "href")) link)))))))
+	    (unless url
+	      (setq url (shimbun-atom-attribute-value
+			 (intern (concat atom-ns "href"))
+			 (car (shimbun-rss-find-el
+			       (intern (concat atom-ns "link")) entry)))))
 	    (when url
 	      (let* ((date (or (shimbun-rss-get-date shimbun url)
 			       (shimbun-rss-node-text atom-ns 'modified entry)
@@ -102,10 +107,16 @@
 		     (id (shimbun-atom-build-message-id shimbun url date))
 		     content)
 		;; save contents
-		(let (type mode)
-		  (dolist (content-node (shimbun-rss-find-el
-					 (intern (concat atom-ns "content"))
-					 entry))
+		(let ((contentsym 'content)
+		      type mode)
+		  (dolist (content-node (or (shimbun-rss-find-el
+					     (intern (concat atom-ns "content"))
+					     entry)
+					    (progn
+					      (setq contentsym 'summary)
+					      (shimbun-rss-find-el
+					       (intern (concat atom-ns "summary"))
+					       entry))))
 		    (setq type (or (shimbun-atom-attribute-value
 				    (intern (concat atom-ns "type"))
 				    content-node)
@@ -118,17 +129,17 @@
 		     ((string-match "xhtml" type)
 		      ;; xhtml (type text/xhtml,application/xhtml+xml)
 		      (setq content (shimbun-atom-rebuild-node
-				     atom-ns 'content entry)))
+				     atom-ns contentsym entry)))
 		     (t
 		      ;; text or html(without xhtml)
 		      (if (string= "escaped" mode)
 			  ;; escaped CDATA
 			  (setq content (shimbun-rss-node-text
-					 atom-ns 'content entry))
+					 atom-ns contentsym entry))
 			;; non-escaped, but  "<>& to &xxx;
 			(setq content (shimbun-decode-entities-string
 				       (shimbun-rss-node-text
-					atom-ns 'content entry))))))))
+					    atom-ns contentsym entry))))))))
 		(when (and id content)
 		  (shimbun-hash-set-item shimbun id content))))))))))