From 8be1afa12b700b93ed92365cab05c0ef81d643aa Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 10 May 2018 12:26:47 +0200 Subject: Add ability to embed a video in Twitter The instance should be whitelisted first --- .../edit-custom-config.component.html | 471 +++++++++++---------- .../edit-custom-config.component.ts | 14 +- .../shared/forms/form-validators/custom-config.ts | 7 + client/src/polyfills.ts | 2 +- config/default.yaml | 9 + config/production.yaml.example | 9 + server/controllers/api/config.ts | 6 + server/controllers/client.ts | 4 +- server/initializers/checker.ts | 3 +- server/initializers/constants.ts | 6 + server/tests/api/check-params/config.ts | 6 + server/tests/api/server/config.ts | 14 + server/tests/client.ts | 30 +- shared/models/server/custom-config.model.ts | 7 + 14 files changed, 365 insertions(+), 223 deletions(-) diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html index 021252456..252d43c8f 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html +++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html @@ -1,222 +1,259 @@ -
Update PeerTube configuration
-
-
Instance
- -
- - -
- {{ formErrors.instanceName }} -
-
- -
- - -
- {{ formErrors.instanceShortDescription }} -
-
- -
- - -
- {{ formErrors.instanceDescription }} -
-
- -
- - -
- {{ formErrors.instanceTerms }} -
-
- -
- -
- -
-
- {{ formErrors.instanceDefaultClientRoute }} -
-
- -
- - - -
- -
-
- {{ formErrors.instanceDefaultNSFWPolicy }} -
-
- -
Cache
- -
- - -
- {{ formErrors.cachePreviewsSize }} -
-
- -
Signup
- -
- - - - -
- -
- - -
- {{ formErrors.signupLimit }} -
-
- -
Administrator
- -
- - -
- {{ formErrors.adminEmail }} -
-
- -
Users
- -
- -
- -
-
- {{ formErrors.userVideoQuota }} -
-
- -
Transcoding
- -
- - - - -
- - - -
- -
- -
-
- {{ formErrors.transcodingThreads }} -
-
- -
- - - -
-
- -
Customizations
- -
- - - -
- {{ formErrors.customizationJavascript }} -
-
- -
- - - -
- {{ formErrors.customizationCSS }} -
-
+ + + + +
Instance
+ +
+ + +
+ {{ formErrors.instanceName }} +
+
+ +
+ + +
+ {{ formErrors.instanceShortDescription }} +
+
+ +
+ + +
+ {{ formErrors.instanceDescription }} +
+
+ +
+ + +
+ {{ formErrors.instanceTerms }} +
+
+ +
+ +
+ +
+
+ {{ formErrors.instanceDefaultClientRoute }} +
+
+ +
+ + + +
+ +
+
+ {{ formErrors.instanceDefaultNSFWPolicy }} +
+
+ +
Signup
+ +
+ + + + +
+ +
+ + +
+ {{ formErrors.signupLimit }} +
+
+ +
Administrator
+ +
+ + +
+ {{ formErrors.adminEmail }} +
+
+ +
Users
+ +
+ +
+ +
+
+ {{ formErrors.userVideoQuota }} +
+
+
+ + + +
Twitter
+ +
+ + + +
+ {{ formErrors.servicesTwitterUsername }} +
+
+ +
+ + + + + + +
+
+ + + +
Transcoding
+ +
+ + + + +
+ + + +
+ +
+ +
+
+ {{ formErrors.transcodingThreads }} +
+
+ +
+ + + +
+
+ +
Cache
+ +
+ + + + +
+ {{ formErrors.cachePreviewsSize }} +
+
+ +
Customizations
+ +
+ + + +
+ {{ formErrors.customizationJavascript }} +
+
+ +
+ + + +
+ {{ formErrors.customizationCSS }} +
+
+
+
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts index 2ab371cbb..a1e334a74 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts +++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts @@ -8,7 +8,7 @@ import { FormReactive, USER_VIDEO_QUOTA } from '@app/shared' import { ADMIN_EMAIL, CACHE_PREVIEWS_SIZE, - INSTANCE_NAME, INSTANCE_SHORT_DESCRIPTION, + INSTANCE_NAME, INSTANCE_SHORT_DESCRIPTION, SERVICES_TWITTER_USERNAME, SIGNUP_LIMIT, TRANSCODING_THREADS } from '@app/shared/forms/form-validators/custom-config' @@ -49,6 +49,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { instanceTerms: '', instanceDefaultClientRoute: '', instanceDefaultNSFWPolicy: '', + servicesTwitterUsername: '', cachePreviewsSize: '', signupLimit: '', adminEmail: '', @@ -60,6 +61,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { validationMessages = { instanceShortDescription: INSTANCE_SHORT_DESCRIPTION.MESSAGES, instanceName: INSTANCE_NAME.MESSAGES, + servicesTwitterUsername: SERVICES_TWITTER_USERNAME, cachePreviewsSize: CACHE_PREVIEWS_SIZE.MESSAGES, signupLimit: SIGNUP_LIMIT.MESSAGES, adminEmail: ADMIN_EMAIL.MESSAGES, @@ -92,6 +94,8 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { instanceTerms: [ '' ], instanceDefaultClientRoute: [ '' ], instanceDefaultNSFWPolicy: [ '' ], + servicesTwitterUsername: [ '', SERVICES_TWITTER_USERNAME.VALIDATORS ], + servicesTwitterWhitelisted: [ ], cachePreviewsSize: [ '', CACHE_PREVIEWS_SIZE.VALIDATORS ], signupEnabled: [ ], signupLimit: [ '', SIGNUP_LIMIT.VALIDATORS ], @@ -175,6 +179,12 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { css: this.form.value['customizationCSS'] } }, + services: { + twitter: { + username: this.form.value['servicesTwitterUsername'], + whitelisted: this.form.value['servicesTwitterWhitelisted'] + } + }, cache: { previews: { size: this.form.value['cachePreviewsSize'] @@ -228,6 +238,8 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { instanceTerms: this.customConfig.instance.terms, instanceDefaultClientRoute: this.customConfig.instance.defaultClientRoute, instanceDefaultNSFWPolicy: this.customConfig.instance.defaultNSFWPolicy, + servicesTwitterUsername: this.customConfig.services.twitter.username, + servicesTwitterWhitelisted: this.customConfig.services.twitter.whitelisted, cachePreviewsSize: this.customConfig.cache.previews.size, signupEnabled: this.customConfig.signup.enabled, signupLimit: this.customConfig.signup.limit, diff --git a/client/src/app/shared/forms/form-validators/custom-config.ts b/client/src/app/shared/forms/form-validators/custom-config.ts index c9cef2e09..e3d9a4c7b 100644 --- a/client/src/app/shared/forms/form-validators/custom-config.ts +++ b/client/src/app/shared/forms/form-validators/custom-config.ts @@ -14,6 +14,13 @@ export const INSTANCE_SHORT_DESCRIPTION = { } } +export const SERVICES_TWITTER_USERNAME = { + VALIDATORS: [ Validators.required ], + MESSAGES: { + 'required': 'Twitter username is required.' + } +} + export const CACHE_PREVIEWS_SIZE = { VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ], MESSAGES: { diff --git a/client/src/polyfills.ts b/client/src/polyfills.ts index 12b317101..423a7b915 100644 --- a/client/src/polyfills.ts +++ b/client/src/polyfills.ts @@ -35,6 +35,7 @@ import 'core-js/es6/regexp'; import 'core-js/es6/map'; import 'core-js/es6/weak-map'; import 'core-js/es6/set'; +import 'core-js/es7/object'; /** IE10 and IE11 requires the following for NgClass support on SVG elements */ // import 'classlist.js'; // Run `npm install --save classlist.js`. @@ -44,7 +45,6 @@ import 'core-js/es6/set'; // For Google Bot import 'core-js/es6/reflect'; - /** Evergreen browsers require these. **/ // Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove. import 'core-js/es7/reflect' diff --git a/config/default.yaml b/config/default.yaml index 25dde72c9..2826e76f8 100644 --- a/config/default.yaml +++ b/config/default.yaml @@ -90,3 +90,12 @@ instance: customizations: javascript: '' # Directly your JavaScript code (without