I have tried to put my tiddlywiki into a php file insted of a html
file.
Purpose : to be able to include some usefull php code at the top, like
gzip compression (to reduce the size of the file to download) and a
HTTP_REFERER tracker.
The gzip compression **** ob_start("ob_gzhandler"); **** could reduce
the size of the file until 70%, a terrific improve for dial up
users !!!
Unfortunalty, two lines of javascript send me an error:
Line 296
macroError: "Error in macro <<%0>>",
I have change it in
macroError: "Error in macro <<" + "%0" + ">>",
now it's ok
Line 1292
lookaheadRegExp: /\[(<?)(>?)[Ii][Mm][Gg]\[(?:([^\|\]]+)\|)?([^\[\]\|]+)
\](?:\[([^\]]*)\])?\]/mg,
The <? is a pb because it is the same symbol that in php.
I have tried to changed it in:
lookaheadRegExp: new RegExp("/\\[(<" + "?)(>?)[Ii][Mm][Gg]\\[(?:([^\\|\
\]]+)\\|)?([^\\[\\]\\|]+)\\](?:\\[([^\\]]*)\\])?\\])", "mg"),
To avoid the sequence <? but I got an errror.
Does someone as an idea to do the trick?
the good code is as follow
lookaheadRegExp: new RegExp("\\[(<" + "?)(>?)[Ii][Mm][Gg]\\[(?:([^\\|\
\]]+)\\|)?([^\\[\\]\\|]+)\\](?:\\[([^\\]]*)\\])?\\]", "mg"),
now the tiddlywiki work well as a php file !!!
To of the source file:
<?php
// Tracks referer
$refererInfo = parse_url($_SERVER["HTTP_REFERER"]);
$handle = fopen("$DOCUMENT_ROOT/referer-" . date("ymd") .
".txt", "a");
fputs($handle, $_SERVER["HTTP_REFERER"] . "\n");
fclose($handle);
// gzip compression
ob_start ("ob_gzhandler");
// cache optimization because my tiddlywiki is rarely modified
header("Cache-Control: must-revalidate");
$offset = 3600 * 24 ;
$ExpStr = "Expires: " .
gmdate("D, d M Y H:i:s",
time() + $offset) . " GMT";
header($ExpStr);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
See the result of the compression with this website:
http://www.gidnetwork.com/tools/gzip-test.php
The url to be tested: http://www.superphysique.net
Results:
Web page compressed? Yes
Compression type? gzip
Size, Markup (bytes) 266,259
Size, Compressed (bytes) 68,189
Compression % 74.4
The best of tiddlywiki !!! One size and quickly viewed by readers!!!
I should note (as you have discovered) that plain text like TiddlyWiki
compresses very well (70-80% typically). Compression cam be achieved in
a number of ways depending on what server you are using, and ALL modern
browsers will decompress the content before showing it to the user.
As far as I know there are no side-effects or drawbacks to this. It
just makes things faster. With Apache, simply install the mod_gzip
module.
http://www.bluestream.org/Networking/gzip.htm
Note that by default, mod_gzip will only compress things smaller than
1MB. I'm sure some people have TW's out there that are larger than
this, so you might want to increase the mod_gzip_maximum_file_size
parameter.
--
Cheers,
Bob McElrath [Univ. of California at Davis, Department of Physics]
"The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all progress
depends on the unreasonable man."
-- George Bernard Shaw, Maxims for Revolutionists
lookaheadRegExp: /\[([<]?)(>?)[Ii][Mm][Gg]\[(?:([^\|\]]+)\|)?([^\[\]\|]
+)
\](?:\[([^\]]*)\])?\]/mg,
This is untested, but should solve the problem without the need for
using a new RegExp.
Martin
http://trac.tiddlywiki.org/tiddlywiki/ticket/304
I'm also a fan of using the web server to do gzip compression,
although I've just checked and found it's been somehow switched off
tiddlywiki.com. Ooops.
Cheers
Jeremy
--
Jeremy Ruston
mailto:jer...@osmosoft.com
http://www.tiddlywiki.com