remote-publish (from ~/emacs/etc/common/common.el)
(defun remote-publish (orig dest)
"Use rsync to transfer published files to a remote destination."
(start-process
"emacs-wiki-srync" "*emacs-wiki-rsync*" "rsync" "--archive" "--delete"
"--rsh=ssh"
(file-name-as-directory
(expand-file-name orig))
dest))
~/emacs/etc/common/emacswiki.el
(require 'emacs-wiki)
(require 'emacs-wiki-project)
(require 'emacs-wiki-menu)
(require 'table)
(require 'update-remote)
(defun jem-insert-file (filename)
"Insert the contents of a file on publishing."
(if (and emacs-wiki-publishing-p
(file-readable-p filename))
(ignore (insert-file-contents filename))
(concat "ERROR! '" filename "' not found!")))
(defun jem-ew-publish-wiki-source (pagetitle)
"Publishes the wiki source of a page, called from the header"
(when pagetitle
(copy-file (concat "~/web/homepage/" pagetitle)
(concat emacs-wiki-publishing-directory "/src/" pagetitle ".txt")
t)))
(require 'htmlize)
(defun jem-ew-fontified-example-tag (beg end highlight-p mode)
(if highlight-p
(progn
(emacs-wiki-multiline-maybe beg end)
(goto-char end))
(let ((content (buffer-substring beg end))
(replacement ""))
(delete-region beg end)
(save-excursion
(with-temp-buffer
(insert content)
(goto-char (point-min))
(while (looking-at "^$")
(forward-line))
(delete-region (point-min) (point))
(funcall mode)
(font-lock-fontify-buffer)
(save-excursion
(set-buffer (htmlize-buffer))
(goto-char (point-min))
(search-forward "<pre>\n")
(let ((beginreg (point)))
(search-forward "</pre>")
(backward-char 6)
(setq replacement (buffer-substring beginreg (point)))
(kill-buffer (current-buffer))))))
(let ((current-begin (point)))
(insert "<pre class=\"sourcecode\">\n")
(insert replacement)
(insert "</pre>\n")
(add-text-properties current-begin (point) '(rear-nonsticky (read-only)
read-only t))))))
(defun jem-ew-syntax-highlight-tag (tagname mode)
(let ((symbolname (concat "jem-ew-autogenerated-highlight-tag-" (symbol-name mode))))
(fset (intern symbolname)
`(lambda (beg end highlight-p)
(jem-ew-fontified-example-tag beg end highlight-p (quote ,mode))))
(add-to-list 'emacs-wiki-markup-tags
`(,tagname t nil t ,(intern symbolname)) t)))
(defvar jem-ew-queued-boxes nil
"A list of boxes to create.")
(defun jem-ew-markup (string)
"Markup string using EmacsWiki markup, and return the results."
(let ((project emacs-wiki-current-project))
(with-temp-buffer
(let* ((emacs-wiki-current-project project)
(emacs-wiki-publishing-header "<--!STARTHERE!-->")
(emacs-wiki-publishing-footer "<--!ENDHERE!-->"))
(insert string)
(goto-char (point-min))
(emacs-wiki-replace-markup "BOX!")
(let ((beg (point-min))
(end (point-max)))
(goto-char beg)
(search-forward emacs-wiki-publishing-header)
(setq beg (point))
(search-forward emacs-wiki-publishing-footer)
(setq end (- (point) (length emacs-wiki-publishing-footer)))
(replace-regexp-in-string "%23" "#"
(replace-regexp-in-string "\\(</?p>\\|\n\\)" ""
(buffer-substring beg end))))))))
(defun jem-ew-create-box (beg end &optional highlightp)
"Create a box."
(unless highlightp
(add-to-list 'jem-ew-queued-boxes (buffer-substring beg end) t)
(delete-region beg end)))
(defun jem-ew-make-boxes ()
"Insert DIV-tags for all boxes on the page."
(let ((result "")
(content-div-start "<div class=\"menucontent\">\n")
(content-div-end "\n\n</div>\n"))
(while jem-ew-queued-boxes
(let ((items (split-string (car jem-ew-queued-boxes) "\n")))
(let ((contents "")
(content-div-inserted nil))
(while items
(let ((item (erc-trim-string (car items))))
(when (not (string= item ""))
(save-match-data
(cond
((string-match "^{{\\(.*\\)}}$" item)
(setq contents (concat contents
"\n\n<div class=\"menusubheader\">"
(match-string 1 item)
"</div>\n")))
((string-match "^{\\(.*\\)}$" item)
(when content-div-inserted
(setq contents (concat contents content-div-end)))
(setq contents (concat contents
"<div class=\"menuheader\">"
(match-string 1 item)
"</div>\n"
content-div-start)
content-div-inserted t))
((string-match "^\\[[0-9]+\\]" item)
(unless content-div-inserted
(setq contents (concat contents content-div-start)
content-div-inserted t))
(setq contents (concat contents item " <br/>\n")))
(t
(unless content-div-inserted
(setq contents (concat contents content-div-start)
content-div-inserted t))
(setq contents (concat contents " - " item "\n")))))))
(setq items (cdr items)))
(when content-div-inserted
(setq contents (concat contents content-div-end)))
(setq result (concat result
"<div class=\"rightpanel\">"
(jem-ew-markup contents) "\n"
"</div>\n"))))
(setq jem-ew-queued-boxes (cdr jem-ew-queued-boxes)))
result))
(add-to-list 'emacs-wiki-markup-tags
'("box" t nil nil jem-ew-create-box))
(jem-ew-syntax-highlight-tag "cppexample" 'c++-mode)
(jem-ew-syntax-highlight-tag "htmlexample" 'html-mode)
(jem-ew-syntax-highlight-tag "example" 'lisp-mode)
(jem-ew-syntax-highlight-tag "cexample" 'c-mode)
(setq emacs-wiki-directories '("~/web/homepage")
emacs-wiki-rsync-destination "es.gnu.org:/home/jemarch/public_html/homepage"
emacs-wiki-home-page "WelcomePage"
emacs-wiki-publishing-directory "~/www/own/homepage"
emacs-wiki-style-sheet "<link rel=\"stylesheet\" type=\"text/css\" href=\"../styles/wiki_style.css\">"
emacs-wiki-maintainer "NotFound"
emacs-wiki-project-server-prefix "http://es.gnu.org/~jemarch/homepage/"
emacs-wiki-publishing-transforms '(("WelcomePage" . "index"))
emacs-wiki-inline-images t
emacs-wiki-publishing-header "<lisp>(jem-insert-file \"~/web/design/header_homepage.html\")</lisp>"
emacs-wiki-publishing-footer "<lisp>(jem-insert-file \"~/web/design/footer_homepage.html\")</lisp>")
(setq emacs-wiki-project "homepage")
(setq emacs-wiki-default-project "homepage")
(defun jem-emacs-wiki-publish ()
(interactive)
"Publish all wikis"
(emacs-wiki-publish 1)
(publish-wiki))
(defun publish-wiki ()
"Publish the wiki onto `emacs-wiki-rsync-destination'"
(interactive)
(remote-publish emacs-wiki-publishing-directory
emacs-wiki-rsync-destination))
(global-set-key "\C-c\C-f" 'emacs-wiki-find-file)
(define-key emacs-wiki-mode-map "\C-c\C-p" 'jem-emacs-wiki-publish)
(add-hook 'emacs-wiki-after-markup-hook
(lambda () (iso-iso2sgml (point-min) (point-max))))
|