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

Patches for sb-slashdot and sb-perlentaucher-de



Attached are patches for the Slashdot and Perlentaucher-de shimbuns;
please see the ChangeLog for details. There's also a patch for the
documentation, explaining the new variables of the Slashdot shimbun.

Regards,
David
diff --git a/ChangeLog b/ChangeLog
index d694337..3df272b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2008-09-20  David Engster  <dengste@xxxxxx>
+
+	* sb-perlentaucher-de.el (shimbun-perlentaucher-de-url-regexp): Adapt
+	to new URL scheme in RSS feed.
+
+	* sb-slashdot.el: Require sb-multi and use it.
+	(shimbun-slashdot-content-end, shimbun-slashdot-content-start): Remove.
+	(shimbun-slashdot-get-comments, shimbun-slashdot-comment-threshold)
+	(shimbun-slashdot-comment-display): New variables.
+	(shimbun-slashdot-regexp-author-time): Relax regexp.
+	(shimbun-slashdot-regexp-comment-system): New variable.
+	(shimbun-slashdot-get-headers): Replace HTML tags in subject.
+	(shimbun-multi-next-url, shimbun-clear-contents): New overriden
+	methods.
+
 2008-09-15  ARISAWA Akihiro  <ari@xxxxxxxxxxxxxxxx>
 
 	* sb-yahoo-auctions.el (shimbun-yahoo-auctions-content-start)
diff --git a/sb-perlentaucher-de.el b/sb-perlentaucher-de.el
index 385a969..feedfd4 100644
--- a/sb-perlentaucher-de.el
+++ b/sb-perlentaucher-de.el
@@ -32,7 +32,7 @@
 (defvar shimbun-perlentaucher-de-from-address "invalid@xxxxxxxxxxxxxxxx")
 (defvar shimbun-perlentaucher-de-content-start "<div class=\"col_middle\">")
 (defvar shimbun-perlentaucher-de-content-end "<div class=\"col_right\">")
-(defvar shimbun-perlentaucher-de-url-regexp "rss.feedsportal.com/.*/\\([0-9a-f]+\\)/story.*\\.htm")
+(defvar shimbun-perlentaucher-de-url-regexp "rss.feedsportal.com/.*/\\([^/]+\\)/story.*\\.htm")
 
 (defvar shimbun-perlentaucher-de-x-face-alist
   '(("default" . "\
diff --git a/sb-slashdot.el b/sb-slashdot.el
index 8674e7f..0574e5d 100644
--- a/sb-slashdot.el
+++ b/sb-slashdot.el
@@ -23,8 +23,9 @@
 ;;; Code:
 
 (require 'shimbun)
+(require 'sb-multi)
 
-(luna-define-class shimbun-slashdot (shimbun) ())
+(luna-define-class shimbun-slashdot (shimbun-multi shimbun) ())
 
 (defvar shimbun-slashdot-group-url
   '(("frontpage" "http://www.slashdot.org")
@@ -44,20 +45,25 @@
 
 (defvar shimbun-slashdot-url "http://www.slashdot.org")
 
-(defvar shimbun-slashdot-content-start
-  "<div class=\"intro\".*?>")
+(defvar shimbun-slashdot-get-comments t
+  "Flag if comments should be retrieved.")
 
-;; This also strips the comments - change this accordingly if you want
-;; to see them.
-(defvar shimbun-slashdot-content-end
-  "<div class=\"commentBox\".*?>")
+(defvar shimbun-slashdot-comment-threshold 3
+  "Threshold for displayed comments.")
+
+(defvar shimbun-slashdot-comment-display "flat"
+  "Display type of comments.
+Can be 'flat', 'thread', or 'nested'.")
 
 (defvar shimbun-slashdot-regexp-section-id-subject
   "<div class=\"\\(generaltitle\\|briefarticles\\)\"[^\0]*?\
 <a href=\".*slashdot.org/\\(.*?\\)/\\(.*?\\).shtml\">\\(.*?\\)</a>")
 
 (defvar shimbun-slashdot-regexp-author-time
-  "Posted by[^a-zA-Z]*\\(.*\\)[^\0]*?@\\([0-9]+\\):\\([0-9]+\\)\\(AM\\|PM\\)")
+  "Posted[\t \n]+by[^a-zA-Z]*\\(.*\\)[^\0]*?@\\([0-9]+\\):\\([0-9]+\\)\\(AM\\|PM\\)")
+
+(defvar shimbun-slashdot-regexp-comment-system
+  "use <a href=\"\\(.+\\)\">the classic discussion system")
 
 (defvar shimbun-slashdot-groups
   (mapcar 'car shimbun-slashdot-group-url))
@@ -93,6 +99,8 @@ Face: iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAgID////5Zpl0AAA
 			   (upcase section)
 			 (capitalize section))
 		       ": " (match-string 4)))
+	(while (string-match "</?[a-zA-Z]+?>" subject)
+	  (setq subject (replace-match "\"" t t subject)))
 	(if (string= (match-string 1) "briefarticles")
 	    (progn
 	      (setq hour "00")
@@ -136,6 +144,41 @@ Face: iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAgID////5Zpl0AAA
 	      headers)))
     headers))
 
