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

[patch] w3m-relationship-slashdot-estimate



2007-02-04  David Hansen  <david.hansen@xxxxxxxxxxxxxxxxxxx>

            * w3m.el (w3m-relationship-estimate-rules): added
            `w3m-relationship-slashdot-estimate'.
            (w3m-relationship-slashdot-estimate): new function.
Index: w3m.el
===================================================================
RCS file: /storage/cvsroot/emacs-w3m/w3m.el,v
retrieving revision 1.1243
diff -c -r1.1243 w3m.el
*** w3m.el	2 Feb 2007 03:02:48 -0000	1.1243
--- w3m.el	4 Feb 2007 04:13:15 -0000
***************
*** 1840,1846 ****
       ,(concat "<A HREF=" w3m-html-string-regexp ">\\[&laquo;\\]</A>")
       nil nil)
      (w3m-relationship-oddmuse-estimate)
!     (w3m-relationship-magicpoint-estimate))
    "*Rules to estimate relationships between a retrieved page and others."
    :group 'w3m
    :type '(repeat
--- 1840,1847 ----
       ,(concat "<A HREF=" w3m-html-string-regexp ">\\[&laquo;\\]</A>")
       nil nil)
      (w3m-relationship-oddmuse-estimate)
!     (w3m-relationship-magicpoint-estimate)
!     (w3m-relationship-slashdot-estimate))
    "*Rules to estimate relationships between a retrieved page and others."
    :group 'w3m
    :type '(repeat
***************
*** 5585,5590 ****
--- 5586,5615 ----
  		    "<a href=\"\\(http://[^\"]+?/wiki\\?search=[^\"]*\\)\""))))
  	(w3m-relationship-search-patterns url next prev)))))
  
+ (defun w3m-relationship-slashdot-estimate (url)
+   (goto-char (point-min))
+   (when (and (string-match
+               "slashdot\\.org/\\(article\\|comments\\)\\.pl\\?"
+               url)
+              (search-forward "<div class=\"linkCommentPage\">" nil t))
+     (let ((min (point)) (max (save-excursion (search-forward "</div>" nil t))))
+       ;; move to the position of the current page indicator and then search
+       ;; for the next and previous link within the current <div>
+       (when (and max (re-search-forward "<b>\\(([0-9]+)\\)</b>" max t))
+         (let ((re (concat "<a href=" w3m-html-string-regexp ">")))
+           (when (save-excursion (re-search-backward re min t))
+             (setq w3m-previous-url
+                   (w3m-expand-url(w3m-decode-anchor-string
+                                   (or (match-string 2)
+                                       (match-string 3)
+                                       (match-string 1))))))
+           (when (re-search-forward re max t)
+             (setq w3m-next-url
+                   (w3m-expand-url(w3m-decode-anchor-string
+                                   (or (match-string 2)
+                                       (match-string 3)
+                                       (match-string 1)))))))))))
+ 
  (defun w3m-relationship-search-patterns (url next previous
  					     &optional start contents)
    "Search relationships with given patterns."