;; * mixi-get-logs
;; * mixi-get-diaries
;; * mixi-get-new-diaries
+;; * mixi-search-diaries
;; * mixi-get-communities
;; * mixi-get-bbses
;; * mixi-get-new-bbses
;; 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)
"&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>")
(defconst mixi-diary-time-regexp
;; 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 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)))))
(mixi-object-touch diary)))
(defun mixi-diary-owner (diary)
(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)))
+
;; Community object.
(defvar mixi-community-cache (make-hash-table :test 'equal))
(defun mixi-make-community (id &optional name)