Gnus development mailing list
 help / color / mirror / Atom feed
* nnrss.el and <enclosure /> element
@ 2005-04-21 15:36 David Hansen
  2005-04-22  0:15 ` David Hansen
  0 siblings, 1 reply; 6+ messages in thread
From: David Hansen @ 2005-04-21 15:36 UTC (permalink / raw)


Hello,

seems like nnrss.el ignores the enclosure element.  See

http://www.thetwowayweb.com/payloadsforrss#aNewElement

Would be nice if it's rendered as a download link at the end of
the message.

David




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: nnrss.el and <enclosure /> element
  2005-04-21 15:36 nnrss.el and <enclosure /> element David Hansen
@ 2005-04-22  0:15 ` David Hansen
  2005-04-22  2:08   ` Katsumi Yamaoka
  0 siblings, 1 reply; 6+ messages in thread
From: David Hansen @ 2005-04-22  0:15 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 270 bytes --]

On Thu, 21 Apr 2005 17:36:05 +0200 David Hansen wrote:

> seems like nnrss.el ignores the enclosure element.

OK, did it myself, in case someone is interested the attached
patch is against current CVS HEAD.

But be aware it's the first time i touched gnus code.

David


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: nnrss.diff --]
[-- Type: text/x-patch, Size: 3880 bytes --]

--- cvs-src/gnus/lisp/nnrss.el	2005-04-21 23:37:13.000000000 +0200
+++ share/emacs/site-lisp/nnrss.el	2005-04-22 02:09:15.934656168 +0200
@@ -195,6 +195,7 @@
 				   (delete "" (split-string (nth 6 e) "\n+"))
 				   " ")))
 	      (link (nth 2 e))
+              (enclosure (nth 7 e))
 	      ;; Enable encoding of Newsgroups header in XEmacs.
 	      (default-enable-multibyte-characters t)
 	      (rfc2047-header-encoding-alist
@@ -203,18 +204,21 @@
 			 rfc2047-header-encoding-alist)
 		 rfc2047-header-encoding-alist))
 	      rfc2047-encode-encoded-words body)
-	  (when (or text link)
+	  (when (or text link enclosure)
 	    (insert "\n")
 	    (insert "<#multipart type=alternative>\n"
 		    "<#part type=\"text/plain\">\n")
 	    (setq body (point))
-	    (if text
-		(progn
-		  (insert text "\n")
-		  (when link
-		    (insert "\n" link "\n")))
-	      (when link
-		(insert link "\n")))
+	    (when text
+              (insert text "\n")
+              (when (or link enclosure)
+                (insert "\n")))
+            (when link
+              (insert link "\n"))
+            (when enclosure
+              (insert (car enclosure) " "
+                      (nth 2 enclosure) " "
+                      (nth 3 enclosure) "\n"))
 	    (setq body (buffer-substring body (point)))
 	    (insert "<#/part>\n"
 		    "<#part type=\"text/html\">\n"
@@ -223,6 +227,10 @@
 	      (insert text "\n"))
 	    (when link
 	      (insert "<p><a href=\"" link "\">link</a></p>\n"))
+            (when enclosure
+              (insert "<p><a href=\"" (car enclosure) "\">"
+                      (cadr enclosure) "</a> " (nth 2 enclosure)
+                      " " (nth 3 enclosure) "</p>\n"))
 	    (insert "</body></html>\n"
 		    "<#/part>\n"
 		    "<#/multipart>\n"))
@@ -519,8 +527,8 @@
 ;;; Snarf functions
 
 (defun nnrss-check-group (group server)
-  (let (file xml subject url extra changed author
-	     date rss-ns rdf-ns content-ns dc-ns)
+  (let (file xml subject url extra changed author date
+             enclosure rss-ns rdf-ns content-ns dc-ns)
     (if (and nnrss-use-local
 	     (file-exists-p (setq file (expand-file-name
 					(nnrss-translate-file-chars
@@ -568,6 +576,27 @@
 	(setq date (or (nnrss-node-text dc-ns 'date item)
 		       (nnrss-node-text rss-ns 'pubDate item)
 		       (message-make-date)))
+        (when (setq enclosure (cadr (assq (intern (concat rss-ns "enclosure")) item)))
+          (let ((url (cdr (assq 'url enclosure)))
+                (len (cdr (assq 'length enclosure)))
+                (type (cdr (assq 'type enclosure)))
+                (name))
+            (setq len
+                  (if (and len (integerp (setq len (string-to-number len))))
+                      ;; actually already in `ls-lisp-format-file-size' but
+                      ;; probably not worth to require it for one function
+                      (do ((size (/ len 1.0) (/ size 1024.0))
+                           (post-fixes (list "" "k" "M" "G" "T" "P" "E")
+                                       (cdr post-fixes)))
+                          ((< size 1024)
+                           (format "%.1f%s" size (car post-fixes))))
+                    "0"))
+            (setq url (or url ""))
+            (setq name (if (string-match "/\\([^/]*\\)$" url)
+                            (match-string 1 url)
+                          "file"))
+            (setq type (or type ""))
+            (setq enclosure (list url name len type))))
 	(push
 	 (list
 	  (incf nnrss-group-max)
@@ -576,7 +605,8 @@
 	  (and subject (nnrss-mime-encode-string subject))
 	  (and author (nnrss-mime-encode-string author))
 	  date
-	  (and extra (nnrss-decode-entities-string extra)))
+	  (and extra (nnrss-decode-entities-string extra))
+          enclosure)
 	 nnrss-group-data)
 	(puthash (or url extra) t nnrss-group-hashtb)
 	(setq changed t))

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: nnrss.el and <enclosure /> element
  2005-04-22  0:15 ` David Hansen
@ 2005-04-22  2:08   ` Katsumi Yamaoka
  2005-04-22  9:55     ` David Hansen
  0 siblings, 1 reply; 6+ messages in thread
From: Katsumi Yamaoka @ 2005-04-22  2:08 UTC (permalink / raw)


>>>>> In <87oec7k6og.fsf@robotron.ath.cx> David Hansen wrote:

>> seems like nnrss.el ignores the enclosure element.

> OK, did it myself, in case someone is interested the attached
> patch is against current CVS HEAD.

> But be aware it's the first time i touched gnus code.

> David

> --- cvs-src/gnus/lisp/nnrss.el	2005-04-21 23:37:13.000000000 +0200
> +++ share/emacs/site-lisp/nnrss.el	2005-04-22 02:09:15.934656168 +0200

That's great and seems to be useful to all users.  It doesn't
look a tiny change, so you need to have assigned the copyright
to FSF for Emacs (or Gnus).  If not, you will have to send a
mail to:

(concat [99 111 112 121 114 105 103 104 116 45 99 108 101 114 107 64 102 115 102 46 111 114 103])

And I'll appreciate you writing the ChangeLog entry.

Regards,



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: nnrss.el and <enclosure /> element
  2005-04-22  2:08   ` Katsumi Yamaoka
