652b364e4d2609ff90a4425695f9c3e47bbb5438
[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=\"2013-03-22T17:25+0100\"/>
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=\"content\">
24 <div id=\"header\">&nbsp;</div>
25 <div id=\"leftColumn\">
26   <div id=\"navigation\">
27   <ul>
28     <li><a href=\"index.html\"   >home</a></li>
29     <li><a href=\"sitemap.html\" >sitemap</a></li>
30     <li><a href=\"contact.html\" >contact</a></li>
31   </ul>
32   </div>
33 </div>
34 <div id=\"mainText\">
35 <p id=\"kicker\">@TITLE@</p>
36 "))
37
38 (defun gpgweb-insert-footer ()
39   (goto-char (point-max))
40   (insert "<div id=\"cpyright\">
41   <a rel=\"license\" href=\"http://creativecommons.org/licenses/by-sa/3.0/\"
42     ><img alt=\"CC-BY-SA 3.0\" style=\"border: 0\"
43           src=\"share/cc-by-sa-3.0_80x15.png\"/></a>
44    <br/>These web pages are Copyright 1998--2013 The GnuPG Project and
45   licensed under a
46   <a rel=\"license\" href=\"http://creativecommons.org/licenses/by-sa/3.0/\"
47    >Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.  See
48    <a href=\"copying.html\">copying<a/> for details.
49 </div>
50 </div>
51 </div>
52 </body>
53 </html>
54 "))
55
56
57 (defun gpgweb-postprocess-html ()
58   (gpgweb-insert-header)
59   (gpgweb-insert-footer)
60   (let ((fname (file-name-nondirectory (buffer-file-name))))
61     (when (string-match "\\.\\([a-z][a-z]\\.\\)?html$" fname)
62           (setq fname (substring fname 0 (match-beginning 0))))
63     (goto-char (point-min))
64     (while (search-forward "href=\"@FNAME@" nil t)
65       (replace-match (concat "href=\"" fname) t nil))
66     (goto-char (point-min))
67     (while (search-forward "@MENU-ACTIVE@" nil t)
68       (replace-match "" t nil))))
69
70 (defun gpgweb-org-to-html (plist filename pub-dir)
71   (add-hook 'org-export-html-final-hook
72             'gpgweb-postprocess-html)
73   (org-publish-org-to-html plist filename pub-dir)
74   (remove-hook 'org-export-html-final-hook
75                'gpgweb-postprocess-html))
76
77 (defun gpgweb-upload ()
78    ())
79 ;  (let ((stagedir (plist-get project-plist :publishing-directory)))
80 ;    (message "gpgweb stagedir '%s'" stagedir)
81 ;    (shell-command
82 ;     (concat "rsync -rlt --exclude \"*~\" " stagedir "/ "
83 ;             "werner@trithemius.gnupg.org:"
84 ;             "/var/www/all/preview.gnupg.org/htdocs/"))))
85
86
87 (provide 'gpgweb)