(goto-char (point-min))
(while (re-search-forward "\r" nil t)
(replace-match "\n" t t)))
+ ;; FIXME: Decode entities.
(buffer-string)))
;; Cache.
(mixi-object-name object) "-id"))))
(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)))
+
(defun mixi-object-set-timestamp (object timestamp)
"Set the timestamp of OBJECT."
(unless (mixi-object-p object)
(defmacro mixi-object-touch (object)
`(mixi-object-set-timestamp ,object (current-time)))
+(defconst mixi-object-url-regexp
+ "/\\(show\\|view\\)_\\([a-z]+\\)\\.pl")
+
+(defun mixi-make-object-from-url (url)
+ "Return a mixi object from URL."
+ (when (string-match mixi-object-url-regexp url)
+ (let ((name (match-string 2 url)))
+ (when (string= name "bbs")
+ (setq name "topic"))
+ (let ((func (intern (concat mixi-object-prefix "make-" name
+ "-from-url"))))
+ (funcall func url)))))
+
;; Friend object.
(defvar mixi-friend-cache (make-hash-table :test 'equal))
(defun mixi-make-friend (id &optional nick)
mixi-friend-cache))
(defun mixi-make-me ()
+ "Return a my object."
(unless mixi-me
(with-mixi-retrieve "/home.pl"
(if (string-match mixi-my-id-regexp buffer)
(signal 'error (list 'who-am-i)))))
mixi-me)
+(defconst mixi-friend-url-regexp
+ "/show_friend\\.pl\\?id=\\([0-9]+\\)")
+
+(defun mixi-make-friend-from-url (url)
+ "Return a friend object from URL."
+ (when (string-match mixi-friend-url-regexp url)
+ (let ((id (match-string 1 url)))
+ (mixi-make-friend id))))
+
(defmacro mixi-friend-p (friend)
`(eq (mixi-object-class ,friend) 'mixi-friend))
(cons 'mixi-diary (vector nil owner id nil nil nil))
mixi-diary-cache)))
+(defconst mixi-diary-url-regexp
+ "/view_diary\\.pl\\?id=\\([0-9]+\\)&owner_id=\\([0-9]+\\)")
+
+(defun mixi-make-diary-from-url (url)
+ "Return a diary object from URL."
+ (when (string-match mixi-diary-url-regexp url)
+ (let ((id (match-string 1 url))
+ (owner-id (match-string 2 url)))
+ (mixi-make-diary (mixi-make-friend owner-id) id))))
+
(defmacro mixi-diary-p (diary)
`(eq (mixi-object-class ,diary) 'mixi-diary))
nil nil nil nil))
mixi-community-cache))
+(defconst mixi-community-url-regexp
+ "/view_community\\.pl\\?id=\\([0-9]+\\)")
+
+(defun mixi-make-community-from-url (url)
+ "Return a community object from URL."
+ (when (string-match mixi-community-url-regexp url)
+ (let ((id (match-string 1 url)))
+ (mixi-make-community id))))
+
(defmacro mixi-community-p (community)
`(eq (mixi-object-class ,community) 'mixi-community))
(defmacro mixi-community-page (community)
`(concat "/view_community.pl?id=" (mixi-community-id ,community)))
+;; FIXME: Not community specific.
(defconst mixi-community-nodata-regexp
"^¥Ç¡¼¥¿¤¬¤¢¤ê¤Þ¤»¤ó")
(defconst mixi-community-name-regexp
(cons 'mixi-topic (vector nil community id nil nil nil nil))
mixi-topic-cache))
+(defconst mixi-topic-url-regexp
+ "/view_bbs\\.pl\\?id=\\([0-9]+\\)\\(&comment_count=[0-9]+\\)?&comm_id=\\([0-9]+\\)")
+
+(defun mixi-make-topic-from-url (url)
+ "Return a topic object from URL."
+ (when (string-match mixi-topic-url-regexp url)
+ (let ((id (match-string 1 url))
+ (community-id (match-string 3 url)))
+ (mixi-make-topic (mixi-make-community community-id) id))))
+
(defmacro mixi-topic-p (topic)
`(eq (mixi-object-class ,topic) 'mixi-topic))
(cons 'mixi-message (vector nil id box nil nil nil nil))
mixi-message-cache))
+(defconst mixi-message-url-regexp
+ "/view_message\\.pl\\?id=\\([a-z0-9]+\\)&box=\\([a-z]+\\)")
+
+(defun mixi-make-message-from-url (url)
+ "Return a message object from URL."
+ (when (string-match mixi-message-url-regexp url)
+ (let ((id (match-string 1 url))
+ (box (match-string 2 url)))
+ (mixi-make-message id box))))
+
(defmacro mixi-message-p (message)
`(eq (mixi-object-class ,message) 'mixi-message))