diff --git a/min/builder/index.html b/min/builder/index.html new file mode 100644 index 0000000..486b124 --- /dev/null +++ b/min/builder/index.html @@ -0,0 +1,24 @@ + + + Minify URI Builder + + +

Minify URI Builder

+ +
    +
    Add file +
    + +

    + + + + +
    URI/min (opens in new window)
    HTML
    + + + \ No newline at end of file diff --git a/min/builder/index.js b/min/builder/index.js new file mode 100644 index 0000000..7e7e5da --- /dev/null +++ b/min/builder/index.js @@ -0,0 +1,79 @@ +// @todo update test links when reordering, app instructions +var MUB = { + _uid : 0 + ,newLi : function () { + return '
  1. http://' + location.host + '/' + + ' ' + + ' test link
  2. '; + } + ,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(/&/, '&'); + $('#uriA').html(uriH)[0].href = uri; + $('#uriHtml').val( + ext === 'js' + ? '' + : '' + ); + $('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; \ No newline at end of file diff --git a/min/config.php b/min/config.php index 6f82207..d8023a3 100644 --- a/min/config.php +++ b/min/config.php @@ -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. diff --git a/min/index.php b/min/index.php index 327ed2f..4eb4525 100644 --- a/min/index.php +++ b/min/index.php @@ -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(); + }