Add file copying and started work on a new CSS.
[gnupg-doc.git] / web / share / gpgweb.el
1 ;;; gpgweb.el --- elisp helper code for the GnuPG web pages
2
3 (require 'org-exp)
4
5 (defun gpgweb-insert-header ()
6   (goto-char (point-min))
7   (insert "<?xml version=\"1.0\" encoding=\"utf-8\"?>
8 <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
9                \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
10 <html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">
11 <head>
12 <title>" title "</title>
13 <meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\"/>
14 <meta name=\"title\" content=\"" title "\"/>
15 <meta name=\"generator\" content=\"Org-mode\"/>
16 <meta name=\"generated\" content=\"" generated-at "\"/>
17 <meta name=\"author\" content=\"Werner Koch\"/>
18 <meta name=\"description\" content=\"\"/>
19 <meta name=\"keywords\" content=\"\"/>
20 <link rel=\"stylesheet\" href=\"share/site.css\" type=\"text/css\" />
21 </head>
22 <body>
23 <div id=\"header\">&nbsp;</div>
24 <div id=\"leftColumn\">
25   <div id=\"navigation\">
26   <ul>
27     <li><a href=\"index.html\"                 >Home</a></li>
28     <li><a href=\"download/index.html\"        >Download</a></li>
29     <li><a href=\"documentation/index.html\"   >Documentation</a></li>
30     <li><a href=\"related_software/index.html\">Related software</a></li>
31     <li><a href=\"misc/index.html\"            >Miscellaneous</a></li>
32     <li><a href=\"sitemap.html\"               >Sitemap</a></li>
33   </ul>
34   </div>
35 </div>
36 <div id=\"mainText\">
37 "))
38
39 (defun gpgweb-insert-footer ()
40   (goto-char (point-max))
41   (insert "<div id=\"cpyright\">
42     <a rel=\"license\" href=\"http://creativecommons.org/licenses/by-sa/3.0/\"
43       ><img alt=\"CC-BY-SA 3.0\" style=\"border: 0\"
44             src=\"share/cc-by-sa-3.0_80x15.png\"/></a><br/>
45     These web pages are
46     Copyright 1998--2013 The GnuPG Project<a href=\"copying.html\">ยน</a>
47     and licensed under a
48     <a rel=\"license\" href=\"http://creativecommons.org/licenses/by-sa/3.0/\"
49     >Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.  See
50     <a href=\"copying.html\">copying<a/> for details.
51 </div>
52 </div>
53 </body>
54 </html>
55 "))
56
57
58 ;; Our publishing tweaks:
59 ;;
60 ;; - Substitute @FNAME@ by the actual file name.
61 ;; - Substitute @MENU-ACTIVE@ by an empty string.
62 (defun gpgweb-postprocess-html ()
63   (let ((fname (file-name-nondirectory (buffer-file-name)))
64         (generated-at (org-today)))
65     (gpgweb-insert-header)
66     (gpgweb-insert-footer)
67     (when (string-match "\\.\\([a-z][a-z]\\.\\)?html$" fname)
68           (setq fname (substring fname 0 (match-beginning 0))))
69     (goto-char (point-min))
70     (while (search-forward "href=\"@FNAME@" nil t)
71       (replace-match (concat "href=\"" ) t nil))
72     (goto-char (point-min))
73     (while (search-forward "@MENU-ACTIVE@" nil t)
74       (replace-match "" t nil))))
75
76 (defun gpgweb-org-to-html (plist filename pub-dir)
77   (add-hook 'org-export-html-final-hook
78             'gpgweb-postprocess-html)
79   (org-publish-org-to-html plist filename pub-dir)
80   (remove-hook 'org-export-html-final-hook
81                'gpgweb-postprocess-html))
82
83 (defun gpgweb-upload ()
84   (let ((stagedir (plist-get project-plist :publishing-directory)))
85     (message "gpgweb  rootdir '%s'" gpgweb-root-dir)
86     (message "gpgweb stagedir '%s'" stagedir)
87     (shell-command
88      (concat "rsync -rlt --exclude \"*~\" " stagedir "/ "
89              "werner@trithemius.gnupg.org:"
90              "/var/www/www/w3.gnupg.org/htdocs/"))))
91
92
93 (provide 'gpgweb)