+(luna-define-method shimbun-multi-next-url ((shimbun shimbun-slashdot)
+                                            header url)
+  (if (and shimbun-slashdot-get-comments
+	   (progn
+	     (goto-char (point-min))
+	     (re-search-forward shimbun-slashdot-regexp-comment-system nil t)))
+      (let ((url (concat "http:" (match-string 1))))
+	(when (string-match "threshold=\\([0-9]\\)" url)
+	  (setq url
+		(replace-match
+		 (number-to-string shimbun-slashdot-comment-threshold)
+		 t t url 1)))
+	(when (string-match "mode=\\([a-zA-Z]+\\)" url)
+	  (setq url
+		(replace-match shimbun-slashdot-comment-display t t url 1)))
+	url)
+    nil))
+
+(luna-define-method shimbun-clear-contents :around ((shimbun
+						     shimbun-slashdot)
+						    header)
+  (goto-char (point-min))
+  (if (or (null shimbun-slashdot-get-comments)
+	  (re-search-forward "<div class=\"intro\".*?>" nil t))
+      (progn
+	(goto-char (point-min))
+	(shimbun-remove-tags "<html>" "<div class=\"intro\".*?>")
+	(shimbun-remove-tags "<div class=\"commentBox\".*?>" "</html>")
+	(when shimbun-slashdot-get-comments
+	  (goto-char (point-max))
+	  (insert "\n<br><br>&#012\n")))
+    (shimbun-remove-tags "<html>" "<a name=\"topcomment\">")
+    (shimbun-remove-tags "<div id=\"footer\">" "</html>")))
+
+
 (provide 'sb-slashdot)
 
 ;;; sb-slashdot.el ends here
diff --git a/emacs-w3m.texi b/emacs-w3m.texi
index 7bc575f..e292b0d 100644
--- a/emacs-w3m.texi
+++ b/emacs-w3m.texi
@@ -5285,7 +5285,35 @@ perlentaucher-de.aktuell
 rediff.news
 
 @item @uref{http://www.slashdot.org/, Slashdot}
-slashdot.frontpage
+slashdot.frontpage slashdot.apple slashdot.askslashdot
+slashdot.books slashdot.developers slashdot.games
+slashdot.hardware slashdot.interviews slashdot.IT
+slashdot.linux slashdot.mobile slashdot.politics
+slashdot.science
+
+The following variables are availabe for configuring the comment section
+of the Slashdot shimbun:
+
+@table @code
+@item shimbun-slashdot-get-comments
+@vindex shimbun-slashdot-get-comments
+If set to t (the default), comments will be retrieved for every article.
+They are separated from the intro text through a linefeed character, so
+that you can access them by pressing the ``Next Page'' button in the
+article buffer.  Setting this variable to nil will deactivate retrieval
+of comments.
+
+@item shimbun-slashdot-comment-threshold
+@vindex shimbun-slashdot-comment-threshold
+Threshold for displayed comments (default: 3).  Can be a number between
+-1 (all comments) and 5 (highest rating).
+
+@item shimbun-slashdot-comment-display
+@vindex shimbun-slashdot-comment-display
+Type of display for the comments (default: flat).  Can be either
+``flat'', ``thread'' or ``nested''.  Note that this must be a string,
+not a symbol.
+@end table
 
 @item @uref{http://slashdot.jp/, Slashdot Japan}
 slashdot-jp.story slashdot-jp.askslashdot slashdot-jp.bookreview