X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=sb-mixi.el;h=248929b403445ad329bbd9bd4adb12d75888c65f;hb=6f0347f9ea0b4a65df004ea48dd7c930a7e9e0cd;hp=f790d37204e98a156be86ab9969ae21b6bb4afab;hpb=1cb706d7fc9dfca40b5c795178cf25a201b0153e;p=elisp%2Fmixi.git diff --git a/sb-mixi.el b/sb-mixi.el index f790d37..248929b 100644 --- a/sb-mixi.el +++ b/sb-mixi.el @@ -1,6 +1,6 @@ ;;; sb-mixi.el --- shimbun backend for mixi -;; Copyright (C) 2006 OHASHI Akira +;; Copyright (C) 2006, 2007 OHASHI Akira ;; Author: OHASHI Akira ;; Keywords: news @@ -33,14 +33,17 @@ (require 'mixi-utils) (require 'shimbun) +(defconst shimbun-mixi-revision "$Revision: 1.58 $") + (eval-and-compile (luna-define-class shimbun-mixi (shimbun) (comment-cache)) (luna-define-internal-accessors 'shimbun-mixi)) -(defcustom shimbun-mixi-group-alist +(defconst shimbun-mixi-default-group-alist '(("new-diaries" . mixi-get-new-diaries) ("new-comments" . mixi-get-new-comments) ("new-bbses" . mixi-get-new-bbses) + ("new-bbs-comments" . mixi-get-new-bbs-comments) ("messages" . mixi-get-messages) ("messages.sent" . (lambda (range) @@ -96,9 +99,12 @@ ("news.pickup.it" . (lambda (range) (mixi-get-news 'IT 'pickup range)))) + "An alist of mixi shimbun group default definition.") + +(defcustom shimbun-mixi-group-alist nil "*An alist of mixi shimbun group definition. Each element looks like (NAME . URL) or (NAME . FUNCTION). -NAME is a shimbun group name. +NAME is a shimbun group name that you can name it as you like. URL is the URL for mixi access point of the group. If URL is friend's, get his/her diaries as article. If community's, get its BBSes. If diary's or BBS's, get its comments. @@ -108,12 +114,12 @@ of mixi object." :type '(repeat (cons :fromat "%v" (string :tag "Group name") (radio (string :tag "URL") - (const :tag "New diaries" mixi-get-new-diaries) - (const :tag "New comments" mixi-get-new-comments) - (const :tag "New BBSes" mixi-get-new-bbses) - (const :tag "Messages" mixi-get-messages) - (const :tag "Logs" mixi-get-logs) - (function :tag "Other function"))))) + (function :tag "Function"))))) + +(defcustom shimbun-mixi-get-profile-with-diary t + "*If non-nil, get his/her profile together with diaries." + :group 'shimbun + :type 'boolean) ;; FIXME: Don't use this user option. (defcustom shimbun-mixi-page-articles 10 @@ -126,6 +132,10 @@ of mixi object." h.d+'g\\I{D>Ocy?Rc4uYUyOZj2%2Kl>,x-!MCSsyi3!L}psrrC1jlF,O?Ui>qf)X;sBz`/}\\066X%$ siG'|4K!2?==|oB&#E'5GGH\\#z[muyQ"))) +(defun shimbun-mixi-group-alist () + (append shimbun-mixi-default-group-alist + shimbun-mixi-group-alist)) + (luna-define-method initialize-instance :after ((shimbun shimbun-mixi) &rest init-args) (shimbun-mixi-set-comment-cache-internal shimbun @@ -137,58 +147,62 @@ of mixi object." (mixi-logout)) (luna-define-method shimbun-groups ((shimbun shimbun-mixi)) - (mapcar 'car shimbun-mixi-group-alist)) + (mapcar 'car (shimbun-mixi-group-alist))) (luna-define-method shimbun-reply-to ((shimbun shimbun-mixi)) mixi-reply-to) (defun shimbun-mixi-get-headers (shimbun objects &optional range) - (when objects - (let (headers) - (catch 'stop - (mapc (lambda (object) - (when (mixi-object-p object) - (let ((class (mixi-object-class object))) - (when (mixi-parent-p object) - (let ((comments (mixi-get-comments object range))) - (mapc (lambda (header) - (push header headers)) - (shimbun-mixi-get-headers shimbun - comments)))) - (let ((id (mixi-make-message-id object))) - (when (and (eq class 'mixi-comment) - (shimbun-search-id shimbun id)) - (throw 'stop nil)) - (push - (shimbun-create-header - 0 - (mixi-make-title object - (string-match - "^new-" - (shimbun-current-group-internal - shimbun))) - (mixi-make-author object) - (mixi-make-date object) - id - (if (eq class 'mixi-comment) - (mixi-make-message-id - (mixi-comment-parent object)) - "") - 0 0 - (mixi-make-url object)) - headers) - (when (eq class 'mixi-comment) - (puthash id (mixi-comment-content object) - (shimbun-mixi-comment-cache-internal - shimbun))))))) - objects)) - headers))) + (let (headers) + (catch 'stop + (while objects + (let ((object (car objects))) + (when (and shimbun-mixi-get-profile-with-diary + (mixi-diary-p object)) + (let ((owner (mixi-diary-owner object))) + (unless (mixi-object-realized-p owner) + (mixi-realize-friend owner)))) + (when (mixi-parent-p object) + (let* ((comments (mixi-get-comments object range)) + (comment-headers (shimbun-mixi-get-headers shimbun + comments))) + (while comment-headers + (push (car comment-headers) headers) + (setq comment-headers (cdr comment-headers))))) + (let ((class (mixi-object-class object)) + (id (mixi-make-message-id object))) + (when (and (eq class 'mixi-comment) + (shimbun-search-id shimbun id)) + (throw 'stop nil)) + (push + (shimbun-create-header + 0 + (mixi-make-title object (string-match + "^new-" + (shimbun-current-group-internal + shimbun))) + (mixi-make-author object) + (mixi-make-date object) + id + (if (eq class 'mixi-comment) + (mixi-make-message-id (mixi-comment-parent object)) + "") + 0 0 + (mixi-make-url object)) + headers) + (when (eq class 'mixi-comment) + (puthash id (mixi-comment-content object) + (shimbun-mixi-comment-cache-internal shimbun))))) + (setq objects (cdr objects)))) + headers)) (luna-define-method shimbun-get-headers ((shimbun shimbun-mixi) &optional range) (let ((url-or-function (cdr (assoc (shimbun-current-group-internal shimbun) - shimbun-mixi-group-alist))) - (range (when (integerp range) (* range shimbun-mixi-page-articles)))) + (shimbun-mixi-group-alist)))) + (range (shimbun-header-index-pages range))) + (when (integerp range) + (setq range (* range shimbun-mixi-page-articles))) (shimbun-sort-headers (shimbun-mixi-get-headers shimbun (mixi-make-objects url-or-function range) @@ -199,14 +213,15 @@ of mixi object." (cache (shimbun-mixi-comment-cache-internal shimbun)) (article (gethash message-id cache))) (unless (stringp article) - (let ((parent (mixi-make-object-from-url url))) - (mapc (lambda (comment) - (let ((id (mixi-make-message-id comment)) - (content (mixi-comment-content comment))) - (puthash id content cache) - (when (string= id message-id) - (setq article content)))) - (mixi-get-comments parent)))) + (let* ((parent (mixi-make-object-from-url url)) + (comments (mixi-get-comments parent))) + (while comments + (let ((id (mixi-make-message-id (car comments))) + (content (mixi-comment-content (car comments)))) + (puthash id content cache) + (when (string= id message-id) + (setq article content))) + (setq comments (cdr comments))))) article)) (luna-define-method shimbun-article ((shimbun shimbun-mixi) @@ -230,33 +245,6 @@ of mixi object." (shimbun-message shimbun "shimbun: Make contents...done"))) ""))))) -(defconst shimbun-mixi-to-regexp - "^mixi;\\([a-z]+\\);?\\([a-z0-9]+\\)?;?\\([0-9]+\\)?;?\\([0-9]+\\)?") - -(defun shimbun-mixi-send-mail (to title content) - (when (string-match shimbun-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 'sb-mixi) ;;; sb-mixi.el ends here