1 ;; mixi-utils.el --- Utilities for mixi object
3 ;; Copyright (C) 2007 OHASHI Akira
5 ;; Author: OHASHI Akira <bg66@koka-in.org>
6 ;; Keywords: hypermedia
8 ;; This file is *NOT* a part of Emacs.
10 ;; This program is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; This program is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with this program; if not, you can either send email to this
22 ;; program's maintainer or write to: The Free Software Foundation,
23 ;; Inc.; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29 ;; If you have bug reports and/or suggestions for improvement, please
30 ;; send them via <URL:http://mixi.jp/view_community.pl?id=1596390>.
36 (defvar mixi-reply-to nil)
38 (defmacro with-mixi-class (object &rest body)
39 `(let ((class (mixi-object-class ,object)))
41 (put 'with-mixi-class 'lisp-indent-function 'defun)
42 (put 'with-mixi-class 'edebug-form-spec '(body))
44 (defun mixi-make-title (object &optional add-parent)
45 (with-mixi-class object
46 (cond ((eq class 'mixi-comment)
47 (concat "Re: " (mixi-make-title
48 (mixi-comment-parent object) add-parent)))
50 (mixi-friend-nick (mixi-log-friend object)))
52 (let ((prefix (when (eq class 'mixi-event) "[¥¤¥Ù¥ó¥È]"))
53 (subject (mixi-object-title object))
54 (suffix (when add-parent
56 (if (eq class 'mixi-diary)
58 (mixi-diary-owner object))
60 (mixi-bbs-community object)))
62 (concat prefix subject suffix))))))
64 (defun mixi-make-author (object)
65 (with-mixi-class object
66 (if (eq class 'mixi-news)
67 (mixi-news-media object)
68 (let ((owner (if (eq class 'mixi-log)
69 (mixi-log-friend object)
70 (mixi-object-owner object))))
71 (mixi-friend-nick owner)))))
73 (defun mixi-make-date (object)
74 (let* ((time (mixi-object-time object))
75 (cts (current-time-string time))
76 (day-of-week (substring cts 0 3))
77 (month (substring cts 4 7)))
78 (concat day-of-week ", "
79 (format-time-string "%d" time) " "
81 (format-time-string "%Y %H:%M:%S %z" time))))
83 (defun mixi-make-message-id (object)
84 (with-mixi-class object
86 (format-time-string "<%Y%m%d%H%M" (mixi-object-time object)) "."
87 (cond ((eq class 'mixi-comment)
88 (concat (mixi-friend-id (mixi-comment-owner object)) "@"
89 (mixi-object-id (mixi-comment-parent object)) "."
90 (mixi-friend-id (mixi-object-owner
91 (mixi-comment-parent object))) "."))
93 (concat (mixi-friend-id (mixi-log-friend object)) "@"))
95 (concat (mixi-object-id object) "@"
96 (if (eq class 'mixi-news)
97 (mixi-news-media-id object)
98 (mixi-object-id (mixi-object-owner object))) ".")))
99 (mixi-object-name object) ".mixi.jp>")))
101 (defun mixi-make-url (object)
102 (with-mixi-class object
103 (cond ((eq class 'mixi-diary)
104 (mixi-expand-url (mixi-diary-page object)))
105 ((eq class 'mixi-topic)
106 (mixi-expand-url (mixi-topic-page object)))
107 ((eq class 'mixi-event)
108 (mixi-expand-url (mixi-event-page object)))
109 ((eq class 'mixi-comment)
110 (concat (mixi-make-url (mixi-comment-parent object))
112 ((eq class 'mixi-message)
113 (mixi-expand-url (mixi-message-page object)))
114 ((eq class 'mixi-news)
115 (mixi-news-page object))
116 ((eq class 'mixi-log)
117 (mixi-expand-url (mixi-friend-page (mixi-log-friend object))))
118 ((eq class 'mixi-friend)
119 (mixi-expand-url (mixi-friend-page object))))))
121 (defun mixi-make-content (object)
122 (with-mixi-class object
123 (cond ((eq class 'mixi-event)
124 (let ((limit (mixi-event-limit object)))
125 (setq limit (if limit
126 (format-time-string "%Yǯ%m·î%dÆü" limit)
129 "<dt>³«ºÅÆü»þ¡§</dt>"
130 "<dd>" (mixi-event-date object) "</dd>\n"
131 "<dt>³«ºÅ¾ì½ê¡§</dt>"
132 "<dd>" (mixi-event-place object) "</dd>\n"
134 "<dd>" (mixi-event-detail object) "</dd>\n"
135 "<dt>Ê罸´ü¸Â¡§</dt>"
136 "<dd>" limit "</dd>\n"
138 "<dd>" (mixi-event-members object) "</dd>\n"
140 ((eq class 'mixi-friend)
141 (if (mixi-object-realized-p object)
142 (let ((sex (if (eq (mixi-friend-sex object) 'male) "ÃË" "½÷"))
143 (age (number-to-string (mixi-friend-age object)))
145 (concat (mapconcat (lambda (number)
146 (number-to-string number))
147 (mixi-friend-birthday object) "·î")
149 (blood-type (symbol-name
150 (mixi-friend-blood-type object)))
151 (hobby (mapconcat 'identity
152 (mixi-friend-hobby object) ", ")))
155 "<dd>" (mixi-friend-name object) "</dd>\n"
157 "<dd>" sex "À</dd>\n"
159 "<dd>" (mixi-friend-address object) "</dd>\n"
161 "<dd>" age "ºÐ</dd>\n"
163 "<dd>" birthday "</dd>\n"
165 "<dd>" blood-type "·¿</dd>\n"
167 "<dd>" (mixi-friend-birthplace object) "</dd>\n"
169 "<dd>" hobby "</dd>\n"
171 "<dd>" (mixi-friend-job object) "</dd>\n"
173 "<dd>" (mixi-friend-organization object) "</dd>\n"
174 "<dt>¼«¸Ê¾Ò²ð¡§</dt>"
175 "<dd>" (mixi-friend-profile object) "</dd>\n"
177 (concat "<a href=\"" (mixi-make-url object)
178 "\">¥×¥í¥Õ¥£¡¼¥ë¤òɽ¼¨¤¹¤ë</a>")))
179 (t (mixi-object-content object)))))
181 (defun mixi-make-reply-to (object)
182 (setq mixi-reply-to "mixi;")
183 (with-mixi-class object
186 (cond ((eq class 'mixi-diary)
187 (concat mixi-reply-to "comment;diary;"
188 (mixi-friend-id (mixi-diary-owner object)) ";"
189 (mixi-diary-id object)))
191 (concat mixi-reply-to "comment;"
192 (mixi-object-name object) ";"
193 (mixi-community-id (mixi-bbs-community object)) ";"
194 (mixi-bbs-id object)))
195 ((eq class 'mixi-community)
196 (concat mixi-reply-to "topic;"
197 (mixi-community-id object)))
198 ((or (eq class 'mixi-news) (eq object (mixi-make-me)))
199 (concat mixi-reply-to "diary"))
200 ((eq class 'mixi-message)
201 (concat mixi-reply-to "message;"
202 (mixi-friend-id (mixi-message-owner object))))
203 ((or (eq class 'mixi-friend) (eq class 'mixi-log))
204 (concat mixi-reply-to "message;"
205 (mixi-friend-id object))))))))
207 (provide 'mixi-utils)
209 ;;; mixi-utils.el ends here