major refactor

This commit is contained in:
Szekeres Bálint
2018-02-18 14:02:11 +01:00
parent c3bd38b58f
commit fc21e3f87c
18 changed files with 592 additions and 353 deletions

View File

@@ -10,6 +10,19 @@
return repeatedString;
};
var masonry = new Masonry('main .files .grid', {
itemSelector: '.grid-item',
columnWidth: '.grid-sizer',
percentPosition: true,
initLayout: false,
stagger: 0,
transitionDuration: '0.6s'
});
angular
.module('NginxConfigIoApp', ['ngclipboard', '720kb.tooltips'])
.config(function NginxCongigIoConfig($locationProvider) {
@@ -22,17 +35,25 @@
// PRIVATE VARIABLES //
///////////////////////
var data = {
domain: 'example.com',
path: '/var/www/example.com',
domain: '',
path: '',
document_root: '/public',
https: false,
http2: true,
email: 'hello@example.com',
cdn: false,
cert_type: 'letsencrypt',
email: '',
ssl_certificate: '',
ssl_certificate_key:'',
non_www: true,
cdn: false,
index_html: false,
php: '7.2',
index_php: true,
index_html: false,
wordpress: false,
file_structure: 'unified',
@@ -64,6 +85,9 @@
$scope.dataInit = false;
$scope.isDirty = false;
$scope.sslCertificateChanged = false;
$scope.sslCertificateKeyChanged = false;
$scope.extensions = {
assets: 'css(\\.map)?|js(\\.map)?',
fonts: 'ttf|ttc|otf|eot|woff|woff2',
@@ -79,9 +103,38 @@
$scope.clipboardCopy = undefined;
/////////////////////
// SCOPE FUNCTIONS //
/////////////////////
$scope.domain = function() {
return $scope.data.domain ? $scope.data.domain : 'example.com';
};
$scope.sslCertificate = function() {
if ($scope.isLetsEncrypt()) {
return '/etc/letsencrypt/live/' + $scope.domain() + '/fullchain.pem'
}
if ($scope.data.ssl_certificate) {
return $scope.data.ssl_certificate;
}
return '/etc/nginx/ssl/' + $scope.domain() + '.crt';
};
$scope.sslCertificateKey = function() {
if ($scope.isLetsEncrypt()) {
return '/etc/letsencrypt/live/' + $scope.domain() + '/privkey.pem'
}
if ($scope.data.ssl_certificate_key) {
return $scope.data.ssl_certificate_key;
}
return '/etc/nginx/ssl/' + $scope.domain() + '.key';
};
$scope.refreshHighlighting = function() {
var sourceCodes = document.querySelectorAll('main .file .code.source');
@@ -93,6 +146,10 @@
if (_sourceCode.nextSibling.children.length && _sourceCode.nextSibling.children[0].children.length) {
hljs.highlightBlock(_sourceCode.nextSibling.children[0].children[0]);
}
_sourceCode.classList.add('hidden');
masonry.reloadItems();
masonry.layout();
}, 0, true, sourceCode);
}
};
@@ -101,6 +158,10 @@
var hashData = $location.search();
for (var key in hashData) {
if (hashData[key] === 'false') {
hashData[key] = false;
}
if ($scope.data[key] !== undefined && typeof $scope.data[key] === typeof hashData[key]) {
$scope.isDirty = true;
$scope.data[key] = hashData[key];
@@ -154,6 +215,85 @@
///////////////////////////
// SCOPE QUERY FUNCTIONS //
///////////////////////////
$scope.isUnified = function() {
return $scope.data.file_structure === 'unified';
};
$scope.isModularized = function() {
return !$scope.isUnified();
};
$scope.isHTTPS = function() {
return $scope.data.https;
};
$scope.isHTTP2 = function() {
return $scope.isHTTPS() && $scope.data.http2;
};
$scope.isLetsEncrypt = function() {
return $scope.isHTTPS() && $scope.data.cert_type === 'letsencrypt';
};
$scope.isCustomCert = function() {
return $scope.isHTTPS() && $scope.data.cert_type === 'custom';
};
$scope.isNonWWW = function() {
return $scope.data.non_www;
};
$scope.isWWW = function() {
return !$scope.isNonWWW();
};
$scope.isCDN = function() {
return $scope.isWWW() && $scope.data.cdn;
};
$scope.isIndexHtml = function() {
return $scope.data.index_html;
};
$scope.isPHP = function() {
return $scope.data.php !== 'off';
};
$scope.isIndexPhp = function() {
return $scope.isPHP() && $scope.data.index_php;
};
$scope.isWordPress = function() {
return $scope.isPHP() && $scope.data.wordpress;
};
$scope.isAccessLog = function() {
return $scope.data.access_log;
};
$scope.isGzip = function() {
return $scope.data.gzip;
};
$scope.isServerTokens = function() {
return $scope.data.server_tokens;
};
$scope.isLogNotFound = function() {
return $scope.data.log_not_found;
};
$scope.isLimitReq = function() {
return $scope.data.limit_req;
};
//////////////////
// SCOPE EVENTS //
//////////////////

9
public/assets/js/masonry.pkgd.min.js vendored Normal file

File diff suppressed because one or more lines are too long