diff --git a/core/base-service/examples.js b/core/base-service/examples.js index cc7d313b3acc26b8f6a8f03a5b5c5a3be44b1937..5f4248ad09056720b9c1fc600e7a92f1017df0ed 100644 --- a/core/base-service/examples.js +++ b/core/base-service/examples.js @@ -2,6 +2,7 @@ const Joi = require('@hapi/joi') const pathToRegexp = require('path-to-regexp') +const categories = require('../../services/categories') const coalesceBadge = require('./coalesce-badge') const { makeFullUrl } = require('./route') @@ -154,7 +155,9 @@ function transformExample(inExample, index, ServiceClass) { style: style === 'flat' ? undefined : style, namedLogo, }, - keywords, + keywords: keywords.concat( + categories.find(c => c.id === ServiceClass.category).keywords + ), documentation: documentation ? { __html: documentation } : undefined, } } diff --git a/core/base-service/examples.spec.js b/core/base-service/examples.spec.js index 3e4d254698c5e297b6aed0466fd0282cebdee5c7..387fec0456d160005da9d63db3e2d3a69e524a28 100644 --- a/core/base-service/examples.spec.js +++ b/core/base-service/examples.spec.js @@ -84,6 +84,7 @@ test(transformExample, function() { defaultBadgeData: { label: 'downloads', }, + category: 'platform-support', } given( @@ -109,7 +110,7 @@ test(transformExample, function() { namedLogo: undefined, style: undefined, }, - keywords: ['hello'], + keywords: ['hello', 'platform'], documentation: undefined, }) @@ -135,7 +136,7 @@ test(transformExample, function() { namedLogo: undefined, style: undefined, }, - keywords: ['hello'], + keywords: ['hello', 'platform'], documentation: undefined, }) @@ -162,7 +163,7 @@ test(transformExample, function() { namedLogo: undefined, style: undefined, }, - keywords: ['hello'], + keywords: ['hello', 'platform'], documentation: undefined, }) }) diff --git a/core/base-service/service-definitions.js b/core/base-service/service-definitions.js index 2128e5a0e7c3f4a5e22ccddc00a33840cb0f5b98..c89f151bc28e24eb89a162123a2fa99ce2ffe1a6 100644 --- a/core/base-service/service-definitions.js +++ b/core/base-service/service-definitions.js @@ -66,6 +66,7 @@ const serviceDefinitionExport = Joi.object({ Joi.object({ id: Joi.string().required(), name: Joi.string().required(), + keywords: arrayOfStrings, }) ) .required(), diff --git a/doc/TUTORIAL.md b/doc/TUTORIAL.md index bebe931170f932238db31c6c43eecc19c7e5ca01..ac5679237864157673946bd6b576ec00a816d338 100644 --- a/doc/TUTORIAL.md +++ b/doc/TUTORIAL.md @@ -324,7 +324,7 @@ module.exports = class GemVersion extends BaseJsonService { - `namedParams`: Provide a valid example of params we can substitute into the pattern. In this case we need a valid ruby gem, so we've picked [formatador](https://rubygems.org/gems/formatador). - `staticPreview`: On the index page we want to show an example badge, but for performance reasons we want that example to be generated without making an API call. `staticPreview` should be populated by calling our `render()` method with some valid data. - - `keywords`: If we want to provide additional keywords other than the title, we can add them here. This helps users to search for relevant badges. + - `keywords`: If we want to provide additional keywords other than the title and the category, we can add them here. This helps users to search for relevant badges. Save, run `npm start`, and you can see it [locally](http://127.0.0.1:3000/). diff --git a/frontend/lib/service-definitions/index.spec.ts b/frontend/lib/service-definitions/index.spec.ts index 035037a4d1851cd93c5126651c5e080f32147969..b83c603b9b667970a8e675a3ebcdae626d8318c9 100644 --- a/frontend/lib/service-definitions/index.spec.ts +++ b/frontend/lib/service-definitions/index.spec.ts @@ -4,7 +4,7 @@ import { findCategory, getDefinitionsForCategory } from '.' describe('Service definition helpers', function() { test(findCategory, () => { - given('build').expect({ id: 'build', name: 'Build' }) + given('build').expect({ id: 'build', name: 'Build', keywords: ['build'] }) given('foo').expect(undefined) }) diff --git a/frontend/lib/service-definitions/index.ts b/frontend/lib/service-definitions/index.ts index 23d5b0314eed0412ff28696d3dbbc74fe60a880c..a962c74910e8004f9e86ee062a368ddfa78ddf51 100644 --- a/frontend/lib/service-definitions/index.ts +++ b/frontend/lib/service-definitions/index.ts @@ -5,6 +5,7 @@ import definitions from '../../../service-definitions.yml' export interface Category { id: string name: string + keywords: string[] } export interface ExampleSignature { diff --git a/services/categories.js b/services/categories.js index 985718576a0906e1b4e34e183a23ef9550a2b616..fc45a33520bd7d39fa6c026f7977d5772b782576 100644 --- a/services/categories.js +++ b/services/categories.js @@ -1,21 +1,25 @@ 'use strict' module.exports = [ - { id: 'build', name: 'Build' }, - { id: 'coverage', name: 'Code Coverage' }, - { id: 'analysis', name: 'Analysis' }, - { id: 'chat', name: 'Chat' }, - { id: 'dependencies', name: 'Dependencies' }, - { id: 'size', name: 'Size' }, - { id: 'downloads', name: 'Downloads' }, - { id: 'funding', name: 'Funding' }, - { id: 'issue-tracking', name: 'Issue Tracking' }, - { id: 'license', name: 'License' }, - { id: 'rating', name: 'Rating' }, - { id: 'social', name: 'Social' }, - { id: 'version', name: 'Version' }, - { id: 'platform-support', name: 'Platform & Version Support' }, - { id: 'monitoring', name: 'Monitoring' }, - { id: 'activity', name: 'Activity' }, - { id: 'other', name: 'Other' }, + { id: 'build', name: 'Build', keywords: ['build'] }, + { id: 'coverage', name: 'Code Coverage', keywords: ['coverage'] }, + { id: 'analysis', name: 'Analysis', keywords: ['analysis'] }, + { id: 'chat', name: 'Chat', keywords: ['chat'] }, + { id: 'dependencies', name: 'Dependencies', keywords: ['dependencies'] }, + { id: 'size', name: 'Size', keywords: ['size'] }, + { id: 'downloads', name: 'Downloads', keywords: ['downloads'] }, + { id: 'funding', name: 'Funding', keywords: ['funding'] }, + { id: 'issue-tracking', name: 'Issue Tracking', keywords: ['issue'] }, + { id: 'license', name: 'License', keywords: ['license'] }, + { id: 'rating', name: 'Rating', keywords: ['rating'] }, + { id: 'social', name: 'Social', keywords: ['social'] }, + { id: 'version', name: 'Version', keywords: ['version'] }, + { + id: 'platform-support', + name: 'Platform & Version Support', + keywords: ['platform'], + }, + { id: 'monitoring', name: 'Monitoring', keywords: ['monitoring'] }, + { id: 'activity', name: 'Activity', keywords: ['activity'] }, + { id: 'other', name: 'Other', keywords: [] }, ] diff --git a/services/github/github-downloads.service.js b/services/github/github-downloads.service.js index 4b28158250b2fe616893c09f410a83c39e14697d..8c1ea820beceb9ec33eb552390db6b0b1319b2bb 100644 --- a/services/github/github-downloads.service.js +++ b/services/github/github-downloads.service.js @@ -22,8 +22,6 @@ const releaseArraySchema = Joi.alternatives().try( Joi.array().length(0) ) -const keywords = ['github download'] - module.exports = class GithubDownloads extends GithubAuthV3Service { static get category() { return 'downloads' @@ -50,7 +48,6 @@ module.exports = class GithubDownloads extends GithubAuthV3Service { downloadCount: 857000, }), documentation, - keywords, }, { title: 'GitHub Releases', @@ -66,7 +63,6 @@ module.exports = class GithubDownloads extends GithubAuthV3Service { downloadCount: 27000, }), documentation, - keywords, }, { title: 'GitHub Pre-Releases', @@ -82,7 +78,6 @@ module.exports = class GithubDownloads extends GithubAuthV3Service { downloadCount: 2000, }), documentation, - keywords, }, { title: 'GitHub Releases (by Release)', @@ -98,7 +93,6 @@ module.exports = class GithubDownloads extends GithubAuthV3Service { downloadCount: 490000, }), documentation, - keywords, }, { title: 'GitHub Releases (by Asset)', @@ -115,7 +109,6 @@ module.exports = class GithubDownloads extends GithubAuthV3Service { downloadCount: 3000, }), documentation, - keywords, }, { title: 'GitHub Pre-Releases (by Asset)', @@ -132,7 +125,6 @@ module.exports = class GithubDownloads extends GithubAuthV3Service { downloadCount: 237, }), documentation, - keywords, }, ] } diff --git a/services/github/github-last-commit.service.js b/services/github/github-last-commit.service.js index e7a28983c62ef4930ddb9f49f2fa08dd4fb22abc..499b928a904af2b2ea3987a637a36c0b9b583394 100644 --- a/services/github/github-last-commit.service.js +++ b/services/github/github-last-commit.service.js @@ -6,7 +6,7 @@ const { age: ageColor } = require('../color-formatters') const { GithubAuthV3Service } = require('./github-auth-service') const { documentation, errorMessagesFor } = require('./github-helpers') const commonExampleAttrs = { - keywords: ['activity', 'latest'], + keywords: ['latest'], documentation, } diff --git a/services/github/github-license.service.js b/services/github/github-license.service.js index bd33d1ab0b3be29cb2a51400d5d5aa4bca61bfea..21787c206eab86d7656b8aac9d018ba97b39a47f 100644 --- a/services/github/github-license.service.js +++ b/services/github/github-license.service.js @@ -32,7 +32,6 @@ module.exports = class GithubLicense extends GithubAuthV3Service { message: 'MIT', color: 'green', }, - keywords: ['license'], documentation, }, ] diff --git a/services/jira/jira-sprint.service.js b/services/jira/jira-sprint.service.js index a75ca1e3b84c187415e32e1e37e4264068302ce1..5fe1f48bc1c832be6fefa119314f9a3929f36f91 100644 --- a/services/jira/jira-sprint.service.js +++ b/services/jira/jira-sprint.service.js @@ -64,7 +64,6 @@ module.exports = class JiraSprint extends BaseJsonService { numTotalIssues: 28, }), documentation, - keywords: ['issues'], }, ] } diff --git a/services/vaadin-directory/vaadin-directory-rating-count.service.js b/services/vaadin-directory/vaadin-directory-rating-count.service.js index 02aa2b1672ce4749cc66e614659d2e5886c4bd05..496143c1d485516458a8be226b903372f4f3ca8d 100644 --- a/services/vaadin-directory/vaadin-directory-rating-count.service.js +++ b/services/vaadin-directory/vaadin-directory-rating-count.service.js @@ -23,7 +23,7 @@ module.exports = class VaadinDirectoryRatingCount extends BaseVaadinDirectorySer pattern: 'rating-count/:packageName', namedParams: { packageName: 'vaadinvaadin-grid' }, staticPreview: this.render({ ratingCount: 6 }), - keywords: ['vaadin-directory', 'rating-count', 'rating count'], + keywords: ['vaadin-directory', 'rating-count'], }, ] } diff --git a/services/vaadin-directory/vaadin-directory-rating.service.js b/services/vaadin-directory/vaadin-directory-rating.service.js index 5ebfb3c90efac94bf64d001fe6478b0bf3782085..f1a6546fa4d404e5e917eea78b2f567df7232891 100644 --- a/services/vaadin-directory/vaadin-directory-rating.service.js +++ b/services/vaadin-directory/vaadin-directory-rating.service.js @@ -23,7 +23,7 @@ module.exports = class VaadinDirectoryRating extends BaseVaadinDirectoryService pattern: ':format(stars|rating)/:packageName', namedParams: { format: 'rating', packageName: 'vaadinvaadin-grid' }, staticPreview: this.render({ format: 'rating', score: 4.75 }), - keywords: ['vaadin-directory', 'rating'], + keywords: ['vaadin-directory'], }, ] } diff --git a/services/vaadin-directory/vaadin-directory-version.service.js b/services/vaadin-directory/vaadin-directory-version.service.js index 95187b41df04d74ae1a129d56766fab3ec768aa2..bb68f93a37f922b0ac10841e4b36c64f450a8ec9 100644 --- a/services/vaadin-directory/vaadin-directory-version.service.js +++ b/services/vaadin-directory/vaadin-directory-version.service.js @@ -22,7 +22,7 @@ module.exports = class VaadinDirectoryVersion extends BaseVaadinDirectoryService pattern: 'v/:packageName', namedParams: { packageName: 'vaadinvaadin-grid' }, staticPreview: renderVersionBadge({ version: 'v5.3.0-alpha4' }), - keywords: ['vaadin-directory', 'version', 'latest version'], + keywords: ['vaadin-directory', 'latest'], }, ] }