;; mixi.el --- API libraries for accessing to mixi -*- coding: euc-jp -*-
-;; Copyright (C) 2005, 2006, 2007, 2008 OHASHI Akira
+;; Copyright (C) 2005, 2006, 2007, 2008, 2009 OHASHI Akira
;; Author: OHASHI Akira <bg66@koka-in.org>
;; Keywords: hypermedia
;; * mixi-get-friends
;; * mixi-get-favorites
;; * mixi-get-logs
+;; * mixi-get-self-logs
;; * mixi-get-recommended-friends (indies)
;; * mixi-get-diaries
;; * mixi-get-new-diaries
(autoload 'w3m-retrieve "w3m")
(autoload 'url-retrieve-synchronously "url"))
-(defconst mixi-revision "$Revision: 1.200 $")
+(defconst mixi-revision "$Revision: 1.205 $")
(defgroup mixi nil
"API library for accessing to mixi."
:type 'number
:group 'mixi)
+(defcustom mixi-replace-tab-and-space-to-nbsp t
+ "*If non-nil, replace tab and space to for keeping formatted."
+ :type 'boolean
+ :group 'mixi)
+
(defcustom mixi-cache-expires nil
"*Seconds for expiration of a cached object."
:type '(radio (integer :tag "Expired seconds")
(setq pos (+ (match-end 0) 1)))
string))
+(defun mixi-replace-tab-and-space-to-nbsp (string)
+ (when mixi-replace-tab-and-space-to-nbsp
+ (let ((pos 0))
+ (while (or (string-match "\t" string pos)
+ (string-match " " string pos))
+ (if (string= (match-string 0 string) "\t")
+ (setq string (replace-match (make-string tab-width ?\ )
+ nil nil string))
+ (setq string (replace-match " " nil nil string))
+ (setq pos (+ (match-end 0) 1))))
+ string)))
+
;; Object.
(defconst mixi-object-prefix "mixi-")
(signal 'wrong-type-argument (list 'mixi-log-p log)))
(aref (cdr log) 1))
-(defmacro mixi-log-list-page ()
- `(concat "/show_log.pl"))
+(defconst mixi-log-list-page "/show_log.pl")
(defconst mixi-log-list-regexp
- "\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\) <a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.*?\\)</a>")
+ "\\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\):\\([0-9]+\\)</span><span class=\"name\"><a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.*?\\)</a>")
-;;;###autoload
-(defun mixi-get-logs (&optional range)
- "Get logs."
- (let ((items (mixi-get-matched-items (mixi-log-list-page)
+(defun mixi-get-logs-internal (list-page &optional range)
+ (let ((items (mixi-get-matched-items list-page
mixi-log-list-regexp
- range)))
+ range))
+ (year (nth 5 (decode-time (current-time))))
+ (month (nth 4 (decode-time (current-time)))))
(mapcar (lambda (item)
- (mixi-make-log (mixi-make-friend (nth 5 item) (nth 6 item))
- (encode-time 0
- (string-to-number (nth 4 item))
- (string-to-number (nth 3 item))
- (string-to-number (nth 2 item))
- (string-to-number (nth 1 item))
- (string-to-number (nth 0 item)))))
+ (let ((month-of-item (string-to-number (nth 0 item))))
+ (when (> month-of-item month)
+ (decf year))
+ (setq month month-of-item)
+ (mixi-make-log (mixi-make-friend (nth 4 item) (nth 5 item))
+ (encode-time 0
+ (string-to-number (nth 3 item))
+ (string-to-number (nth 2 item))
+ (string-to-number (nth 1 item))
+ month year))))
items)))
+;;;###autoload
+(defun mixi-get-logs (&optional range)
+ "Get logs."
+ (mixi-get-logs-internal mixi-log-list-page range))
+
+(defconst mixi-log-self-list-page "/show_self_log.pl")
+
+;;;###autoload
+(defun mixi-get-self-logs (&optional range)
+ "Get self logs."
+ (mixi-get-logs-internal mixi-log-self-list-page range))
+
;; Recommended friend.
(defmacro mixi-recommended-friend-list-page ()
`(concat "http://indies.mixi.jp/recommend.pl"))
<h2>\\(.+?\\)\\(¤µ¤ó\\)?¤ÎÆüµ</h2>")
(defconst mixi-diary-title-regexp
"<div class=\"listDiaryTitle\">
-<dl class=\"clearfix\">
+<dl>
<dt>\\([^<\n]+\\)\\(<span>\\)?")
(defconst mixi-diary-time-regexp
"<dd>\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü\\([0-9]+\\):\\([0-9]+\\)</dd>")
(setq fields `(("post_key" . ,post-key)
("id" . ,(mixi-friend-id (mixi-make-me)))
("diary_title" . ,title)
- ("diary_body" . ,content)
+ ("diary_body" . ,(mixi-replace-tab-and-space-to-nbsp
+ content))
("submit" . "confirm")))
(with-mixi-post-form (mixi-post-diary-page) fields
(unless (re-search-forward mixi-post-succeed-regexp nil t)
(mixi-post-error 'cannot-find-key community)))
(setq fields `(("post_key" . ,post-key)
("bbs_title" . ,title)
- ("bbs_body" . ,content)
+ ("bbs_body" . ,(mixi-replace-tab-and-space-to-nbsp
+ content))
("submit" . "confirm")))
(with-mixi-post-form (mixi-post-topic-page community) fields
(unless (re-search-forward mixi-post-succeed-regexp nil t)
(setq fields
`(("post_key" . ,post-key)
("owner_id" . ,(mixi-friend-id (mixi-diary-owner parent)))
- ("comment_body" . ,content)
+ ("comment_body" . ,(mixi-replace-tab-and-space-to-nbsp
+ content))
("submit" . "confirm")))
(setq fields `(("post_key" . ,post-key)
- ("comment" . ,content)
+ ("comment" . ,(mixi-replace-tab-and-space-to-nbsp
+ content))
("submit" . "confirm"))))
(with-mixi-post-form (funcall page parent) fields
(unless (re-search-forward mixi-post-succeed-regexp nil t)
<dd>\\([0-9]+\\)ǯ\\([0-9]+\\)·î\\([0-9]+\\)Æü \\([0-9]+\\)»þ\\([0-9]+\\)ʬ</dd>")
(defconst mixi-message-owner-regexp
"<dt>º¹½Ð¿Í</dt>
-<dd>\\(
-<a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.*\\)</a>\\|mixi</dd>\\)")
+<dd>\\(<a href=\"show_friend\\.pl\\?id=\\([0-9]+\\)\">\\(.*\\)</a>\\|mixi</dd>\\)")
(defconst mixi-message-content-regexp
"<div id=\"message_body\" class=\"messageDetailBody\">\\(\\(.\\|\r?\n\\)*?\\)</div>")
(when ,box (concat "&box=" ,box))))
(defconst mixi-message-list-regexp
- "<a href=\"view_message\\.pl\\?id=\\(.+\\)&box=\\(.+\\)\">")
+ "<a href=\"view_message\\.pl\\?id=\\(.+\\)&box=\\([^&\"]+\\)")
;;;###autoload
(defun mixi-get-messages (&rest box-or-range)
(mixi-post-error 'cannot-find-key friend)))
(setq fields `(("post_key" . ,post-key)
("subject" . ,title)
- ("body" . ,content)
+ ("body" . ,(mixi-replace-tab-and-space-to-nbsp content))
("yes" . "¡¡Á÷¡¡¿®¡¡")
("submit" . "confirm")))
(with-mixi-post-form (mixi-post-message-page friend) fields
(unless (or (null parent) (mixi-echo-p parent))
(signal 'wrong-type-argument (list 'mixi-echo-p parent)))
(let (fields post-key)
- (with-mixi-retrieve (mixi-post-echo-page)
+ (with-mixi-retrieve (format (mixi-new-echo-list-page) 1)
(if (re-search-forward mixi-post-key-regexp nil t)
(setq post-key (match-string 1))
(mixi-post-error 'cannot-find-key)))