[dokuwiki] [PATCH] plugin:s5: add configurable hack for firefox "save as" bugs

  • From: Mike Frysinger <vapier@xxxxxxxxxx>
  • To: andi@xxxxxxxxxxxxxx
  • Date: Fri, 10 Oct 2008 18:21:48 -0400

Firefox has some bugs where it does not completely save content referenced
by CSS files (see upstream bugs #115107 #126309).  So make an optional
little hack that has a bunch of hidden '<img>' references to all theme
files.

Signed-off-by: Mike Frysinger <vapier@xxxxxxxxxx>
---
 conf/default.php |    2 ++
 renderer.php     |   15 +++++++++++++++
 2 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/conf/default.php b/conf/default.php
index cd1f40c..078c4ad 100644
--- a/conf/default.php
+++ b/conf/default.php
@@ -2,3 +2,5 @@
 
 $conf['template']    = 'dokuwiki';
 
+/* Workaround "Save As" bugs in Firefox (#115107 #126309) */
+$conf['ff-save-hack'] = 1;
diff --git a/renderer.php b/renderer.php
index 18b1a7d..8af6c44 100644
--- a/renderer.php
+++ b/renderer.php
@@ -102,6 +102,21 @@ class renderer_plugin_s5 extends Doku_Renderer_xhtml {
 <script src="'.$this->getThemeFileURI('slides.js').'" 
type="text/javascript"></script>
 </head>
 <body>
+';
+
+        if ($this->getConf('ff-save-hack')) {
+            $this->doc .= '<!-- bogus references to all themed files so "save 
as" works in firefox (works around #115107 #126309) -->'."\n";
+            $theme_dir = dirname(__FILE__).'/ui/'.$this->tpl;
+            $d = opendir($theme_dir);
+            while (($f = readdir($d)) !== false) {
+                if (is_dir($theme_dir.'/'.$f))
+                    continue;
+                $this->doc .= '<img style="visibility: hidden;" width="0" 
height="0" src="'.$this->base.$this->tpl.'/'.$f.'">'."\n";
+            }
+            closedir($d);
+        }
+
+        $this->doc .= '
 <div class="layout">
 <div id="controls"><!-- DO NOT EDIT --></div>
 <div id="currentSlide"><!-- DO NOT EDIT --></div>
-- 
1.5.3.3

-- 
DokuWiki mailing list - more info at
http://wiki.splitbrain.org/wiki:mailinglist

Other related posts:

  • » [dokuwiki] [PATCH] plugin:s5: add configurable hack for firefox "save as" bugs