mirror of
https://github.com/mrclay/minify.git
synced 2025-08-20 04:41:29 +02:00
crude builder app for generating URIs quickly
This commit is contained in:
24
min/builder/index.html
Normal file
24
min/builder/index.html
Normal file
@@ -0,0 +1,24 @@
|
||||
<!doctype html>
|
||||
<head>
|
||||
<title>Minify URI Builder</title>
|
||||
<style type="text/css">
|
||||
#sources {margin:0; padding:0;}
|
||||
#sources li {margin:0 0 0 40px}
|
||||
#add {margin:5px 0 1em 40px}
|
||||
li span {margin:0 3px}
|
||||
</style>
|
||||
</head>
|
||||
<h1>Minify URI Builder</h1>
|
||||
|
||||
<ol id=sources></ol>
|
||||
<div id=add><a href='#'>Add file +</a></div>
|
||||
|
||||
<p><button id=update>Update</button></p>
|
||||
|
||||
<table style="display:none">
|
||||
<tr><th>URI</th><td><a id=uriA target="_blank">/min</a> <small>(opens in new window)</small></td></tr>
|
||||
<tr><th>HTML</th><td><input id=uriHtml type=text size=80 readonly></td></tr>
|
||||
</table>
|
||||
|
||||
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="index.js"></script>
|
79
min/builder/index.js
Normal file
79
min/builder/index.js
Normal file
@@ -0,0 +1,79 @@
|
||||
// @todo update test links when reordering, app instructions
|
||||
var MUB = {
|
||||
_uid : 0
|
||||
,newLi : function () {
|
||||
return '<li id="li' + MUB._uid + '">http://' + location.host + '<span>/</span><input type=text size=20>'
|
||||
+ ' <button title="Remove">x</button> <button title="Include Earlier">↑</button>'
|
||||
+ ' <button title="Include Later">↓</button> <a href=# target="_blank" '
|
||||
+ 'title="Open this URL in a new window">test link</a></li>';
|
||||
}
|
||||
,addLi : function () {
|
||||
$('#sources').append(MUB.newLi());
|
||||
var li = $('#li' + MUB._uid)[0];
|
||||
$('button[title=Remove]', li).click(function () {
|
||||
$(li).remove();
|
||||
});
|
||||
$('button[title$=Earlier]', li).click(function () {
|
||||
$(li).prev('li').find('input').each(function () {
|
||||
// this = previous li input
|
||||
var tmp = this.value;
|
||||
this.value = $('input', li).val();
|
||||
$('input', li).val(tmp);
|
||||
});
|
||||
});
|
||||
$('button[title$=Later]', li).click(function () {
|
||||
$(li).next('li').find('input').each(function () {
|
||||
// this = next li input
|
||||
var tmp = this.value;
|
||||
this.value = $('input', li).val();
|
||||
$('input', li).val(tmp);
|
||||
});
|
||||
});
|
||||
$('input', li).keyup(function () {
|
||||
$('a', li)[0].href = '/' + this.value;
|
||||
});
|
||||
++MUB._uid;
|
||||
}
|
||||
,update : function () {
|
||||
var sources = []
|
||||
,ext = false
|
||||
,fail = false;
|
||||
$('#sources input').each(function () {
|
||||
if (! fail && this.value && (m = this.value.match(/\.(css|js)$/))) {
|
||||
var thisExt = m[1];
|
||||
if (ext === false)
|
||||
ext = thisExt;
|
||||
else if (thisExt !== ext) {
|
||||
fail = true;
|
||||
return alert('extensions must match!');
|
||||
}
|
||||
if (-1 != $.inArray(this.value, sources)) {
|
||||
fail = true;
|
||||
return alert('duplicate file!');
|
||||
}
|
||||
sources.push(this.value);
|
||||
}
|
||||
});
|
||||
if (fail || ! sources.length)
|
||||
return;
|
||||
var uri = '/min/?f=' + sources.join(',')
|
||||
,uriH = uri.replace(/</, '<').replace(/>/, '>').replace(/&/, '&');
|
||||
$('#uriA').html(uriH)[0].href = uri;
|
||||
$('#uriHtml').val(
|
||||
ext === 'js'
|
||||
? '<script type="text/javascript" src="' + uriH + '"></script>'
|
||||
: '<link type="text/css" rel="stylesheet" href="' + uriH + '" />'
|
||||
);
|
||||
$('table').show();
|
||||
}
|
||||
,init : function () {
|
||||
$('#add a').click(MUB.addLi);
|
||||
$('#uriHtml').click(function () {
|
||||
this.select();
|
||||
}).focus(function () {
|
||||
this.select();
|
||||
});
|
||||
$('#update').click(MUB.update);
|
||||
}
|
||||
};
|
||||
window.onload = MUB.init;
|
@@ -5,6 +5,13 @@
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Forward empty requests to URI Builder app. After initial setup this
|
||||
* should be set to false.
|
||||
**/
|
||||
$min_forwardToBuilder = true;
|
||||
|
||||
|
||||
/**
|
||||
* For best performance, specify your temp directory here.
|
||||
* Otherwise Minify will have to load extra code to guess.
|
||||
|
@@ -69,4 +69,15 @@ if (isset($_GET['g'])) {
|
||||
$_GET['files'] = $min_base . str_replace(',', ',' . $min_base, $_GET['f']);
|
||||
|
||||
Minify::serve('Version1', $min_serveOptions);
|
||||
|
||||
} elseif ($min_forwardToBuilder) {
|
||||
|
||||
header('Location: builder/');
|
||||
exit();
|
||||
|
||||
} else {
|
||||
|
||||
header("HTTP/1.0 404 Not Found");
|
||||
exit();
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user