web: Prepare for auto-builder
authorWerner Koch <wk@gnupg.org>
Sat, 16 Jul 2016 11:48:57 +0000 (13:48 +0200)
committerWerner Koch <wk@gnupg.org>
Sat, 16 Jul 2016 11:48:57 +0000 (13:48 +0200)
* web/share/setup.inc: Remove setupfile swdb.mac.
* web/index.org: Add keyword +GPGWEB-NEED_SWDB
* web/download/index.org: Ditto.
* web/download/cvs_access.org: Ditto.
* web/download/integrity_check.org: Ditto.
* web/download/release_notes.org: Ditto.
* web/related_software/libgcrypt/index.org: Ditto.
* web/share/gpgweb.el (gpgweb-setup-project): Install preprocess hook.
(gpgweb-preprocess): New.
(gpgweb-postprocess-html): Adjust RE.
* tools/build-website.sh: New.

tools/build-website.sh [new file with mode: 0755]
web/download/cvs_access.org
web/download/index.org
web/download/integrity_check.org
web/download/release_notes.org
web/index.org
web/related_software/libgcrypt/index.org
web/share/gpgweb.el
web/share/setup.inc

diff --git a/tools/build-website.sh b/tools/build-website.sh
new file mode 100755 (executable)
index 0000000..1190dab
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+set -e
+
+pgm=build-website.sh
+root_dir="$(pwd)/gnupg-doc/web"
+stage_dir="$(pwd)/gpgweb-stage"
+
+if [ ! -d "${root_dir}" ]; then
+   echo "$pgm: directory '${root_dir}' missing" >&2;
+   exit 1
+fi
+if [ ! -d "${stage_dir}" ]; then
+   echo "$pgm: directory '${stage_dir}' missing" >&2;
+   exit 1
+fi
+cd "${root_dir}"
+
+echo "========================================================"
+echo "gpgweb site building started on $(date -u -Iseconds)"
+echo "========================================================"
+
+emacs23 -q --batch  \
+  --eval "(require 'assoc)" \
+  --eval "(require 'org)" \
+  --eval "(setq make-backup-files nil)" \
+  --eval "(setq gpgweb-root-dir  \"${root_dir}/\")" \
+  --eval "(setq gpgweb-stage-dir \"${stage_dir}/\")" \
+  --eval "(require 'gpgweb (concat gpgweb-root-dir \"share/gpgweb.el\"))" \
+  --eval "(setq org-publish-use-timestamps-flag nil)" \
+  --eval "(setq org-export-html-toplevel-hlevel 1)" \
+  --eval "(setq org-export-html-coding-system 'utf-8)" \
+  --eval "(gpgweb-setup-project)" \
+  --eval "(org-publish-initialize-cache \"gpgweb\")" \
+  --eval "(message \"root=(%s)\" gpgweb-root-dir)" \
+  --eval "(org-publish \"gpgweb\" t nil)"
+
+echo "========================================================="
+echo "gpgweb site building finished on $(date -u -Iseconds)"
+echo "========================================================="
index ac2323b..6e62328 100644 (file)
@@ -1,6 +1,7 @@
 #+TITLE: GnuPG - GIT Access
 #+STARTUP: showall
 #+SETUPFILE: "../share/setup.inc"
+#+GPGWEB-NEED-SWDB
 
 * GIT Access
 
index 2a5fa82..3e1d602 100644 (file)
@@ -1,6 +1,7 @@
 #+TITLE: GnuPG - Download
 #+STARTUP: showall align
 #+SETUPFILE: "../share/setup.inc"
+#+GPGWEB-NEED-SWDB
 #+OPTIONS: ^:{}
 #+macro: check_sig_note  GnuPG distributions are signed. It is wise and more secure to check out for their [[integrity_check.org][@@html:<a href="integrity_check.html">@@integrity@@html:</a>@@]].
 #+macro: ftpopen  @@html:<a href="@@
index 5989351..ba4d393 100644 (file)
@@ -1,6 +1,7 @@
 #+TITLE: GnuPG - Integrity Check
 #+STARTUP: showall
 #+SETUPFILE: "../share/setup.inc"
+#+GPGWEB-NEED-SWDB
 #+OPTIONS:  ^:{}
 
 * Integrity Check
index cf94abd..61be7f4 100644 (file)
@@ -1,6 +1,7 @@
 #+TITLE: GnuPG - Release Notes
 #+STARTUP: showall
 #+SETUPFILE: "../share/setup.inc"
+#+GPGWEB-NEED-SWDB
 #+macro: announce  [[http://lists.gnupg.org/pipermail/gnupg-announce/$1.html][Announcement]]
 
 * Release Notes
index e007a31..c11c0af 100644 (file)
@@ -1,6 +1,7 @@
 #+TITLE: The GNU Privacy Guard
 #+STARTUP: showall
 #+SETUPFILE: "share/setup.inc"
+#+GPGWEB-NEED-SWDB
 
 * The GNU Privacy Guard
 #+index: GnuPG
index 366c4a3..4bfd79d 100644 (file)
@@ -1,5 +1,6 @@
 #+STARTUP: showall
 #+SETUPFILE: "../../share/setup.inc"
+#+GPGWEB-NEED-SWDB
 
 * Libgcrypt
 
index 0b6091f..a1e9556 100644 (file)
      :completion-function gpgweb-upload))
 
    (aput 'org-publish-project-alist "gpgweb"
-   '(:components ("gpgweb-org" "gpgweb-other")))))
+   '(:components ("gpgweb-org" "gpgweb-other")))
+
+   (add-hook 'org-export-before-processing-hook 'gpgweb-preprocess)))
+
+
+(defun gpgweb-preprocess (backend)
+  "Insert certain stuff before processing."
+  (let ()
+    (goto-char (point-min))
+    (when (re-search-forward
+           "^#\\+GPGWEB-NEED-SWDB\\b" 2048 t)
+      (beginning-of-line)
+      (kill-line 1)
+      (insert (org-file-contents (concat gpgweb-root-dir "swdb.mac")
+                                 'noerror)))))
 
 
 (defun gpgweb-insert-header (title committed-at)
@@ -348,7 +362,7 @@ string of the source file or nil if not available."
     (prog1 (with-current-buffer work-buffer
              (let ((fname (file-name-nondirectory htmlfile))
                    (fname-2 (replace-regexp-in-string
-                              ".*/stage\\(/.*\\)$" "\\1" htmlfile t))
+                              ".*/gpgweb-stage\\(/.*\\)$" "\\1" htmlfile t))
                    (title (org-publish-find-title orgfile)))
                ;; Insert header, menu, and footer.
                (gpgweb-insert-header title committed-at)
index 71afb88..c5517df 100644 (file)
@@ -1,9 +1,11 @@
 # Setup file for this site.
 #
-# Include the version macros.
-# FIXME: Figure out a way to use SETUPFILE based on the directory of
-#        the currently SETUPFILE loaded file.
-#+SETUPFILE: "/home/wk/s/gnupg-doc/web/swdb.mac"
+# Note: To include swdb.org in an org file add the line
+#   #+GPGWEB-NEED-SWDB
+# in the first 2k of the file.  It is not possible to include that file
+# from here because we don't have a way to specify gpgweb-root-dir as
+# part of the filename.  A dedicated pre-process feature like above is
+# probably more efficient anyway.
 
 
 # Org version 8 does not anymore expand macros in all places.  We use