From: bg66 Date: Wed, 8 Nov 2006 01:32:41 +0000 (+0000) Subject: * mixi.el (mixi-object-url-regexp): New regexp. X-Git-Tag: cache-file-branchpoint~24 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=b3e1d55a222fc1591a95bb3105ee4fc0b88f5d8c;p=elisp%2Fmixi.git * mixi.el (mixi-object-url-regexp): New regexp. (mixi-friend-url-regexp): Ditto. (mixi-diary-url-regexp): Ditto. (mixi-topic-url-regexp): Ditto. (mixi-message-url-regexp): Ditto. (mixi-community-url-regexp): Ditto. (mixi-object-content): New function. (mixi-make-object-from-url): Ditto. (mixi-make-friend-from-url): Ditto. (mixi-make-diary-from-url): Ditto. (mixi-make-community-from-url): Ditto. (mixi-make-topic-from-url): Ditto. (mixi-make-message-from-url): Ditto. --- diff --git a/ChangeLog b/ChangeLog index 9bb9638..bcda9b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2006-11-08 OHASHI Akira + + * mixi.el (mixi-object-url-regexp): New regexp. + (mixi-friend-url-regexp): Ditto. + (mixi-diary-url-regexp): Ditto. + (mixi-topic-url-regexp): Ditto. + (mixi-message-url-regexp): Ditto. + (mixi-community-url-regexp): Ditto. + (mixi-object-content): New function. + (mixi-make-object-from-url): Ditto. + (mixi-make-friend-from-url): Ditto. + (mixi-make-diary-from-url): Ditto. + (mixi-make-community-from-url): Ditto. + (mixi-make-topic-from-url): Ditto. + (mixi-make-message-from-url): Ditto. + 2006-11-06 OHASHI Akira * mixi.el (mixi-expand-url): New macro. diff --git a/mixi.el b/mixi.el index 15314c6..a29e343 100644 --- a/mixi.el +++ b/mixi.el @@ -382,6 +382,7 @@ Increase this value when unexpected error frequently occurs." (goto-char (point-min)) (while (re-search-forward " " nil t) (replace-match "\n" t t))) + ;; FIXME: Decode entities. (buffer-string))) ;; Cache. @@ -461,6 +462,14 @@ Increase this value when unexpected error frequently occurs." (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) @@ -470,6 +479,19 @@ Increase this value when unexpected error frequently occurs." (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) @@ -479,6 +501,7 @@ Increase this value when unexpected error frequently occurs." 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) @@ -486,6 +509,15 @@ Increase this value when unexpected error frequently occurs." (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)) @@ -834,6 +866,16 @@ Increase this value when unexpected error frequently occurs." (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)) @@ -977,12 +1019,22 @@ Increase this value when unexpected error frequently occurs." 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 @@ -1204,6 +1256,16 @@ Increase this value when unexpected error frequently occurs." (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)) @@ -1510,6 +1572,16 @@ Increase this value when unexpected error frequently occurs." (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))