Add short description in config
authorChocobozzz <me@florianbigard.com>
Thu, 15 Mar 2018 13:31:08 +0000 (14:31 +0100)
committerChocobozzz <me@florianbigard.com>
Thu, 15 Mar 2018 13:34:47 +0000 (14:34 +0100)
19 files changed:
client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html
client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.scss
client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
client/src/app/core/server/server.service.ts
client/src/app/shared/forms/form-validators/custom-config.ts
config/default.yaml
config/production.yaml.example
server/controllers/api/config.ts
server/initializers/constants.ts
server/lib/job-queue/handlers/activitypub-http-broadcast.ts
server/lib/job-queue/handlers/activitypub-http-unicast.ts
server/models/activitypub/actor-follow.ts
server/tests/api/check-params/config.ts
server/tests/api/server/config.ts
shared/models/server/about.model.ts
shared/models/server/custom-config.model.ts
shared/models/server/customization.model.ts [deleted file]
shared/models/server/server-config.model.ts
support/doc/production.md

index c7ddaaf010bd92d8b0ee3f49febeac262022f9a2..6658a095d07ef7ddeb93d7232c32cf75bbead260 100644 (file)
     </div>
   </div>
 
+  <div class="form-group">
+    <label for="instanceShortDescription">Short description</label>
+    <textarea
+        id="instanceShortDescription" formControlName="instanceShortDescription"
+        [ngClass]="{ 'input-error': formErrors['instanceShortDescription'] }"
+    ></textarea>
+    <div *ngIf="formErrors.instanceShortDescription" class="form-error">
+      {{ formErrors.instanceShortDescription }}
+    </div>
+  </div>
+
   <div class="form-group">
     <label for="instanceDescription">Description</label><my-help helpType="markdownText"></my-help>
     <my-markdown-textarea
index e72f30c6965c2db90daf944a1c28f28cfef526e7..e81044554d56e9f1aabf0eae26b93e00cf2e1ce0 100644 (file)
@@ -34,4 +34,8 @@ textarea {
   @include peertube-textarea(500px, 150px);
 
   display: block;
+
+  &#instanceShortDescription {
+    height: 100px;
+  }
 }
index c38bc326acfb44a27701ab90ed24cc3971529c41..9ab8b08d0fdc2f5ab9787da17129e235630ecd8a 100644 (file)
@@ -8,7 +8,7 @@ import { FormReactive, USER_VIDEO_QUOTA } from '@app/shared'
 import {
   ADMIN_EMAIL,
   CACHE_PREVIEWS_SIZE,
-  INSTANCE_NAME,
+  INSTANCE_NAME, INSTANCE_SHORT_DESCRIPTION,
   SIGNUP_LIMIT,
   TRANSCODING_THREADS
 } from '@app/shared/forms/form-validators/custom-config'
