+2006-12-12 OHASHI Akira <bg66@koka-in.org>
+
+ * mixi.el (mixi-url-retrieve): Simplify.
+
+2006-12-11 OHASHI Akira <bg66@koka-in.org>
+
+ * mixi.el (mixi-diary-time-regexp): Follow the change of mixi;
+ Fix regexp.
+ (mixi-diary-title-regexp): Ditto.
+ (mixi-diary-content-regexp): Ditto.
+ (mixi-diary-realize): Follow the change above.
+
+2006-12-11 OHASHI Akira <bg66@koka-in.org>
+
+ * mixi.el (mixi-search-bbs-list-page): New macro.
+ (mixi-search-bbs-list-regexp): New regexp.
+ (mixi-search-bbses): New function.
+
+2006-12-11 OHASHI Akira <bg66@koka-in.org>
+
+ * mixi.el (mixi-search-community-list-page): New macro.
+ (mixi-search-community-list-regexp): New regexp.
+ (mixi-search-communities): New function.
+
+2006-12-11 OHASHI Akira <bg66@koka-in.org>
+
+ * mixi.el (mixi-cache-expires): Set the default value to nil.
+
+2006-12-08 OHASHI Akira <bg66@koka-in.org>
+
+ * sb-mixi.el (shimbun-mixi-initialize-comment-cache): Abolish.
+ (initialize-instance): Follow the change above.
+ (shimbun-close): Set the comment cache to nil.
+
+2006-12-08 OHASHI Akira <bg66@koka-in.org>
+
+ * mixi.el (mixi-topic-comment-list-regexp): Fix regexp.
+ (mixi-message): Rename the STRING argument to STRINGS.
+ (mixi-login): Follow the cange above.
+ (mixi-parse-buffer): Fix error message.
+
+2006-12-07 OHASHI Akira <bg66@koka-in.org>
+
+ * mixi.el (mixi-diary-owner-nick-regexp): Fix regexp.
+ (mixi-topic-owner-regexp): Ditto.
+
+2006-12-05 OHASHI Akira <bg66@koka-in.org>
+
+ * sb-mixi.el (shimbun-mixi-logout-p): New user option.
+ (shimbun-mixi-initialize-comment-cache): New macro.
+ (initialize-instance): Use it.
+ (shimbun-close): New method.
+
+2006-12-04 OHASHI Akira <bg66@koka-in.org>
+
+ * mixi.el (mixi-url-encode-and-quote-percent-string): New function.
+ (mixi-search-diary-list-page): New macro.
+ (mixi-search-diary-list-regexp): New regexp.
+ (mixi-search-diaries): New function.
+ (mixi-diary-closed-regexp): New regexp.
+ (mixi-diary-realize): Use it.
+
+ * sb-mixi.el (shimbun-mixi-group-alist): Fix docs.
+
+2006-12-04 OHASHI Akira <bg66@koka-in.org>
+
+ * mixi.el (mixi-diary-content-regexp): Fix regexp.
+
+2006-12-01 OHASHI Akira <bg66@koka-in.org>
+
+ * mixi.el (mixi-diary-comment-list-page): Use `full=1' instead of
+ `page=%d'.
+ (mixi-get-comments): Get comments in latest order.
+
+2006-12-01 OHASHI Akira <bg66@koka-in.org>
+
+ * mixi.el (mixi-parse-buffer): Rename from `mixi-retrieve-1', and
+ swap `buffer' argument and `url'.
+ (mixi-url-retrieve): Follow the change above.
+ (mixi-w3m-retrieve): Ditto.
+ (mixi-curl-retrieve): Ditto.
+
+2006-11-30 OHASHI Akira <bg66@koka-in.org>
+
+ * mixi.el (mixi-get-matched-items): Rename `max-numbers' to `range',
+ and swap `range' and `regexp'.
+ (mixi-get-friends): Follow the change above.
+ (mixi-get-favorites): Ditto.
+ (mixi-get-logs): Ditto.
+ (mixi-get-diaries): Ditto.
+ (mixi-get-new-diaries): Ditto.
+ (mixi-get-communities): Ditto.
+ (mixi-get-bbses): Ditto.
+ (mixi-get-new-bbses): Ditto.
+ (mixi-get-comments): Ditto.
+ (mixi-get-new-comments): Ditto.
+ (mixi-get-messages): Ditto.
+ (mixi-get-introductions): Ditto.
+
+2006-11-30 OHASHI Akira <bg66@koka-in.org>
+
+ * sb-mixi.el (shimbun-comment-article): Simplify.
+
+2006-11-29 OHASHI Akira <bg66@koka-in.org>
+
+ * sb-mixi.el (shimbun-comment-article): Cache the content of all
+ comment.
+
+2006-11-29 OHASHI Akira <bg66@koka-in.org>
+
+ * sb-mixi.el (shimbun-mixi): Add the COMMENT-CACHE slot.
+ (initialize-instance): New method.
+ (shimbun-mixi-get-headers): Cache the content of comment.
+ (shimbun-comment-article): Use cache.
+ (shimbun-article): Follow the change above.
+
+2006-11-28 OHASHI Akira <bg66@koka-in.org>
+
+ * sb-mixi.el (shimbun-mixi-x-face-alist): New variable.
+
+2006-11-28 OHASHI Akira <bg66@koka-in.org>
+
+ * mixi.el (mixi-object-title): Follow the event object.
+ (mixi-object-content): Ditto.
+ (mixi-bbs-owner): New alias.
+ (mixi-bbs-id): Ditto.
+ (mixi-bbs-time): Ditto.
+ (mixi-bbs-title): Ditto.
+ (mixi-bbs-content): Ditto.
+
+ * sb-mixi.el (shimbun-mixi-make-subject): Follow the change above.
+ (shimbun-mixi-make-body): Ditto.
+
+2006-11-27 OHASHI Akira <bg66@koka-in.org>
+
+ * mixi.el (mixi-event-cache): New variable.
+ (mixi-make-event): New function.
+ (mixi-event-url-regexp): New constant.
+ (mixi-make-event-from-url): New function.
+ (mixi-event-p): New macro.
+ (mixi-event-page): Ditto.
+ (mixi-event-time-regexp): New regexp.
+ (mixi-event-title-regexp): Ditto.
+ (mixi-event-owner-regexp): Ditto.
+ (mixi-event-date-regexp): Ditto.
+ (mixi-event-place-regexp): Ditto.
+ (mixi-event-detail-regexp): Ditto.
+ (mixi-event-limit-regexp): Ditto.
+ (mixi-event-members-regexp): Ditto.
+ (mixi-event-realize): New function.
+ (mixi-event-community): New accessor method.
+ (mixi-event-id): Ditto.
+ (mixi-event-time): Ditto.
+ (mixi-event-title): Ditto.
+ (mixi-event-owner): Ditto.
+ (mixi-event-date): Ditto.
+ (mixi-event-place): Ditto.
+ (mixi-event-detail): Ditto.
+ (mixi-event-limit): Ditto.
+ (mixi-event-members): Ditto.
+ (mixi-event-set-time): Ditto.
+ (mixi-event-set-title): Ditto.
+ (mixi-event-set-owner): Ditto.
+ (mixi-event-set-date): Ditto.
+ (mixi-event-set-place): Ditto.
+ (mixi-event-set-detail): Ditto.
+ (mixi-event-set-limit): Ditto.
+ (mixi-event-set-members): Ditto.
+ (mixi-bbs-list-page): Rename from `mixi-topic-list-page'.
+ (mixi-bbs-list-regexp): Rename from `mixi-topic-list-regexp'.
+ (mixi-get-bbses): Rename from `mixi-get-topics'.
+ (mixi-new-bbs-list-page): Rename from `mixi-new-topic-list-page'.
+ (mixi-new-bbs-list-regexp): Rename from `mixi-new-topic-list-regexp'.
+ (mixi-get-new-bbses): Rename from `mixi-get-new-topics'.
+ (mixi-bbs-list-regexp): Follow the change above.
+ (mixi-get-bbses): Ditto.
+ (mixi-new-bbs-list-regexp): Ditto.
+ (mixi-get-new-bbses): Ditto.
+ (mixi-event-comment-list-page): New function.
+ (mixi-event-comment-list-regexp): New constant.
+
+ * sb-mixi.el (shimbun-mixi-group-alist): Follow the change above.
+ (shimbun-mixi-make-subject): Ditto.
+ (shimbun-mixi-make-xref): Ditto.
+ (shimbun-mixi-get-headers): Ditto.
+ (shimbun-get-headers): Ditto.
+ (shimbun-mixi-make-body): New function.
+ (shimbun-article): Follow the change above.
+
+2006-11-27 OHASHI Akira <bg66@koka-in.org>
+
+ * sb-mixi.el (shimbun-mixi-get-headers): Don't quit even if there are
+ comments which have already gotten.
+
+2006-11-27 OHASHI Akira <bg66@koka-in.org>
+
+ * mixi.el (mixi-topic-content-regexp): Fix regexp.
+ (mixi-topic-realize): Follow the change above.
+
2006-11-25 OHASHI Akira <bg66@koka-in.org>
* mixi.el (mixi-save-cache): Use `symbol-value' instead of
;; * mixi-get-logs
;; * mixi-get-diaries
;; * mixi-get-new-diaries
+;; * mixi-search-diaries
;; * mixi-get-communities
-;; * mixi-get-topics
-;; * mixi-get-new-topics
+;; * mixi-search-communities
+;; * mixi-get-bbses
+;; * mixi-get-new-bbses
+;; * mixi-search-bbses
;; * mixi-get-comments
;; * mixi-get-new-comments
;; * mixi-get-messages
;;
;; Display newest 3 diaries like a mail format.
;;
-;; (let ((max-numbers 3)
-;; (buffer (generate-new-buffer "*temp*"))
+;; (let ((range 3)
+;; (buffer (get-buffer-create "*temp*"))
;; (format "%Y/%m/%d %H:%M"))
;; (pop-to-buffer buffer)
;; (mapc (lambda (diary)
;; (let ((subject (mixi-diary-title diary))
-;; ;; Don't get owner's nick at first for omitting a useless
-;; ;; retrieval.
;; (from (mixi-friend-nick (mixi-diary-owner diary)))
;; (date (format-time-string format (mixi-diary-time diary)))
;; (body (mixi-remove-markup (mixi-diary-content diary))))
;; "Subject: " subject "\n"
;; "Date: " date "\n\n"
;; body "\n\n")))
-;; (mixi-get-new-diaries max-numbers))
+;; (mixi-get-new-diaries range))
;; (set-buffer-modified-p nil)
;; (setq buffer-read-only t)
;; (goto-char (point-min)))
;; Display newest 3 diaries including newest 3 comments like a mail format.
;; Comments are displayed like a reply mail.
;;
-;; (let ((max-numbers 3)
-;; (buffer (generate-new-buffer "*temp*"))
+;; (let ((range 3)
+;; (buffer (get-buffer-create "*temp*"))
;; (format "%Y/%m/%d %H:%M"))
;; (pop-to-buffer buffer)
;; (mapc (lambda (diary)
;; (let ((subject (mixi-diary-title diary))
-;; ;; Don't get owner's nick at first for omitting a useless
-;; ;; retrieval.
;; (from (mixi-friend-nick (mixi-diary-owner diary)))
;; (date (format-time-string format (mixi-diary-time diary)))
;; (body (mixi-remove-markup (mixi-diary-content diary))))
;; "Subject: " subject "\n"
;; "Date: " date "\n\n"
;; body "\n\n")))
-;; (mixi-get-comments diary max-numbers))))
-;; (mixi-get-new-diaries max-numbers))
+;; (mixi-get-comments diary range))))
+;; (mixi-get-new-diaries range))
;; (set-buffer-modified-p nil)
;; (setq buffer-read-only t)
;; (goto-char (point-min)))
+;; Bug reports:
+;;
+;; If you have bug reports and/or suggestions for improvement, please
+;; send them via <URL:http://mixi.jp/view_community.pl?id=1596390>.
+
;;; Code:
(eval-when-compile (require 'cl))
:type 'number
:group 'mixi)
-(defcustom mixi-cache-expires 3600
+(defcustom mixi-cache-expires nil
"*Seconds for expiration of a cached object."
:type '(radio (integer :tag "Expired seconds")
(const :tag "Don't expire" nil)
(defvar mixi-me nil)
;; Utilities.
-(defmacro mixi-message (string)
- `(concat "[mixi] " ,string))
+(defmacro mixi-message (&rest strings)
+ `(concat "[mixi] " ,@strings))
(defconst mixi-message-adult-contents
"¤³¤Î¥Ú¡¼¥¸¤«¤éÀè¤Ï¥¢¥À¥ë¥È¡ÊÀ®¿Í¸þ¤±¡Ë¥³¥ó¥Æ¥ó¥Ä¤¬´Þ¤Þ¤ì¤Æ¤¤¤Þ¤¹¡£<br>
(defmacro mixi-retrieve (url &optional post-data)
`(funcall mixi-retrieve-function ,url ,post-data))
-(defun mixi-retrieve-1 (buffer url &optional post-data)
+(defun mixi-parse-buffer (url buffer &optional post-data)
(when (string-match mixi-message-adult-contents buffer)
(if mixi-accept-adult-contents
(setq buffer (mixi-retrieve url "submit=agree"))
(setq buffer (mixi-retrieve (concat url "?")))))
(when (string-match mixi-warning-continuously-accessing buffer)
- (error (mixi-message "Continuously accessing")))
+ (error (mixi-message "Access denied. Please wait a while and increase "
+ "the value of `mixi-continuously-access-interval'.")))
(if (not (string-match mixi-message-continuously-accessing buffer))
buffer
(message (mixi-message "Waiting for continuously accessing..."))
(error (mixi-message "Cannot retrieve")))
(with-current-buffer buffer
(goto-char (point-min))
- (if (re-search-forward "HTTP/[0-9.]+ 302 Moved" nil t)
- (if (re-search-forward
- (concat "Location: " mixi-url "\\(.+\\)") nil t)
- (setq ret (mixi-url-retrieve (match-string 1) post-data))
- (setq ret (mixi-url-retrieve "/home.pl" post-data)))
- (unless (re-search-forward "HTTP/[0-9.]+ 200 OK" nil t)
- (error (mixi-message "Cannot retrieve")))
- (search-forward "\n\n")
- (setq ret (decode-coding-string
- (buffer-substring-no-properties (point) (point-max))
- mixi-coding-system))
- (kill-buffer buffer)
- (setq ret (mixi-retrieve-1 ret url post-data))))
- ret))
+ (while (looking-at "HTTP/[0-9]+\\.[0-9]+ [13][0-9][0-9]")
+ (delete-region (point) (re-search-forward "\r?\n\r?\n")))
+ (unless (looking-at "HTTP/[0-9]+\\.[0-9]+ 200")
+ (error (mixi-message "Cannot retrieve")))
+ (delete-region (point) (re-search-forward "\r?\n\r?\n"))
+ (setq ret (decode-coding-string (buffer-string) mixi-coding-system))
+ (kill-buffer buffer)
+ (mixi-parse-buffer url ret post-data))))
(defun mixi-w3m-retrieve (url &optional post-data)
"Retrieve the URL and return gotten strings."
(error (mixi-message "Cannot retrieve"))
(w3m-decode-buffer url)
(let ((ret (buffer-substring-no-properties (point-min) (point-max))))
- (mixi-retrieve-1 ret url post-data))))))
+ (mixi-parse-buffer url ret post-data))))))
(defun mixi-curl-retrieve (url &optional post-data)
"Retrieve the URL and return gotten strings."
(error (mixi-message "Cannot retrieve")))
(delete-region (point) (re-search-forward "\r?\n\r?\n"))
(setq ret (decode-coding-string (buffer-string) mixi-coding-system))
- (mixi-retrieve-1 ret url post-data))))
+ (mixi-parse-buffer url ret post-data))))
(defconst mixi-my-id-regexp
"<a href=\"add_diary\\.pl\\?id=\\([0-9]+\\)")
"Login to mixi."
(when (and (eq mixi-retrieve-function 'mixi-w3m-retrieve)
(not w3m-use-cookies))
- (error
- (mixi-message
- "Require to accept cookies. Please set `w3m-use-cookies' to t.")))
+ (error (mixi-message "Require to accept cookies. Please set "
+ "`w3m-use-cookies' to t.")))
(let ((email (or email mixi-default-email
(read-from-minibuffer (mixi-message "Login Email: "))))
(password (or password mixi-default-password
(put 'with-mixi-retrieve 'lisp-indent-function 'defun)
(put 'with-mixi-retrieve 'edebug-form-spec '(form body))
-(defun mixi-get-matched-items (url max-numbers regexp)
+(defun mixi-get-matched-items (url regexp &optional range)
"Get matched items to REGEXP in URL."
(let ((page 1)
ids)
(catch 'end
- (while (or (null max-numbers) (< (length ids) max-numbers))
+ (while (or (null range) (< (length ids) range))
(with-mixi-retrieve (format url page)
(let ((pos 0)
found)
(while (and (string-match regexp buffer pos)
- (or (null max-numbers) (< (length ids) max-numbers)))
+ (or (null range) (< (length ids) range)))
(let ((num 1)
list)
(while (match-string num buffer)
(when (not found)
(throw 'end ids))))
(incf page)))
- ;; FIXME: Sort? Now order by newest.
(reverse ids)))
;; stolen (and modified) from shimbun.el
;; FIXME: Decode entities.
(buffer-string)))
+;; stolen (and modified) from w3m.el
+;; FIXME: Hmm.
+(defun mixi-url-encode-and-quote-percent-string (string)
+ (apply (function concat)
+ (mapcar
+ (lambda (char)
+ (cond
+ ((eq char ?\n) ; newline
+ "%%0D%%0A")
+ ((string-match "[-a-zA-Z0-9_:/.]" (char-to-string char)) ; xxx?
+ (char-to-string char)) ; printable
+ ((char-equal char ?\x20) ; space
+ "+")
+ (t
+ (format "%%%%%02x" char)))) ; escape
+ ;; Coerce a string into a list of chars.
+ (append (encode-coding-string (or string "") mixi-coding-system)
+ nil))))
+
;; Cache.
;; stolen from time-date.el
(defun mixi-time-less-p (t1 t2)
"Return the title of OBJECT."
(unless (mixi-object-p object)
(signal 'wrong-type-argument (list 'mixi-object-p object)))
- (let ((func (intern (concat mixi-object-prefix
- (mixi-object-name object) "-title"))))
- (funcall func object)))
+ (let ((class (mixi-object-class object))
+ (func (intern (concat mixi-object-prefix
+ (mixi-object-name object) "-title")))
+ prefix)
+ (cond ((eq class 'mixi-event)
+ (setq prefix "[¥¤¥Ù¥ó¥È]")))
+ (concat prefix (funcall func object))))
(defun mixi-object-content (object)
"Return the content of OBJECT."
(unless (mixi-object-p object)
(signal 'wrong-type-argument (list 'mixi-object-p object)))
- (let ((func (intern (concat mixi-object-prefix
- (mixi-object-name object) "-content"))))
- (funcall func object)))
+ (let ((class (mixi-object-class object)))
+ (cond ((eq class 'mixi-event)
+ (let ((limit (mixi-event-limit object)))
+ (setq limit (if limit
+ (format-time-string "%Yǯ%m·î%dÆü" limit)
+ "»ØÄê¤Ê¤·"))
+ (concat "<dl><dt>³«ºÅÆü»þ¡§</dt>"
+ "<dd>" (mixi-event-date object) "</dd>"
+ "<dt>³«ºÅ¾ì½ê¡§</dt>"
+ "<dd>" (mixi-event-place object) "</dd>"
+ "<dt>¾ÜºÙ¡§</dt>"
+ "<dd>" (mixi-event-detail object) "</dd>"
+ "<dt>Ê罸´ü¸Â¡§</dt>"
+ "<dd>" limit "</dd>"
+ "<dt>»²²Ã¼Ô¡§</dt>"
+ "<dd>" (mixi-event-members object) "</dd></dl>")))
+ (t
+ (let ((func (intern (concat mixi-object-prefix
+ (mixi-object-name object) "-content"))))
+ (funcall func object))))))
(defun mixi-object-set-timestamp (object timestamp)
"Set the timestamp of OBJECT."
(when (> (length args) 2)
(signal 'wrong-number-of-arguments (list 'mixi-get-friends (length args))))
(let ((friend (nth 0 args))
- (max-numbers (nth 1 args)))
- (when (or (not (mixi-friend-p friend)) (mixi-friend-p max-numbers))
+ (range (nth 1 args)))
+ (when (or (not (mixi-friend-p friend)) (mixi-friend-p range))
(setq friend (nth 1 args))
- (setq max-numbers (nth 0 args)))
+ (setq range (nth 0 args)))
(unless (or (null friend) (mixi-friend-p friend))
(signal 'wrong-type-argument (list 'mixi-friend-p friend)))
(let ((ids (mixi-get-matched-items (mixi-friend-list-page friend)
- max-numbers
- mixi-friend-list-id-regexp))
+ mixi-friend-list-id-regexp
+ range))
(nicks (mixi-get-matched-items (mixi-friend-list-page friend)
- max-numbers
- mixi-friend-list-nick-regexp)))
+ mixi-friend-list-nick-regexp
+ range)))
(let ((index 0)
ret)
(while (< index (length ids))
"<td BGCOLOR=#FDF9F2><font COLOR=#996600>̾ Á°</font></td>
<td COLSPAN=2 BGCOLOR=#FFFFFF>\\(.+\\)</td></tr>")
-(defun mixi-get-favorites (&optional max-numbers)
+(defun mixi-get-favorites (&optional range)
"Get favorites."
(let ((ids (mixi-get-matched-items (mixi-favorite-list-page)
- max-numbers
- mixi-favorite-list-id-regexp))
+ mixi-favorite-list-id-regexp
+ range))
(nicks (mixi-get-matched-items (mixi-favorite-list-page)
- max-numbers
- mixi-favorite-list-nick-regexp)))
+ mixi-favorite-list-nick-regexp
+ range)))
(let ((index 0)
ret)
(while (< index (length ids))
(defconst mixi-log-list-regexp
"\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\) <a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.*\\)</a></li>")
-(defun mixi-get-logs (&optional max-numbers)
+(defun mixi-get-logs (&optional range)
"Get logs."
(let ((items (mixi-get-matched-items (mixi-log-list-page)
- max-numbers
- mixi-log-list-regexp)))
+ mixi-log-list-regexp
+ range)))
(mapcar (lambda (item)
(mixi-make-log (mixi-make-friend (nth 5 item) (nth 6 item))
(encode-time 0
`(concat "/view_diary.pl?id=" (mixi-diary-id ,diary)
"&owner_id=" (mixi-friend-id (mixi-diary-owner ,diary))))
-;; FIXME: Remove `¤µ¤ó'.
+(defconst mixi-diary-closed-regexp
+ "<td>ͧ¿Í\\(¤Îͧ¿Í\\)?¤Þ¤Ç¸ø³«¤Î¤¿¤áÆɤळ¤È¤¬½ÐÍè¤Þ¤»¤ó¡£</td></tr>")
(defconst mixi-diary-owner-nick-regexp
- "<td WIDTH=490 background=http://img\\.mixi\\.jp/img/bg_w\\.gif><b><font COLOR=#605048>\\(.+\\)\\(¤µ¤ó\\)?¤ÎÆüµ</font></b></td>")
+ "<td WIDTH=490 background=http://img\\.mixi\\.jp/img/bg_w\\.gif><b><font COLOR=#605048>\\(.+?\\)\\(¤µ¤ó\\)?¤ÎÆüµ</font></b></td>")
(defconst mixi-diary-time-regexp
- "<td ALIGN=center ROWSPAN=2 NOWRAP WIDTH=95 bgcolor=#FFD8B0>\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü<br>\\([0-9]+\\):\\([0-9]+\\)</td>")
+ "<td \\(align\\|ALIGN\\)=\"?center\"? \\(rowspan\\|ROWSPAN\\)=\"?[23]\"? \\(nowrap=\"nowrap\"\\|NOWRAP\\) \\(width\\|WIDTH\\)=\"?95\"? bgcolor=\"?#FFD8B0\"?>\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü\\(<br />\\|<br>\\)\\([0-9]+\\):\\([0-9]+\\)</td>")
(defconst mixi-diary-title-regexp
- "<td BGCOLOR=#FFF4E0 WIDTH=430> \\([^<]+\\)</td></tr>")
+ "<td \\(bgcolor\\|BGCOLOR\\)=\"?#FFF4E0\"? width=\"?430\"?> \\([^<]+\\)</td>")
(defconst mixi-diary-content-regexp
- "<td CLASS=h12>\\(.+\\)</td></tr>")
+ "<td \\(class\\|CLASS\\)=\"?h12\"?>\\(.*\\)</td>")
(defun mixi-diary-realize (diary)
"Realize a DIARY."
;; FIXME: Check a expiration of cache?
(unless (mixi-object-realize-p diary)
(with-mixi-retrieve (mixi-diary-page diary)
- (if (string-match mixi-diary-owner-nick-regexp buffer)
- (mixi-friend-set-nick (mixi-diary-owner diary)
- (match-string 1 buffer))
- (signal 'error (list 'cannot-find-owner-nick diary)))
- (if (string-match mixi-diary-time-regexp buffer)
- (mixi-diary-set-time
- diary (encode-time 0 (string-to-number (match-string 5 buffer))
- (string-to-number (match-string 4 buffer))
- (string-to-number (match-string 3 buffer))
- (string-to-number (match-string 2 buffer))
- (string-to-number (match-string 1 buffer))))
- (signal 'error (list 'cannot-find-time diary)))
- (if (string-match mixi-diary-title-regexp buffer)
- (mixi-diary-set-title diary (match-string 1 buffer))
- (signal 'error (list 'cannot-find-title diary)))
- (if (string-match mixi-diary-content-regexp buffer)
- (mixi-diary-set-content diary (match-string 1 buffer))
- (signal 'error (list 'cannot-find-content diary))))
+ (unless (string-match mixi-diary-closed-regexp buffer)
+ (if (string-match mixi-diary-owner-nick-regexp buffer)
+ (mixi-friend-set-nick (mixi-diary-owner diary)
+ (match-string 1 buffer))
+ (signal 'error (list 'cannot-find-owner-nick diary)))
+ (if (string-match mixi-diary-time-regexp buffer)
+ (mixi-diary-set-time
+ diary (encode-time 0 (string-to-number (match-string 10 buffer))
+ (string-to-number (match-string 9 buffer))
+ (string-to-number (match-string 7 buffer))
+ (string-to-number (match-string 6 buffer))
+ (string-to-number (match-string 5 buffer))))
+ (signal 'error (list 'cannot-find-time diary)))
+ (if (string-match mixi-diary-title-regexp buffer)
+ (mixi-diary-set-title diary (match-string 2 buffer))
+ (signal 'error (list 'cannot-find-title diary)))
+ (if (string-match mixi-diary-content-regexp buffer)
+ (mixi-diary-set-content diary (match-string 2 buffer))
+ (signal 'error (list 'cannot-find-content diary)))))
(mixi-object-touch diary)))
(defun mixi-diary-owner (diary)
(signal 'wrong-number-of-arguments
(list 'mixi-get-diaries (length args))))
(let ((friend (nth 0 args))
- (max-numbers (nth 1 args)))
- (when (or (not (mixi-friend-p friend)) (mixi-friend-p max-numbers))
+ (range (nth 1 args)))
+ (when (or (not (mixi-friend-p friend)) (mixi-friend-p range))
(setq friend (nth 1 args))
- (setq max-numbers (nth 0 args)))
+ (setq range (nth 0 args)))
(unless (or (null friend) (mixi-friend-p friend))
(signal 'wrong-type-argument (list 'mixi-friend-p friend)))
(let ((items (mixi-get-matched-items (mixi-diary-list-page friend)
- max-numbers
- mixi-diary-list-regexp)))
+ mixi-diary-list-regexp
+ range)))
(mapcar (lambda (item)
(mixi-make-diary friend (nth 0 item)))
items))))
(defconst mixi-new-diary-list-regexp
"<a class=\"new_link\" href=view_diary\\.pl\\?id=\\([0-9]+\\)&owner_id=\\([0-9]+\\)>")
-(defun mixi-get-new-diaries (&optional max-numbers)
+(defun mixi-get-new-diaries (&optional range)
"Get new diaries."
(let ((items (mixi-get-matched-items (mixi-new-diary-list-page)
- max-numbers
- mixi-new-diary-list-regexp)))
+ mixi-new-diary-list-regexp
+ range)))
+ (mapcar (lambda (item)
+ (mixi-make-diary (mixi-make-friend (nth 1 item)) (nth 0 item)))
+ items)))
+
+(defmacro mixi-search-diary-list-page (keyword)
+ `(concat "/search_diary.pl?page=%d&submit=search&keyword="
+ (mixi-url-encode-and-quote-percent-string keyword)))
+
+(defconst mixi-search-diary-list-regexp
+ "<a href=\"view_diary\\.pl\\?id=\\([0-9]+\\)&owner_id=\\([0-9]+\\)\">")
+
+(defun mixi-search-diaries (keyword &optional range)
+ (let ((items (mixi-get-matched-items (mixi-search-diary-list-page keyword)
+ mixi-search-diary-list-regexp
+ range)))
(mapcar (lambda (item)
(mixi-make-diary (mixi-make-friend (nth 1 item)) (nth 0 item)))
items)))
(signal 'wrong-number-of-arguments
(list 'mixi-get-communities (length args))))
(let ((friend (nth 0 args))
- (max-numbers (nth 1 args)))
- (when (or (not (mixi-friend-p friend)) (mixi-friend-p max-numbers))
+ (range (nth 1 args)))
+ (when (or (not (mixi-friend-p friend)) (mixi-friend-p range))
(setq friend (nth 1 args))
- (setq max-numbers (nth 0 args)))
+ (setq range (nth 0 args)))
(unless (or (null friend) (mixi-friend-p friend))
(signal 'wrong-type-argument (list 'mixi-friend-p friend)))
(let ((ids (mixi-get-matched-items (mixi-community-list-page friend)
- max-numbers
- mixi-community-list-id-regexp))
+ mixi-community-list-id-regexp
+ range))
(names (mixi-get-matched-items (mixi-community-list-page friend)
- max-numbers
- mixi-community-list-name-regexp)))
+ mixi-community-list-name-regexp
+ range)))
(let ((index 0)
ret)
(while (< index (length ids))
(incf index))
(reverse ret)))))
+(defmacro mixi-search-community-list-page (keyword)
+ `(concat "/search_community.pl?page=%d&&sort=date&type=com&submit=main"
+ "&keyword=" (mixi-url-encode-and-quote-percent-string keyword)
+ "&category_id=0"))
+
+(defconst mixi-search-community-list-regexp
+ "<td WIDTH=90 VALIGN=top ROWSPAN=4 ALIGN=center background=http://img\\.mixi\\.jp/img/bg_line\\.gif><a href=\"view_community\\.pl\\?id=\\([0-9]+\\)\"><img SRC=\"http://img-c[0-9]+\\.mixi\\.jp/photo/comm/[^.]+\\.jpg\" VSPACE=3 border=0></a></td>
+<td NOWRAP WIDTH=90 BGCOLOR=#FDF9F2><font COLOR=#996600>¥³¥ß¥å¥Ë¥Æ¥£Ì¾</font></td>
+<td COLSPAN=2 WIDTH=370 BGCOLOR=#FFFFFF>\\([^<]+\\)</td></tr>")
+
+;; FIXME: Support category.
+(defun mixi-search-communities (keyword &optional range)
+ (let ((items (mixi-get-matched-items (mixi-search-community-list-page
+ keyword)
+ mixi-search-community-list-regexp
+ range)))
+ (mapcar (lambda (item)
+ (mixi-make-community (nth 0 item) (nth 1 item)))
+ items)))
+
;; Topic object.
(defvar mixi-topic-cache (make-hash-table :test 'equal))
(defun mixi-make-topic (community id)
"<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
"<td bgcolor=\"#fff4e0\"> \\([^<]+\\)</td>")
-;; FIXME: Remove `¤µ¤ó'.
(defconst mixi-topic-owner-regexp
- "<td bgcolor=\"#fdf9f2\"> <font color=\"#dfb479\"></font> <a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.*\\)\\(¤µ¤ó\\)?</a>")
+ "<td bgcolor=\"#fdf9f2\"> <font color=\"#dfb479\"></font> <a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.*?\\)\\(¤µ¤ó\\)?</a>")
(defconst mixi-topic-content-regexp
- "<td class=\"h120\"><table><tr>\\(.+\\)?\n?\\(.+\\)?\n?\\(.+\\)?\n?</tr></table>\\(.+\\)</td>")
+ "<table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"5\"><tr><td class=\"h120\"><table><tr>\\(<td width=\"130\" height=\"140\" align=\"center\" valign=\"middle\"><a href=\"javascript:void(0)\" onClick=\"MM_openBrWindow('show_bbs_picture\\.pl\\?id=[0-9]+&number=[0-9]+','pict','width=680,height=660,toolbar=no,scrollbars=yes,left=5,top=5')\"><img src=\"http://ic[0-9]+\\.mixi\\.jp/[^.]+\\.jpg\" border=\"0\"></a></td>\n\\)*</tr></table>\\(.+\\)</td></tr></table>")
(defun mixi-topic-realize (topic)
"Realize a TOPIC."
(match-string 2 buffer)))
(signal 'error (list 'cannot-find-owner topic)))
(if (string-match mixi-topic-content-regexp buffer)
- (mixi-topic-set-content topic (match-string 4 buffer))
+ (mixi-topic-set-content topic (match-string 2 buffer))
(signal 'error (list 'cannot-find-content topic))))
(mixi-object-touch topic)))
(signal 'wrong-type-argument (list 'mixi-topic-p topic)))
(aset (cdr topic) 6 content))
-(defmacro mixi-topic-list-page (community)
+;; Event object.
+(defvar mixi-event-cache (make-hash-table :test 'equal))
+(defun mixi-make-event (community id)
+ "Return a event object."
+ (mixi-make-cache (list (mixi-community-id community) id)
+ (cons 'mixi-event (vector nil community id nil nil nil nil
+ nil nil nil nil))
+ mixi-event-cache))
+
+(defconst mixi-event-url-regexp
+ "/view_event\\.pl\\?id=\\([0-9]+\\)\\(&comment_count=[0-9]+\\)?&comm_id=\\([0-9]+\\)")
+
+(defun mixi-make-event-from-url (url)
+ "Return a event object from URL."
+ (when (string-match mixi-event-url-regexp url)
+ (let ((id (match-string 1 url))
+ (community-id (match-string 3 url)))
+ (mixi-make-event (mixi-make-community community-id) id))))
+
+(defmacro mixi-event-p (event)
+ `(eq (mixi-object-class ,event) 'mixi-event))
+
+(defmacro mixi-event-page (event)
+ `(concat "/view_event.pl?id=" (mixi-event-id ,event)
+ "&comm_id=" (mixi-community-id (mixi-event-community ,event))))
+
+(defconst mixi-event-time-regexp
+ "<td ROWSPAN=11 BGCOLOR=#FFD8B0 ALIGN=center VALIGN=top WIDTH=110>
+\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü<br>
+\\([0-9]+\\):\\([0-9]+\\)</td>")
+(defconst mixi-event-title-regexp
+ "<td bgcolor=#FFF4E0 width=410> \\([^<]+\\)</td>")
+(defconst mixi-event-owner-regexp
+ "<td BGCOLOR=#FDF9F2> <a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.*\\)</a>")
+(defconst mixi-event-date-regexp
+ "<td BGCOLOR=#FFFFFF ALIGN=center NOWRAP>³«ºÅÆü»þ</td>
+<td BGCOLOR=#FFFFFF>
+ \\(.+\\)
+</td>")
+(defconst mixi-event-place-regexp
+ "<td BGCOLOR=#FFFFFF ALIGN=center NOWRAP>³«ºÅ¾ì½ê</td>
+<td BGCOLOR=#FFFFFF>
+ \\(.+\\)
+</td>")
+(defconst mixi-event-detail-regexp
+ "<td BGCOLOR=#FFFFFF ALIGN=center NOWRAP>¾ÜºÙ</td>
+<td BGCOLOR=#FFFFFF><table BORDER=0 CELLSPACING=0 CELLPADDING=5><tr><td CLASS=h120>\\(.+\\)</td></tr></table></td>")
+(defconst mixi-event-limit-regexp
+ "<td BGCOLOR=#FFFFFF ALIGN=center NOWRAP>Ê罸´ü¸Â</td>
+<td BGCOLOR=#FFFFFF> \\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü</td>")
+(defconst mixi-event-members-regexp
+ "<td BGCOLOR=#FFFFFF ALIGN=center NOWRAP>»²²Ã¼Ô</td>
+<td BGCOLOR=#FFFFFF>
+<table BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100%>
+<tr>
+<td> \\(.+\\)</td>")
+
+(defun mixi-event-realize (event)
+ "Realize a EVENT."
+ ;; FIXME: Check a expiration of cache?
+ (unless (mixi-object-realize-p event)
+ (with-mixi-retrieve (mixi-event-page event)
+ (if (string-match mixi-event-time-regexp buffer)
+ (mixi-event-set-time
+ event (encode-time 0 (string-to-number (match-string 5 buffer))
+ (string-to-number (match-string 4 buffer))
+ (string-to-number (match-string 3 buffer))
+ (string-to-number (match-string 2 buffer))
+ (string-to-number (match-string 1 buffer))))
+ (signal 'error (list 'cannot-find-time event)))
+ (if (string-match mixi-event-title-regexp buffer)
+ (mixi-event-set-title event (match-string 1 buffer))
+ (signal 'error (list 'cannot-find-title event)))
+ (if (string-match mixi-event-owner-regexp buffer)
+ (mixi-event-set-owner event
+ (mixi-make-friend (match-string 1 buffer)
+ (match-string 2 buffer)))
+ (signal 'error (list 'cannot-find-owner event)))
+ (if (string-match mixi-event-date-regexp buffer)
+ (mixi-event-set-date event (match-string 1 buffer))
+ (signal 'error (list 'cannot-find-date event)))
+ (if (string-match mixi-event-place-regexp buffer)
+ (mixi-event-set-place event (match-string 1 buffer))
+ (signal 'error (list 'cannot-find-place event)))
+ (if (string-match mixi-event-detail-regexp buffer)
+ (mixi-event-set-detail event (match-string 1 buffer))
+ (signal 'error (list 'cannot-find-detail event)))
+ (when (string-match mixi-event-limit-regexp buffer)
+ (mixi-event-set-limit
+ event (encode-time 0 0 0 (string-to-number (match-string 3 buffer))
+ (string-to-number (match-string 2 buffer))
+ (string-to-number (match-string 1 buffer)))))
+ (if (string-match mixi-event-members-regexp buffer)
+ (mixi-event-set-members event (match-string 1 buffer))
+ (signal 'error (list 'cannot-find-members event))))
+ (mixi-object-touch event)))
+
+(defun mixi-event-community (event)
+ "Return the community of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (aref (cdr event) 1))
+
+(defun mixi-event-id (event)
+ "Return the id of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (aref (cdr event) 2))
+
+(defun mixi-event-time (event)
+ "Return the time of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (mixi-event-realize event)
+ (aref (cdr event) 3))
+
+(defun mixi-event-title (event)
+ "Return the title of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (mixi-event-realize event)
+ (aref (cdr event) 4))
+
+(defun mixi-event-owner (event)
+ "Return the owner of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (mixi-event-realize event)
+ (aref (cdr event) 5))
+
+(defun mixi-event-date (event)
+ "Return the date of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (mixi-event-realize event)
+ (aref (cdr event) 6))
+
+(defun mixi-event-place (event)
+ "Return the place of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (mixi-event-realize event)
+ (aref (cdr event) 7))
+
+(defun mixi-event-detail (event)
+ "Return the detail of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (mixi-event-realize event)
+ (aref (cdr event) 8))
+
+(defun mixi-event-limit (event)
+ "Return the limit of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (mixi-event-realize event)
+ (aref (cdr event) 9))
+
+(defun mixi-event-members (event)
+ "Return the members of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (mixi-event-realize event)
+ (aref (cdr event) 10))
+
+(defun mixi-event-set-time (event time)
+ "Set the time of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (aset (cdr event) 3 time))
+
+(defun mixi-event-set-title (event title)
+ "Set the title of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (aset (cdr event) 4 title))
+
+(defun mixi-event-set-owner (event owner)
+ "Set the owner of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (unless (mixi-friend-p owner)
+ (signal 'wrong-type-argument (list 'mixi-friend-p owner)))
+ (aset (cdr event) 5 owner))
+
+(defun mixi-event-set-date (event date)
+ "Set the date of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (aset (cdr event) 6 date))
+
+(defun mixi-event-set-place (event place)
+ "Set the place of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (aset (cdr event) 7 place))
+
+(defun mixi-event-set-detail (event detail)
+ "Set the detail of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (aset (cdr event) 8 detail))
+
+(defun mixi-event-set-limit (event limit)
+ "Set the limit of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (aset (cdr event) 9 limit))
+
+(defun mixi-event-set-members (event members)
+ "Set the members of EVENT."
+ (unless (mixi-event-p event)
+ (signal 'wrong-type-argument (list 'mixi-event-p event)))
+ (aset (cdr event) 10 members))
+
+;; Bbs object.
+(defalias 'mixi-bbs-owner 'mixi-object-owner)
+(defalias 'mixi-bbs-id 'mixi-object-id)
+(defalias 'mixi-bbs-time 'mixi-object-time)
+(defalias 'mixi-bbs-title 'mixi-object-title)
+(defalias 'mixi-bbs-content 'mixi-object-content)
+
+(defmacro mixi-bbs-list-page (community)
`(concat "/list_bbs.pl?page=%d"
"&id=" (mixi-community-id ,community)))
-(defconst mixi-topic-list-regexp
- "<a href=view_bbs\\.pl\\?id=\\([0-9]+\\)")
+(defconst mixi-bbs-list-regexp
+ "<a href=view_\\(bbs\\|event\\)\\.pl\\?id=\\([0-9]+\\)")
-(defun mixi-get-topics (community &optional max-numbers)
- "Get topics of COMMUNITY."
+(defun mixi-get-bbses (community &optional range)
+ "Get bbese of COMMUNITY."
(unless (mixi-community-p community)
(signal 'wrong-type-argument (list 'mixi-community-p community)))
- (let ((items (mixi-get-matched-items (mixi-topic-list-page community)
- max-numbers
- mixi-topic-list-regexp)))
+ (let ((items (mixi-get-matched-items (mixi-bbs-list-page community)
+ mixi-bbs-list-regexp
+ range)))
(mapcar (lambda (item)
- (mixi-make-topic community (nth 0 item)))
+ (let ((name (nth 0 item)))
+ (when (string= name "bbs")
+ (setq name "topic"))
+ (let ((func (intern (concat "mixi-make-" name))))
+ (funcall func community (nth 1 item)))))
items)))
-(defmacro mixi-new-topic-list-page ()
+(defmacro mixi-new-bbs-list-page ()
`(concat "/new_bbs.pl?page=%d"))
-(defconst mixi-new-topic-list-regexp
- "<a href=\"view_bbs\\.pl\\?id=\\([0-9]+\\)&comment_count=[0-9]+&comm_id=\\([0-9]+\\)\" class=\"new_link\">")
+(defconst mixi-new-bbs-list-regexp
+ "<a href=\"view_\\(bbs\\|event\\)\\.pl\\?id=\\([0-9]+\\)&comment_count=[0-9]+&comm_id=\\([0-9]+\\)\" class=\"new_link\">")
-(defun mixi-get-new-topics (&optional max-numbers)
+(defun mixi-get-new-bbses (&optional range)
"Get new topics."
- (let ((items (mixi-get-matched-items (mixi-new-topic-list-page)
- max-numbers
- mixi-new-topic-list-regexp)))
+ (let ((items (mixi-get-matched-items (mixi-new-bbs-list-page)
+ mixi-new-bbs-list-regexp
+ range)))
(mapcar (lambda (item)
- (mixi-make-topic (mixi-make-community (nth 1 item))
- (nth 0 item)))
+ (let ((name (nth 0 item)))
+ (when (string= name "bbs")
+ (setq name "topic"))
+ (let ((func (intern (concat "mixi-make-" name))))
+ (funcall func (mixi-make-community (nth 2 item))
+ (nth 1 item)))))
+ items)))
+
+(defmacro mixi-search-bbs-list-page (keyword)
+ `(concat "/search_topic.pl?page=%d&type=top&submit=search"
+ "&keyword=" (mixi-url-encode-and-quote-percent-string keyword)
+ "&community_id=0&category_id=0"))
+
+(defconst mixi-search-bbs-list-regexp
+ "<a href=\"view_\\(bbs\\|event\\)\\.pl\\?id=\\([0-9]+\\)&comm_id=\\([0-9]+\\)\"><img src=http://img\\.mixi\\.jp/img/shbtn\\.gif ALT=¾ÜºÙ¤ò¸«¤ë BORDER=0 WIDTH=104 HEIGHT=19></a>")
+
+;; FIXME: Support community and category.
+(defun mixi-search-bbses (keyword &optional range)
+ (let ((items (mixi-get-matched-items (mixi-search-bbs-list-page keyword)
+ mixi-search-bbs-list-regexp
+ range)))
+ (mapcar (lambda (item)
+ (let ((name (nth 0 item)))
+ (when (string= name "bbs")
+ (setq name "topic"))
+ (let ((func (intern (concat "mixi-make-" name))))
+ (funcall func (mixi-make-community (nth 2 item))
+ (nth 1 item)))))
items)))
;; Comment object.
(aref (cdr comment) 3))
(defun mixi-diary-comment-list-page (diary)
- (concat "/view_diary.pl?page=%d"
+ (concat "/view_diary.pl?full=1"
"&id=" (mixi-diary-id diary)
"&owner_id=" (mixi-friend-id (mixi-diary-owner diary))))
?\\(
+\\|<font color=\"#f2ddb7\">| </font><a href=\"delete_bbs_comment\\.pl\\?id=[0-9]+&comm_id=[0-9]+&comment_id=[0-9]+\">ºï½ü</a>
\\|\\)</td>
</tr>
<tr>
</td>
</tr>")
-(defun mixi-get-comments (parent &optional max-numbers)
+(defun mixi-event-comment-list-page (event)
+ (concat "/view_event.pl?page=all"
+ "&id=" (mixi-event-id event)
+ "&comm_id=" (mixi-community-id (mixi-event-community event))))
+
+;; FIXME: Split regexp to time, owner(id and nick) and contents.
+(defconst mixi-event-comment-list-regexp
+ "<tr>
+<td ROWSPAN=2 ALIGN=center BGCOLOR=#F2DDB7 WIDTH=110>
+\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü<br>
+\\([0-9]+\\):\\([0-9]+\\)<br>
+\\(</td>\\)
+\\(<td BGCOLOR=#FDF9F2>\\)
+<font COLOR=#F8A448><b>[^<]+</b> :</font>
+<a HREF=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.*\\)</a>
+
+</td>
+</tr>
+\\(<tr>\\)
+<td ALIGN=center BGCOLOR=#FFFFFF>
+<table BORDER=0 CELLSPACING=0 CELLPADDING=5 WIDTH=500>
+<tr><td CLASS=h120>\\(.+\\)</td></tr>
+</table>
+</td>
+</tr>")
+
+(defun mixi-get-comments (parent &optional range)
"Get comments of PARENT."
(unless (mixi-object-p parent)
(signal 'wrong-type-argument (list 'mixi-object-p parent)))
(regexp (eval (intern (concat mixi-object-prefix name
"-comment-list-regexp")))))
(let ((items (mixi-get-matched-items
- (funcall list-page parent) max-numbers regexp)))
+ (funcall list-page parent) regexp)))
+ (let (list)
+ (catch 'stop
+ (mapc (lambda (item)
+ (when (and (numberp range)
+ (>= (length list) range))
+ (throw 'stop nil))
+ (setq list (cons item list)))
+ (reverse items)))
+ (setq items (reverse list)))
(mapcar (lambda (item)
(mixi-make-comment parent (mixi-make-friend
(nth 7 item) (nth 8 item))
(defconst mixi-new-comment-list-regexp
"<a href=\"view_diary\\.pl\\?id=\\([0-9]+\\)&owner_id=\\([0-9]+\\)&comment_count=[0-9]+\" class=\"new_link\">")
-(defun mixi-get-new-comments (&optional max-numbers)
+(defun mixi-get-new-comments (&optional range)
"Get new comments."
(let ((items (mixi-get-matched-items (mixi-new-comment-list-page)
- max-numbers
- mixi-new-comment-list-regexp)))
+ mixi-new-comment-list-regexp
+ range)))
(mapcar (lambda (item)
- ;; FIXME: Return comments?
(mixi-make-diary (mixi-make-friend (nth 1 item)) (nth 0 item)))
items)))
(signal 'wrong-number-of-arguments
(list 'mixi-get-messages (length args))))
(let ((box (nth 0 args))
- (max-numbers (nth 1 args)))
+ (range (nth 1 args)))
(when (or (not (mixi-message-box-p box))
- (mixi-message-box-p max-numbers))
+ (mixi-message-box-p range))
(setq box (nth 1 args))
- (setq max-numbers (nth 0 args)))
+ (setq range (nth 0 args)))
(let ((items (mixi-get-matched-items
(mixi-message-list-page
(when box (mixi-message-box-name box)))
- max-numbers
- mixi-message-list-regexp)))
+ mixi-message-list-regexp
+ range)))
(mapcar (lambda (item)
(mixi-make-message (nth 0 item) (nth 1 item)))
items))))
(signal 'wrong-number-of-arguments
(list 'mixi-get-introduction (length args))))
(let ((friend (nth 0 args))
- (max-numbers (nth 1 args)))
- (when (or (not (mixi-friend-p friend)) (mixi-friend-p max-numbers))
+ (range (nth 1 args)))
+ (when (or (not (mixi-friend-p friend)) (mixi-friend-p range))
(setq friend (nth 1 args))
- (setq max-numbers (nth 0 args)))
+ (setq range (nth 0 args)))
(unless (or (null friend) (mixi-friend-p friend))
(signal 'wrong-type-argument (list 'mixi-friend-p friend)))
(let* ((regexp (if friend mixi-introduction-list-regexp
mixi-my-introduction-list-regexp))
(items (mixi-get-matched-items (mixi-introduction-list-page friend)
- max-numbers
- regexp)))
+ regexp
+ range)))
(mapcar (lambda (item)
(mixi-make-introduction (or friend (mixi-make-me))
(mixi-make-friend (nth 0 item)
;;; Commentary:
+;; If you have bug reports and/or suggestions for improvement, please
+;; send them via <URL:http://mixi.jp/view_community.pl?id=1596390>.
+
;;; Code:
(require 'mixi)
(require 'shimbun)
-(luna-define-class shimbun-mixi (shimbun) ())
+(eval-and-compile
+ (luna-define-class shimbun-mixi (shimbun) (comment-cache))
+ (luna-define-internal-accessors 'shimbun-mixi))
(defcustom shimbun-mixi-group-alist '(("new-diaries" . mixi-get-new-diaries)
("new-comments" . mixi-get-new-comments)
- ("new-topics" . mixi-get-new-topics)
+ ("new-bbses" . mixi-get-new-bbses)
("messages" . mixi-get-messages)
("my-diaries" . "/home.pl"))
"*An alist of mixi shimbun group definition.
Each element looks like (NAME . URL) or (NAME . FUNCTION).
NAME is a shimbun group name.
URL is the URL for mixi access point of the group. When URL is friend's, get
-his/her diaries as article. When community's, get its topics. When diary's
-or topic's, get its comments.
-FUNCTION is the function for getting articles."
+his/her diaries as article. When community's, get its BBSes. When diary's
+or BBS's, get its comments.
+FUNCTION is the function which has one `range' argument and returns the list
+of mixi object."
:group 'shimbun
:type '(repeat (cons :fromat "%v"
(string :tag "Group name")
(radio (string :tag "URL")
(const :tag "New diaries" mixi-get-new-diaries)
(const :tag "New comments" mixi-get-new-comments)
- (const :tag "New topics" mixi-get-new-topics)
+ (const :tag "New BBSes" mixi-get-new-bbses)
(const :tag "Messages" mixi-get-messages)
(function :tag "Other function")))))
+;; FIXME: Don't use this user option.
(defcustom shimbun-mixi-page-articles 10
"*How many articles are there in one page."
:group 'shimbun
:type 'integer)
(defcustom shimbun-mixi-get-comment-p t
- "*If non-nil, get diaries or topics together with its comments."
+ "*If non-nil, get diaries or BBSes together with its comments."
+ :group 'shimbun
+ :type 'boolean)
+
+(defcustom shimbun-mixi-logout-p nil
+ "*If non-ni, Logout from mixi when shimbun server was closed."
:group 'shimbun
:type 'boolean)
+(defvar shimbun-mixi-x-face-alist
+ '(("default" . "X-Face: CY;j#FoBnpK^37`-IoJvN!J^u;GciiPmMQ@T)~RP1]t8iv?v)/bVI:I\"F!JfWJvhM5{zY!=
+ h.d+'g\\I{D>Ocy?Rc4uYUyOZj2%2Kl>,x-!MCSsyi3!L}psrrC1jlF,O?Ui>qf)X;sBz`/}\\066X%$
+ siG'|4K!2?==|oB&#E'5GGH\\#z[muyQ")))
+
+(luna-define-method initialize-instance :after ((shimbun shimbun-mixi)
+ &rest init-args)
+ (shimbun-mixi-set-comment-cache-internal shimbun
+ (make-hash-table :test 'equal))
+ shimbun)
+
+(luna-define-method shimbun-close :after ((shimbun shimbun-mixi))
+ (shimbun-mixi-set-comment-cache-internal shimbun nil)
+ (when shimbun-mixi-logout-p
+ (mixi-logout)))
+
(luna-define-method shimbun-groups ((shimbun shimbun-mixi))
(mapcar 'car shimbun-mixi-group-alist))
(defun shimbun-mixi-make-subject (object)
(let ((class (mixi-object-class object)))
- (if (eq class 'mixi-comment)
- (concat "Re: " (mixi-object-title (mixi-comment-parent object)))
- (mixi-object-title object))))
+ (cond ((eq class 'mixi-comment)
+ (concat "Re: " (shimbun-mixi-make-subject
+ (mixi-comment-parent object))))
+ (t (mixi-object-title object)))))
(defun shimbun-mixi-make-from (object)
(let ((owner (mixi-object-owner object)))
(mixi-expand-url (mixi-diary-page object)))
((eq class 'mixi-topic)
(mixi-expand-url (mixi-topic-page object)))
+ ((eq class 'mixi-event)
+ (mixi-expand-url (mixi-event-page object)))
((eq class 'mixi-comment)
(concat (shimbun-mixi-make-xref (mixi-comment-parent object))
"#comment"))
((eq class 'mixi-message)
(mixi-expand-url (mixi-message-page object))))))
+(defun shimbun-mixi-make-body (object)
+ (mixi-object-content object))
+
(defun shimbun-mixi-get-headers (shimbun objects &optional range)
(when objects
(let (headers)
(when (mixi-object-p object)
(let ((class (mixi-object-class object))
(id (shimbun-mixi-make-message-id object)))
- (when (and (eq class 'mixi-comment)
- (shimbun-search-id shimbun id))
- (throw 'stop nil))
(push
(shimbun-create-header
0
headers)
(when (and shimbun-mixi-get-comment-p
(or (eq class 'mixi-diary)
- (eq class 'mixi-topic)))
+ (eq class 'mixi-topic)
+ (eq class 'mixi-event)))
(let ((comments (mixi-get-comments object range)))
(mapc (lambda (header)
(push header headers))
(shimbun-mixi-get-headers shimbun
- comments)))))))
+ comments))))
+ (when (eq class 'mixi-comment)
+ (puthash id (mixi-comment-content object)
+ (shimbun-mixi-comment-cache-internal
+ shimbun))))))
objects))
headers)))
(cond ((eq class 'mixi-friend)
(setq objects (mixi-get-diaries object range)))
((eq class 'mixi-community)
- (setq objects (mixi-get-topics object range)))
- ((or (eq class 'mixi-diary) (eq class 'mixi-topic))
+ (setq objects (mixi-get-bbses object range)))
+ ((or (eq class 'mixi-diary)
+ (eq class 'mixi-topic)
+ (eq class 'mixi-event))
(setq objects (mixi-get-comments object range)))
(t (error (concat (symbol-name class)
" is not supported yet.")))))
(setq objects (funcall url-or-function range)))
(shimbun-sort-headers (shimbun-mixi-get-headers shimbun objects range))))
-(defun shimbun-comment-article (url header)
- (let ((parent (mixi-make-object-from-url url))
- (date (shimbun-header-date header))
- (message-id (shimbun-header-id header)))
- (catch 'found
- (mapc (lambda (comment)
- (let ((id (mixi-friend-id (mixi-comment-owner comment)))
- (time (shimbun-mixi-make-date comment)))
- (when (and (string= time date)
- (string-match (concat "^<[0-9]+\\." id "@")
- message-id))
- ;; FIXME: Concat parent's information?
- (throw 'found (mixi-comment-content comment)))))
- ;; FIXME: Limit range?
- (mixi-get-comments parent)))))
+(defun shimbun-comment-article (url shimbun header)
+ (let* ((message-id (shimbun-header-id header))
+ (cache (shimbun-mixi-comment-cache-internal shimbun))
+ (article (gethash message-id cache)))
+ (unless (stringp article)
+ (let ((parent (mixi-make-object-from-url url)))
+ (mapc (lambda (comment)
+ (let ((id (shimbun-mixi-make-message-id comment))
+ ;; FIXME: Concat parent's information?
+ (content (mixi-comment-content comment)))
+ (puthash id content cache)
+ (when (string= id message-id)
+ (setq article content))))
+ (mixi-get-comments parent))))
+ article))
(luna-define-method shimbun-article ((shimbun shimbun-mixi)
header &optional outbuf)
(or (with-temp-buffer
(let* ((url (shimbun-article-url shimbun header))
(article (if (string-match "#comment$" url)
- (shimbun-comment-article url header)
+ (shimbun-comment-article url shimbun header)
;; FIXME: Concat community information?
- (mixi-object-content
+ (shimbun-mixi-make-body
(mixi-make-object-from-url url)))))
(when (stringp article)
(insert article)))