X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=mixi-utils.el;h=aad03b8d0efb6e3ad0a57433d7b57e8d7359eeab;hb=c67537056dbe67ab33587553ca3098dfebb15576;hp=e65c6d9574ec9744852bd637019369a8a30d0a54;hpb=9443267dab60ae19ddfa69e36ce38df8ab8860b9;p=elisp%2Fmixi.git diff --git a/mixi-utils.el b/mixi-utils.el index e65c6d9..aad03b8 100644 --- a/mixi-utils.el +++ b/mixi-utils.el @@ -1,6 +1,6 @@ -;; mixi-utils.el --- Utilities for mixi object +;; mixi-utils.el --- Utilities for mixi object -*- coding: euc-jp -*- -;; Copyright (C) 2007 OHASHI Akira +;; Copyright (C) 2007, 2008 OHASHI Akira ;; Author: OHASHI Akira ;; Keywords: hypermedia @@ -18,9 +18,9 @@ ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with this program; if not, you can either send email to this -;; program's maintainer or write to: The Free Software Foundation, -;; Inc.; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +;; along with GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. ;;; Commentary: @@ -41,6 +41,20 @@ (put 'with-mixi-class 'lisp-indent-function 'defun) (put 'with-mixi-class 'edebug-form-spec '(body)) +(defun mixi-make-objects (url-or-function &optional range) + (if (stringp url-or-function) + (let ((object (mixi-make-object-from-url url-or-function))) + (with-mixi-class object + (cond ((eq class 'mixi-friend) + (mixi-get-diaries object range)) + ((eq class 'mixi-community) + (mixi-get-bbses object range)) + ((mixi-parent-p object) + (mixi-get-comments object range)) + (t (error (concat (symbol-name class) + " is not supported yet.")))))) + (funcall url-or-function range))) + (defun mixi-make-title (object &optional add-parent) (with-mixi-class object (cond ((eq class 'mixi-comment) @@ -53,22 +67,33 @@ (subject (mixi-object-title object)) (suffix (when add-parent (concat " (" - (if (eq class 'mixi-diary) - (mixi-friend-nick - (mixi-diary-owner object)) - (mixi-community-name - (mixi-bbs-community object))) + (cond ((eq class 'mixi-diary) + (mixi-friend-nick + (mixi-diary-owner object))) + ((eq class 'mixi-news) + (mixi-news-media object)) + (t + (mixi-community-name + (mixi-bbs-community object)))) ")")))) (concat prefix subject suffix)))))) -(defun mixi-make-author (object) +(defun mixi-make-author (object &optional add-comment-count) (with-mixi-class object - (if (eq class 'mixi-news) - (mixi-news-media object) - (let ((owner (if (eq class 'mixi-log) - (mixi-log-friend object) - (mixi-object-owner object)))) - (mixi-friend-nick owner))))) + (cond ((eq class 'mixi-news) + (mixi-news-media object)) + ((and add-comment-count + (eq class 'mixi-comment) + (mixi-bbs-p (mixi-comment-parent object))) + (concat (mixi-comment-count object) " " + (mixi-friend-nick (mixi-comment-owner object)))) + ((eq class 'mixi-release) + "mixi±¿±Ä»ö̳¶É") + (t + (let ((owner (if (eq class 'mixi-log) + (mixi-log-friend object) + (mixi-object-owner object)))) + (mixi-friend-nick owner)))))) (defun mixi-make-date (object) (let* ((time (mixi-object-time object)) @@ -80,10 +105,10 @@ month " " (format-time-string "%Y %H:%M:%S %z" time)))) -(defun mixi-make-message-id (object) +(defun mixi-make-id-1 (object) (with-mixi-class object (concat - (format-time-string "<%Y%m%d%H%M" (mixi-object-time object)) "." + (format-time-string "%Y%m%d%H%M" (mixi-object-time object)) "." (cond ((eq class 'mixi-comment) (concat (mixi-friend-id (mixi-comment-owner object)) "@" (mixi-object-id (mixi-comment-parent object)) "." @@ -91,12 +116,22 @@ (mixi-comment-parent object))) ".")) ((eq class 'mixi-log) (concat (mixi-friend-id (mixi-log-friend object)) "@")) + ((eq class 'mixi-release) + (concat (md5 (mixi-release-title object)) "@")) (t (concat (mixi-object-id object) "@" (if (eq class 'mixi-news) (mixi-news-media-id object) (mixi-object-id (mixi-object-owner object))) "."))) - (mixi-object-name object) ".mixi.jp>"))) + (mixi-object-name object)))) + +(defun mixi-make-message-id (object) + (format "<%s.mixi.jp>" (mixi-make-id-1 object))) + +(defun mixi-make-tag-uri (object) + (format "tag:mixi.jp,%s:%s" + (format-time-string "%Y-%m-%d" (mixi-object-time object)) + (mixi-make-id-1 object))) (defun mixi-make-url (object) (with-mixi-class object @@ -113,41 +148,50 @@ (mixi-expand-url (mixi-message-page object))) ((eq class 'mixi-news) (mixi-news-page object)) + ((eq class 'mixi-release) + (let ((url (mixi-release-list-page))) + (mixi-expand-url (substring url 0 + (string-match "?" url))))) ((eq class 'mixi-log) (mixi-expand-url (mixi-friend-page (mixi-log-friend object)))) ((eq class 'mixi-friend) (mixi-expand-url (mixi-friend-page object)))))) +(defun mixi-make-encoded-url (object) + (mixi-url-encode-string (mixi-make-url object))) + (defun mixi-make-content (object) (with-mixi-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 "
" - "
³«ºÅÆü»þ¡§
" - "
" (mixi-event-date object) "
\n" - "
³«ºÅ¾ì½ê¡§
" - "
" (mixi-event-place object) "
\n" - "
¾ÜºÙ¡§
" - "
" (mixi-event-detail object) "
\n" - "
Ê罸´ü¸Â¡§
" - "
" limit "
\n" - "
»²²Ã¼Ô¡§
" - "
" (mixi-event-members object) "
\n" - "
"))) + (concat "
" + "
³«ºÅÆü»þ¡§
" + "
" (mixi-event-date object) "
\n" + "
³«ºÅ¾ì½ê¡§
" + "
" (mixi-event-place object) "
\n" + "
¾ÜºÙ¡§
" + "
" (mixi-event-detail object) "
\n" + "
Ê罸´ü¸Â¡§
" + "
" (mixi-event-limit object) "
\n" + "
»²²Ã¼Ô¡§
" + "
" (mixi-event-members object) "
\n" + "
")) ((eq class 'mixi-friend) (if (mixi-object-realized-p object) (let ((sex (if (eq (mixi-friend-sex object) 'male) "ÃË" "½÷")) - (age (number-to-string (mixi-friend-age object))) - (birthday - (concat (mapconcat (lambda (number) - (number-to-string number)) - (mixi-friend-birthday object) "·î") - "Æü")) - (blood-type (symbol-name - (mixi-friend-blood-type object))) + (age (if (numberp (mixi-friend-age object)) + (number-to-string (mixi-friend-age object)) + "??")) + (birthday (if (mixi-friend-birthday object) + (concat + (mapconcat (lambda (number) + (number-to-string number)) + (mixi-friend-birthday object) + "·î") "Æü") + "??·î??Æü")) + (blood-type (if (mixi-friend-blood-type object) + (symbol-name + (mixi-friend-blood-type object)) + "?")) (hobby (mapconcat 'identity (mixi-friend-hobby object) ", "))) (concat "
" @@ -176,6 +220,8 @@ "
")) (concat "¥×¥í¥Õ¥£¡¼¥ë¤òɽ¼¨¤¹¤ë"))) + ((eq class 'mixi-log) + (mixi-make-content (mixi-log-friend object))) (t (mixi-object-content object))))) (defun mixi-make-reply-to (object) @@ -202,7 +248,36 @@ (mixi-friend-id (mixi-message-owner object)))) ((or (eq class 'mixi-friend) (eq class 'mixi-log)) (concat mixi-reply-to "message;" - (mixi-friend-id object)))))))) + (mixi-friend-id object))) + (t + (concat mixi-reply-to "diary"))))))) + +(defconst mixi-to-regexp + "^mixi;\\([a-z]+\\);?\\([a-z0-9]+\\)?;?\\([0-9]+\\)?;?\\([0-9]+\\)?") + +(defun mixi-send-mail (to title content) + (when (string-match mixi-to-regexp to) + (let ((method (match-string 1 to))) + (cond ((string= method "comment") + (let ((parent (match-string 2 to)) + (owner-id (match-string 3 to)) + (id (match-string 4 to))) + (if (string= parent "diary") + (mixi-post-comment + (mixi-make-diary (mixi-make-friend owner-id) id) content) + (let ((func (intern + (concat mixi-object-prefix "make-" parent)))) + (mixi-post-comment + (funcall func (mixi-make-community owner-id) id) + content))))) + ((string= method "topic") + (mixi-post-topic (mixi-make-community (match-string 2 to)) + title content)) + ((string= method "diary") + (mixi-post-diary title content)) + ((string= method "message") + (mixi-post-message (mixi-make-friend (match-string 2 to)) + title content)))))) (provide 'mixi-utils)