web: More updates to the donation pages.
[gnupg-doc.git] / web / share / gpgweb.el
1 ;;; gpgweb.el --- elisp helper code for the GnuPG web pages
2
3 (require 'org-exp)
4 ;; cl-macs is required by ox-html.el but for whatever reasons not
5 ;; autoloaded.
6 (load-library "cl-macs")
7
8 (defun gpgweb-setup-project ()
9   (progn
10    (aput 'org-publish-project-alist "gpgweb-org"
11    '(:base-directory "~/s/gnupg-doc/web"
12      :base-extension "org"
13      :language "en"
14      :html-extension "html"
15      :recursive t
16      :publishing-directory "../stage"
17      :publishing-function gpgweb-org-to-html
18      :body-only t
19      :section-numbers nil
20      :tags nil
21      :with-toc nil
22      :makeindex t
23      :auto-sitemap t
24      :sitemap-title "GnuPG - Sitemap"
25      :sitemap-sort-folders "last"
26      :sitemap-file-entry-format "%t  @@html:<span id=\"smallnote\">@@(%d)@@html:</span>@@"
27      :style-include-default nil
28      :timestamp-file t
29      :html-head "<link rel=\"stylesheet\" href=\"gnupg.css\" type=\"text/css\" />"
30      :html-head-include-scripts nil))
31
32    (aput 'org-publish-project-alist "gpgweb-other"
33    '(:base-directory "."
34      :base-extension "jpg\\|png\\|css\\|txt\\|rss"
35      :recursive t
36      :publishing-directory "../stage"
37      :publishing-function org-publish-attachment
38      :completion-function gpgweb-upload))
39
40    (aput 'org-publish-project-alist "gpgweb"
41    '(:components ("gpgweb-org" "gpgweb-other")))))
42
43
44
45
46 (defun gpgweb-insert-header (title)
47   (goto-char (point-min))
48   (insert "<?xml version=\"1.0\" encoding=\"utf-8\"?>
49 <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
50                \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
51 <html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">
52 <head>
53 <title>" title "</title>
54 <meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\"/>
55 <meta name=\"title\" content=\"" title "\"/>
56 <meta name=\"generator\" content=\"Org-mode\"/>
57 <meta name=\"generated\" content=\"" generated-at "\"/>
58 <meta name=\"author\" content=\"Werner Koch\"/>
59 <meta name=\"description\" content=\"\"/>
60 <meta name=\"keywords\" content=\"\"/>
61 <link rel=\"stylesheet\" href=\"/share/site.css\" type=\"text/css\" />
62 </head>
63 <body>
64 <div id=\"header\">&nbsp;</div>
65 <div id=\"leftColumn\">
66   <nav>
67   <ul>
68     <li><a href=\"/index.html\"                 >Home</a></li>
69       <ul>
70         <li><a href=\"/features.html\" >Features</a></li>
71         <li><a href=\"/news.html\"     >News</a></li>
72         <li><a href=\"/service.html\"  >Service</a></li>
73         <li><a href=\"/legal.html\"    >Legal</a></li>
74       </ul>
75     <li><a href=\"/donate/index.html\"          >Donate</a></li>
76       <ul>
77         <li><a href=\"/donate/kudos.html\" >List of Donors</a></li>
78       </ul>
79     <li><a href=\"/download/index.html\"        >Download</a></li>
80       <ul>
81         <li><a href=\"/download/integrity_check.html\"
82                                                 >Integrity&nbsp;Check</a></li>
83         <li><a href=\"/download/supported_systems.html\"
84                                                 >Supported&nbsp;Systems</a></li>
85         <li><a href=\"/download/release_notes.html\"
86                                                 >Release&nbsp;Notes</a></li>
87         <li><a href=\"/download/mirrors.html\"   >Mirrors</a></li>
88         <li><a href=\"/download/cvs_access.html\" >GIT</a></li>
89       </ul>
90     <li><a href=\"/documentation/index.html\"   >Documentation</a></li>
91       <ul>
92         <li><a href=\"/documentation/howtos.html\"       >HOWTOs</a></li>
93         <li><a href=\"/documentation/manuals.html\"      >Manuals</a></li>
94         <li><a href=\"/documentation/guides.html\"       >Guides</a></li>
95         <li><a href=\"/documentation/faqs.html\"         >FAQs</a></li>
96         <li><a href=\"/documentation/mailing-lists.html\"
97                                                  >Mailing&nbsp;Lists</a></li>
98         <li><a href=\"/documentation/sites.html\"    >Sites</a></li>
99         <li><a href=\"/documentation/bts.html\"      >Bug&nbsp;Tracker</a></li>
100       </ul>
101     <li><a href=\"/related_software/index.html\">Related software</a></li>
102       <ul>
103         <li><a href=\"/related_software/frontends.html\" >Frontends</a></li>
104         <li><a href=\"/related_software/tools.html\"     >Tools</a></li>
105         <li><a href=\"/related_software/libraries.html\" >Libraries</a></li>
106         <li><a href=\"/related_software/swlist.html\"    >All</a></li>
107       </ul>
108     <li><a href=\"/misc/index.html\"            >Miscellaneous</a></li>
109       <ul>
110         <li><a href=\"/misc/links.html\"         >Links</a></li>
111         <li><a href=\"/misc/logo-contest.html\"  >Logo&nbsp;Contest</a></li>
112         <li><a href=\"/misc/thanks.html\"        >Thanks</a></li>
113       </ul>
114     <li><a href=\"/blog/index.html\"            >Blog</a></li>
115     <li><a href=\"/privacy-policy.html\"        >Privacy Policy</a></li>
116     <li><a href=\"/sitemap.html\"               >Sitemap</a></li>
117   </ul>
118   </nav>
119 </div>
120 <main>
121 "))
122
123 (defun gpgweb-insert-footer ()
124   (goto-char (point-min))
125   (unless (search-forward "<!--disable-copyright-footer-->" nil t)
126     (goto-char (point-max))
127     (insert "<div id=\"cpyright\">
128     <a rel=\"license\" href=\"http://creativecommons.org/licenses/by-sa/3.0/\"
129       ><img alt=\"CC-BY-SA 3.0\" style=\"border: 0\"
130             src=\"/share/cc-by-sa-3.0_80x15.png\"/></a><br/>
131     These web pages are
132     Copyright 1998--2014 The GnuPG Project<a href=\"/copying.html\">ยน</a>
133     and licensed under a
134     <a rel=\"license\" href=\"http://creativecommons.org/licenses/by-sa/3.0/\"
135     >Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.  See
136     <a href=\"/copying.html\">copying</a> for details.
137 </div>
138 </main>
139 </body>
140 </html>")))
141
142
143 ;;; Post-process the generated HTML file:
144 ;;;
145 ;;; - Insert header and footer
146 ;;; - Insert "class=selected" into the active menu entry
147 ;;; - Fixup sitemap.
148 (defun gpgweb-postprocess-html (plist orgfile htmlfile)
149   (let* ((visitingp (find-buffer-visiting htmlfile))
150          (work-buffer (or visitingp (find-file-noselect htmlfile))))
151     (prog1 (with-current-buffer work-buffer
152              (let ((fname (file-name-nondirectory htmlfile))
153                    (fname-2 (replace-regexp-in-string
154                              ".*/stage\\(/.*\\)$" "\\1" htmlfile t))
155                    (title (org-publish-find-title orgfile))
156                    (generated-at (org-today))
157                    (tmppnt))
158                ;; Insert the header and mark the active menu
159                (gpgweb-insert-header title)
160                (setq tmppnt (point))
161                (goto-char (point-min))
162                (while (re-search-forward
163                        (concat "href=\"" (regexp-quote fname-2) "\"")
164                        tmppnt t)
165                  (replace-match "\\& class=\"selected\"" t))
166
167                ; Insert the footer
168                (gpgweb-insert-footer)
169
170                ; Fixup the sitemap
171                (when (string-equal fname "sitemap.html")
172                  (goto-char (point-min))
173                  (while (re-search-forward
174                          "^.*<li>.*>\\(GnuPG - \\).*<span.*$" nil t)
175                    (replace-match "" t nil nil 1)))
176
177                ; Due to a problem with the current org exporter (cases
178                ; were we link to file mapped via a webserver alias) we
179                ; have to use a full URL at some places in the org
180                ; source.  We fix that up here.
181                (goto-char (point-min))
182                (while (re-search-forward
183                        "href=\"\\(https://www.gnupg.org\\)/.*\"" nil t)
184                  (replace-match "" t t nil 1))
185
186                ; And save the changes
187                (basic-save-buffer))
188       (unless visitingp (kill-buffer work-buffer))))))
189
190 ;;;
191 ;;; The publishing function used by the HTML exporter
192 ;;;
193 (defun gpgweb-org-to-html (plist filename pub-dir)
194   (gpgweb-postprocess-html plist filename
195                            (org-html-publish-to-html plist filename pub-dir)))
196
197
198 (defun gpgweb-upload ()
199   (let ((stagedir (plist-get project-plist :publishing-directory)))
200     (message "gpgweb  rootdir '%s'" gpgweb-root-dir)
201     (message "gpgweb stagedir '%s'" stagedir)
202     (shell-command
203      (concat "cd " gpgweb-root-dir " && cd " stagedir
204              "&& rsync -rlt --exclude \"*~\" ./ "
205              "werner@trithemius.gnupg.org:"
206              "/var/www/www/www.gnupg.org/htdocs/"))))
207
208
209 (provide 'gpgweb)
210
211 ;; commit 6f5180bd9fc230a31913cbdb9a4dd48cc247adc2
212 ;; Author: Rick Frankel <rick@rickster.com>
213 ;; Date:   Wed Oct 2 18:26:27 2013 -0400
214 ;;
215 ;;     Fix escaping of links in html export.
216 ;;
217 ;;     * lisp/ox-html.el (org-html-link): Unescape org-escaped links an
218 ;;       re-escape for html (browser).
219 ;;
220 ;;
221 ;; diff --git a/lisp/ox-html.el b/lisp/ox-html.el
222 ;; index 66862bc..0600204 100644
223 ;; --- a/lisp/ox-html.el
224 ;; +++ b/lisp/ox-html.el
225 ;; @@ -2624,7 +2624,9 @@ INFO is a plist holding contextual information.  See
226 ;;          (path
227 ;;           (cond
228 ;;            ((member type '("http" "https" "ftp" "mailto"))
229 ;; -           (concat type ":" raw-path))
230 ;; +           (org-link-escape
231 ;; +            (org-link-unescape
232 ;; +             (concat type ":" raw-path)) org-link-escape-chars-browser))
233 ;;            ((string= type "file")
234 ;;             ;; Treat links to ".org" files as ".html", if needed.
235 ;;             (setq raw-path