index, fallback refactor

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

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

@ -186,18 +186,27 @@
</div> </div>
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<div class="form-group"> <label class="form-label">File structure</label>
<label class="form-label"> <div class="form-subgroup">
<span tooltips tooltip-template="Defines files that will be used as an index."><code>index</code></span> <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> </label>
<input type="text" class="form-control form-control-sm" ng-model="data.index" placeholder="index.html{{ isPHP() ? ' index.php' : '' }}">
</div> </div>
<div class="form-check mb-2"> </div>
<input class="form-check-input" type="checkbox" id="index_html" ng-model="data.index_html"> <div class="form-subgroup">
<label class="form-check-label" for="index_html"> <div class="form-check">
<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> <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> </label>
</div> </div>
</div>
</div>
</div>
<div class="card">
<div class="card-body">
<div class="form-group"> <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 input-group-sm" tooltips tooltip-template="PHP-FPM via TCP or unix socket.">
<div class="input-group-prepend"> <div class="input-group-prepend">
@ -214,14 +223,6 @@
</select> </select>
</div> </div>
</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-subgroup" ng-if="isPHP()" ng-cloak>
<div class="form-check"> <div class="form-check">
<input class="form-check-input" type="checkbox" id="wordpress" ng-model="data.wordpress"> <input class="form-check-input" type="checkbox" id="wordpress" ng-model="data.wordpress">
@ -234,23 +235,25 @@
</div> </div>
<div class="card"> <div class="card">
<div class="card-body"> <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-subgroup">
<div class="form-check"> <div class="form-check">
<input class="form-check-input" type="radio" id="unified" ng-model="data.file_structure" value="unified"> <input class="form-check-input" type="radio" id="index.html" ng-model="data.index" value="index.html">
<label class="form-check-label" for="unified"> <label class="form-check-label" for="index.html">index.html</label>
<span tooltips tooltip-template="Combine configuration to a single file.<br><br><i>(if possible)</i>">unified</span>
</label>
</div> </div>
</div> </div>
<div class="form-subgroup"> <div class="form-subgroup" ng-if="isPHP()">
<div class="form-check"> <div class="form-check">
<input class="form-check-input" type="radio" id="modularized" ng-model="data.file_structure" value="modularized"> <input class="form-check-input" type="radio" id="index.php" ng-model="data.index" value="index.php">
<label class="form-check-label" for="modularized"> <label class="form-check-label" for="index.php">index.php</label>
<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="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> </div>
<div class="card"> <div class="card">

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

@ -19,9 +19,12 @@ server {<!--
root $base{{ data.document_root }};</span><!-- root $base{{ data.document_root }};</span><!--
✘ PHP --><span ng-if="!isPHP()"> ✘ PHP --><span ng-if="!isPHP()">
root /var/www/{{ domain() }}{{ data.document_root }};</span> root /var/www/{{ domain() }}{{ data.document_root }};</span><!--
index {{ data.index ? data.index : 'index.html' + (isPHP() ? ' index.php' : '') }};<!-- ✔ unified && ✔ index.php --><span ng-if="isUnified() && isIndexPhp()">
# index.php
index index.php;</span><!--
✔ HTTPS --><span ng-if="isHTTPS()"> ✔ HTTPS --><span ng-if="isHTTPS()">
@ -32,16 +35,11 @@ server {<!--
✔ Let's Encrypt --><span ng-if="isCertLetsEncrypt()"> ✔ Let's Encrypt --><span ng-if="isCertLetsEncrypt()">
ssl_trusted_certificate /etc/letsencrypt/live/{{ domain() }}/fullchain.pem;</span></span><!-- ssl_trusted_certificate /etc/letsencrypt/live/{{ domain() }}/fullchain.pem;</span></span><!--
✔ unified && ✔ PHP --><span ng-if="isUnified() && isPHP()"> ✔ fallback --><span ng-if="isFallback()">
# index
index {{ isIndexHtml() ? 'index.html ' : '' }}index.php;</span><!--
(✔ PHP && ✔ index.php) || ✔ index.html --><span ng-if="isIndexPhp() || isIndexHtml()">
# $uri{{ isIndexHtml() ? ', index.html' : '' }}{{ isIndexPhp() ? ', index.php' : '' }} # $uri{{ isFallback() ? (', ' + data.index) : '' }}
location / { 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><!-- }</span><!--
✔ unified --><span ng-if="isModularized()"> ✔ unified --><span ng-if="isModularized()">

Loading…
Cancel
Save