* sb-mixi.el (shimbun-mixi-make-subject): Add SHIMBUN argument.
authorbg66 <bg66>
Mon, 18 Dec 2006 09:33:26 +0000 (09:33 +0000)
committerbg66 <bg66>
Mon, 18 Dec 2006 09:33:26 +0000 (09:33 +0000)
(shimbun-mixi-get-headers): Follow the change above.

* mixi.el (mixi-topic-community-regexp): New regexp.
(mixi-topic-realize): Use it.
(mixi-event-community-regexp): New regexp.
(mixi-event-realize): Use it.
(mixi-bbs-list): New constant.
(mixi-bbs-p): New macro.
(mixi-bbs-community): New function.

ChangeLog
mixi.el
sb-mixi.el

index e852d61..bbb0e29 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 2006-12-18  OHASHI Akira  <bg66@koka-in.org>
 
+       * sb-mixi.el (shimbun-mixi-make-subject): Add SHIMBUN argument.
+       (shimbun-mixi-get-headers): Follow the change above.
+
+       * mixi.el (mixi-topic-community-regexp): New regexp.
+       (mixi-topic-realize): Use it.
+       (mixi-event-community-regexp): New regexp.
+       (mixi-event-realize): Use it.
+       (mixi-bbs-list): New constant.
+       (mixi-bbs-p): New macro.
+       (mixi-bbs-community): New function.
+
+2006-12-18  OHASHI Akira  <bg66@koka-in.org>
+
        * mixi.el (mixi-curl-cookie-file): Change the default value to
        ~/.mixi/cookies.txt.
 
diff --git a/mixi.el b/mixi.el
index 18aa4dc..c3c5aa1 100644 (file)
--- a/mixi.el
+++ b/mixi.el
@@ -1460,6 +1460,8 @@ Increase this value when unexpected error frequently occurs."
   `(concat "/view_bbs.pl?id=" (mixi-topic-id ,topic)
           "&comm_id=" (mixi-community-id (mixi-topic-community ,topic))))
 
+(defconst mixi-topic-community-regexp
+  "<td width=\"595\" background=\"http://img\\.mixi\\.jp/img/bg_w\\.gif\"><b>\\[\\(.+\\)\\] ¥È¥Ô¥Ã¥¯</b></td>")
 (defconst mixi-topic-time-regexp
   "<td rowspan=\"3\" width=\"110\" bgcolor=\"#ffd8b0\" align=\"center\" valign=\"top\" nowrap>\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü<br>\\([0-9]+\\):\\([0-9]+\\)</td>")
 (defconst mixi-topic-title-regexp
@@ -1474,6 +1476,10 @@ Increase this value when unexpected error frequently occurs."
   ;; FIXME: Check a expiration of cache?
   (unless (mixi-object-realize-p topic)
     (with-mixi-retrieve (mixi-topic-page topic)
+      (if (string-match mixi-topic-community-regexp buffer)
+         (mixi-community-set-name (mixi-topic-community topic)
+                                  (match-string 1 buffer))
+       (signal 'error (list 'cannot-find-community topic)))
       (if (string-match mixi-topic-time-regexp buffer)
          (mixi-topic-set-time
           topic (encode-time 0 (string-to-number (match-string 5 buffer))
@@ -1588,6 +1594,8 @@ Increase this value when unexpected error frequently occurs."
   `(concat "/view_event.pl?id=" (mixi-event-id ,event)
           "&comm_id=" (mixi-community-id (mixi-event-community ,event))))
 
