download ZIP

fixes #7
pull/12/head
Szekeres Bálint 7 years ago
parent 23f6aa20d0
commit ba68d8fb02

@ -52,3 +52,5 @@ Online nginx configuration generator.
* [ngclipboard](http://sachinchoolur.github.io/ngclipboard/) - AngularJS directive for clipboard.js
* [Angular Tooltips](https://720kb.github.io/angular-tooltips/) - helper tooltips
* [Masonry](https://masonry.desandro.com) - files grid layout
* [JSZip](https://stuk.github.io/jszip) - generating zip package
* [FileSaver](https://github.com/eligrey/FileSaver.js) - downloading zip file

@ -220,6 +220,11 @@ main .files .card.actions .card-body {
main .files .card.actions .btn img {
vertical-align: -2px;
margin-right: 0.1rem;
height: 1rem;
}
main .files .card.actions .btn-sm img {
height: 0.9rem;
}

@ -0,0 +1 @@
<svg viewBox="0 0 14 10.2667" xmlns="http://www.w3.org/2000/svg"><path d="m9.3333 5.8333a.2246.2246 0 0 0 -.2333-.2333h-1.6333v-2.5667a.2367.2367 0 0 0 -.2334-.2333h-1.4a.2367.2367 0 0 0 -.2333.2333v2.5667h-1.6333a.2367.2367 0 0 0 -.2334.2333.2268.2268 0 0 0 .0657.1677l2.5666 2.5667a.2472.2472 0 0 0 .3354 0l2.559-2.5594a.2739.2739 0 0 0 .0733-.175zm4.6667 1.6334a2.8007 2.8007 0 0 1 -2.8 2.8h-7.9333a3.1462 3.1462 0 0 1 -2.3078-.9589 3.1458 3.1458 0 0 1 -.9589-2.3078 3.261 3.261 0 0 1 1.8813-2.9531q-.0147-.2189-.0146-.3136a3.5965 3.5965 0 0 1 1.0933-2.6395 3.5968 3.5968 0 0 1 2.64-1.0938 3.737 3.737 0 0 1 3.4562 2.3188 1.8569 1.8569 0 0 1 2.53.0947 1.7989 1.7989 0 0 1 .5468 1.32 1.7849 1.7849 0 0 1 -.2986 1.0065 2.76 2.76 0 0 1 1.5567.988 2.71 2.71 0 0 1 .6089 1.7387z" fill="#fff"/></svg>

After

Width:  |  Height:  |  Size: 797 B

@ -193,6 +193,26 @@
gtag('event', 'reset');
};
$scope.downloadZip = function() {
var zip = new JSZip();
var sourceCodes = document.querySelectorAll('main .file .code.source');
for (var i = 0; i < sourceCodes.length; i++) {
var sourceCode = sourceCodes[i];
var name = sourceCode.dataset.filename;
var content = sourceCode.children[0].children[0].innerText;
zip.file(name, content);
}
zip.generateAsync({ type: 'blob' })
.then(function(content) {
saveAs(content, 'nginxconfig.io-' + $scope.domain() + '.zip');
});
};
$scope.clipboardSuccess = function(key) {
$scope.clipboardCopy = key;

@ -0,0 +1,2 @@
/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
var saveAs=saveAs||function(e){"use strict";if(!("undefined"==typeof e||"undefined"!=typeof navigator&&/MSIE [1-9]\./.test(navigator.userAgent))){var t=e.document,n=function(){return e.URL||e.webkitURL||e},o=t.createElementNS("http://www.w3.org/1999/xhtml","a"),r="download"in o,a=function(e){var t=new MouseEvent("click");e.dispatchEvent(t)},i=/constructor/i.test(e.HTMLElement)||e.safari,d=/CriOS\/[\d]+/.test(navigator.userAgent),f=function(t){(e.setImmediate||e.setTimeout)(function(){throw t},0)},s="application/octet-stream",u=4e4,c=function(e){var t=function(){"string"==typeof e?n().revokeObjectURL(e):e.remove()};setTimeout(t,u)},l=function(e,t,n){t=[].concat(t);for(var o=t.length;o--;){var r=e["on"+t[o]];if("function"==typeof r)try{r.call(e,n||e)}catch(a){f(a)}}},v=function(e){return/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob([String.fromCharCode(65279),e],{type:e.type}):e},p=function(t,f,u){u||(t=v(t));var p,w=this,m=t.type,y=m===s,S=function(){l(w,"writestart progress write writeend".split(" "))},h=function(){if((d||y&&i)&&e.FileReader){var o=new FileReader;return o.onloadend=function(){var t=d?o.result:o.result.replace(/^data:[^;]*;/,"data:attachment/file;"),n=e.open(t,"_blank");n||(e.location.href=t),t=void 0,w.readyState=w.DONE,S()},o.readAsDataURL(t),void(w.readyState=w.INIT)}if(p||(p=n().createObjectURL(t)),y)e.location.href=p;else{var r=e.open(p,"_blank");r||(e.location.href=p)}w.readyState=w.DONE,S(),c(p)};return w.readyState=w.INIT,r?(p=n().createObjectURL(t),void setTimeout(function(){o.href=p,o.download=f,a(o),S(),c(p),w.readyState=w.DONE})):void h()},w=p.prototype,m=function(e,t,n){return new p(e,t||e.name||"download",n)};return"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob?function(e,t,n){return t=t||e.name||"download",n||(e=v(e)),navigator.msSaveOrOpenBlob(e,t)}:(w.abort=function(){},w.readyState=w.INIT=0,w.WRITING=1,w.DONE=2,w.error=w.onwritestart=w.onprogress=w.onwrite=w.onabort=w.onerror=w.onwriteend=null,m)}}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this);"undefined"!=typeof module&&module.exports?module.exports.saveAs=saveAs:"undefined"!=typeof define&&null!==define&&null!==define.amd&&define("FileSaver.js",function(){return saveAs});

File diff suppressed because one or more lines are too long

@ -341,7 +341,7 @@
<img src="assets/img/clipboard-dark.svg" alt="Copy to clipboard">
</button>
<span class="clipboard-success" ng-if="clipboardCopy === 'nginx.conf'">Copied!</span>
<div class="code source">
<div class="code source" data-filename="nginx.conf">
<pre><code class="nginx" ng-include="'templates/conf/nginx.conf.html?v=COMMIT_HASH'" onload="refreshHighlighting()"></code></pre>
</div><div id="file-nginx" class="code highlighted"></div>
</div>
@ -351,7 +351,7 @@
<img src="assets/img/clipboard-dark.svg" alt="Copy to clipboard">
</button>
<span class="clipboard-success" ng-if="clipboardCopy === 'example.com'">Copied!</span>
<div class="code source">
<div class="code source" data-filename="sites-enabled/{{ domain() }}.conf">
<pre><code class="nginx" ng-include="'templates/conf/example.com.conf.html?v=COMMIT_HASH?v=COMMIT_HASH'" onload="refreshHighlighting()"></code></pre>
</div><div id="file-domain" class="code highlighted"></div>
</div>
@ -361,7 +361,7 @@
<img src="assets/img/clipboard-dark.svg" alt="Copy to clipboard">
</button>
<span class="clipboard-success" ng-if="clipboardCopy === '_ssl.conf'">Copied!</span>
<div class="code source">
<div class="code source" data-filename="_ssl.conf">
<pre><code class="nginx" ng-include="'templates/conf/_ssl.conf.html?v=COMMIT_HASH'" onload="refreshHighlighting()"></code></pre>
</div><div id="file-ssl" class="code highlighted"></div>
</div>
@ -371,7 +371,7 @@
<img src="assets/img/clipboard-dark.svg" alt="Copy to clipboard">
</button>
<span class="clipboard-success" ng-if="clipboardCopy === '_letsencrypt.conf'">Copied!</span>
<div class="code source">
<div class="code source" data-filename="_letsencrypt.conf">
<pre><code class="nginx" ng-include="'templates/conf/_letsencrypt.conf.html?v=COMMIT_HASH'" onload="refreshHighlighting()"></code></pre>
</div><div id="file-letsencrypt" class="code highlighted"></div>
</div>
@ -381,7 +381,7 @@
<img src="assets/img/clipboard-dark.svg" alt="Copy to clipboard">
</button>
<span class="clipboard-success" ng-if="clipboardCopy === '_general.conf'">Copied!</span>
<div class="code source">
<div class="code source" data-filename="_general.conf">
<pre><code class="nginx" ng-include="'templates/conf/_general.conf.html?v=COMMIT_HASH'" onload="refreshHighlighting()"></code></pre>
</div><div id="file-general" class="code highlighted"></div>
</div>
@ -391,7 +391,7 @@
<img src="assets/img/clipboard-dark.svg" alt="Copy to clipboard">
</button>
<span class="clipboard-success" ng-if="clipboardCopy === '_php.conf'">Copied!</span>
<div class="code source">
<div class="code source"data-filename="_php.conf">
<pre><code class="nginx" ng-include="'templates/conf/_php.conf.html?v=COMMIT_HASH'" onload="refreshHighlighting()"></code></pre>
</div><div id="file-php" class="code highlighted"></div>
</div>
@ -401,7 +401,7 @@
<img src="assets/img/clipboard-dark.svg" alt="Copy to clipboard">
</button>
<span class="clipboard-success" ng-if="clipboardCopy === '_php_fastcgi.conf'">Copied!</span>
<div class="code source">
<div class="code source" data-filename="_php_fastcgi.conf">
<pre><code class="nginx" ng-include="'templates/conf/_php_fastcgi.conf.html?v=COMMIT_HASH'" onload="refreshHighlighting()"></code></pre>
</div><div id="file-php_fastcgi" class="code highlighted"></div>
</div>
@ -411,19 +411,24 @@
<img src="assets/img/clipboard-dark.svg" alt="Copy to clipboard">
</button>
<span class="clipboard-success" ng-if="clipboardCopy === '_wordpress.conf'">Copied!</span>
<div class="code source">
<div class="code source" data-filename="_wordpress.conf">
<pre><code class="nginx" ng-include="'templates/conf/_wordpress.conf.html?v=COMMIT_HASH'" onload="refreshHighlighting()"></code></pre>
</div><div id="file-wordpress" class="code highlighted"></div>
</div>
</div>
<div class="card actions" ng-cloak>
<div class="card-body text-center">
<div class="mb-1">
<input type="text" id="url" class="form-control form-control-sm" ng-value="location.absUrl()" readonly>
<div class="mb-2">
<div class="input-group">
<input type="text" id="url" class="form-control form-control-sm" ng-value="location.absUrl()" readonly>
<div class="input-group-append">
<button class="btn btn-primary" ngclipboard data-clipboard-target="#url" ngclipboard-success="clipboardSuccess('url')"><img src="assets/img/clipboard.svg" alt="Copy to clipboard"> Copy URL</button>
</div>
</div>
<div class="clipboard-success" ng-if="clipboardCopy === 'url'">Copied!</div>
</div>
<div class="mb-3">
<button class="btn btn-primary" ngclipboard data-clipboard-target="#url" ngclipboard-success="clipboardSuccess('url')"><img src="assets/img/clipboard.svg" alt="Copy to clipboard"> Copy URL</button>
<div class="clipboard-success" ng-if="clipboardCopy === 'url'">Copied!</div>
<button class="btn btn-primary" ng-click="downloadZip()"><img src="assets/img/download.svg" alt="Download"> Download ZIP</button>
</div>
<div>
<button class="btn btn-sm btn-danger" ng-click="reset()"><img src="assets/img/refresh.svg" alt="Reset"> Reset</button>
@ -449,7 +454,7 @@
</main>
<footer>
<div class="container-fluid">
Lovingly made at <img src="assets/img/balaton.svg" alt="Lake Balaton" class="balaton"><span class="text-muted">(<a href="https://en.wikipedia.org/wiki/Lake_Balaton" target="_blank">Lake Balaton, Hungary</a>)</span>
Lovingly made at <img src="assets/img/balaton.svg" alt="Lake Balaton" class="balaton"> <a href="https://en.wikipedia.org/wiki/Lake_Balaton" target="_blank">Lake Balaton, Hungary</a>
<div class="crypto">
BTC: <strong>1CeKtgNStn5BGk46gt14kNMhsnJoFGUfkN</strong><br>
ETH: <strong>0xe84Bc747dc81329894e610747B99C6bd51437269</strong><br>
@ -472,6 +477,8 @@
<script src="assets/js/ngclipboard.min.js?v=1.1.3"></script>
<script src="assets/js/angular-tooltips.min.js?v=1.2.2"></script>
<script src="assets/js/masonry.pkgd.min.js?v=4.2.1"></script>
<script src="assets/js/jszip.min.js?v=3.1.5"></script>
<script src="assets/js/filesaver.min.js?v=1.3.4"></script>
<script src="assets/js/app.js?v=COMMIT_HASH"></script>
</body>
</html>

Loading…
Cancel
Save