@ 2005-04-22  9:55     ` David Hansen
  2005-04-22 10:30       ` Katsumi Yamaoka
  0 siblings, 1 reply; 6+ messages in thread
From: David Hansen @ 2005-04-22  9:55 UTC (permalink / raw)


On Fri, 22 Apr 2005 11:08:01 +0900 Katsumi Yamaoka wrote:

>>>>>> In <87oec7k6og.fsf@robotron.ath.cx> David Hansen wrote:
>
>> --- cvs-src/gnus/lisp/nnrss.el	2005-04-21 23:37:13.000000000 +0200
>> +++ share/emacs/site-lisp/nnrss.el	2005-04-22 02:09:15.934656168 +0200
>
> That's great and seems to be useful to all users.  It doesn't
> look a tiny change, so you need to have assigned the copyright
> to FSF for Emacs (or Gnus).  If not, you will have to send a
> mail to:

Wrote them, no clue how long this will take though...

> And I'll appreciate you writing the ChangeLog entry.

2005-04-22  David Hansen  <david.hansen@physik.fu-berlin.de>

	* lisp/nnrss.el (nnrss-check-group, nnrss-request-article):
          Support the enclosure element of <item>

David




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: nnrss.el and <enclosure /> element
  2005-04-22  9:55     ` David Hansen
@ 2005-04-22 10:30       ` Katsumi Yamaoka
  2005-04-26 16:31         ` David Hansen
  0 siblings, 1 reply; 6+ messages in thread
From: Katsumi Yamaoka @ 2005-04-22 10:30 UTC (permalink / raw)


>>>>> In <87k6mvp23q.fsf@robotron.ath.cx> David Hansen wrote:

>> so you need to have assigned the copyright to FSF for Emacs
>> (or Gnus).

> Wrote them, no clue how long this will take though...

It might not be a problem if you intend to sign the paper.

> 2005-04-22  David Hansen  <david.hansen@physik.fu-berlin.de>

> 	* lisp/nnrss.el (nnrss-check-group, nnrss-request-article):
>           Support the enclosure element of <item>

I've installed your patch in the Gnus trunk.  Thanks.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: nnrss.el and <enclosure /> element
  2005-04-22 10:30       ` Katsumi Yamaoka
@ 2005-04-26 16:31         ` David Hansen
  0 siblings, 0 replies; 6+ messages in thread
From: David Hansen @ 2005-04-26 16:31 UTC (permalink / raw)


On Fri, 22 Apr 2005 19:30:24 +0900 Katsumi Yamaoka wrote:

>>>>>> In <87k6mvp23q.fsf@robotron.ath.cx> David Hansen wrote:
>
>>> so you need to have assigned the copyright to FSF for Emacs
>>> (or Gnus).
>
>> Wrote them, no clue how long this will take though...
>
> It might not be a problem if you intend to sign the paper.

Just mailed back the signed papers.

David




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-04-26 16:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-21 15:36 nnrss.el and <enclosure /> element David Hansen
2005-04-22  0:15 ` David Hansen
2005-04-22  2:08   ` Katsumi Yamaoka
2005-04-22  9:55     ` David Hansen
2005-04-22 10:30       ` Katsumi Yamaoka
2005-04-26 16:31         ` David Hansen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).