Update copying, fixup the CSS, and add a menu.
[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   <nav>
26   <ul>
27     <li><a href=\"/index.html\"                 >Home</a></li>
28       <ul>
29         <li><a href=\"/features.html\" >Features</a></li>
30         <li><a href=\"/news.html\"     >News</a></li>
31         <li><a href=\"/service.html\"  >Service</a></li>
32         <li><a href=\"/legal.html\"    >Legal</a></li>
33       </ul>
34     <li><a href=\"/download/index.html\"        >Download</a></li>
35       <ul>
36         <li><a href=\"/download/integrity_check.html\"
37                                                 >Integrity&nbsp;Check</a></li>
38         <li><a href=\"/download/supported_systems.html\"
39                                                 >Supported&nbsp;Systems</a></li>
40         <li><a href=\"/download/release_notes.html\"
41                                                 >Release&nbsp;Notes</a></li>
42         <li><a href=\"/download/mirrors.html\"   >Mirrors</a></li>
43         <li><a href=\"/download/cvs_access.html\" >GIT</a></li>
44       </ul>
45     <li><a href=\"/documentation/index.html\"   >Documentation</a></li>
46       <ul>
47         <li><a href=\"/documentation/howtos.html\"       >HOWTOs</a></li>
48         <li><a href=\"/documentation/manuals.html\"      >Manuals</a></li>
49         <li><a href=\"/documentation/guides.html\"       >Guides</a></li>
50         <li><a href=\"/documentation/faqs.html\"         >FAQs</a></li>
51         <li><a href=\"/documentation/mailing-lists.html\"
52                                                  >Mailing&nbsp;Lists</a></li>
53         <li><a href=\"/documentation/sites.html\"    >Sites</a></li>
54         <li><a href=\"/documentation/bts.html\"      >Bug&nbsp;Tracker</a></li>
55       </ul>
56     <li><a href=\"/related_software/index.html\">Related software</a></li>
57       <ul>
58         <li><a href=\"/related_software/frontends.html\" >Frontends</a></li>
59         <li><a href=\"/related_software/tools.html\"     >Tools</a></li>
60         <li><a href=\"/related_software/libraries.html\" >Libraries</a></li>
61       </ul>
62     <li><a href=\"/misc/index.html\"            >Miscellaneous</a></li>
63       <ul>
64         <li><a href=\"/misc/links.html\"         >Links</a></li>
65         <li><a href=\"/misc/logo-contest.html\"  >Logo&nbsp;Contest</a></li>
66         <li><a href=\"/misc/thanks.html\"        >Thanks</a></li>
67         <li><a href=\"/misc/donations.html\"     >Donations</a></li>
68       </ul>
69     <li><a href=\"/sitemap.html\"               >Sitemap</a></li>
70   </ul>
71   </nav>
72 </div>
73 <main>
74 "))
75
76 (defun gpgweb-insert-footer ()
77   (goto-char (point-max))
78   (insert "<div id=\"cpyright\">
79     <a rel=\"license\" href=\"http://creativecommons.org/licenses/by-sa/3.0/\"
80       ><img alt=\"CC-BY-SA 3.0\" style=\"border: 0\"
81             src=\"share/cc-by-sa-3.0_80x15.png\"/></a><br/>
82     These web pages are
83     Copyright 1998--2013 The GnuPG Project<a href=\"copying.html\">ยน</a>
84     and licensed under a
85     <a rel=\"license\" href=\"http://creativecommons.org/licenses/by-sa/3.0/\"
86     >Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.  See
87     <a href=\"copying.html\">copying<a/> for details.
88     </div>
89 </main>
90 </body>
91 </html>
92 "))
93
94
95 ;; Our publishing tweaks:
96 ;;
97 ;; - Substitute @FNAME@ by the actual file name.
98 ;; - Substitute @MENU-ACTIVE@ by an empty string.
99 (defun gpgweb-postprocess-html ()
100   (let ((fname (file-name-nondirectory (buffer-file-name)))
101         (generated-at (org-today)))
102     (gpgweb-insert-header)
103     (gpgweb-insert-footer)
104     (when (string-match "\\.\\([a-z][a-z]\\.\\)?html$" fname)
105           (setq fname (substring fname 0 (match-beginning 0))))
106     (goto-char (point-min))
107     (while (search-forward "href=\"@FNAME@" nil t)
108       (replace-match (concat "href=\"" ) t nil))
109     (goto-char (point-min))
110     (while (search-forward "@MENU-ACTIVE@" nil t)
111       (replace-match "" t nil))))
112
113 (defun gpgweb-org-to-html (plist filename pub-dir)
114   (add-hook 'org-export-html-final-hook
115             'gpgweb-postprocess-html)
116   (org-publish-org-to-html plist filename pub-dir)
117   (remove-hook 'org-export-html-final-hook
118                'gpgweb-postprocess-html))
119
120 (defun gpgweb-upload ()
121   (let ((stagedir (plist-get project-plist :publishing-directory)))
122     (message "gpgweb  rootdir '%s'" gpgweb-root-dir)
123     (message "gpgweb stagedir '%s'" stagedir)
124     (shell-command
125      (concat "rsync -rlt --exclude \"*~\" " stagedir "/ "
126              "werner@trithemius.gnupg.org:"
127              "/var/www/www/w3.gnupg.org/htdocs/"))))
128
129
130 (provide 'gpgweb)