From: bg66 Date: Mon, 4 Dec 2006 01:27:35 +0000 (+0000) Subject: * mixi.el (mixi-url-encode-and-quote-percent-string): New function. X-Git-Tag: mixi-el-1_0_0~175 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=80bdde1531649682e0920da30793cffc60a481a1;p=elisp%2Fmixi.git * mixi.el (mixi-url-encode-and-quote-percent-string): New function. (mixi-search-diary-list-page): New macro. (mixi-search-diary-list-regexp): New regexp. (mixi-search-diaries): New function. (mixi-diary-closed-regexp): New regexp. (mixi-diary-realize): Use it. * sb-mixi.el (shimbun-mixi-group-alist): Fix docs. --- diff --git a/ChangeLog b/ChangeLog index 7ef5d9f..e4a8126 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2006-12-04 OHASHI Akira + * mixi.el (mixi-url-encode-and-quote-percent-string): New function. + (mixi-search-diary-list-page): New macro. + (mixi-search-diary-list-regexp): New regexp. + (mixi-search-diaries): New function. + (mixi-diary-closed-regexp): New regexp. + (mixi-diary-realize): Use it. + + * sb-mixi.el (shimbun-mixi-group-alist): Fix docs. + +2006-12-04 OHASHI Akira + * mixi.el (mixi-diary-content-regexp): Fix regexp. 2006-12-01 OHASHI Akira diff --git a/mixi.el b/mixi.el index da770f8..a87dc7d 100644 --- a/mixi.el +++ b/mixi.el @@ -31,6 +31,7 @@ ;; * mixi-get-logs ;; * mixi-get-diaries ;; * mixi-get-new-diaries +;; * mixi-search-diaries ;; * mixi-get-communities ;; * mixi-get-bbses ;; * mixi-get-new-bbses @@ -400,6 +401,25 @@ Increase this value when unexpected error frequently occurs." ;; FIXME: Decode entities. (buffer-string))) +;; stolen (and modified) from w3m.el +;; FIXME: Hmm. +(defun mixi-url-encode-and-quote-percent-string (string) + (apply (function concat) + (mapcar + (lambda (char) + (cond + ((eq char ?\n) ; newline + "%%0D%%0A") + ((string-match "[-a-zA-Z0-9_:/.]" (char-to-string char)) ; xxx? + (char-to-string char)) ; printable + ((char-equal char ?\x20) ; space + "+") + (t + (format "%%%%%02x" char)))) ; escape + ;; Coerce a string into a list of chars. + (append (encode-coding-string (or string "") mixi-coding-system) + nil)))) + ;; Cache. ;; stolen from time-date.el (defun mixi-time-less-p (t1 t2) @@ -947,6 +967,8 @@ Increase this value when unexpected error frequently occurs." "&owner_id=" (mixi-friend-id (mixi-diary-owner ,diary)))) ;; FIXME: Remove `¤µ¤ó'. +(defconst mixi-diary-closed-regexp + "ͧ¿Í\\(¤Îͧ¿Í\\)?¤Þ¤Ç¸ø³«¤Î¤¿¤áÆɤळ¤È¤¬½ÐÍè¤Þ¤»¤ó¡£") (defconst mixi-diary-owner-nick-regexp "\\(.+\\)\\(¤µ¤ó\\)?¤ÎÆüµ­") (defconst mixi-diary-time-regexp @@ -961,24 +983,25 @@ Increase this value when unexpected error frequently occurs." ;; FIXME: Check a expiration of cache? (unless (mixi-object-realize-p diary) (with-mixi-retrieve (mixi-diary-page diary) - (if (string-match mixi-diary-owner-nick-regexp buffer) - (mixi-friend-set-nick (mixi-diary-owner diary) - (match-string 1 buffer)) - (signal 'error (list 'cannot-find-owner-nick diary))) - (if (string-match mixi-diary-time-regexp buffer) - (mixi-diary-set-time - diary (encode-time 0 (string-to-number (match-string 5 buffer)) - (string-to-number (match-string 4 buffer)) - (string-to-number (match-string 3 buffer)) - (string-to-number (match-string 2 buffer)) - (string-to-number (match-string 1 buffer)))) - (signal 'error (list 'cannot-find-time diary))) - (if (string-match mixi-diary-title-regexp buffer) - (mixi-diary-set-title diary (match-string 1 buffer)) - (signal 'error (list 'cannot-find-title diary))) - (if (string-match mixi-diary-content-regexp buffer) - (mixi-diary-set-content diary (match-string 1 buffer)) - (signal 'error (list 'cannot-find-content diary)))) + (unless (string-match mixi-diary-closed-regexp buffer) + (if (string-match mixi-diary-owner-nick-regexp buffer) + (mixi-friend-set-nick (mixi-diary-owner diary) + (match-string 1 buffer)) + (signal 'error (list 'cannot-find-owner-nick diary))) + (if (string-match mixi-diary-time-regexp buffer) + (mixi-diary-set-time + diary (encode-time 0 (string-to-number (match-string 5 buffer)) + (string-to-number (match-string 4 buffer)) + (string-to-number (match-string 3 buffer)) + (string-to-number (match-string 2 buffer)) + (string-to-number (match-string 1 buffer)))) + (signal 'error (list 'cannot-find-time diary))) + (if (string-match mixi-diary-title-regexp buffer) + (mixi-diary-set-title diary (match-string 1 buffer)) + (signal 'error (list 'cannot-find-title diary))) + (if (string-match mixi-diary-content-regexp buffer) + (mixi-diary-set-content diary (match-string 1 buffer)) + (signal 'error (list 'cannot-find-content diary))))) (mixi-object-touch diary))) (defun mixi-diary-owner (diary) @@ -1073,6 +1096,21 @@ Increase this value when unexpected error frequently occurs." (mixi-make-diary (mixi-make-friend (nth 1 item)) (nth 0 item))) items))) +(defmacro mixi-search-diary-list-page (keyword) + `(concat "/search_diary.pl?page=%d&submit=search&keyword=" + (mixi-url-encode-and-quote-percent-string keyword))) + +(defconst mixi-search-diary-list-regexp + "") + +(defun mixi-search-diaries (keyword &optional range) + (let ((items (mixi-get-matched-items (mixi-search-diary-list-page keyword) + mixi-search-diary-list-regexp + range))) + (mapcar (lambda (item) + (mixi-make-diary (mixi-make-friend (nth 1 item)) (nth 0 item))) + items))) + ;; Community object. (defvar mixi-community-cache (make-hash-table :test 'equal)) (defun mixi-make-community (id &optional name) diff --git a/sb-mixi.el b/sb-mixi.el index a11ea26..e10123c 100644 --- a/sb-mixi.el +++ b/sb-mixi.el @@ -47,7 +47,7 @@ NAME is a shimbun group name. URL is the URL for mixi access point of the group. When URL is friend's, get his/her diaries as article. When community's, get its BBSes. When diary's or BBS's, get its comments. -FUNCTION is the function for getting articles." +FUNCTION is the function having one `range' argument for getting articles." :group 'shimbun :type '(repeat (cons :fromat "%v" (string :tag "Group name")