;; $Id: dancer-diary.el,v 1.93 2009/01/04 03:42:29 dancer Exp $
;; included in diary cvs since 2001 Aug 19.
;; Emacs LISP script for writing HTML diary inside EMACS.
;; Copyright 2001-2005 Junichi Uekawa
(provide 'dancer-diary)
(require 'psgml-html)
(defvar dancer-diary-diary-title-japanese
"つれづれ日記"
"The title string for the diary page for Japanese dancer-diary")
(defvar dancer-diary-diary-title-english
"Diary for "
"The title string for the diary page for English dancer-diary,
make sure that this string ends with a space, or it will look funny")
(defvar dancer-diary-category-alist
'(("Life" . 1))
"Associated list storing the possible list of categories")
(defvar dancer-diary-thisurl-prefix
"http://unconfigured.org/"
"The URL prefix, such as http://www.netfort.gr.jp/~dancer/diary/")
(defvar dancer-diary-thismonth-update t
"Update current-month diary index or not.")
(defvar dancer-diary-rss-author nil
"The name of the author for rss entry")
(defvar dancer-diary-rss-title "dancer-diary recent entries"
"The name of the author for rss entry")
(defvar dancer-diary-punctuation-stop-marks-regexp
"\\([^??..。]*.\\)"
"Punctuation marks for stopping the title text.")
(add-to-list 'auto-mode-alist '("diary/[^/]*\.html\.ja$" . dancer-diary-japanese-mode))
(add-to-list 'auto-mode-alist '("diary/[^/]*\.html\.en$" . dancer-diary-english-mode))
(defvar dancer-diary-google-analytics-code
;; start google analytics code
(concat
"\n"
"\n"
;; end google analytics code
)
"Google Analytics code")
(defun dancer-diary-internal-make-local-variable ()
"An internal function to make local variables for ths major mode."
(mapcar 'make-local-variable '(dancer-diary-string-today-function
dancer-diary-insert-topindex-function
dancer-diary-thismonth-filename-string
dancer-diary-index-html dancer-diary-currentmonth-string dancer-diary-last-update-string
dancer-diary-create-template-html-function dancer-diary-string-thismonth-diaryindex
dancer-diary-update-date-function dancer-diary-category-alist
dancer-diary-thisurl-prefix
dancer-diary-html-filename-postfix
dancer-diary-thismonth-update
sgml-set-face))
;; I want html-mode fontification to take priority.
(setq sgml-set-face nil))
(define-derived-mode dancer-diary-english-mode html-mode "DDiaryE"
"Major mode for editing diary in english html file
Commands:
\\[dancer-diary-insert-new-entry] New diary entry
\\[dancer-diary-insert-local-img] Insert img tag for local file
\\[dancer-diary-insert-local-link] Insert link with local file.
\\[dancer-diary-insert-local-url] Insert URL
\\[dancer-diary-insert-local-url-with-trackback] Insert URL with trackback
\\{dancer-diary-english-mode-map}
"
(dancer-diary-internal-make-local-variable)
(setq dancer-diary-insert-topindex-function
'(dancer-diary-english-insert-topindex))
(setq dancer-diary-create-template-html-function
'(dancer-diary-create-template-html-english))
(setq dancer-diary-html-filename-postfix ".html.en")
(setq dancer-diary-index-html "index.html.en")
(setq dancer-diary-currentmonth-string "This month's diary")
(setq dancer-diary-last-update-string "Last update: ")
(setq dancer-diary-string-today-function '(dancer-diary-string-today-english))
(setq dancer-diary-todo-section-english
(concat "
\n"
"
Plans
\n"
"
\n"
"
\n"
"
\n"))
;; load the config before action
(load (concat default-directory "dancer-diary-config.el") t)
;; variables that need to be updated
(setq dancer-diary-update-date-function
'(lambda () ""
(progn
(setq dancer-diary-thismonth-filename-string (concat (dancer-diary-indexdatelocal-now) dancer-diary-html-filename-postfix))
(setq dancer-diary-string-thismonth-diaryindex
(concat
"Diary in " (dancer-diary-string-thismonth-english)
))
)))
(funcall dancer-diary-update-date-function)
;;(dancer-diary-expand-images)
)
(define-derived-mode dancer-diary-japanese-mode html-mode "DDiaryJ"
"Major mode for editing diary in Japanese html file
Commands:
\\[dancer-diary-insert-new-entry] 新しい日記のエントリ
\\[dancer-diary-insert-local-img] イメージを追加
\\[dancer-diary-insert-local-link] ローカルファイルへのリンクを追加
\\[dancer-diary-insert-local-url] URLを挿入
\\[dancer-diary-insert-local-url-with-trackback] トラックバックつきでURLを挿入
\\{dancer-diary-japanese-mode-map}
編集用のモードです。
"
(dancer-diary-internal-make-local-variable)
(setq dancer-diary-insert-topindex-function
'(dancer-diary-japanese-insert-topindex))
(setq dancer-diary-create-template-html-function
'(dancer-diary-create-template-html-japanese))
(setq dancer-diary-html-filename-postfix ".html.ja")
(setq dancer-diary-index-html "index.html.ja")
(setq dancer-diary-currentmonth-string "今月の日記")
(setq dancer-diary-last-update-string "最終更新時間:")
(setq dancer-diary-string-today-function '(dancer-diary-string-today-japanese))
(setq dancer-diary-todo-section-japanese
(concat "
"))
(progn
;;update the last-updated
(delete-region (progn (beginning-of-line) (point)) (progn (end-of-line) (point)))
;remove the original line.
(insert (concat ;insert new information
"
\n"
)))
)
)
(save-buffer))))
(defun dancer-diary-conditional-insert-entry (category-string)
"Insert some entry, conditionally creating a new entry, if the right file is being opened.
Returns the buffer of the new blog entry, with the current point before
"
(interactive (list (completing-read "Category: " dancer-diary-category-alist nil t)))
(funcall dancer-diary-update-date-function) ;update current date
(if (not (equal (file-name-nondirectory (buffer-file-name)) dancer-diary-thismonth-filename-string))
(progn ; The curret month's diary is not the current buffer.
(if (file-exists-p dancer-diary-thismonth-filename-string)
(find-file dancer-diary-thismonth-filename-string) ;find this month's diary!
;; Otherwise, create the file from a template, and then find-file later ?
(find-file dancer-diary-thismonth-filename-string) ;create the file
(eval dancer-diary-create-template-html-function) ;edit it.
)
)
)
;; Enter an entry, This may have switched to a new buffer.
(save-excursion
(goto-line 1)
(if (not (search-forward (concat "
" (eval dancer-diary-string-today-function) "
") nil t nil ) )
;if this string does not already exist.
(dancer-insert-date) ; insert the date
))
(dancer-diary-insert-new-entry category-string)
(current-buffer))
(defun dancer-skip-to-first-diary-entry ()
(goto-line 1)
(if (search-forward "
" nil t)
(beginning-of-line) ; this is all..
(progn ;otherwise look for
(search-forward "")
(end-of-line)
(insert "\n")
)
)
)
(defun dancer-diary-insert-new-entry (category-string)
"New entry for today's diary. Called every time an entry is made"
(let* ((anchor-string (concat (dancer-diary-string-today-cryptic) "-" (substring (current-time-string) 11 19))))
(goto-line 1)
(search-forward "
\n"
)))
(defun dancer-diary-english-insert-topindex ()
"Insert the top indexing entry created from the filename, for next, prev, and other-language
This function is for English"
(insert (concat "
\n")))
(dancer-diary-internal-list-categories-start-dump-category search-string (cdr my-data-string-alist)))))
(defun dancer-diary-internal-list-categories-start-dump (my-available-categories-alist my-data-string-alist)
"Dump the list of categories to the output"
(if my-available-categories-alist
(progn
(insert (concat
"