+(defconst mixi-event-community-regexp
+  "<td WIDTH=595 background=http://img\\.mixi\\.jp/img/bg_w\\.gif><b>\\[\\(.+\\)\\] ¥¤¥Ù¥ó¥È</b></td>")
 (defconst mixi-event-time-regexp
   "<td ROWSPAN=11 BGCOLOR=#FFD8B0 ALIGN=center VALIGN=top WIDTH=110>
 \\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü<br>
@@ -1624,6 +1632,10 @@ Increase this value when unexpected error frequently occurs."
   ;; FIXME: Check a expiration of cache?
   (unless (mixi-object-realize-p event)
     (with-mixi-retrieve (mixi-event-page event)
+      (if (string-match mixi-event-community-regexp buffer)
+         (mixi-community-set-name (mixi-event-community event)
+                                  (match-string 1 buffer))
+       (signal 'error (list 'cannot-find-title event)))
       (if (string-match mixi-event-time-regexp buffer)
          (mixi-event-set-time
           event (encode-time 0 (string-to-number (match-string 5 buffer))
@@ -1778,10 +1790,24 @@ Increase this value when unexpected error frequently occurs."
   (aset (cdr event) 10 members))
 
 ;; Bbs object.
-(defalias 'mixi-bbs-owner 'mixi-object-owner)
+(defconst mixi-bbs-list '(mixi-topic mixi-event))
+
+(defmacro mixi-bbs-p (object)
+  `(when (memq (mixi-object-class ,object) mixi-bbs-list)
+     t))
+
+(defun mixi-bbs-community (object)
+  "Return the community of OBJECT."
+  (unless (mixi-bbs-p object)
+    (signal 'wrong-type-argument (list 'mixi-bbs-p object)))
+  (let ((func (intern (concat mixi-object-prefix
+                             (mixi-object-name object) "-community"))))
+    (funcall func object)))
+
 (defalias 'mixi-bbs-id 'mixi-object-id)
 (defalias 'mixi-bbs-time 'mixi-object-time)
 (defalias 'mixi-bbs-title 'mixi-object-title)
+(defalias 'mixi-bbs-owner 'mixi-object-owner)
 (defalias 'mixi-bbs-content 'mixi-object-content)
 
 (defmacro mixi-bbs-list-page (community)
index 227fda3..340450d 100644 (file)
@@ -71,7 +71,7 @@ of mixi object."
   :type 'boolean)
 
 (defcustom shimbun-mixi-logout-p nil
-  "*If non-ni, Logout from mixi when shimbun server was closed."
+  "*If non-ni, logout from mixi when shimbun server was closed."
   :group 'shimbun
   :type 'boolean)
 
@@ -94,14 +94,23 @@ of mixi object."
 (luna-define-method shimbun-groups ((shimbun shimbun-mixi))
   (mapcar 'car shimbun-mixi-group-alist))
 
-(defun shimbun-mixi-make-subject (object)
+(defun shimbun-mixi-make-subject (shimbun object)
   (let ((class (mixi-object-class object)))
-    (cond ((eq class 'mixi-comment)
-          (concat "Re: " (shimbun-mixi-make-subject
-                          (mixi-comment-parent object))))
-         ((eq class 'mixi-event)
-          (concat "[¥¤¥Ù¥ó¥È]" (mixi-event-title object)))
-         (t (mixi-object-title object)))))
+    (if (eq class 'mixi-comment)
+        (concat "Re: " (shimbun-mixi-make-subject
+                       shimbun (mixi-comment-parent object)))
+      (let ((prefix (when (eq class 'mixi-event) "[¥¤¥Ù¥ó¥È]"))
+           (subject (mixi-object-title object))
+           (suffix (when (string-match
+                          "^new-" (shimbun-current-group-internal shimbun))
+                     (concat " ("
+                             (if (eq class 'mixi-diary)
+                                 (mixi-friend-nick
+                                  (mixi-diary-friend object))
+                               (mixi-community-name
+                                (mixi-bbs-community object)))
+                             ")"))))
+       (concat prefix subject suffix)))))
 
 (defun shimbun-mixi-make-from (object)
   (let ((owner (mixi-object-owner object)))
@@ -175,7 +184,7 @@ of mixi object."
                    (push
                     (shimbun-create-header
                      0
-                     (shimbun-mixi-make-subject object)
+                     (shimbun-mixi-make-subject shimbun object)
                      (shimbun-mixi-make-from object)
                      (shimbun-mixi-make-date object)
                      id