OSDN Git Service

Develop
authorkubo <hirosandesu@users.sourceforge.jp>
Thu, 23 Sep 2010 20:35:50 +0000 (05:35 +0900)
committerkubo <hirosandesu@users.sourceforge.jp>
Thu, 23 Sep 2010 20:35:50 +0000 (05:35 +0900)
hatena-diary-mode.el [new file with mode: 0644]
hatena-kw.el [new file with mode: 0644]
hatena-tools.pl [new file with mode: 0644]
hatena-vars.el [new file with mode: 0644]

diff --git a/hatena-diary-mode.el b/hatena-diary-mode.el
new file mode 100644 (file)
index 0000000..1d4e395
--- /dev/null
@@ -0,0 +1,704 @@
+;; hatena-diary-mode.el --- major mode for Hatena::Diary (http://d.hatena.ne.jp)
+
+;; Created:     Thu Jun 17  2004
+;; Keywords:    blog emacs 
+;; author:      hikigaeru <http://d.hatena.ne.jp/hikigaeru/>
+;;              hirosandesu <http://d.hatena.ne.jp/suttanipaata/>
+;;
+;; ¸ø³«¥Ú¡¼¥¸:    http://sourceforge.jp/projects/hatena-diary-el/
+;; Special Thanks to :
+;;              http://d.hatena.ne.jp/hikigaeru/20040617
+;;              http://d.hatena.ne.jp/dev-null 
+;;              and all users
+
+;; This program supports the update of your Hatena-Diary. 
+;; This program is Elisp program that operates by Emacs. 
+;; Copyright (C) 2010  hirosandesu
+
+;; This program is free software; you can redistribute it and/or modify 
+;; it under the terms of the GNU General Public License as published 
+;; by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful, 
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of 
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 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, see <http://www.gnu.org/licenses/>.
+
+
+(defconst hatena-version "2.0" "Version number of hatena.el")
+
+;; ¢£¥¤¥ó¥¹¥È¡¼¥ëÊýË¡
+;; 1) Å¬Åö¤Ê¥Ç¥£¥ì¥¯¥È¥ê¤Ë¤³¤Î¥Õ¥¡¥¤¥ë¤ò¤ª¤¯.
+;;    (~/elisp/ Æâ¤Ë¤ª¤¤¤¿¤È¤¹¤ë). 
+;;
+;; 2) .emacs ¤Ë¼¡¤Î 4 ¹Ô¤òÄɲ乤ë.
+;; (setq load-path (cons (expand-file-name "~/elisp") load-path))
+;; (load "hatena-diary-mode")
+;; (setq hatena-usrid "your username on Hatena::Diary")
+;; (setq hatena-plugin-directory "~/elisp")
+;;    `hatena-use-file' ¤ò non-nil ¤Ë¤¹¤ë¤È¥Ñ¥¹¥ï¡¼¥É¤ò base64 ¤Ç
+;;    °Å¹æ²½¤·¤Æ¥Õ¥¡¥¤¥ë¤ËÊݸ¤·¤Þ¤¹¤¬¡¢"¿Í´Ö¤¬¸«¤Æ¤¹¤°¤ï¤«¤é¤Ê¤¤"¤°¤é¤¤¤Î
+;;    °ÕÌ£¤·¤«¤Ê¤¤¤Î¤ÇÃí°Õ¤·¤Æ²¼¤µ¤¤¡£
+;;
+;; ¢£»È¤¤Êý
+;; 
+;; 1)Æüµ­¤ò½ñ¤¯
+;;    `M-x hatena' ¤Çº£Æü¤ÎÆüµ­¤¬³«¤­¤Þ¤¹. ¤¿¤À¤Î¥Æ¥­¥¹¥È¥Õ¥¡¥¤¥ë¤Ç¤¹¡£
+;;    ¥¿¥¤¥È¥ë ¤òÉÕ¤±¤¿¤¤¾ì¹ç¤Ï¡¢°ì¹ÔÌܤˠ"title" ¤È½ñ¤¤¤Æ¡¢¤½¤Î¸å¤Ë¥Æ¥­¥¹¥È¤ò
+;;    Â³¤±¤Æ¤¯¤À¤µ¤¤¡£
+;;
+;; 2)¥Ý¥¹¥È¤¹¤ë
+;;    Æüµ­¤ò½ñ¤¤¤¿¤é, \C-c\C-p ¤Ç send ¤Ç¤­¤Þ¤¹.
+;;    ¥Þ¡¼¥¯¥¢¥Ã¥×¤Ï¡¢¤Ï¤Æ¤Ê¤Îµ­Ë¡¤Ë½¾¤¤¤Þ¤¹¡£
+;;    \C-ct ¤Ç¡Ö¹¹¿·¡×¤È¡Ö¤Á¤ç¤Ã¤È¤·¤¿¹¹¿·¡×¤òÀڤ꤫¤¨¤Þ¤¹¡£
+;; 
+;; 3)ÊÑ¿ô¤ä´Ø¿ô
+;;
+;;    `hatena-change-trivial' "¤Á¤ç¤Ã¤È¤·¤¿¹¹¿·"¤«¤É¤¦¤«¤ò digit ¤ËÊѤ¨¤Þ¤¹¡£
+;;    `hatena-entry-type' ¥¨¥ó¥È¥ê¤Î "*" ¤ÎÆ°ºî¤òÀڤ꤫¤¨¤Þ¤¹¡£
+;;                        0 ¤Ç *pn* ¤Ë¡¢1 ¤Ç *t* (¥¿¥¤¥à¥¹¥¿¥ó¥×)¤Ë¤Ê¤ê¤Þ¤¹¡£
+;;
+;;    `hatena-submit' (\C-c\C-p) Æüµ­¤ò¤Ï¤Æ¤Ê¤Ë¥Ý¥¹¥È¤·¤Þ¤¹
+;;    `hatena-delete-diary' ¤½¤ÎÆü¤ÎÆüµ­¤ò web ¤«¤éºï½ü.
+;;    `hatena-find-previous' (\C-c\C-b) 
+;;    `hatena-find-followings' (\C-c\C-f). ¤½¤ì¤¾¤ì¡¢Á°¤ÎÆü¤È¼¡¤ÎÆü¤Î
+;;    Æüµ­¥Õ¥¡¥¤¥ë¤ò³«¤¯¡£°ú¿ô¤òÍ¿¤¨¤ë¤È¤½¤ÎÆü¿ô¤À¤±¥¸¥ã¥ó¥×¡£
+;;    ( Îã \C 1 2 \C-c\C-b ¤Ç12ÆüÁ° )
+;;    `hatena-exit' Æüµ­ buffer ¤ò save ¤·¤Æ ¤¹¤Ù¤Æ kill
+;;    `hatena-browser-function' ¤Ë 'browse-url ¤È¤«¤ä¤ë¤ÈÆüµ­¤ò¥Ý¥¹¥È
+;;    ¤·¤¿¸å¤½¤ÎÆü url ¤ò°ú¿ô¤È¤·¤Æ¥Ö¥é¥¦¥¶¤ò¸Æ¤Ó¤Þ¤¹.
+;;    `hatena-insert-webdiary' ¤Ï¤Æ¤Ê¥Ð¥Ã¥Õ¥¡¤Ç¼Â¹Ô¤¹¤ë¤È¡¢¸½ºß web ¤Ë
+;;    ¥¢¥Ã¥×¤µ¤ì¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë¤ò¼è¤Ã¤Æ¤¯¤ë¡£ o
+;;    `hatena-twitter' Æüµ­¹¹¿·»þ¤ËTwitter¤ËÄÌÃΤ¹¤ë¤«¤É¤¦¤«¤òÊѤ¨¤Þ¤¹¡£
+;;
+;; 4) ¾å°Ì¥â¡¼¥É
+;;    hatena-diary-mode ¤Ï¥Ç¥Õ¥©¥ë¥È¤Ç html-mode ¤ËÈ碌¤Æ¤¤¤Þ¤¹¡£¤³¤ì¤ò
+;;    html-helper-mode ¤Ë¤·¤¿¤±¤ì¤Ð¡¢
+;;
+;;    -(define-derived-mode hatena-diary-mode html-mode "Hatena"
+;;    +(define-derived-mode hatena-diary-mode html-helper-mode "Hatena"
+;;
+;;    ¤È¤·¤Æ `eval-buffer' ¤·¤Æ²¼¤µ¤¤¡£
+;;
+;; 5) hook ¤Ë¤Ä¤¤¤Æ
+;;    hook ¤È¤Ï¥é¥¤¥Ö¥é¥ê¤òÆɹþ¤ó¤À»þ¡¢½é´ü²½¤¹¤ë»þ¤Ê¤É¡¢ÆÃÄê¤Î¥¿¥¤¥ß
+;;    ¥ó¥°¤Ç¸Æ¤Ó½Ð¤·¤¿¤¤´Ø¿ô¤òÊÝ»ý¤¹¤ëÊÑ¿ô¤Ç¤¹¡£hatena-diary-mode ¤Ë¤Ï°Ê²¼¤Î
+;;    hook ¤¬¤¢¤ê¤Þ¤¹
+;;
+;;    `hatena-diary-mode-hooks' Hatena mode ¤Ë¤·¤¿»þ¤Ë¸Æ¤Ð¤ì¤ë hook .
+;;     Îã .emacs ¤Ë
+;;    (add-hook 'hatena-diary-mode-hooks 
+;;       '(lambda ()
+;;          (setq line-spacing 8) ;;¹Ô¤¬µÍ¤Þ¤Ã¤Æ¤ë¤È¥¤¥ä¡¢
+;;          ))
+;;
+;;    `hatena-diary-mode-submit-hook' Æüµ­¤ò¥Ý¥¹¥È`hatena-submit' ¤¹¤ëľÁ°¤Ë
+;;     ¸Æ¤Ó½Ð¤¹´Ø¿ô¤Ç¤¹¡£Î㤨¤Ð¡¢Ï¢Â³¤·¤Ê¤¤²þ¹Ô¤ò¤¹¤Ù¤Æ½ü¤¯¡¢¤Ê¤É¤Î½èÍý¤¬¹Í¤¨¤é¤ì¤Þ¤¹¡£
+;;
+;;    (add-hook 'hatena-diary-mode-submit-hook
+;;       '(lambda ()
+;;           (goto-char (point-min))
+;;          (replace-regexp "\\([^\n]\\)\n\\([^\n]\\)" "\\1\\2")))
+;;     
+
+
+(require 'hatena-vars)
+(require 'hatena-kw)
+(require 'font-lock)
+(require 'derived)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;ËÜÂÎ
+
+(if hatena-diary-mode-map
+    ()
+  (setq hatena-diary-mode-map (make-keymap))
+  (define-key hatena-diary-mode-map "\C-c\C-p" 'hatena-submit)
+  (define-key hatena-diary-mode-map "\C-c\C-b" 'hatena-find-previous)
+  (define-key hatena-diary-mode-map "\C-c\C-f" 'hatena-find-following)
+  (define-key hatena-diary-mode-map "\C-ct" 'hatena-change-trivial))
+
+(defconst hatena-today-buffer nil)
+(defun hatena (&optional date)
+  "Hatena::Diary ¥Ú¡¼¥¸¤ò³«¤¯. "
+  (interactive)
+  (unless (file-exists-p hatena-directory)
+    (make-directory hatena-directory t))
+  (if (not date)
+      (progn
+       ;;º£Æü¤ÎÆüµ­¤Î¥Ð¥Ã¥Õ¥¡¤ò³Îǧ(cookie ¤Î´ÉÍý¤Î¤¿¤á)
+       ;;¸ºß¤·¤Ê¤±¤ì¤Ð¡¢¥¯¥Ã¥­¡¼¤ò¼èÆÀ¤¹¤ë¡£
+       (let ((buffer-new-p t)
+             (file-new-p t))
+         (if (memq hatena-today-buffer (buffer-list))
+             (setq buffer-new-p nil)
+           (hatena-login))
+         (setq hatena-today-buffer
+               (find-file 
+                (concat hatena-directory (hatena-today-date))))
+         ;;¥Õ¥¡¥¤¥ë¡¢¥Ð¥Ã¥Õ¥¡¤¬Â¸ºß¤·¤Ê¤±¤ì¤Ð¡¢web¤ÎÆüµ­¤ò¥Á¥§¥Ã¥¯
+         (if (file-exists-p (concat hatena-directory (hatena-today-date)))
+             (setq file-new-p nil))
+         (if (and file-new-p buffer-new-p)
+             (progn 
+               (message "Æüµ­¥Õ¥¡¥¤¥ë¤â¥Ð¥Ã¥Õ¥¡¤â¤¢¤ê¤Þ¤»¤ó¡£Web¤ò¥Á¥§¥Ã¥¯¤·¤Þ¤¹")
+               (hatena-insert-webdiary)))
+         )
+       )
+    (if (string-match hatena-fname-regexp date)
+        (find-file (concat hatena-directory date))
+      (error "Not date"))
+    
+    )
+  ;;keyword-cheating
+  (if hatena-kw-if
+      (hatena-kw-init)
+    nil)
+  )
+
+(define-derived-mode hatena-diary-mode html-mode "Hatena"
+"¤Ï¤Æ¤Ê¥â¡¼¥É. "
+    (font-lock-add-keywords 'hatena-diary-mode
+          (list
+           (list "^\\(Title\\) \\(.*\\)$"
+                 '(1 hatena-header-face t)
+                 '(2 hatena-title-face t))
+          ;; ¸«½Ð¤·
+           (list  "\\(<[^\n/].*>\\)\\([^<>\n]*\\)\\(</.*>\\)"
+                  '(1 hatena-html-face t)
+                  '(2 hatena-link-face t)
+                  '(3 hatena-html-face t))
+          ;; ¸«½Ð¤·2
+           (list  "^\\(\\*[^\n ]*\\) \\(.*\\)$"
+                  '(1 hatena-markup-face t)
+                  '(2 hatena-html-face t))
+          ;;Æü쵭ˡ
+           (list "\\(\\[?\\(a:id\\|f:id\\|i:id\\|r:id\\|map:id\\|graph:id\\|g.hatena:id\\|b:id:\\|id\\|google\\|isbn\\|asin\\|http\\|http\\|ftp\\|mailto\\|search\\|amazon\\|rakuten\\|jan\\|ean\\|question\\|tex\\):\\(\\([^\n]*\\]\\)\\|[^ ¡¡\n]*\\)\\)"
+                 '(1 hatena-markup-face t))
+           (list  "^:\\([^:\n]+\\):"
+                  '(0 hatena-markup-face t)
+                  '(1 hatena-link-face t))
+           (list  "^\\([-+]+\\)"
+                  '(1 hatena-markup-face t))
+           (list  "\\(((\\).*\\())\\)"
+                  '(1 hatena-markup-face t)
+                  '(2 hatena-markup-Face T))
+           (list  "^\\(>>\\|<<\\|><!--\\|--><\\|>|?|\\||?|<\\)"
+                  '(1 hatena-markup-face t))
+           (list  "\\(s?https?://\[-_.!~*'()a-zA-Z0-9;/?:@&=+$,%#\]+\\)"
+                  '(1 hatena-html-face t))))
+    (font-lock-mode 1)
+    (set-buffer-modified-p nil)
+  (run-hooks 'hatena-diary-mode-hook))
+
+;;hatena-diary-mode ¥È¥°¥ë
+(setq auto-mode-alist
+      (append 
+       (list 
+       (cons (concat hatena-directory hatena-fname-regexp) 'hatena-diary-mode))
+       auto-mode-alist))
+
+
+(defun hatena-today-date(&optional offset date)
+;; date ¤ÏǤ°Õ¤ÎÆüÉÕ¡¢offset ¤ÏǤ°Õ¤Î»þ´Ö¡¢-24 ¤Ç°ìÆü¿Ê¤à
+  (let ( (lst (if date
+                 (progn
+                   (string-match "\\([0-9][0-9][0-9][0-9]\\)\\([0-9][0-9]\\)\\([0-9][0-9]\\)" date)
+                   (list 0 0 0 
+                         (string-to-int (match-string 3 date))
+                         (string-to-int (match-string 2 date))
+                         (string-to-int (match-string 1 date)) 0 nil 32400))
+                 (decode-time (current-time))) ))
+    (setcar 
+     (nthcdr 2 lst) 
+     (- (nth 2 lst) (if offset offset hatena-change-day-offset)))
+    (format-time-string "%Y%m%d" 
+                       (apply 'encode-time lst ))))
+
+(defun hatena-submit (&optional file userid)
+ "¤Ï¤Æ¤ÊÆüµ­ http://d.hatena.ne.jp/ ¤Ë post ¥á¥½¥Ã¥É¤ÇÆüµ­¤òÁ÷¤ë. curl ¤ò»È¤¦. "
+  (interactive)
+
+  (if file nil 
+    (setq file buffer-file-name)
+    (save-excursion
+      ;;"*t*" ¤Ë¤¹¤ë¤« "*pn*" ¤Ë¤¹¤ë¤«
+      (cond ( (= hatena-entry-type 0)
+             (progn
+               (let ((i 0)
+                     (j 0))
+                 (goto-char (point-min))
+                 (while (re-search-forward "^\\*p\\([0-9]\\)\\*" nil t)
+                   (if (< i (setq j (string-to-int (match-string 1))))
+                       (setq i j)))
+                 (goto-char (point-min))
+                 (while (re-search-forward "^\\(\\*\\)\\([[ ]\\)" nil t)
+                   (replace-match 
+                    (concat "*p" (format "%d" (setq i (1+ i))) "*\\2")
+                    )))))
+           ( (= hatena-entry-type 1)
+             (progn
+               (goto-char (point-min))
+               (while (re-search-forward "^\\(\\*\\)\\([[ ]\\)" nil t)
+                 (replace-match 
+                  (concat "*t*\\2")
+                  ))))
+    (t nil)
+    )
+      ;;¥¿¥¤¥È¥ë¤Î*t*¤ò»þ´Ö¤ËÃÖ¤­¤«¤¨¤ë
+      (goto-char (point-min))
+      (let ((i 0))
+       (while (re-search-forward "^\\*t\\*" nil t)
+         (replace-match 
+          (concat "*" (hatena-current-second i) "*")
+          (setq i (1+ i))
+          ))))
+    (save-buffer))
+
+  (if (not userid) 
+      (setq userid hatena-usrid))
+
+  (let ((filename (file-name-nondirectory file)))
+    (if (string-match hatena-fname-regexp filename)
+        (let* 
+            ((year (match-string 1 filename))
+             (month (match-string 2 filename))
+             (day (match-string 3 filename)) 
+             (date (concat year month day))
+             ;;¤Ï¤Æ¤Ê¤ËÄÌÃΤ¹¤ë¥¿¥¤¥à¥¹¥¿¥ó¥×
+             (timestamp 
+              (format-time-string "%Y%m%d%H%m%S" (current-time)))
+             
+             (baseurl (concat "http://d.hatena.ne.jp/" userid "/"))
+             (referer (concat baseurl "edit?date=" date))
+             (nexturl (concat baseurl (concat year month day)))
+             (url (concat baseurl "edit"))
+
+             (title "")
+             (send-file file)
+             (full-body 
+              (with-temp-buffer
+                (insert-file-contents send-file)
+               ;; ¥Ð¥Ã¥Õ¥¡¤òÁ÷¤ëÁ°¤Ë¸Æ¤Ð¤ì¤ë hooks
+               (run-hooks 'hatena-diary-mode-submit-hook)
+                (cond ( (string-match "\\`title[ ¡¡]*\\(.*\\)?\n" (buffer-string))
+                       (progn 
+                         (setq title (match-string 1 (buffer-string)))
+                         (substring (buffer-string)
+                                    (length (match-string 0 (buffer-string))))
+                         ))
+                     ;;¸Å¤¤¼ÂÁõ
+                     ( (string-match hatena-header-regexp (buffer-string))
+                       (progn
+                         (setq title (match-string 1 (buffer-string)))
+                         (substring (buffer-string)
+                                    (1+ (length (match-string 0 (buffer-string)))))) )
+                     (t (buffer-string)))))
+             (body (hatena-url-encode-string full-body hatena-default-coding-system))
+             (trivial (if hatena-trivial "1" "0"))
+             (twit (hatena-url-encode-string hatena-twitter-prefix hatena-default-coding-system))
+             (post-data 
+              (concat "dummy=1"
+                     "&mode=enter"
+                      "&body=" body 
+                      "&trivial=" trivial 
+                      "&title=" title 
+                      "&day=" day 
+                      "&month=" month 
+                      "&year=" year 
+             "&twitter_notification_enabled=" (if hatena-twitter-flag "1" "")
+             "&twitter_notification_prefix=" twit
+                     ;; session ID for POST to hatena
+                     ;; this is a scheme of ensuring security in Hatena::Diary
+                     (concat "&rkm="
+                             (let* ((md5sum (md5 (with-temp-buffer
+                                                   (insert-file-contents hatena-cookie)
+                                                   (re-search-forward "rk\\s \\([0-9a-zA-Z]+\\)")
+                                                   (concat (buffer-substring
+                                                            (match-beginning 1)
+                                                            (match-end 1)))) nil nil 'utf-8))
+                                    (p 0)
+                                    (temp ""))
+                               (while (> (length md5sum) p)
+                                 (setq temp
+                                       (concat
+                                        temp
+                                        (char-to-string (string-to-number
+                                                         (substring md5sum p (+ p 2)) 16))))
+                                 (setq p (+ p 2)))
+                               (substring (base64-encode-string temp) 0 22)))
+                     ;; if "date" element exists ,
+                     ;; command can't create the new page at hatena
+                      (if (hatena-check-newpage referer) 
+                          (concat "&date=" date))
+                      "&timestamp=" timestamp )))
+
+         (with-temp-file hatena-tmpfile 
+           (insert post-data))
+
+         (message "%s => %s" filename referer)
+         (call-process hatena-curl-command nil nil nil 
+                       "-b" hatena-cookie
+                       "-x" hatena-proxy
+                       "--data" (concat "@" hatena-tmpfile)
+                       url)
+         
+         (message "posted")
+         (and (functionp hatena-browser-function)
+              (funcall hatena-browser-function nexturl))
+         )
+      (error "Not Hatena file: %s" file)))
+  (setq hatena-twitter-prefix nil))
+
+(defun hatena-login ()
+  (interactive)
+  (if (file-exists-p hatena-cookie)
+      (delete-file hatena-cookie))
+  (message (concat "logging in to \"" hatena-url "\" as \"" hatena-usrid "\""))
+  (let ((password (hatena-ask-password)))
+
+    (call-process hatena-curl-command nil nil nil 
+                 "-k"  "-c" hatena-cookie
+                 "-x" hatena-proxy
+                 "-d" (concat "name=" hatena-usrid)
+                 "-d" (concat "password=" password)
+                 "-d" (concat "autologin=1")
+                 "-d" (concat "mode=enter")
+                 "https://www.hatena.ne.jp/login"))
+    (message "Say HAPPY! to Hatena::Diary"))
+
+
+(defun hatena-check-newpage (urldate)
+  "¥Ú¡¼¥¸¤¬ºîÀ®ºÑ¤ß¤«¤É¤¦¤«¥Á¥§¥Ã¥¯"
+  (message "checking diary ....")
+  (call-process hatena-curl-command nil nil nil 
+                  "-o" hatena-tmpfile2
+                  "-b" hatena-cookie
+                  urldate)
+  (if (save-excursion
+        (find-file hatena-tmpfile2)
+        (prog1 
+            (string-match "name=\"date\"" 
+                          (buffer-string))
+          (kill-this-buffer)))
+      (progn  
+       (message "modify diary")
+       t)
+    (message "make new diary") nil))
+
+(defun hatena-diary-file-p(file)
+  (let ((fname (file-name-nondirectory file)))
+    (if (string-match hatena-fname-regexp fname) t nil)))
+
+(defun hatena-get-diary-string(&optional date)
+  "¤Ï¤Æ¤Ê¤Ë¤¢¤ëÆüµ­¥Õ¥¡¥¤¥ë¤ò¼è¤ê¡¢¤½¤Îʸ»úÎó¤òÊÖ¤¹¡£
+¥í¥°¥¤¥ó¤·¤Æ¤¤¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£"
+  (if (not date) (error "not date"))
+  (message "checking diary of %s ...." date)
+  (let ((urldate (concat "http://d.hatena.ne.jp/"
+                         hatena-usrid
+                         "/edit?date="
+                         date)))
+    (call-process hatena-curl-command nil nil nil 
+                  "-o" hatena-tmpfile
+                  "-b" hatena-cookie
+                  urldate))
+  (with-temp-buffer
+    "*hatena-get*"
+    (insert-file-contents hatena-tmpfile)
+    ;;¤³¤³¤Ê¤ó¤È¤«...
+    (goto-char (point-min))(while (replace-string "&quot;" "\""))
+    (goto-char (point-min))(while (replace-string "&amp;" "&"))
+    (goto-char (point-min))(while (replace-string "&gt;" ">"))
+    (goto-char (point-min))(while (replace-string "&lt;" "<"))
+    (goto-char (point-min))(while (replace-string "&#39;" "'"))
+
+    (if (string-match "<textarea[^>\n]*>\\(\\(\n\\|.\\)*?\\)</textarea>" 
+                      (buffer-string))
+          (match-string 1 (buffer-string)) nil)))
+
+(defun hatena-insert-webdiary(&optional date)
+  "web ¤ÎÆüµ­¤òÁÞÆþ¤¹¤ë¡£"
+  (interactive)
+  (if date nil
+      (setq date (file-name-nondirectory buffer-file-name)))
+  (if (string-match hatena-fname-regexp date)
+      (insert (hatena-get-diary-string date))
+    (error "not date or hatena file")))
+
+(defun hatena-delete-diary(&optional file userid)
+  "Æüµ­¤òºï½ü¤¹¤ë¡£¥í¡¼¥«¥ë¤Ïºï½ü¤·¤Ê¤¤¡£"
+  (interactive)
+  ;;¥Ð¥Ã¥Õ¥¡¤«¤éÆɤà¤ÈÁ÷¿®»þ´Ö¤Î¤È¤³¤í¤Ë"deleted"
+    (if file nil 
+      (setq file buffer-file-name))
+    (if (not userid)
+       (setq userid hatena-usrid))
+    (let ((filename (file-name-nondirectory file)))
+      (if (string-match hatena-fname-regexp filename)
+         (let* 
+             ((year (match-string 1 filename))
+              (month (match-string 2 filename))
+              (day (match-string 3 filename)) 
+              (date (concat year month day))
+              (baseurl (concat "http://d.hatena.ne.jp/" userid "/"))
+              (referer (concat baseurl "edit?date=" date))
+              (url (concat baseurl "edit"))
+
+              (edit (hatena-url-encode-string "¤³¤ÎÆü¤òºï½ü"))
+              (post-data 
+               (concat "edit=" edit
+                       "&date=" date
+                       (concat "&rkm="
+                             (let* 
+                                 ((md5sum (md5 
+                                           (with-temp-buffer
+                                             (insert-file-contents hatena-cookie)
+                                             (re-search-forward "rk\\s \\([0-9a-zA-Z]+\\)")
+                                             (concat (buffer-substring
+                                                      (match-beginning 1)
+                                                      (match-end 1)))) nil nil 'utf-8))
+                                  (p 0)
+                                  (temp ""))
+                               (while (> (length md5sum) p)
+                                 (setq temp
+                                       (concat
+                                        temp
+                                        (char-to-string (string-to-number
+                                                         (substring md5sum p (+ p 2)) 16))))
+                                 (setq p (+ p 2)))
+                               (substring (base64-encode-string temp) 0 22)))
+                       "&mode=delete")))
+           (message "deleting %s" referer)
+           (with-temp-file hatena-tmpfile (insert post-data))
+           
+           (call-process hatena-curl-command nil nil nil 
+                         "-b" hatena-cookie
+                         "-x" hatena-proxy
+                         "--data" (concat "@" hatena-tmpfile)
+                         url)
+           
+           (message "deleted"))
+       (error "Not Hatena file: %s" file))))
+
+(defun hatena-logout()
+  (interactive)
+  (call-process hatena-curl-command nil nil nil 
+               "-b" hatena-cookie
+               "-x" hatena-proxy
+               "http://d.hatena.ne.jp/logout")
+  (message "logged out from d.hatena.ne.jp"))
+
+(defun hatena-ask-password()
+  (let (pass str)
+    (if (null hatena-use-file)
+       (setq pass (read-passwd "password ? : "))
+      ;;¥Õ¥¡¥¤¥ë¤¬Ìµ¤«¤Ã¤¿¾ì¹ç¤Ïºî¤ë¡£
+      (if (not (file-exists-p hatena-password-file))
+         (append-to-file (point) (point) hatena-password-file))
+      (setq str (with-temp-buffer nil            
+                 (insert-file-contents hatena-password-file)
+                 (buffer-string)))
+      (if (string-match "[^ ]+" str)
+         (setq pass (base64-decode-string (match-string 0 str)))
+       (setq pass (read-passwd "password ? : "))
+       (with-temp-file hatena-password-file
+         (insert (base64-encode-string
+                  (format "%s" pass)))))
+    pass)))
+
+(defun hatena-exit()
+  "hatena-fname-regexp¤Ë¥Þ¥Ã¥Á¤¹¤ë¥Ð¥Ã¥Õ¥¡¤ò¤¹¤Ù¤ÆÊݸ¤·¤Æ¾Ãµî"
+  (interactive)
+  (if (yes-or-no-p "save all diaries and kill buffer ?")
+      (progn
+       (let ((buflist (buffer-list))         
+             (i 0))
+         (while (< i (length buflist))
+           (let ((bufname (buffer-name (nth i (buffer-list)))))
+             (if (string-match hatena-fname-regexp bufname)
+                 (progn 
+                   (if (buffer-modified-p (nth i (buffer-list)))
+                       (save-buffer (nth i (buffer-list))))
+                   (kill-buffer (nth i (buffer-list)))))
+             (setq i (1+ i))))))))
+
+(defun hatena-find-previous (&optional count file)
+  "count ÆüÁ°¤ÎÆüµ­¤ò³«¤¯ count ¤¬ nil ¤Ê¤é°ìÆü¤À¤±Ìá¤ë"
+  (interactive "p")
+  (hatena-find-pf (if count (- count) -1) (buffer-name)))
+
+(defun hatena-find-following (&optional count file)
+  "count Æü¸å¤ÎÆüµ­¤ò³«¤¯ count ¤¬ nil ¤Ê¤é°ìÆü¤À¤±¤¹¤¹¤à"
+  (interactive "p")
+  (hatena-find-pf (if count count 1) (buffer-name)))
+
+(defun hatena-find-pf(count &optional file)
+  (if (equal major-mode 'hatena-diary-mode)
+      (if (not file)
+         (setq file (buffer-name)))
+    (error "not hatena mode"))
+  (let ((find-previous 
+        (lambda (element count lst)
+          (let* ((sublst (member element lst))
+                 (result (+ (- (length lst) (length sublst))
+                            count)))
+            (if (or (null sublst)
+                    (< result 0)) nil
+              (nth result lst)))))
+       previous)
+    (setq previous
+         (funcall find-previous
+                  (file-name-nondirectory file)
+                  (if (not count) 1 count)
+                  (directory-files 
+                   hatena-directory 
+                   nil hatena-fname-regexp)))
+    (if previous (find-file (concat (file-name-directory file) previous))
+      ;;¸«¤Ä¤«¤é¤Ê¤¤»þ¤Ï¡¢Ì¤Íè¤ÎÆüÉÕ¤ò¿Ò¤Í¤ë¡£
+      (let ((filename (read-string "ºîÀ®¤·¤¿¤¤ÆüÉÕ¤òÆþÎÏ: " 
+                                  (hatena-today-date (* -24 count) (buffer-name)) nil)))
+       (if (string-match hatena-fname-regexp filename)
+           (progn
+             (find-file filename)
+             (save-buffer))
+         (error "ÆüÉÕ¥Õ¥¡¥¤¥ë¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó!!"))))))
+
+(defun hatena-get-webdiary ()
+  "http://d.hatena.ne.jp/usrid/export ¤ò¼è¤Ã¤Æ¤­¤ÆÊÑ´¹¡£Â­¤ê¤Ê¤¤Æüµ­Ê¬¤ò¥Õ¥¡¥¤¥ë¤Ë­¤¹¡£"
+  (interactive)
+  ;;export¤ò¤È¤Ã¤Æ¤¯¤ë
+  (call-process hatena-curl-command nil nil nil 
+               "-o" hatena-tmpfile
+               "-b" hatena-cookie
+               (concat "http://d.hatena.ne.jp/" hatena-usrid "/export" ))
+
+  ;;export ¤Ï utf-8 ¤Ê¤Î¤Ç¡¢hatena-default-coding-system  ¤Ëľ¤¹¡£
+  (let ((filelst (directory-files 
+                  hatena-directory 
+                  nil hatena-fname-regexp))
+       (title-regexp "<day date=\"\\([0-9][0-9][0-9][0-9]\\)-\\([0-9][0-9]\\)-\\([0-9][0-9]\\)\" title=\"\\(.*\\)\">\n<body>\n")
+       pt-start pt-end day title body)
+    (with-temp-buffer 
+      "*hatena-get*"
+      (insert-file-contents hatena-tmpfile)
+      (set-buffer-file-coding-system hatena-default-coding-system)
+      (hatena-translate-reverse-region (point-min) (point-max))
+      
+      (while (re-search-forward title-regexp nil t)
+       (setq day (concat (match-string 1) (match-string 2) (match-string 3)))
+       (setq title (match-string 4))
+       (setq pt-start (match-end 0))
+       (re-search-forward "</body>\n</day>" nil t)
+       (setq pt-end (match-beginning 0))
+       (setq body (buffer-substring pt-start pt-end))
+       (save-excursion
+         (if (null (member day filelst))
+             (progn
+               (hatena day)
+               (set-buffer-file-coding-system hatena-default-coding-system)
+               (message "creatig %s" day)
+               (insert body)
+               (save-buffer)
+               (kill-buffer (current-buffer))))))
+      (message "finished"))))
+
+
+
+(defun hatena-url-encode-string (str &optional coding)
+  "w3m-url-encode-string ¤«¤é¥³¥Ô¡¼"
+  (apply (function concat)
+        (mapcar
+         (lambda (ch)
+           (cond
+            ((eq ch ?\n)               ; newline
+             "%0D%0A")
+            ((string-match "[-a-zA-Z0-9_:/.]" (char-to-string ch)) ; xxx?
+             (char-to-string ch))      ; printable
+            ((char-equal ch ?\x20)     ; space
+             "+")
+            (t
+             (format "%%%02x" ch))))   ; escape
+         ;; Coerce a string to a list of chars.
+         (append (encode-coding-string (or str "")
+                                       (or coding
+                                           buffer-file-coding-system
+                                           'iso-2022-7bit))
+                 nil))))
+
+(defun hatena-twitter-prefix-input (ts)
+  "Æüµ­¹¹¿·»þ¤ÎÆâÍÆÆþÎÏ"
+  (interactive "sTwitter prefix:")
+  (setq hatena-twitter-prefix ts))
+
+;----------------Æüìʸ»ú¤ÎÊÑ´¹----------------
+;;yahtml ¤ò²þÊÑ
+(defvar hatena-entity-reference-chars-alist
+  '((?> . "gt") (?< . "lt") (?& . "amp") (?\" . "quot"))
+  "translation table from character to entity reference")
+(defvar hatena-entity-reference-chars-regexp "[><&\\]")
+(defvar hatena-entity-reference-chars-reverse-regexp "&\\(gt\\|lt\\|amp\\|quot\\);")
+
+(defun hatena-translate-region (beg end)
+  "Translate inhibited literals."
+  (interactive "r")
+  (save-excursion
+    (save-restriction
+      (narrow-to-region beg end)
+      (let ((ct hatena-entity-reference-chars-alist))
+       (goto-char beg)
+       (while (re-search-forward hatena-entity-reference-chars-regexp nil t)
+         (replace-match
+          (concat "&" (cdr (assoc (preceding-char) ct)) ";")))))))
+
+(defun hatena-translate-reverse-region (beg end)
+  "Translate entity references to literals."
+  (interactive "r")
+  (save-excursion
+    (save-restriction
+      (narrow-to-region beg end)
+      (let ((ct hatena-entity-reference-chars-alist))
+       (goto-char beg)
+       (while (re-search-forward
+               hatena-entity-reference-chars-reverse-regexp nil t)
+         ;(setq c (preceding-char))
+         (replace-match 
+          (string (car 
+                (rassoc (match-string 1)
+                        ct)))))))))
+
+(defun hatena-change-trivial ()
+  (interactive)
+  (if (not hatena-trivial)
+      (progn
+       (message "¤Á¤ç¤Ã¤È¤·¤¿¹¹¿·¥â¡¼¥É")
+       (setq hatena-trivial t))
+    (setq hatena-trivial nil)
+    (message "¹¹¿·¥â¡¼¥É")))
+
+(defun hatena-twitter ()
+  (interactive)
+  (if (not hatena-twitter-flag)
+      (progn
+       (message "twitter¤ËÄÌÃÎ")
+       (setq hatena-twitter-flag t))
+    (setq hatena-twitter-flag nil)
+    (message "twitter¤Ë¤ÏÄÌÃΤ·¤Ê¤¤")))
+
+(defun hatena-current-second(number)
+  "¸½ºß¤Þ¤Ç¤ÎÉÿô¤òÊÖ¤¹¡£emacs ¤Ç¤ÏÀ°¿ô¤¬¥±¥¿°î¤ì¤¹¤ë¤Î¤Ç¡¢ÉâÆ°¾®¿ôÅÀ¤Ç"
+  (let* ((ct (current-time))
+        (high (float (car ct)))
+        (low (float (car (cdr ct))))
+        str)
+    (setq str (format "%f"(+ 
+                          (+ (* high (lsh 2 15)) low)
+                          number)))
+    (substring str 0 10) ;;
+    ))
+
+(provide 'hatena-diary-mode)
+
+;;;;;end of file
diff --git a/hatena-kw.el b/hatena-kw.el
new file mode 100644 (file)
index 0000000..bdf36bd
--- /dev/null
@@ -0,0 +1,133 @@
+(provide 'hatena-kw)\r
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
+;;;; kw-cheating-section.\r
+\r
+;;hatena-kw-cheating ¤ò»È¤¦¾ì¹ç¡£`hatena-tools.pl' ¤Î¤¢¤ë¥Ç¥£¥ì¥¯¥È¥ê¡£\r
+;;hatena-mode.el ¤ÈƱ¤¸¡£\r
+(defvar hatena-plugin-directory nil)\r
+\r
+(defconst hatena-kw-if nil\r
+  "¥Ç¥Õ¥©¥ë¥È¤Ç kw-cheating(¾¿Í¤ÎÆüµ­¤Îή¤·Æɤß) ¤ò¤¹¤ë¤«¤É¤¦¤«")\r
+\r
+(defvar hatena-kw-list-buf nil)\r
+(defvar hatena-kw-cheating-buf nil)\r
+(defvar hatena-edit-buf nil)\r
+\r
+(defvar hatena-kw-process nil\r
+  "perl ¤Î¥×¥í¥»¥¹")\r
+\r
+(defun hatena-kw-init()\r
+  (interactive)\r
+  ;;¤Þ¤ºÁë¤ò°ì¤Ä¤Ë¥ê¥»¥Ã¥È¤·¤Æ¤«¤é¡¢Æó¤Ä¤Ë³ä¤ë¡£\r
+  ;;¤³¤¦¤¹¤ë¤È¡¢¤¤¤Ä `M-x hatena' ¤·¤Æ¤âÁ뤬Æó¤Ä¤¢¤ë¾õ¶·¤Ë¤Ê¤ë¡£\r
+  (delete-other-windows)\r
+  (setq hatena-edit-buf (current-buffer))\r
+  ;;hatena-edit-wdw Æüµ­¤ò½ñ¤¯¥Ð¥Ã¥Õ¥¡\r
+  ;;hatena-keyword-cheating-wdw Â¾¤ÎÆüµ­¤ò¸«¤ë¥¦¥£¥ó¥É¥¦\r
+  (setq hatena-edit-wdw (selected-window))\r
+  (setq hatena-kw-cheating-wdw \r
+       (split-window hatena-edit-wdw \r
+                     (floor (* (window-height)\r
+                               hatena-kw-window-split-ratio))))\r
+  (save-selected-window \r
+    (select-window hatena-kw-cheating-wdw)\r
+    (setq hatena-kw-cheating-buf\r
+         (switch-to-buffer "*hatena-keyword-cheating*"))\r
+    (setq mode-name "Hatena kw-cheating"))\r
+  ;;¥¿¥¤¥Þ¡¼¥¹¥¿¡¼¥È\r
+  (if hatena-kw-post-timer\r
+      (cancel-timer hatena-kw-post-timer))\r
+  (if hatena-kw-ruby-timer\r
+      (cancel-timer hatena-kw-ruby-timer))\r
+  (if hatena-kw-get-timer\r
+      (cancel-timer hatena-kw-get-timer))\r
+  (setq hatena-kw-post-timer\r
+       (run-at-time 0 \r
+                    hatena-kw-repeat\r
+                    'hatena-kw-post-func))\r
+  (setq hatena-kw-ruby-timer\r
+       (run-at-time (/ hatena-kw-repeat 4)\r
+                    hatena-kw-repeat\r
+                    'hatena-kw-ruby-func))\r
+  (setq hatena-kw-get-timer\r
+       (run-at-time (/ hatena-kw-repeat 2);; get ¤Ï post ¤è¤ê¾¯¤·Ã٤餻¤ë\r
+                    hatena-kw-repeat\r
+                    'hatena-kw-get-func))\r
+  ;; ¤Ï¤Æ¤Ê¤Ë¥­¡¼¥ï¡¼¥É¤òÌ䤤¹ç¤ï¤»¤ë¤¿¤á¤Î¥Ú¡¼¥¸¤òºî¤ë\r
+  (hatena-kw-submit hatena-kw-temp-diary t)\r
+  (message (concat "creating diary on " hatena-url "for kw-cheating"))\r
+  )\r
+\r
+(defun hatena-kw-final()\r
+  (interactive)\r
+  (if hatena-kw-post-timer\r
+      (cancel-timer hatena-kw-post-timer))\r
+  (if hatena-kw-ruby-timer\r
+      (cancel-timer hatena-kw-ruby-timer))\r
+  (if hatena-kw-get-timer\r
+      (cancel-timer hatena-kw-get-timer)))\r
+\r
+(defun hatena-kw-post-func()\r
+  "`hatena-kw-temp-diary' ¤ËÈóƱ´ü¥Ý¥¹¥È. "\r
+;  (if (string-match "Hatena" mode-name)\r
+      (progn\r
+       (hatena-kw-submit hatena-kw-temp-diary))\r
+;    (cancel-timer hatena-kw-post-timer));; hatena-diary-mode ¤Ç¤Ê¤±¤ì¤Ð¡¢Ä¾¤Á¤ËÄä»ß¤¹¤ë¡£\r
+  )\r
+\r
+(defun hatena-kw-get-func()\r
+  "ruby ¤Î output ¤ò hatena-kw-cheating-buf ¤Ëɽ¼¨¤¹¤ë¡£"\r
+;  (if (string-match "Hatena" mode-name)\r
+;      (progn\r
+         (with-current-buffer (current-buffer)\r
+           (set-buffer hatena-kw-cheating-buf)\r
+           (delete-region (point-min) (point-max)) ;;Á´Éô¾Ã¤·¤Æ\r
+           ;;from insert-file-contents-as-coding-system\r
+           (let ((coding-system-for-read 'euc-jp)\r
+                 format-alist)\r
+             (insert-file-contents hatena-kw-result-file))\r
+           ;;´Ê°×¥ì¥ó¥À¥ê¥ó¥°\r
+           (goto-char (point-min))\r
+           (while (re-search-forward "<[^>]+>" nil t)\r
+                              (replace-match "" nil nil))\r
+           (goto-char (point-min))\r
+           (while (re-search-forward "\n\t+" nil t)\r
+                              (replace-match "\n" nil nil))\r
+           (goto-char (point-min))\r
+           (while (re-search-forward "\n+" nil t)\r
+                              (replace-match "\n" nil nil))\r
+           \r
+           )\r
+;        )\r
+;    (cancel-timer hatena-kw-get-timer) ;; hatena-diary-mode ¤Ç¤Ê¤±¤ì¤Ð¡¢Ä¾¤Á¤ËÄä»ß¤¹¤ë¡£\r
+ ;   (message "Hatena get-timer cancelled"))\r
+  )\r
+\r
+(defvar hatena-kw-process nil)\r
+(defun hatena-kw-perl-func(today)\r
+  "  hatena-tools.pl ¤Ë½èÍý¤òÅϤ¹¡£ "\r
+      (start-process "hatena-kw-process" \r
+                "*hatena keyword*"\r
+                "perl"\r
+                (concat hatena-plugin-directory "hatena-tools.pl")\r
+                (concat hatena-directory today)\r
+                "firefox"\r
+                "10"\r
+                "10"\r
+                )\r
+)\r
+;(hatena-kw-perl-func "20051016")\r
+\r
+\r
+(defun hatena-current-second(number)\r
+  "¸½ºß¤Þ¤Ç¤ÎÉÿô¤òÊÖ¤¹¡£emacs ¤Ç¤ÏÀ°¿ô¤¬¥±¥¿°î¤ì¤¹¤ë¤Î¤Ç¡¢ÉâÆ°¾®¿ôÅÀ¤Ç"\r
+  (let* ((ct (current-time))\r
+        (high (float (car ct)))\r
+        (low (float (car (cdr ct))))\r
+        str)\r
+    (setq str (format "%f"(+ \r
+                          (+ (* high (lsh 2 15)) low)\r
+                          number)))\r
+    (substring str 0 10) ;;\r
+    ))\r
+\r
diff --git a/hatena-tools.pl b/hatena-tools.pl
new file mode 100644 (file)
index 0000000..fffea85
--- /dev/null
@@ -0,0 +1,75 @@
+#!/usr/local/bin/perl\r
+\r
+use strict;\r
+use XMLRPC::Lite;\r
+use LWP::Simple;\r
+use Jcode;\r
+\r
+my $rpc = XMLRPC::Lite->new;\r
+my $body ="";\r
+my $command = $ARGV[1];\r
+my $sleep_time = $ARGV[2];\r
+my $repeat_time = $ARGV[3];\r
+$rpc->proxy('http://d.hatena.ne.jp/xmlrpc');\r
+\r
+open BASETEXT, $ARGV[0];\r
+while($_ = <BASETEXT>){\r
+    chomp;\r
+    $body = $body."$_\n";\r
+}\r
+close BASETEXT;\r
+\r
+#XMLRPC¤ò»È¤Ã¤Æ¥­¡¼¥ï¡¼¥É¤ò¼èÆÀ¤¹¤ë¤¿¤á¤Î¥µ¥Ö¥ë¡¼¥Á¥ó\r
+\r
+my $res = $rpc->call(\r
+                    'hatena.setKeywordLink',\r
+                    {\r
+                        body => XMLRPC::Data->type('string',Jcode->new($body,'euc')->utf8),\r
+                        score => 0,\r
+#                           cname => ['book','movie'],\r
+#                           a_target => '_blank',\r
+#                           a_class => 'keyword',\r
+                    }\r
+                    );\r
+if (my $fault = $res->fault){\r
+    for (keys %{$fault}){\r
+    warn $_."=>".$fault->{$_};\r
+  }\r
+} else {\r
+  $body = $res->result;\r
+  $body =~ s/&lt;/</ig;\r
+  $body =~ s/&gt;/>/ig;\r
+  $body =~ s/&quot;/"/ig;\r
+#  print Jcode->new($body,'utf8')->euc;\r
+}\r
+\r
+$body = Jcode->new($body,'utf8')->euc;\r
+my @hoge=();\r
+\r
+while( $body =~ /(http:\/\/d.hatena.ne.jp\/[^"]+)/g )\r
+{\r
+    @hoge = (@hoge , $1)\r
+}\r
+\r
+my $num = @hoge;\r
+my $tmpurl="";\r
+my $targeturl="";\r
+my @heke=();\r
+\r
+while( $repeat_time > 0)\r
+{\r
+    $tmpurl = get($hoge[int(rand $num-1)]);\r
+    @heke=();\r
+    while( $tmpurl =~ /<a href="(\/[a-zA-Z0-9]+\/[0-9]{8})">/g ){\r
+       @heke = (@heke , $1);\r
+       }\r
+    $num = @heke;\r
+    print @heke;\r
+    print "\n";\r
+    \r
+    $targeturl = $heke[int(rand $num-1)];\r
+    print $targeturl;\r
+    system ($command ,"http://d.hatena.ne.jp".$targeturl);\r
+    sleep $sleep_time;\r
+    $repeat_time = $repeat_time-1;\r
+}\r
diff --git a/hatena-vars.el b/hatena-vars.el
new file mode 100644 (file)
index 0000000..7d23210
--- /dev/null
@@ -0,0 +1,159 @@
+(provide 'hatena-vars)\r
+\r
+(defgroup hatena nil\r
+  "major mode for Hatena::Diary"\r
+  :prefix "hatena-"\r
+  :group 'hypermedia)\r
+\r
+(defgroup hatena-face nil\r
+  "Hatena, Faces."\r
+  :prefix "hatena-"\r
+  :group 'hatena)\r
+\r
+(defcustom hatena-usrid nil\r
+  "hatena-diary-mode ¤Î¥æ¡¼¥¶¡¼Ì¾"\r
+  :type 'string\r
+  :group 'hatena)\r
+\r
+(defcustom hatena-directory \r
+  (expand-file-name "~/.hatena/")\r
+  "Æüµ­¤òÊݸ¤¹¤ë¥Ç¥£¥ì¥¯¥È¥ê."\r
+  :type 'directory\r
+  :group 'hatena)\r
+\r
+(defcustom hatena-init-file (concat\r
+                            (file-name-as-directory hatena-directory)\r
+                            "init")\r
+  "*hatena-diary-mode ¤Î½é´ü²½¥Õ¥¡¥¤¥ë¡£"\r
+  :type 'file\r
+  :group 'hatena)\r
+\r
+(defcustom hatena-password-file \r
+  (expand-file-name (concat hatena-directory ".password"))\r
+  "¥Ñ¥¹¤òÊݸ¤¹¤ë¥Õ¥¡¥¤¥ë"\r
+  :type 'file\r
+  :group 'hatena)\r
+\r
+(defcustom hatena-entry-type 1\r
+  "¥¨¥ó¥È¥ê¤Î¥Þ¡¼¥¯¥¢¥Ã¥× * ¤ò¤É¤Î¤è¤¦¤Ë½èÍý¤¹¤ë¤«¡£\r
+0¤Ê¤é * ¤ò *pn* ¤Ë¡¢1 ¤Ê¤é * ¤ò *<time>* ¤ËÃÖ¤­¤«¤¨¤ÆÁ÷¿®"\r
+  :type 'integer\r
+  :group 'hatena)\r
+\r
+(defcustom hatena-change-day-offset 6\r
+  "¤Ï¤Æ¤Ê¤Ç, ÆüÉÕ¤òÊѤ¨¤ë»þ´Ö .+6 ¤Ç¸áÁ° 6 »þ¤ËÆüÉÕ¤òÊѹ¹¤¹¤ë."\r
+  :type 'integer\r
+  :group 'hatena)\r
+\r
+(defcustom hatena-trivial nil\r
+  "¤Á¤ç¤Ã¤È¤·¤¿¹¹¿·¤ò¤¹¤ë¤«¤É¤¦¤«. non-nil ¤Ç\"¤Á¤ç¤Ã¤È¤·¤¿¹¹¿·\"¤Ë¤Ê¤ë"\r
+  :type 'boolean\r
+  :group 'hatena)\r
+\r
+(defcustom hatena-use-file t\r
+  "¥Ñ¥¹¥ï¡¼¥É¤ò(°Å¹æ²½¤·¤Æ)Êݸ¤¹¤ë¤«¤É¤¦¤« non-nil ¤Ê¤é¥Ñ¥¹¥ï¡¼¥É¤ò base 64 ¤Ç¥¨¥ó¥³¡¼¥É¤·¤ÆÊݸ¤¹¤ë"\r
+  :type 'boolean\r
+  :group 'hatena)\r
+\r
+(defcustom hatena-cookie \r
+  (expand-file-name \r
+   (concat hatena-directory "Cookie@hatena"))\r
+  "¥¯¥Ã¥­¡¼¤Î̾Á°¡£"\r
+  :type 'file\r
+  :group 'hatena)\r
+\r
+(defcustom hatena-browser-function nil  ;; ÉáÄ̤ϡ¢'browse-url\r
+  "Function to call browser.\r
+If non-nil, `hatena-submit' calls this function.  The function\r
+is expected to accept only one argument(URL)."\r
+  :type 'symbol\r
+  :group 'hatena)\r
+\r
+(defcustom hatena-proxy ""\r
+  "curl ¤ËɬÍפʻþ¡¢¤³¤³¤ÇÀßÄꤹ¤ë"\r
+  :type 'string\r
+  :group 'hatena)\r
+\r
+(defcustom hatena-default-coding-system 'euc-jp\r
+  "¥Ç¥Õ¥©¥ë¥È¤Î¥³¡¼¥Ç¥£¥ó¥°¥·¥¹¥Æ¥à"\r
+  :type 'symbol\r
+  :group 'hatena)\r
+\r
+\r
+(defcustom hatena-url "http://d.hatena.ne.jp/"\r
+  "¤Ï¤Æ¤Ê¤Î¥¢¥É¥ì¥¹"\r
+  :type 'string\r
+  :group 'hatena)\r
+\r
+(defcustom hatena-twitter-flag nil\r
+  "Æüµ­¹¹¿·»þ¤Ëtwitter¤ËÄÌÃΤò¤¹¤ë¤«¤É¤¦¤«. non-nil ¤Ç\"twitter¤ËÄÌÃÎ\"¤Ë¤Ê¤ë"\r
+  :type 'boolean\r
+  :group 'hatena)\r
+\r
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
+\r
+\r
+;;Æüµ­¥Õ¥¡¥¤¥ë¤ÎÀµµ¬É½¸½\r
+(defvar hatena-fname-regexp\r
+  "\\([0-9][0-9][0-9][0-9]\\)\\([01][0-9]\\)\\([0-3][0-9]\\)$" )\r
+(defvar hatena-diary-mode-map nil)\r
+\r
+;;¸Å¤¤»ÅÍÍ\r
+(defvar hatena-header-regexp \r
+  (concat "\\`      Title: \\(.*\\)\n"\r
+          "Last Update: \\(.*\\)\n"\r
+          "____________________________________________________" ))\r
+\r
+(defvar hatena-tmpfile \r
+  (expand-file-name (concat hatena-directory "hatena-temp.dat")))\r
+(defvar hatena-tmpfile2\r
+  (expand-file-name (concat hatena-directory "hatena-temp2.dat")))\r
+(defvar hatena-curl-command "curl" "curl ¥³¥Þ¥ó¥É")\r
+\r
+(defvar hatena-twitter-prefix nil "twitter¤ËÅê¹Æ¤¹¤ëÆâÍÆ")\r
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
+;;face\r
+\r
+(defvar hatena-font-lock-keywords nil)\r
+(defvar hatena-html-face 'hatena-html-face)\r
+(defvar hatena-title-face 'hatena-title-face)\r
+(defvar hatena-header-face 'hatena-header-face)\r
+(defvar hatena-subtitle-face 'hatena-subtitle-face)\r
+(defvar hatena-markup-face 'hatena-markup-face)\r
+(defvar hatena-link-face 'hatena-link-face)\r
+\r
+(defface hatena-title-face\r
+  '((((class color) (background light)) (:foreground "Navy" :bold t))\r
+    (((class color) (background dark)) (:foreground "wheat" :bold t)))\r
+  "title¤Î face"\r
+  :group 'hatena-face)\r
+\r
+(defface hatena-header-face\r
+  '((((class color) (background light)) (:foreground "Gray70" :bold t))\r
+    (((class color) (background dark)) (:foreground "SkyBlue4" :bold t)))\r
+  "last update¤Î face"\r
+  :group 'hatena-face)\r
+\r
+(defface hatena-subtitle-face \r
+  '((((class color) (background light)) (:foreground "DarkOliveGreen"))\r
+    (((class color) (background dark)) (:foreground "wheat")))\r
+  "¥µ¥Ö¥¿¥¤¥È¥ë¤Îface"\r
+  :group 'hatena-face)\r
+\r
+(defface hatena-markup-face \r
+  '((((class color) (background light)) (:foreground "firebrick" :bold t))\r
+    (((class color) (background dark)) (:foreground "IndianRed3" :bold t)))\r
+  "¤Ï¤Æ¤Ê¤Î¥Þ¡¼¥¯¥¢¥Ã¥×¤Îface"\r
+  :group 'hatena-face)\r
+\r
+(defface hatena-html-face \r
+  '((((class color) (background light)) (:foreground "DarkSeaGreen4"))\r
+    (((class color) (background dark)) (:foreground "Gray50")))\r
+  "html¤Îface"\r
+  :group 'hatena-face)\r
+\r
+(defface hatena-link-face \r
+  '((((class color) (background light)) (:foreground "DarkSeaGreen4"))\r
+    (((class color) (background dark)) (:foreground "wheat")))\r
+  "html¥¿¥°¤Ç¶´¤Þ¤ì¤¿Éôʬ¤Îface"\r
+  :group 'hatena-face)
\ No newline at end of file