Adjust for org-mode 8.0
authorWerner Koch <wk@gnupg.org>
Wed, 6 Nov 2013 19:00:36 +0000 (20:00 +0100)
committerWerner Koch <wk@gnupg.org>
Wed, 6 Nov 2013 21:48:53 +0000 (22:48 +0100)
Org-mode 8 features a #+TOC: keyword which is useful to move the toc
behind the foreword.  There are also lots of other chnages and thus we
better require it.

.gitignore
web/documentation/faqs.org
web/index.org
web/share/gpgweb.el

index ef11cae..c938f5a 100644 (file)
@@ -3,3 +3,6 @@ stage/
 /web/sitemap.org
 .*.orgx
 /web/theindex.inc
+/web/faq/gnupg-faq.pdf
+/web/faq/gnupg-faq.tex
+/web/faq/gnupg-faq.txt
index 71f2e35..0f45e71 100644 (file)
@@ -6,6 +6,6 @@
 
   The GnuPG FAQ is available in 3 formats:
 
-  -  [[http://www.gnupg.org/faq/GnuPG-FAQ.html][HTML]]
+  -  [[../faq/gnupg-faq.html][HTML]]
   -  [[ftp://ftp.gnupg.org/gcrypt/gnupg/GnuPG-FAQ.txt][Text]]
-  -  [[http://git.gnupg.org/cgi-bin/gitweb.cgi?p%3Dgnupg.git%3Ba%3Dblob_plain%3Bf%3Ddoc/faq.org][Org-mode]]
+  -  [[http://git.gnupg.org/cgi-bin/gitweb.cgi?p%3Dgnupg-doc.git%3Ba%3Dblob_plain%3Bf%3Dweb/faq/gnupg-faq.org][Org-mode]]
index 7c064f5..7f24358 100644 (file)
@@ -111,35 +111,5 @@ This is the publishing info used for the GnuPG pages
    (require 'gpgweb (concat gpgweb-root-dir "share/gpgweb.el"))
    (setq org-export-html-toplevel-hlevel 1)
    (setq org-export-html-coding-system 'utf-8)
-
-   (aput 'org-publish-project-alist "gpgweb-org"
-   '(:base-directory "."
-     :base-extension "org"
-     :language "en"
-     :html-extension "html"
-     :recursive t
-     :publishing-directory "../stage"
-     :publishing-function gpgweb-org-to-html
-     :body-only t
-     :section-numbers nil
-     :tags nil
-     :table-of-contents nil
-     :makeindex t
-     :auto-sitemap t
-     :sitemap-title "GnuPG - Sitemap"
-     :style-include-default nil
-     :timestamp-file t
-     :style "<link rel=\"stylesheet\" href=\"gnupg.css\" type=\"text/css\" />"))
-
-   (aput 'org-publish-project-alist "gpgweb-other"
-   '(:base-directory "."
-     :base-extension "jpg\\|png\\|css"
-     :recursive t
-     :publishing-directory "../stage"
-     :publishing-function org-publish-attachment
-     :completion-function gpgweb-upload))
-
-   (aput 'org-publish-project-alist "gpgweb"
-   '(:components ("gpgweb-org" "gpgweb-other"))))
-
+   (gpgweb-setup-project))
 #+end_src
index 62b4798..60c7f1d 100644 (file)
@@ -2,7 +2,41 @@
 
 (require 'org-exp)
 
-(defun gpgweb-insert-header ()
+(defun gpgweb-setup-project ()
+  (progn
+   (aput 'org-publish-project-alist "gpgweb-org"
+   '(:base-directory "~/s/gnupg-doc/web"
+     :base-extension "org"
+     :language "en"
+     :html-extension "html"
+     :recursive t
+     :publishing-directory "../stage"
+     :publishing-function gpgweb-org-to-html
+     :body-only t
+     :section-numbers nil
+     :tags nil
+     :with-toc nil
+     :makeindex t
+     :auto-sitemap t
+     :sitemap-title "GnuPG - Sitemap"
+     :style-include-default nil
+     :timestamp-file t
+     :html-head "<link rel=\"stylesheet\" href=\"gnupg.css\" type=\"text/css\" />"
+     :html-head-include-scripts nil))
+
+   (aput 'org-publish-project-alist "gpgweb-other"
+   '(:base-directory "."
+     :base-extension "jpg\\|png\\|css"
+     :recursive t
+     :publishing-directory "../stage"
+     :publishing-function org-publish-attachment
+     :completion-function gpgweb-upload))
+
+   (aput 'org-publish-project-alist "gpgweb"
+   '(:components ("gpgweb-org" "gpgweb-other")))))
+
+
+(defun gpgweb-insert-header (title)
   (goto-char (point-min))
   (insert "<?xml version=\"1.0\" encoding=\"utf-8\"?>
 <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
 ;;
 ;; - Substitute @FNAME@ by the actual file name.
 ;; - Substitute @MENU-ACTIVE@ by an empty string.
-(defun gpgweb-postprocess-html ()
-  (let ((fname (file-name-nondirectory (buffer-file-name)))
-        (generated-at (org-today)))
-    (gpgweb-insert-header)
-    (gpgweb-insert-footer)
-    (when (string-match "\\.\\([a-z][a-z]\\.\\)?html$" fname)
-          (setq fname (substring fname 0 (match-beginning 0))))
-    (goto-char (point-min))
-    (while (search-forward "href=\"@FNAME@" nil t)
-      (replace-match (concat "href=\"" ) t nil))
-    (goto-char (point-min))
-    (while (search-forward "@MENU-ACTIVE@" nil t)
-      (replace-match "" t nil))))
+(defun gpgweb-postprocess-html (plist orgfile htmlfile)
+  (let* ((visitingp (find-buffer-visiting htmlfile))
+        (work-buffer (or visitingp (find-file-noselect htmlfile))))
+    (prog1 (with-current-buffer work-buffer
+             (let ((fname (file-name-nondirectory htmlfile))
+                   (title (org-publish-find-title orgfile))
+                   (generated-at (org-today)))
+               (message "post processing %s (%s)" htmlfile orgfile)
+               (gpgweb-insert-header title)
+               (gpgweb-insert-footer)
+               (when (string-match "\\.\\([a-z][a-z]\\.\\)?html$" fname)
+                 (setq fname (substring fname 0 (match-beginning 0))))
+               (goto-char (point-min))
+               (while (search-forward "href=\"@FNAME@" nil t)
+                 (replace-match (concat "href=\"" ) t nil))
+               (goto-char (point-min))
+               (while (search-forward "@MENU-ACTIVE@" nil t)
+                 (replace-match "" t nil)))
+             (basic-save-buffer))
+      (unless visitingp (kill-buffer work-buffer)))))
+
 
 (defun gpgweb-org-to-html (plist filename pub-dir)
-  (add-hook 'org-export-html-final-hook
-            'gpgweb-postprocess-html)
-  (org-publish-org-to-html plist filename pub-dir)
-  (remove-hook 'org-export-html-final-hook
-               'gpgweb-postprocess-html))
+  (gpgweb-postprocess-html plist filename
+                           (org-html-publish-to-html plist filename pub-dir)))
 
 (defun gpgweb-upload ()
   (let ((stagedir (plist-get project-plist :publishing-directory)))
     (message "gpgweb  rootdir '%s'" gpgweb-root-dir)
     (message "gpgweb stagedir '%s'" stagedir)
     (shell-command
-     (concat "rsync -rlt --exclude \"*~\" " stagedir "/ "
+     (concat "cd " gpgweb-root-dir " && cd " stagedir
+             "&& rsync -rlt --exclude \"*~\" ./ "
              "werner@trithemius.gnupg.org:"
              "/var/www/www/w3.gnupg.org/htdocs/"))))