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

New previous/next link estimation functions



Hello,

In case you don't know: the emacswiki uses the oddmuse wiki
engine.  The new function will be useful for other emacs-w3m
users too.

2006-08-11  David Hansen <david.hansen@xxxxxxxxxxxxxxxxxx>

        * w3m.el: (w3m-relationship-oddmuse-estimate): New function.
        (w3m-relationship-freshmeat-estimate): New function.
        (w3m-relationship-estimate-rules): Fixed regexp for google groups.
        Added above new functions.
--- cvs-src/emacs-w3m/w3m.el	2006-06-02 22:33:07.000000000 +0200
+++ share/emacs/site-lisp/w3m/w3m.el	2006-08-11 01:25:37.000000000 +0200
@@ -1778,10 +1778,10 @@
 (defcustom w3m-relationship-estimate-rules
   `((w3m-relationship-simple-estimate
      "\\`http://\\(?:www\\|blogsearch\\|groups\\|news\\)\\.google\\.[^/]+/\\(?:search\\|blogsearch\\|groups\\|news\\)"
-     ,(concat "<a href=" w3m-html-string-regexp
-	      "><img src=\\(?:/intl/[^/]+/\\)?nav_next\\.gif")
-     ,(concat "<a href=" w3m-html-string-regexp
-	      "><img src=\\(?:/intl/[^/]+/\\)?nav_previous\\.gif")
+     ,(concat "<a[^>]+?href=" w3m-html-string-regexp
+	      "><img src=\"?\\(?:/\\(?:intl\\|groups\\)/[^/]+/\\)?nav_next\\.gif")
+     ,(concat "<a[^>]+?href=" w3m-html-string-regexp
+	      "><img src=\"\\(?:/\\(?:intl\\|groups\\)/[^/]+/\\)?nav_previous\\.gif")
      nil nil)
     (w3m-relationship-simple-estimate
      "\\`http://beta\\.search\\.yahoo\\.co\\.jp/";
@@ -1795,7 +1795,9 @@
      ,(concat "<a href=" w3m-html-string-regexp "></a>")
      ,(concat "<a href=" w3m-html-string-regexp "></a>")
      nil nil)
-    (w3m-relationship-magicpoint-estimate))
+    (w3m-relationship-magicpoint-estimate)
+    (w3m-relationship-oddmuse-estimate)
+    (w3m-relationship-freshmeat-estimate))
   "*Rules to estimate relationships between a retrieved page and others."
   :group 'w3m
   :type '(repeat
@@ -5462,6 +5464,28 @@
      (eval-when-compile
        (concat "<A HREF=" w3m-html-string-regexp ">\\[index\\]</A>")))))
 
+(defun w3m-relationship-oddmuse-estimate (url)
+  (when (string-match "/wiki\\?search=[^\";]*\\(;page=\\([0-9]+\\)\\)?" url)
+    (let ((re "<a href=\"\\(http://[^\"]+?/wiki\\?search=[^\";]*";)
+          (n (match-string 2 url)))
+      (setq n (or (and n (string-to-number n)) 1))
+      (let ((next (concat re ";page=" (number-to-string (1+ n)) "\\)\""))
+            (prev (cond
+                   ((< 2 n)
+                    (concat re ";page=" (number-to-string (1- n)) "\\)\""))
+                   ((= 2 n)
+                    "<a href=\"\\(http://[^\"]+?/wiki\\?search=[^\"]*\\)\""))))
+        (w3m-relationship-search-patterns url next prev)))))
+
+(defun w3m-relationship-freshmeat-estimate (url)
+  (when (string-match "^http://freshmeat.net/search/"; url)
+        (w3m-relationship-search-patterns
+         url
+         (eval-when-compile
+           (concat "<A HREF=" w3m-html-string-regexp ">\\[&raquo;\\]</A>"))
+         (eval-when-compile
+           (concat "<A HREF=" w3m-html-string-regexp ">\\[&laquo;\\]</A>")))))
+
 (defun w3m-relationship-search-patterns (url next previous
 					     &optional start contents)
   "Search relationships with given patterns."