Allow per-app configuration of robots.txt

https://developers.google.com/search/reference/robots_txt has
the specification

Part of #344
This commit is contained in:
Girish Ramakrishnan
2017-07-14 12:19:27 -05:00
parent 5697bcf43f
commit acd00222e5
12 changed files with 84 additions and 14 deletions

View File

@@ -336,7 +336,8 @@ angular.module('Application').service('Client', ['$http', 'md5', 'Notification',
key: config.key,
memoryLimit: config.memoryLimit,
altDomain: config.altDomain || null,
xFrameOptions: config.xFrameOptions
xFrameOptions: config.xFrameOptions,
robotsTxt: config.robotsTxt || null
};
post('/api/v1/apps/' + id + '/configure', data).success(function (data, status) {

View File

@@ -144,6 +144,16 @@
<input type="text" class="form-control" id="appConfigureXFrameOptionsInput" name="xFrameOptions" placeholder="https://example.com" ng-model="appConfigure.xFrameOptions" uib-tooltip="Leave blank to not allow embedding">
</div>
<br/>
<div class="form-group" ng-class="{ 'has-error': !appConfigureForm.robotsTxt.$dirty && appConfigure.error.robotsTxt }">
<div class="checkbox">
<label>
<input type="checkbox" ng-model="appConfigure.robotsEnabled" id="appConfigureRobotsTxt"> Disallow bots from indexing this app
</label>
</div>
</div>
<div class="hide">
<label class="control-label" for="appConfigureCertificateInput" ng-show="config.isCustomDomain">Certificate (optional)</label>
<div class="has-error text-center" ng-show="appConfigure.error.cert && config.isCustomDomain">{{ appConfigure.error.cert }}</div>

View File

@@ -24,6 +24,7 @@ angular.module('Application').controller('AppsController', ['$scope', '$location
portBindings: {},
portBindingsEnabled: {},
portBindingsInfo: {},
robotsEnabled: false,
certificateFile: null,
certificateFileName: '',
keyFile: null,
@@ -112,6 +113,7 @@ angular.module('Application').controller('AppsController', ['$scope', '$location
$scope.appConfigure.accessRestriction = { users: [], groups: [] };
$scope.appConfigure.xFrameOptions = '';
$scope.appConfigure.customAuth = false;
$scope.appConfigure.robotsEnabled = false;
$scope.appConfigureForm.$setPristine();
$scope.appConfigureForm.$setUntouched();
@@ -204,6 +206,7 @@ angular.module('Application').controller('AppsController', ['$scope', '$location
$scope.appConfigure.memoryLimit = app.memoryLimit || app.manifest.memoryLimit || (256 * 1024 * 1024);
$scope.appConfigure.xFrameOptions = app.xFrameOptions.indexOf('ALLOW-FROM') === 0 ? app.xFrameOptions.split(' ')[1] : '';
$scope.appConfigure.customAuth = !(app.manifest.addons['ldap'] || app.manifest.addons['oauth']);
$scope.appConfigure.robotsEnabled = !!app.robotsTxt;
// create ticks starting from manifest memory limit
$scope.appConfigure.memoryTicks = [
@@ -256,7 +259,9 @@ angular.module('Application').controller('AppsController', ['$scope', '$location
cert: $scope.appConfigure.certificateFile,
key: $scope.appConfigure.keyFile,
xFrameOptions: $scope.appConfigure.xFrameOptions ? ('ALLOW-FROM ' + $scope.appConfigure.xFrameOptions) : 'SAMEORIGIN',
memoryLimit: $scope.appConfigure.memoryLimit === $scope.appConfigure.memoryTicks[0] ? 0 : $scope.appConfigure.memoryLimit
memoryLimit: $scope.appConfigure.memoryLimit === $scope.appConfigure.memoryTicks[0] ? 0 : $scope.appConfigure.memoryLimit,
// preserve arbitrary robots.txt in database
robotsTxt: $scope.appConfigure.robotsEnabled ? ($scope.appConfigure.app.robotsTxt || 'User-agent: *\\nDisallow: /\\n') : null
};
Client.configureApp($scope.appConfigure.app.id, $scope.appConfigure.password, data, function (error) {