;;; Time-stamp: <2005-02-20 20:51:06 jcgs> ;;; Make status tables for directories (provide 'status-table) (require 'page-status) (require 'page-attributes) (require 'webmaster-macros) (defvar auto-table-start-string "" "Marker for start of automatically generated table (so the code can remove the previous version automatically).") (defvar auto-table-end-string "" "Marker for end of automatically generated table (so the code can remove the previous version automatically).") (defun auto-table-start (&optional tabular) "Remove old auto-table markers, and start new ones." (if (search-backward auto-table-start-string (point-min) t) (let ((start (point))) (if (search-forward auto-table-end-string (point-max) t) (progn (delete-region start (point)) (message "Deleted old table")) (progn (message "Could not find old table to delete"))))) (insert auto-table-start-string "\n\n") (when tabular (insert "
\n" " \n") (insert " " "" "" "" "\n")) ) (defun auto-table-end (&optional tabular) "Complete new auto-table markers." (when tabular (insert "
Titlefilename" "(content/total size)statusstarted
\n
\n")) (insert "\n" auto-table-end-string)) (defun file-contents (file) "Return the contents of FILE, as a string." (save-window-excursion (find-file file) (prog1 (buffer-string) (kill-buffer nil)))) (defun page-unlisted (file) "Return whether a page claims to be unlisted" (save-window-excursion (find-file file) (save-excursion (goto-char (point-min)) (re-search-forward "" (point-max) t)))) (defvar indent-page-table nil "Whether to indent the table we produce.") ;;;###autoload (defun link-make-directory (directory types &optional tabular part-of-larger-flat-list status-regexp) "Insert an unsorted list of the files in DIRECTORY that match TYPES. Use optional TABULAR to make a status table instead of a list. Unless optional PART-OF-LARGER-FLAT-LIST given, previous list around point is removed. If optional STATUS-REGEXP given, only include those whose (find-page-status ..) matches STATUS-REGEXP. Any directory containing a file called sitemap-omit-directory is not descended. Directories may give a neat title in a file called title.txt in the directory." (interactive "DInsert index for directory: sInsert index entries for file of type: ") ;; for now, we don't use recursive tables (let* ((html-helper-never-indent (not indent-page-table)) (relative-to webmaster:page-site-homepage-directory-name) (rel-to-len (length relative-to))) (when tabular (setq part-of-larger-flat-list t)) (unless part-of-larger-flat-list (html-helper-indent) (insert "")))) ;;;###autoload (defun link-make-table (directory types &optional tabular) "Make a status table for files in DIRECTORY of TYPES." (interactive "DInsert index for directory: sInsert index entries for file of type: ") (setq tabular current-prefix-arg) (auto-table-start tabular) (link-make-directory directory types tabular nil "") (auto-table-end tabular)) ;;;###autoload (defun link-make-work-table (directory &optional status-regexp) "Make a work list for files in DIRECTORY whose status matches STATUS-REGEXP." (interactive "DInsert work list for directory: sMake entries for status (regexp, defaults sensibly): ") (link-make-directory directory "\\.html$" nil t (if (and (stringp status-regexp) (not (zerop (length status-regexp)))) status-regexp "\\(stub\\)\\|\\(sketch\\)\\|\\(more\\)\\|\\(in progress\\)"))) ;;;###autoload (defun update-index-status-comments () "" (interactive) (save-excursion (goto-char (point-min)) (while (re-search-forward "\\([^<]+\\)\\(\\)?" (point-max) t) (let* ((url (match-string-no-properties 1)) (anchor (match-string-no-properties 2)) (comment (match-beginning 3)) (status (save-match-data (find-page-status url))) (newcomment (if status (format "" status) nil))) (message "%s (%s) : %s (%s)" url status anchor comment) (if status (if comment (replace-match newcomment t t nil 3) (insert newcomment))))))) ;;; end of status-table.el