index, fallback refactor

pull/23/head
Szekeres Bálint 7 years ago
parent 521d65c1f0
commit 0d61ff815b

@ -48,11 +48,10 @@
non_www: true,
cdn: false,
index: '',
index_html: false,
index: 'index.php',
fallback: true,
php: '7.2',
index_php: true,
wordpress: false,
file_structure: 'unified',
@ -343,15 +342,19 @@
};
$scope.isIndexHtml = function() {
return $scope.data.index_html;
return $scope.data.index === 'index.html';
};
$scope.isPHP = function() {
return $scope.data.php !== 'off';
$scope.isIndexPhp = function() {
return $scope.isPHP() && $scope.data.index === 'index.php';
};
$scope.isIndexPhp = function() {
return $scope.isPHP() && $scope.data.index_php;
$scope.isFallback = function() {
return $scope.data.fallback && (!$scope.isIndexPhp() || $scope.isPHP);
};
$scope.isPHP = function() {
return $scope.data.php !== 'off';
};
$scope.isWordPress = function() {

@ -186,18 +186,27 @@
</div>
<div class="card">
<div class="card-body">
<div class="form-group">
<label class="form-label">
<span tooltips tooltip-template="Defines files that will be used as an index."><code>index</code></span>
</label>
<input type="text" class="form-control form-control-sm" ng-model="data.index" placeholder="index.html{{ isPHP() ? ' index.php' : '' }}">
<label class="form-label">File structure</label>
<div class="form-subgroup">
<div class="form-check">
<input class="form-check-input" type="radio" id="unified" ng-model="data.file_structure" value="unified">
<label class="form-check-label" for="unified">
<span tooltips tooltip-template="Combine configuration to a single file.<br><br><i>(if possible)</i>">unified</span>
</label>
</div>
</div>
<div class="form-check mb-2">
<input class="form-check-input" type="checkbox" id="index_html" ng-model="data.index_html">
<label class="form-check-label" for="index_html">
<span tooltips tooltip-template="Pass unhandled requests to index.html.<br><br><i>Angular, React, Vue.js, Ember.js</i>...">index.html <small>handler</small></span>
</label>
<div class="form-subgroup">
<div class="form-check">
<input class="form-check-input" type="radio" id="modularized" ng-model="data.file_structure" value="modularized">
<label class="form-check-label" for="modularized">
<span tooltips tooltip-template="Multiple configuration files<br><br><i>(ideal for multi-domain environment)</i>">modularized</span>
</label>
</div>
</div>
</div>
</div>
<div class="card">
<div class="card-body">
<div class="form-group">
<div class="input-group input-group-sm" tooltips tooltip-template="PHP-FPM via TCP or unix socket.">
<div class="input-group-prepend">
@ -214,14 +223,6 @@
</select>
</div>
</div>
<div class="form-subgroup" ng-if="isPHP()" ng-cloak>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="index_php" ng-model="data.index_php">
<label class="form-check-label" for="index_php">
<span tooltips tooltip-template="Pass unhandled requests to index.php.<br><br><i>Laravel, Lumen, Symfony, Zend, CodeIgniter, Yii, CakePHP, Slim...</i>">index.php <small>handler</small></span>
</label>
</div>
</div>
<div class="form-subgroup" ng-if="isPHP()" ng-cloak>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="wordpress" ng-model="data.wordpress">
@ -234,23 +235,25 @@
</div>
<div class="card">
<div class="card-body">
<label class="form-label">File structure</label>
<label class="form-label"><code tooltips tooltip-template="Defines the file that will be used as an index, optionally configures fallback of unhandled requests.">index</code></label>
<div class="form-subgroup">
<div class="form-check">
<input class="form-check-input" type="radio" id="unified" ng-model="data.file_structure" value="unified">
<label class="form-check-label" for="unified">
<span tooltips tooltip-template="Combine configuration to a single file.<br><br><i>(if possible)</i>">unified</span>
</label>
<input class="form-check-input" type="radio" id="index.html" ng-model="data.index" value="index.html">
<label class="form-check-label" for="index.html">index.html</label>
</div>
</div>
<div class="form-subgroup">
<div class="form-subgroup" ng-if="isPHP()">
<div class="form-check">
<input class="form-check-input" type="radio" id="modularized" ng-model="data.file_structure" value="modularized">
<label class="form-check-label" for="modularized">
<span tooltips tooltip-template="Multiple configuration files<br><br><i>(ideal for multi-domain environment)</i>">modularized</span>
</label>
<input class="form-check-input" type="radio" id="index.php" ng-model="data.index" value="index.php">
<label class="form-check-label" for="index.php">index.php</label>
</div>
</div>
<div class="form-check mt-2">
<input class="form-check-input" type="checkbox" id="fallback" ng-model="data.fallback">
<label class="form-check-label" for="fallback">
<span tooltips tooltip-template="Fallback of unhandled requests.">fallback <small>({{ isIndexPhp() ? 'index.php' : 'index.html' }})</small></span>
</label>
</div>
</div>
</div>
<div class="card">

@ -1,6 +1,6 @@
<!--
✔ modularized --><span ng-if="isModularized()"># index
index {{ isIndexHtml() ? 'index.html ' : '' }}index.php;
✔ modularized && ✔ index.php --><span ng-if="isModularized() && isIndexPhp()"># index.php
index index.php;
</span><!--

@ -3,13 +3,13 @@ server {<!--
✘ HTTPS || ✘ forceHTTPS --><span ng-if="!isHTTPS() || !isForceHTTPS()">
listen {{ data.ipv4 !== '*' ? data.ipv4 + ':' : '' }}80;<!--
✔ IPv6 --><span ng-if="isIPv6()">
✔ IPv6 --><span ng-if="isIPv6()">
listen [{{ data.ipv6 }}]:80;</span></span><!--
✔ HTTPS --><span ng-if="isHTTPS()">
listen {{ data.ipv4 !== '*' ? data.ipv4 + ':' : '' }}443 ssl{{ isHTTP2() ? ' http2' : '' }};<!--
✔ IPv6 --><span ng-if="isIPv6()">
✔ IPv6 --><span ng-if="isIPv6()">
listen [{{ data.ipv6 }}]:443 ssl{{ isHTTP2() ? ' http2' : '' }};</span></span>
server_name {{ isWWW() ? 'www.' : '' }}{{ domain() }};<!--
@ -19,9 +19,12 @@ server {<!--
root $base{{ data.document_root }};</span><!--
✘ PHP --><span ng-if="!isPHP()">
root /var/www/{{ domain() }}{{ data.document_root }};</span>
root /var/www/{{ domain() }}{{ data.document_root }};</span><!--
✔ unified && ✔ index.php --><span ng-if="isUnified() && isIndexPhp()">
index {{ data.index ? data.index : 'index.html' + (isPHP() ? ' index.php' : '') }};<!--
# index.php
index index.php;</span><!--
✔ HTTPS --><span ng-if="isHTTPS()">
@ -32,16 +35,11 @@ server {<!--
✔ Let's Encrypt --><span ng-if="isCertLetsEncrypt()">
ssl_trusted_certificate /etc/letsencrypt/live/{{ domain() }}/fullchain.pem;</span></span><!--
✔ unified && ✔ PHP --><span ng-if="isUnified() && isPHP()">
# index
index {{ isIndexHtml() ? 'index.html ' : '' }}index.php;</span><!--
(✔ PHP && ✔ index.php) || ✔ index.html --><span ng-if="isIndexPhp() || isIndexHtml()">
✔ fallback --><span ng-if="isFallback()">
# $uri{{ isIndexHtml() ? ', index.html' : '' }}{{ isIndexPhp() ? ', index.php' : '' }}
# $uri{{ isFallback() ? (', ' + data.index) : '' }}
location / {
try_files $uri $uri/ {{ isIndexHtml() ? '/index.html' : '' }}{{ isIndexHtml() && isIndexPhp() ? ' ' : '' }}{{ isIndexPhp() ? '/index.php?$query_string' : '' }};
try_files $uri $uri/ {{ isIndexHtml() ? '/index.html' : '' }}{{ isIndexPhp() ? '/index.php?$query_string' : '' }};
}</span><!--
✔ unified --><span ng-if="isModularized()">

Loading…
Cancel
Save