;; ChangeLog to rdf elisp. ;; Copyright 2004 Junichi Uekawa ;; Distributed under terms of GPL version 2 or later. (defvar dancer-changelog-delimiter-regexp "^\\(\t[*]\\|[0-9]\\)" "The regexp for changelog delimiter.") (defun dancer-changelog-to-rdf (changelog-file-name url-base myrssencoding title-string) "Changelog to RDF" (interactive (list (let* ((insert-default-directory nil)) (read-file-name "Changelog filename: ")) (read-input "URL base: ") (read-input "RSS file encoding: ") (read-input "title string: "))) (let* ((rdf-file-name (concat changelog-file-name ".rdf")) (changelog-time-string "") (number-of-entries 0) author-name entry-start entry-end matched-text list-of-rdf-items) ;; select the changelog (find-file changelog-file-name) (beginning-of-buffer) (while (and (re-search-forward dancer-changelog-delimiter-regexp nil t) (< number-of-entries 10)) (setq number-of-entries (+ 1 number-of-entries)) (backward-char 1) (if (string-match "[0-9]" (buffer-substring (point) (+ 1 (point)))) ;; This is time-string (progn (re-search-forward "[^ ]*") (setq changelog-time-string (match-string 0)) (re-search-forward " \\([^<]*\\) <") (setq author-name (match-string 1)) (re-search-forward "\t*") (beginning-of-line)) ;; Otherwise, this is a text string. (save-excursion (forward-char 1) (setq entry-start (point)) (when (re-search-forward dancer-changelog-delimiter-regexp nil t) (progn (setq entry-end (- (point) 1)) (setq matched-text (buffer-substring entry-start entry-end)) (string-match " \\([^:(,]*\\)[(]?[^:]*:\\(.*\\)" matched-text) ;; list-of-rdf-items contains ;; 1: full URL 2: full text 3: headline 4: time (push (append (list (concat url-base (match-string 1 matched-text))) (list (substring matched-text (match-beginning 2) nil)) (list (concat (match-string 1 matched-text) " updated")) (list (concat changelog-time-string "T00:00:00+09:00")) ) list-of-rdf-items))) (backward-char 1))) (forward-char 1)) ;; create RDF file (find-file rdf-file-name) ;; delete contents of rdf file first. (delete-region (point-min) (point-max)) ;; insert header (insert (concat "\n" "\n" " \n" " " title-string "\n" " " url-base "\n" " showing latest 10 \n" " \n" " \n" )) (dolist (current-rdf-item (reverse list-of-rdf-items)) (insert (concat " \n"))) (insert " \n \n \n") (dolist (current-rdf-item (reverse list-of-rdf-items)) (insert (concat " \n" " " (nth 2 current-rdf-item) "\n" " " (nth 0 current-rdf-item) "\n" " " (nth 1 current-rdf-item) "\n" " " (nth 2 current-rdf-item) "\n" " " author-name "\n" " " (nth 3 current-rdf-item) "\n" " \n"))) (insert "\n")) (let* ((coding-system-for-write 'euc-jp-unix)) (save-buffer))) ;; Run this script ;; emacs -batch -q -no-site-file -l changelog-to-rdf.el -f dancer-changelog-to-rdf-run ;; diary/run-diary.sh runs this also. (defun dancer-changelog-to-rdf-run () "A routine to be called from a shell script to automate the daily generation process," ;; this is my local config on viper2. (dancer-changelog-to-rdf "ChangeLog" "http://www.netfort.gr.jp/~dancer/" "euc-jp" "Netfort dancer webpage ChangeLog"))