Tweak my htmlize code in prep for adding my inits to SXEmacs website.
authorSteve Youngs <steve@sxemacs.org>
Wed, 15 Apr 2020 08:26:55 +0000 (18:26 +1000)
committerSteve Youngs <steve@sxemacs.org>
Wed, 15 Apr 2020 08:26:55 +0000 (18:26 +1000)
* 07-html.el (sy-htmlize-appendix): Remove the Valid CSS
Add 'target' to links
Don't use 'uri=referer'.  Use a URL instead.
(url-hexify-string): Autoload it.
(sy-htmlize-append): Compute the URL to use in the Valid XHTML
validation URL.

Signed-off-by: Steve Youngs <steve@sxemacs.org>
07-html.el

index 40d121d..10155ba 100644 (file)
@@ -5,7 +5,7 @@
 ;;     Author: Steve Youngs <steve@sxemacs.org>
 ;; Maintainer: Steve Youngs <steve@sxemacs.org>
 ;;    Created: <2007-12-02>
-;; Time-stamp: <Tuesday Apr 14, 2020 17:04:47 steve>
+;; Time-stamp: <Wednesday Apr 15, 2020 18:03:47 steve>
 ;;   Download: <https://downloads.sxemacs.org/SYinits/>
 ;;   HTMLised: <https://www.sxemacs.org/SYinits/07-html.html>
 ;;   Git Repo: git clone https://git.sxemacs.org/syinit
@@ -185,36 +185,38 @@ html tag.  Done via `htmlize-after-hook'."
     (replace-match
      "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">")))
 
-;; I know that the pages generated by `htmlize.el' are valid HTML/CSS and
+;; I know that the pages generated by `htmlize.el' are valid HTML and
 ;; are created by SXEmacs.  So I announce the fact by adding the appropriate
 ;; logos to the bottom of the page, together with a copyright notice.  This
 ;; is the raw HTML for that.
-(defconst sy-htmlize-appendix
+;; Used to have valid CSS as well but that is way too much mucking
+;; about to get the validator to work from within an iframe.  In case
+;; you are wondering, the CSS produced from htmlize is definitely
+;; valid.
+;; <a href=\"http://jigsaw.w3.org/css-validator/check/referer\" target=\"_blank\">
+;;   <img style=\"padding:0px 0px 0px 5px;border:0;width:88px;height:31px\"
+;;     src=\"/Images/vcss.png\"
+;;     title=\"Valid CSS!\" alt=\"Valid CSS!\" />
+;; </a>
+(defvar sy-htmlize-appendix
   (concat "<!--  SXEmacs Logo -->
     <div class=\"img\">
-      <a href=\"https://www.sxemacs.org/\">
+      <a href=\"https://www.sxemacs.org/\" target=\"_parent\">
        <img style=\"padding:0px 5px 0px 0px;border:0;width:88px;height:31px\"
          src=\"/Images/cbsx.png\"
          title=\"This page was created entirely in SXEmacs\"
          alt=\"Created with SXEmacs\" />
       </a>
 <!--  End SXEmacs Logo -->
-
-<!--  Valid XHTML 1.0 / CSS -->
-      <a href=\"http://validator.w3.org/check?uri=referer\">
-        <img style=\"padding:0px 5px 0px 10px;border:0;width:88px;height:31px\"
+<!--  Valid XHTML 1.0 -->
+      <a href=\"http://validator.w3.org/check?uri=" "%s" "\" target=\"_blank\">
+       <img style=\"padding:0px 5px 0px 10px;border:0;width:88px;height:31px\"
          src=\"/Images/valid-xhtml10.png\"
          title=\"Valid XHTML 1.0 Transitional!\"
          alt=\"Valid XHTML 1.0 Transitional!\" />
       </a>
-      <a href=\"http://jigsaw.w3.org/css-validator/check/referer\">
-       <img style=\"padding:0px 0px 0px 5px;border:0;width:88px;height:31px\"
-         src=\"/Images/vcss.png\"
-         title=\"Valid CSS!\" alt=\"Valid CSS!\" />
-      </a>
     </div>
-
-<!--  End Valid HTML / CSS-->
+<!--  End Valid XHTML 1.0 -->
 
     <h6>Copyright &#169; "
          (format-time-string "%Y") " Steve Youngs<br />
@@ -228,11 +230,15 @@ html tag.  Done via `htmlize-after-hook'."
 ))
 
 ;; Appends the above to each page.  Run from `htmlize-after-hook'.
+(autoload 'url-hexify-string "url-util")
 (defun sy-htmlize-append ()
   "Append some things to the end of files produced by `htmlize.el'."
-  (goto-char (point-max))
-  (re-search-backward "</body>" nil t)
-  (insert sy-htmlize-appendix))
+  (let ((html (url-hexify-string
+              (concat "https://www.sxemacs.org/SYinits/"
+                      (buffer-name)))))
+    (goto-char (point-max))
+    (re-search-backward "</body>" nil t)
+    (insert (format sy-htmlize-appendix html))))
 
 ;; Set a couple of basic things.
 (setq