1
0
mirror of https://github.com/mrclay/minify.git synced 2025-02-25 01:12:35 +01:00

+ encode.php (file encoder tool) and test of Apache content negotiation

This commit is contained in:
Steve Clay 2008-05-26 17:11:48 +00:00
parent 97eaa576ed
commit f4c3b6be24
7 changed files with 99 additions and 0 deletions

View File

@ -0,0 +1,32 @@
<?php
if (isset($_FILES['subject']['name'])) {
require '../../../lib/HTTP/Encoder.php';
$he = new HTTP_Encoder(array(
'content' => file_get_contents($_FILES['subject']['tmp_name'])
,'method' => $_POST['method']
));
header('Content-Type: application/octet-stream');
header('Content-Transfer-Encoding: binary');
header("Content-Disposition: attachment; filename=\"{$_FILES['subject']['name']}."
. ($_POST['method'] == 'deflate'
? 'zd'
: ($_POST['method'] == 'gzip'
? 'zg'
: 'zc'
)
) . '"');
$he->encode();
echo $he->getContent();
exit();
}
?>
<form enctype="multipart/form-data" action="" method="post">
<p>Encode <input type="file" name="subject" /><br />
as <input type="submit" name="method" value="deflate" />
<input type="submit" name="method" value="gzip" />
<input type="submit" name="method" value="compress" />
</p>
</form>

View File

@ -0,0 +1,41 @@
# turn off MultiViews if enabled
#
Options -MultiViews
# For *.var requests, negotiate using type-map
#
AddHandler type-map .var
# use custom extensions so existing handlers for .gz/.Z
# do not interfere
#
AddEncoding x-gzip .zg
AddEncoding x-compress .zc
AddEncoding deflate .zd
# Necessary to add charset while using type-map
#
AddType application/x-javascript;charset=utf-8 js
AddType text/css;charset=utf-8 css
# Below we remove the ETag header and set a far-off Expires
# header. Since clients will aggressively cache, make sure
# to modify the URL (querystring or via mod_rewrite) when
# the resource changes
# remove ETag
FileETag None
# requires mod_expires
#
ExpiresActive On
#
# sets Expires and Cache-Control: max-age, but not "public"
#
ExpiresDefault "access plus 1 year"
# requires mod_headers
#
# adds the "public" to Cache-Control.
#
Header set Cache-Control "public, max-age=31536000"

View File

@ -0,0 +1,12 @@
(function(){var
reMailto=/^mailto:my_name_is_(\S+)_and_the_domain_is_(\S+)$/,reRemoveTitleIf=/^my name is/,oo=window.onload,fixHrefs=function(){var i=0,l,m;while(l=document.links[i++]){if(m=l.href.match(reMailto)){l.href='mailto:'+m[1]+'@'+m[2];if(reRemoveTitleIf.test(l.title)){l.title='';}}}};window.onload=function(){oo&&oo();fixHrefs();};})();;var MrClay=window.MrClay||{};MrClay.QueryString=function(){var parse=function(str){var assignments=str.split('&'),obj={},propValue;for(var i=0,l=assignments.length;i<l;++i){propValue=assignments[i].split('=');if(propValue.length>2||-1!=propValue[0].indexOf('+')||propValue[0]==''){continue;}
if(propValue.length==1){propValue[1]=propValue[0];}
obj[unescape(propValue[0])]=unescape(propValue[1].replace(/\+/g,' '));}
return obj;};function construct_(spec){spec=spec||window;if(typeof spec=='object'){this.window=spec;spec=spec.location.search.substr(1);}else{this.window=window;}
this.vars=parse(spec);}
construct_.reload=function(vars,window_){window_=window_||window;vars=vars||(new MrClay.QueryString(window_)).vars;var l=window_.location,currUrl=l.href,s=MrClay.QueryString.toString(vars),newUrl=l.protocol+'//'+l.hostname+l.pathname
+(s?'?'+s:'')+l.hash;if(currUrl==newUrl){l.reload();}else{l.assign(newUrl);}};construct_.get=function(key,default_,window_){window_=window_||window;return(new MrClay.QueryString(window_)).get(key,default_);};construct_.set=function(key,value,window_){window_=window_||window;(new MrClay.QueryString(window_)).set(key,value).reload();};construct_.toString=function(vars){var pieces=[];for(var prop in vars){pieces.push(escape(prop)+'='+escape(vars[prop]));}
return pieces.join('&');};construct_.prototype.reload=function(){MrClay.QueryString.reload(this.vars,this.window);return this;};construct_.prototype.get=function(key,default_){if(typeof default_=='undefined'){default_=null;}
return(this.vars[key]==null)?default_:this.vars[key];};construct_.prototype.set=function(key,value){var obj={};if(typeof key=='string'){obj[key]=value;}else{obj=key;}
for(var prop in obj){if(obj[prop]==null){delete this.vars[prop];}else{this.vars[prop]=obj[prop];}}
return this;};construct_.prototype.toString=function(){return QueryString.toString(this.vars);};return construct_;}();

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,14 @@
URI: before.js.zd
Content-Type: application/x-javascript; qs=0.9
Content-Encoding: deflate
URI: before.js.zg
Content-Type: application/x-javascript; qs=0.8
Content-Encoding: x-gzip
URI: before.js.zc
Content-Type: application/x-javascript; qs=0.7
Content-Encoding: x-compress
URI: before.js
Content-Type: application/x-javascript; qs=0.6