Remove support for Piwik and adjust privacy policy.
[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"
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=\"/download/index.html\"        >Download</a></li>
76       <ul>
77         <li><a href=\"/download/integrity_check.html\"
78                                                 >Integrity&nbsp;Check</a></li>
79         <li><a href=\"/download/supported_systems.html\"
80                                                 >Supported&nbsp;Systems</a></li>
81         <li><a href=\"/download/release_notes.html\"
82                                                 >Release&nbsp;Notes</a></li>
83         <li><a href=\"/download/mirrors.html\"   >Mirrors</a></li>
84         <li><a href=\"/download/cvs_access.html\" >GIT</a></li>
85       </ul>
86     <li><a href=\"/documentation/index.html\"   >Documentation</a></li>
87       <ul>
88         <li><a href=\"/documentation/howtos.html\"       >HOWTOs</a></li>
89         <li><a href=\"/documentation/manuals.html\"      >Manuals</a></li>
90         <li><a href=\"/documentation/guides.html\"       >Guides</a></li>
91         <li><a href=\"/documentation/faqs.html\"         >FAQs</a></li>
92         <li><a href=\"/documentation/mailing-lists.html\"
93                                                  >Mailing&nbsp;Lists</a></li>
94         <li><a href=\"/documentation/sites.html\"    >Sites</a></li>
95         <li><a href=\"/documentation/bts.html\"      >Bug&nbsp;Tracker</a></li>
96       </ul>
97     <li><a href=\"/related_software/index.html\">Related software</a></li>
98       <ul>
99         <li><a href=\"/related_software/frontends.html\" >Frontends</a></li>
100         <li><a href=\"/related_software/tools.html\"     >Tools</a></li>
101         <li><a href=\"/related_software/libraries.html\" >Libraries</a></li>
102         <li><a href=\"/related_software/swlist.html\"    >All</a></li>
103       </ul>
104     <li><a href=\"/misc/index.html\"            >Miscellaneous</a></li>
105       <ul>
106         <li><a href=\"/misc/links.html\"         >Links</a></li>
107         <li><a href=\"/misc/logo-contest.html\"  >Logo&nbsp;Contest</a></li>
108         <li><a href=\"/misc/thanks.html\"        >Thanks</a></li>
109         <li><a href=\"/misc/donations.html\"     >Donations</a></li>
110       </ul>
111     <li><a href=\"http://blog.gnupg.org/\"      >Blog</a></li>
112     <li><a href=\"/privacy-policy.html\"        >Privacy Policy</a></li>
113     <li><a href=\"/sitemap.html\"               >Sitemap</a></li>
114   </ul>
115   </nav>
116 </div>
117 <main>
118 "))
119
120 (defun gpgweb-insert-footer ()
121   (goto-char (point-min))
122   (unless (search-forward "<!--disable-copyright-footer-->" nil t)
123     (goto-char (point-max))
124     (insert "<div id=\"cpyright\">
125     <a rel=\"license\" href=\"http://creativecommons.org/licenses/by-sa/3.0/\"
126       ><img alt=\"CC-BY-SA 3.0\" style=\"border: 0\"
127             src=\"/share/cc-by-sa-3.0_80x15.png\"/></a><br/>
128     These web pages are
129     Copyright 1998--2014 The GnuPG Project<a href=\"/copying.html\">ยน</a>
130     and licensed under a
131     <a rel=\"license\" href=\"http://creativecommons.org/licenses/by-sa/3.0/\"
132     >Creative Commons Attribution-ShareAlike 3.0 Unported License</a>.  See
133     <a href=\"/copying.html\">copying</a> for details.
134 </div>
135 </main>
136 </body>
137 </html>")))
138
139
140 ;;; The old pwik code.
141 ;;;  (insert "
142 ;;;<script type=\"text/javascript\">
143 ;;;  var _paq = _paq || [];
144 ;;;  _paq.push([\"trackPageView\"]);
145 ;;;  _paq.push([\"enableLinkTracking\"]);
146 ;;;
147 ;;;  (function() {
148 ;;;    var u=((\"https:\" == document.location.protocol) ? \"https\" : \"http\")
149 ;;;            + \"://alberti.gnupg.org/piwik/\";
150 ;;;    _paq.push([\"setTrackerUrl\", u+\"piwik.php\"]);
151 ;;;    _paq.push([\"setSiteId\", \"1\"]);
152 ;;;    var d=document,
153 ;;;        g=d.createElement(\"script\"),
154 ;;;        s=d.getElementsByTagName(\"script\")[0];
155 ;;;    g.type=\"text/javascript\";
156 ;;;    g.defer=true;
157 ;;;    g.async=true;
158 ;;;    g.src=u+\"piwik.js\";
159 ;;;    s.parentNode.insertBefore(g,s);
160 ;;;  })();
161 ;;;</script>
162 ;;;</main>
163 ;;;</body>
164 ;;;</html>
165 ;;;")
166
167 ;;; Post-process the generated HTML file:
168 ;;;
169 ;;; - Insert header and footer
170 ;;; - Insert "class=selected" into the active menu entry
171 ;;; - Fixup sitemap.
172 (defun gpgweb-postprocess-html (plist orgfile htmlfile)
173   (let* ((visitingp (find-buffer-visiting htmlfile))
174          (work-buffer (or visitingp (find-file-noselect htmlfile))))
175     (prog1 (with-current-buffer work-buffer
176              (let ((fname (file-name-nondirectory htmlfile))
177                    (fname-2 (replace-regexp-in-string
178                              ".*/stage\\(/.*\\)$" "\\1" htmlfile t))
179                    (title (org-publish-find-title orgfile))
180                    (generated-at (org-today))
181                    (tmppnt))
182                ;; Insert the header and mark the active menu
183                (gpgweb-insert-header title)
184                (setq tmppnt (point))
185                (goto-char (point-min))
186                (while (re-search-forward
187                        (concat "href=\"" (regexp-quote fname-2) "\"")
188                        tmppnt t)
189                  (replace-match "\\& class=\"selected\"" t))
190
191                ; Insert the footer
192                (gpgweb-insert-footer)
193
194                ; Fixup the sitemap
195                (when (string-equal fname "sitemap.html")
196                  (goto-char (point-min))
197                  (while (re-search-forward
198                          "^.*<li>.*>\\(GnuPG - \\).*<span.*$" nil t)
199                    (replace-match "" t nil nil 1)))
200                (basic-save-buffer))
201       (unless visitingp (kill-buffer work-buffer))))))
202
203 ;;;
204 ;;; The publishing function used by the HTML exporter
205 ;;;
206 (defun gpgweb-org-to-html (plist filename pub-dir)
207   (gpgweb-postprocess-html plist filename
208                            (org-html-publish-to-html plist filename pub-dir)))
209
210
211 (defun gpgweb-upload ()
212   (let ((stagedir (plist-get project-plist :publishing-directory)))
213     (message "gpgweb  rootdir '%s'" gpgweb-root-dir)
214     (message "gpgweb stagedir '%s'" stagedir)
215     (shell-command
216      (concat "cd " gpgweb-root-dir " && cd " stagedir
217              "&& rsync -rlt --exclude \"*~\" ./ "
218              "werner@trithemius.gnupg.org:"
219              "/var/www/www/www.gnupg.org/htdocs/"))))
220
221
222 (provide 'gpgweb)
223
224 ;; commit 6f5180bd9fc230a31913cbdb9a4dd48cc247adc2
225 ;; Author: Rick Frankel <rick@rickster.com>
226 ;; Date:   Wed Oct 2 18:26:27 2013 -0400
227 ;;
228 ;;     Fix escaping of links in html export.
229 ;;
230 ;;     * lisp/ox-html.el (org-html-link): Unescape org-escaped links an
231 ;;       re-escape for html (browser).
232 ;;
233 ;;
234 ;; diff --git a/lisp/ox-html.el b/lisp/ox-html.el
235 ;; index 66862bc..0600204 100644
236 ;; --- a/lisp/ox-html.el
237 ;; +++ b/lisp/ox-html.el
238 ;; @@ -2624,7 +2624,9 @@ INFO is a plist holding contextual information.  See
239 ;;          (path
240 ;;           (cond
241 ;;            ((member type '("http" "https" "ftp" "mailto"))
242 ;; -           (concat type ":" raw-path))
243 ;; +           (org-link-escape
244 ;; +            (org-link-unescape
245 ;; +             (concat type ":" raw-path)) org-link-escape-chars-browser))
246 ;;            ((string= type "file")
247 ;;             ;; Treat links to ".org" files as ".html", if needed.
248 ;;             (setq raw-path