From c67537056dbe67ab33587553ca3098dfebb15576 Mon Sep 17 00:00:00 2001 From: bg66 Date: Tue, 12 Feb 2008 11:05:21 +0000 Subject: [PATCH] * mixi.el (mixi-make-release): New function. (mixi-release-p): New macro. (mixi-release-title): New function. (mixi-release-time): Ditto. (mixi-release-content): Ditto. (mixi-release-list-page): New macro. (mixi-release-list-regexp): New constant. (mixi-get-releases): New function. * mixi-utils.el (mixi-make-author): Support release object. (mixi-make-id-1): Ditto. (mixi-make-url): Ditto. (mixi-make-reply-to): Ditto. * sb-mixi.el (shimbun-mixi): Add release-cache. (shimbun-mixi-default-group-alist): Add releases group. (initialize-instance): Initialize release cache. (shimbun-close): Clear release cache. (shimbun-mixi-release-article): New function. (shimbun-article): Use it. --- ChangeLog | 21 ++++++++++++++++++ mixi-ja.texi | 54 ++++++++++++++++++++++++++++++++++++++++------ mixi-utils.el | 14 ++++++++++-- mixi.el | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- sb-mixi.el | 39 +++++++++++++++++++++++++++------- 5 files changed, 177 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index b4e6db5..da258a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,26 @@ 2008-02-12 OHASHI Akira + * mixi.el (mixi-make-release): New function. + (mixi-release-p): New macro. + (mixi-release-title): New function. + (mixi-release-time): Ditto. + (mixi-release-content): Ditto. + (mixi-release-list-page): New macro. + (mixi-release-list-regexp): New constant. + (mixi-get-releases): New function. + * mixi-utils.el (mixi-make-author): Support release object. + (mixi-make-id-1): Ditto. + (mixi-make-url): Ditto. + (mixi-make-reply-to): Ditto. + * sb-mixi.el (shimbun-mixi): Add release-cache. + (shimbun-mixi-default-group-alist): Add releases group. + (initialize-instance): Initialize release cache. + (shimbun-close): Clear release cache. + (shimbun-mixi-release-article): New function. + (shimbun-article): Use it. + +2008-02-12 OHASHI Akira + * mixi.el (mixi-news-finished-regexp): Follow the change of mixi. (mixi-news-title-regexp): Ditto. (mixi-news-media-time-regexp): Ditto. diff --git a/mixi-ja.texi b/mixi-ja.texi index e97cf7a..475c0ff 100755 --- a/mixi-ja.texi +++ b/mixi-ja.texi @@ -14,7 +14,7 @@ @end direntry @copying -Copyright @copyright{} 2007 @w{OHASHI Akira}. +Copyright @copyright{} 2007, 2008 @w{OHASHI Akira}. @quotation Permission is granted to copy, distribute and/or modify this document @@ -370,7 +370,7 @@ ID $B$rJV5Q$7$^$9!#(B @end defun @defun mixi-diary-time diary -$B;~9o$rJV5Q$7$^$9!#(B +$BF|;~$rJV5Q$7$^$9!#(B @end defun @defun mixi-diary-title diary @@ -469,7 +469,7 @@ ID $B$rJV5Q$7$^$9!#(B @end defun @defun mixi-topic-time topic -$B;~9o$rJV5Q$7$^$9!#(B +$BF|;~$rJV5Q$7$^$9!#(B @end defun @defun mixi-topic-title topic @@ -517,7 +517,7 @@ ID $B$rJV5Q$7$^$9!#(B @end defun @defun mixi-event-time event -$B;~9o$rJV5Q$7$^$9!#(B +$BF|;~$rJV5Q$7$^$9!#(B @end defun @defun mixi-event-title event @@ -568,7 +568,7 @@ comment $B%*%V%8%'%/%H$N3FpJs$rc32$N$4Js9p$rI=$9%*%V%8%'%/%H$G$9!#(B +$B$3$N%*%V%8%'%/%H$rD>@\@8@.$9$k$3$H$OL5$$$H;W$$$^$9!#(B + +@subsubsection $B%"%/%;%5%a%=%C%I(B + +release $B%*%V%8%'%/%H$N3FpJs$rc32$N$4Js9p0lMw$rl9g$O:GBg$G$3$N?t$N?75!G=%j%j!<%9!&>c32$N$4Js9p$N(B +$B$_$rc32$N$4Js9p$9$Y$F(B + +(mixi-get-releases 5) + @result{} $B?75!G=%j%j!<%9!&>c32$N$4Js9p:GBg$G(B 5 $B7oJ,$N$_(B +@end example +@end cartouche +@end defun + @node $BEj9FMQ4X?t(B @section $BEj9FMQ4X?t(B diff --git a/mixi-utils.el b/mixi-utils.el index d2646d0..aad03b8 100644 --- a/mixi-utils.el +++ b/mixi-utils.el @@ -1,6 +1,6 @@ ;; 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 @@ -87,6 +87,8 @@ (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) @@ -114,6 +116,8 @@ (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) @@ -144,6 +148,10 @@ (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) @@ -240,7 +248,9 @@ (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]+\\)?") diff --git a/mixi.el b/mixi.el index 501d0a0..f748c6e 100644 --- a/mixi.el +++ b/mixi.el @@ -45,6 +45,7 @@ ;; * mixi-get-messages ;; * mixi-get-introductions (broken) ;; * mixi-get-news +;; * mixi-get-releases ;; ;; APIs for posting: ;; @@ -138,7 +139,7 @@ (autoload 'w3m-retrieve "w3m") (autoload 'url-retrieve-synchronously "url")) -(defconst mixi-revision "$Revision: 1.183 $") +(defconst mixi-revision "$Revision: 1.184 $") (defgroup mixi nil "API library for accessing to mixi." @@ -3012,6 +3013,69 @@ Increase this value when unexpected error frequently occurs." (nth 2 item)))) items))) +;; Release object. +(defun mixi-make-release (title time content) + "Return a release object." + (cons 'mixi-release (vector title time content))) + +(defmacro mixi-release-p (release) + `(eq (mixi-object-class ,release) 'mixi-release)) + +(defun mixi-release-title (release) + "Return the title of RELEASE." + (unless (mixi-release-p release) + (signal 'wrong-type-argument (list 'mixi-release-p release))) + (aref (cdr release) 0)) + +(defun mixi-release-time (release) + "Return the time of RELEASE." + (unless (mixi-release-p release) + (signal 'wrong-type-argument (list 'mixi-release-p release))) + (aref (cdr release) 1)) + +(defun mixi-release-content (release) + "Return the content of RELEASE." + (unless (mixi-release-p release) + (signal 'wrong-type-argument (list 'mixi-release-p release))) + (aref (cdr release) 2)) + +(defmacro mixi-release-list-page () + `(concat "/release_info.pl?page=%d")) + +(defconst mixi-release-list-regexp + " ¢£ \\(.+\\) +\\([1-9][0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\) + + + + + + +
+ + + + + +
+\\(.+\\) +
") + +;;;###autoload +(defun mixi-get-releases (&optional range) + "Get releases." + (let ((items (mixi-get-matched-items (mixi-release-list-page) + mixi-release-list-regexp + range))) + (mapcar (lambda (item) + (mixi-make-release (nth 0 item) + (encode-time 0 0 0 + (string-to-number (nth 3 item)) + (string-to-number (nth 2 item)) + (string-to-number (nth 1 item))) + (nth 4 item))) + items))) + (provide 'mixi) ;;; mixi.el ends here diff --git a/sb-mixi.el b/sb-mixi.el index e6b04e5..4e78d12 100644 --- a/sb-mixi.el +++ b/sb-mixi.el @@ -1,6 +1,6 @@ ;;; sb-mixi.el --- shimbun backend for mixi -;; Copyright (C) 2006, 2007 OHASHI Akira +;; Copyright (C) 2006, 2007, 2008 OHASHI Akira ;; Author: OHASHI Akira ;; Keywords: news @@ -33,10 +33,10 @@ (require 'mixi-utils) (require 'shimbun) -(defconst shimbun-mixi-revision "$Revision: 1.61 $") +(defconst shimbun-mixi-revision "$Revision: 1.62 $") (eval-and-compile - (luna-define-class shimbun-mixi (shimbun) (comment-cache)) + (luna-define-class shimbun-mixi (shimbun) (comment-cache release-cache)) (luna-define-internal-accessors 'shimbun-mixi)) (defconst shimbun-mixi-default-group-alist @@ -110,7 +110,8 @@ (mixi-get-news 'game-anime 'pickup range))) ("news.pickup.column" . (lambda (range) - (mixi-get-news 'column 'pickup range)))) + (mixi-get-news 'column 'pickup range))) + ("releases" . mixi-get-releases)) "An alist of mixi shimbun group default definition.") (defcustom shimbun-mixi-group-alist nil @@ -157,10 +158,13 @@ of mixi object." &rest init-args) (shimbun-mixi-set-comment-cache-internal shimbun (make-hash-table :test 'equal)) + (shimbun-mixi-set-release-cache-internal shimbun + (make-hash-table :test 'equal)) shimbun) (luna-define-method shimbun-close :after ((shimbun shimbun-mixi)) (shimbun-mixi-set-comment-cache-internal shimbun nil) + (shimbun-mixi-set-release-cache-internal shimbun nil) (mixi-logout)) (luna-define-method shimbun-groups ((shimbun shimbun-mixi)) @@ -241,6 +245,21 @@ of mixi object." (setq comments (cdr comments))))) article)) +(defun shimbun-mixi-release-article (shimbun header) + (let* ((message-id (shimbun-header-id header)) + (cache (shimbun-mixi-release-cache-internal shimbun)) + (article (gethash message-id cache))) + (unless (stringp article) + (let* ((releases (mixi-get-releases))) + (while releases + (let ((id (mixi-make-message-id (car releases))) + (content (mixi-release-content (car releases)))) + (puthash id content cache) + (when (string= id message-id) + (setq article content))) + (setq releases (cdr releases))))) + article)) + (luna-define-method shimbun-article ((shimbun shimbun-mixi) header &optional outbuf) (when (shimbun-current-group-internal shimbun) @@ -249,10 +268,14 @@ of mixi object." (or (with-temp-buffer (let* ((url (shimbun-article-url shimbun header)) (object (mixi-make-object-from-url url)) - (article (if (string-match "#comment$" url) - (shimbun-mixi-comment-article - url shimbun header) - (mixi-make-content object)))) + (article (cond ((string-match "#comment$" url) + (shimbun-mixi-comment-article + url shimbun header)) + ((string-match "release_info.pl$" url) + (shimbun-mixi-release-article + shimbun header)) + (t + (mixi-make-content object))))) (mixi-make-reply-to object) (when (stringp article) (insert article))) -- 1.7.10.4