@@ -44,6 +44,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
   form: FormGroup
   formErrors = {
     instanceName: '',
+    instanceShortDescription: '',
     instanceDescription: '',
     instanceTerms: '',
     instanceDefaultClientRoute: '',
@@ -56,6 +57,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
     customizationCSS: ''
   }
   validationMessages = {
+    instanceShortDescription: INSTANCE_SHORT_DESCRIPTION.MESSAGES,
     instanceName: INSTANCE_NAME.MESSAGES,
     cachePreviewsSize: CACHE_PREVIEWS_SIZE.MESSAGES,
     signupLimit: SIGNUP_LIMIT.MESSAGES,
@@ -84,6 +86,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
   buildForm () {
     const formGroupData = {
       instanceName: [ '', INSTANCE_NAME.VALIDATORS ],
+      instanceShortDescription: [ '', INSTANCE_SHORT_DESCRIPTION.VALIDATORS ],
       instanceDescription: [ '' ],
       instanceTerms: [ '' ],
       instanceDefaultClientRoute: [ '' ],
@@ -158,6 +161,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
     const data: CustomConfig = {
       instance: {
         name: this.form.value['instanceName'],
+        shortDescription: this.form.value['instanceShortDescription'],
         description: this.form.value['instanceDescription'],
         terms: this.form.value['instanceTerms'],
         defaultClientRoute: this.form.value['instanceDefaultClientRoute'],
@@ -214,6 +218,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
   private updateForm () {
     const data = {
       instanceName: this.customConfig.instance.name,
+      instanceShortDescription: this.customConfig.instance.shortDescription,
       instanceDescription: this.customConfig.instance.description,
       instanceTerms: this.customConfig.instance.terms,
       instanceDefaultClientRoute: this.customConfig.instance.defaultClientRoute,
index 2135c3268e843a9662bd74cf512531fbfb26ed6f..bd85d9f0f109c2dc278d16ad9735d22fd206de37 100644 (file)
@@ -21,6 +21,7 @@ export class ServerService {
   private config: ServerConfig = {
     instance: {
       name: 'PeerTube',
+      shortDescription: '',
       defaultClientRoute: '',
       customizations: {
         javascript: '',
index a0966a9a790cad2f3914f4cd4ebfd22c0bf02d4e..c9cef2e09025045dad0a4b09bc8f7992199fb429 100644 (file)
@@ -7,6 +7,13 @@ export const INSTANCE_NAME = {
   }
 }
 
+export const INSTANCE_SHORT_DESCRIPTION = {
+  VALIDATORS: [ Validators.max(250) ],
+  MESSAGES: {
+    'max': 'Short description should not be longer than 250 characters.'
+  }
+}
+
 export const CACHE_PREVIEWS_SIZE = {
   VALIDATORS: [ Validators.required, Validators.min(1), Validators.pattern('[0-9]+') ],
   MESSAGES: {
index 5389f116413ec834639ce6b7885bb375e06576d7..48e5bd067762d0db5964980ada4fa10af002e72a 100644 (file)
@@ -72,6 +72,7 @@ transcoding:
 
 instance:
   name: 'PeerTube'
+  short_description: 'PeerTube, a federated (ActivityPub) video streaming platform using P2P (BitTorrent) directly in the web browser with WebTorrent and Angular.'
   description: 'Welcome to this PeerTube instance!' # Support markdown
   terms: 'No terms for now.' # Support markdown
   default_client_route: '/videos/trending'
index 2f28501b3ae9427d32cd16d072588b986adcd033..45eeffec71ae8ddad1f61e79e125505433c7d307 100644 (file)
@@ -85,6 +85,7 @@ transcoding:
 
 instance:
   name: 'PeerTube'
+  short_description: 'PeerTube, a federated (ActivityPub) video streaming platform using P2P (BitTorrent) directly in the web browser with WebTorrent and Angular.'
   description: '' # Support markdown
   terms: '' # Support markdown
   default_client_route: '/videos/trending'
index a25d7a1577ba4c04df0abb845238561227d5b0eb..62a7839823a981ae259f9007849bd4203e7c4253 100644 (file)
@@ -44,6 +44,7 @@ async function getConfig (req: express.Request, res: express.Response, next: exp
   const json: ServerConfig = {
     instance: {
       name: CONFIG.INSTANCE.NAME,
+      shortDescription: CONFIG.INSTANCE.SHORT_DESCRIPTION,
       defaultClientRoute: CONFIG.INSTANCE.DEFAULT_CLIENT_ROUTE,
       customizations: {
         javascript: CONFIG.INSTANCE.CUSTOMIZATIONS.JAVASCRIPT,
@@ -85,6 +86,7 @@ function getAbout (req: express.Request, res: express.Response, next: express.Ne
   const about: About = {
     instance: {
       name: CONFIG.INSTANCE.NAME,
+      shortDescription: CONFIG.INSTANCE.SHORT_DESCRIPTION,
       description: CONFIG.INSTANCE.DESCRIPTION,
       terms: CONFIG.INSTANCE.TERMS
     }
@@ -116,8 +118,10 @@ async function updateCustomConfig (req: express.Request, res: express.Response,
   const toUpdateJSON = omit(toUpdate, 'videoQuota')
   toUpdateJSON.user['video_quota'] = toUpdate.user.videoQuota
   toUpdateJSON.instance['default_client_route'] = toUpdate.instance.defaultClientRoute
+  toUpdateJSON.instance['short_description'] = toUpdate.instance.shortDescription
   delete toUpdate.user.videoQuota
   delete toUpdate.instance.defaultClientRoute
+  delete toUpdate.instance.shortDescription
 
   await writeFilePromise(CONFIG.CUSTOM_FILE, JSON.stringify(toUpdateJSON, undefined, 2))
 
@@ -139,6 +143,7 @@ function customConfig (): CustomConfig {
   return {
     instance: {
       name: CONFIG.INSTANCE.NAME,
+      shortDescription: CONFIG.INSTANCE.SHORT_DESCRIPTION,
       description: CONFIG.INSTANCE.DESCRIPTION,
       terms: CONFIG.INSTANCE.TERMS,
       defaultClientRoute: CONFIG.INSTANCE.DEFAULT_CLIENT_ROUTE,
index 5946bcd11ce53b54477d54f78e79e3728f51aafa..d12d968032bc45939fd038b9ab730f5d0b4b7878 100644 (file)
@@ -157,6 +157,7 @@ const CONFIG = {
   },
   INSTANCE: {
     get NAME () { return config.get<string>('instance.name') },
+    get SHORT_DESCRIPTION () { return config.get<string>('instance.short_description') },
     get DESCRIPTION () { return config.get<string>('instance.description') },
     get TERMS () { return config.get<string>('instance.terms') },
     get DEFAULT_CLIENT_ROUTE () { return config.get<string>('instance.default_client_route') },
index 159856cdaaeb23d31ada26cb4ed8f4511c9ac4e3..78878fc01a86556e301ceb3ab92960c86103f13e 100644 (file)
@@ -39,7 +39,7 @@ async function processActivityPubHttpBroadcast (job: kue.Job) {
     }
   }
 
-  return ActorFollowModel.updateActorFollowsScoreAndRemoveBadOnes(goodUrls, badUrls, undefined)
+  return ActorFollowModel.updateActorFollowsScore(goodUrls, badUrls, undefined)
 }
 
 // ---------------------------------------------------------------------------
index 9b4188c50c7d6f59e9fa83089c6a52947269691e..e1e1824e50dc25578a3cad95297d6c84a9a9f88f 100644 (file)
@@ -28,9 +28,9 @@ async function processActivityPubHttpUnicast (job: kue.Job) {
 
   try {
     await doRequest(options)
-    ActorFollowModel.updateActorFollowsScoreAndRemoveBadOnes([ uri ], [], undefined)
+    ActorFollowModel.updateActorFollowsScore([ uri ], [], undefined)
   } catch (err) {
-    ActorFollowModel.updateActorFollowsScoreAndRemoveBadOnes([], [ uri ], undefined)
+    ActorFollowModel.updateActorFollowsScore([], [ uri ], undefined)
 
     throw err
   }
index 3c11d1b6722d5ba58974e04506e7bcba7385fee8..d3c438626ad35a58463ad7f64443c6be44780654 100644 (file)
@@ -111,7 +111,7 @@ export class ActorFollowModel extends Model<ActorFollowModel> {
     if (numberOfActorFollowsRemoved) logger.info('Removed bad %d actor follows.', numberOfActorFollowsRemoved)
   }
 
-  static updateActorFollowsScoreAndRemoveBadOnes (goodInboxes: string[], badInboxes: string[], t: Sequelize.Transaction) {
+  static updateActorFollowsScore (goodInboxes: string[], badInboxes: string[], t: Sequelize.Transaction) {
     if (goodInboxes.length === 0 && badInboxes.length === 0) return
 
     logger.info('Updating %d good actor follows and %d bad actor follows scores.', goodInboxes.length, badInboxes.length)
index ca82392700bd33aeb6eaee85049a769b871f1269..3fe517fadb810dc115b8c81d29255be22964bef6 100644 (file)
@@ -16,6 +16,7 @@ describe('Test config API validators', function () {
   const updateParams: CustomConfig = {
     instance: {
       name: 'PeerTube updated',
+      shortDescription: 'my short description',
       description: 'my super description',
       terms: 'my super terms',
       defaultClientRoute: '/videos/recently-added',
index 271a57275f0ecb90636feeb3cca7501523c09e7c..e17588142c49a9f3a35bf1de203521b75e2c3e4a 100644 (file)
@@ -52,6 +52,10 @@ describe('Test config', function () {
     const data = res.body as CustomConfig
 
     expect(data.instance.name).to.equal('PeerTube')
+    expect(data.instance.shortDescription).to.equal(
+      'PeerTube, a federated (ActivityPub) video streaming platform using P2P (BitTorrent) directly in the web browser ' +
+      'with WebTorrent and Angular.'
+    )
     expect(data.instance.description).to.equal('Welcome to this PeerTube instance!')
     expect(data.instance.terms).to.equal('No terms for now.')
     expect(data.instance.defaultClientRoute).to.equal('/videos/trending')
@@ -75,6 +79,7 @@ describe('Test config', function () {
     const newCustomConfig = {
       instance: {
         name: 'PeerTube updated',
+        shortDescription: 'my short description',
         description: 'my super description',
         terms: 'my super terms',
         defaultClientRoute: '/videos/recently-added',
@@ -116,6 +121,7 @@ describe('Test config', function () {
     const data = res.body
 
     expect(data.instance.name).to.equal('PeerTube updated')
+    expect(data.instance.shortDescription).to.equal('my short description')
     expect(data.instance.description).to.equal('my super description')
     expect(data.instance.terms).to.equal('my super terms')
     expect(data.instance.defaultClientRoute).to.equal('/videos/recently-added')
@@ -146,6 +152,7 @@ describe('Test config', function () {
     const data = res.body
 
     expect(data.instance.name).to.equal('PeerTube updated')
+    expect(data.instance.shortDescription).to.equal('my short description')
     expect(data.instance.description).to.equal('my super description')
     expect(data.instance.terms).to.equal('my super terms')
     expect(data.instance.defaultClientRoute).to.equal('/videos/recently-added')
@@ -170,6 +177,7 @@ describe('Test config', function () {
     const data: About = res.body
 
     expect(data.instance.name).to.equal('PeerTube updated')
+    expect(data.instance.shortDescription).to.equal('my short description')
     expect(data.instance.description).to.equal('my super description')
     expect(data.instance.terms).to.equal('my super terms')
   })
@@ -183,6 +191,10 @@ describe('Test config', function () {
     const data = res.body
 
     expect(data.instance.name).to.equal('PeerTube')
+    expect(data.instance.shortDescription).to.equal(
+      'PeerTube, a federated (ActivityPub) video streaming platform using P2P (BitTorrent) directly in the web browser ' +
+      'with WebTorrent and Angular.'
+    )
     expect(data.instance.description).to.equal('Welcome to this PeerTube instance!')
     expect(data.instance.terms).to.equal('No terms for now.')
     expect(data.instance.defaultClientRoute).to.equal('/videos/trending')
index 7d11da850201eaa28999188df914f4b444825f05..10dff8b8f0e0e2e98efa9fb4abd0251f5e3fbe1f 100644 (file)
@@ -1,6 +1,7 @@
 export interface About {
   instance: {
     name: string
+    shortDescription: string
     description: string
     terms: string
   }
index 7f3e2df0272f29456ea854f1ebc0ec38e4f7fd3c..b4d24cfbe158abc0495228bf94232369c94d2f50 100644 (file)
@@ -1,6 +1,7 @@
 export interface CustomConfig {
   instance: {
     name: string
+    shortDescription: string
     description: string
     terms: string
     defaultClientRoute: string
diff --git a/shared/models/server/customization.model.ts b/shared/models/server/customization.model.ts
deleted file mode 100644 (file)
index 4e4d0d1..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-export interface Customization {
-  instance: {
-    customization: {
-      javascript: string
-      css: string
-    }
-  }
-}
index a30c24eb9ae89ea331658da86317a7127b3f0499..c6fa651a8de9d0fd61ac145bbf78b7ac6ba43401 100644 (file)
@@ -3,6 +3,7 @@ export interface ServerConfig {
 
   instance: {
     name: string
+    shortDescription: string
     defaultClientRoute: string
     customizations: {
       javascript: string
index 14042cddffa665f6f6eda911cb53008fa620b683..db0c8d99fc77310aeebcc4f9981861779970a18a 100644 (file)
@@ -152,6 +152,8 @@ logs. You can set another password with:
 $ cd /var/www/peertube/peertube-latest && NODE_CONFIG_DIR=/var/www/peertube/config NODE_ENV=production npm run reset-password -- -u root
 ```
 
+Now you can subscribe to the mailing list for PeerTube administrators: https://framalistes.org/sympa/subscribe/peertube-admin
+
 ## Upgrade
 
 #### Auto (minor versions only)