Skip to content

Commit

Permalink
Migrate deprecated staticExample -> staticPreview (#2650)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmelnikow authored Jan 6, 2019
1 parent a614de5 commit 89113ee
Show file tree
Hide file tree
Showing 105 changed files with 227 additions and 224 deletions.
4 changes: 2 additions & 2 deletions doc/TUTORIAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ module.exports = class GemVersion extends BaseJsonService {
{ // (3)
title: 'Gem',
namedParams: { gem: 'formatador' },
staticExample: this.render({ version: '2.1.0' }),
staticPreview: this.render({ version: '2.1.0' }),
keywords: ['ruby'],
},
]
Expand All @@ -288,7 +288,7 @@ module.exports = class GemVersion extends BaseJsonService {
* `title`: Descriptive text that will be shown next to the badge
* `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).
* `staticExample`: 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. `staticExample` should be populated by calling our `render()` method with some valid data.
* `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.

Save, run `npm start`, and you can see it [locally](http://127.0.0.1:3000/).
Expand Down
8 changes: 7 additions & 1 deletion doc/rewriting-services.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,13 @@ In either case, the service should throw e.g

## Convert the examples

1. Convert all the examples to `pattern`, `namedParams`, and `staticExample`. In some cases you can use the `pattern` inherited from `route`, though in other cases you may need to specify a pattern in the example. For example, when showing download badges for several periods, you may want to render the example with an explicit `dt` instead of `:which`. You will also need to specify a pattern for badges that use a `format` regex in the route.
1. Convert all the examples to `pattern`, `namedParams`, and
`staticPreview`. In some cases you can use the `pattern` inherited
from `route`, though in other cases you may need to specify a pattern
in the example. For example, when showing download badges for several
periods, you may want to render the example with an explicit `dt`
instead of `:which`. You will also need to specify a pattern for badges
that use a `format` regex in the route.

2. Open the frontend and check that the static preview badges look good.
Remember, none of them are live.
Expand Down
10 changes: 5 additions & 5 deletions services/amo/amo.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class AmoDownloads extends LegacyService {
{
title: 'Mozilla Add-on',
namedParams: { addonId: 'dustman' },
staticExample: { message: '12k', color: 'brightgreen' },
staticPreview: { message: '12k', color: 'brightgreen' },
keywords,
},
]
Expand All @@ -62,7 +62,7 @@ class AmoVersion extends LegacyService {
{
title: 'Mozilla Add-on',
namedParams: { addonId: 'dustman' },
staticExample: { message: 'v2.1.0', color: 'blue' },
staticPreview: { message: 'v2.1.0', color: 'blue' },
keywords,
},
]
Expand Down Expand Up @@ -94,7 +94,7 @@ class AmoRating extends LegacyService {
title: 'Mozilla Add-on',
pattern: 'rating/:addonId',
namedParams: { addonId: 'dustman' },
staticExample: {
staticPreview: {
label: 'rating',
message: '4/5',
color: 'brightgreen',
Expand All @@ -105,7 +105,7 @@ class AmoRating extends LegacyService {
title: 'Mozilla Add-on',
pattern: 'stars/:addonId',
namedParams: { addonId: 'dustman' },
staticExample: {
staticPreview: {
label: 'rating',
message: starRating(4),
color: 'brightgreen',
Expand Down Expand Up @@ -135,7 +135,7 @@ class AmoUsers extends LegacyService {
{
title: 'Mozilla Add-on',
namedParams: { addonId: 'dustman' },
staticExample: { message: '706', color: 'brightgreen' },
staticPreview: { message: '706', color: 'brightgreen' },
keywords,
},
]
Expand Down
4 changes: 2 additions & 2 deletions services/ansible/ansible.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class AnsibleGalaxyRoleDownloads extends AnsibleGalaxyRole {
{
title: 'Ansible Role',
namedParams: { roleId: '3078' },
staticExample: this.render({ downloads: 76 }),
staticPreview: this.render({ downloads: 76 }),
},
]
}
Expand Down Expand Up @@ -96,7 +96,7 @@ class AnsibleGalaxyRoleName extends AnsibleGalaxyRole {
{
title: 'Ansible Role',
namedParams: { roleId: '3078' },
staticExample: this.render({
staticPreview: this.render({
name: 'ansible-roles.sublimetext3_packagecontrol',
}),
},
Expand Down
6 changes: 3 additions & 3 deletions services/apm/apm.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class APMDownloads extends BaseAPMService {
{
title: 'APM',
namedParams: { packageName: 'vim-mode' },
staticExample: this.render({ downloads: '60043' }),
staticPreview: this.render({ downloads: '60043' }),
keywords,
},
]
Expand Down Expand Up @@ -103,7 +103,7 @@ class APMVersion extends BaseAPMService {
{
title: 'APM',
namedParams: { packageName: 'vim-mode' },
staticExample: this.render({ version: '0.6.0' }),
staticPreview: this.render({ version: '0.6.0' }),
keywords,
},
]
Expand Down Expand Up @@ -146,7 +146,7 @@ class APMLicense extends BaseAPMService {
{
title: 'APM',
namedParams: { packageName: 'vim-mode' },
staticExample: this.render({ license: 'MIT' }),
staticPreview: this.render({ license: 'MIT' }),
keywords,
},
]
Expand Down
4 changes: 2 additions & 2 deletions services/appveyor/appveyor-ci.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ module.exports = class AppVeyorCi extends AppVeyorBase {
title: 'AppVeyor',
pattern: ':user/:repo',
namedParams: { user: 'gruntjs', repo: 'grunt' },
staticExample: this.render({ status: 'success' }),
staticPreview: this.render({ status: 'success' }),
},
{
title: 'AppVeyor branch',
pattern: ':user/:repo/:branch',
namedParams: { user: 'gruntjs', repo: 'grunt', branch: 'master' },
staticExample: this.render({ status: 'success' }),
staticPreview: this.render({ status: 'success' }),
},
]
}
Expand Down
6 changes: 3 additions & 3 deletions services/aur/aur.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class AurLicense extends BaseAurService {
{
title: 'AUR license',
namedParams: { packageName: 'yaourt' },
staticExample: this.render({ license: 'GPL' }),
staticPreview: this.render({ license: 'GPL' }),
},
]
}
Expand Down Expand Up @@ -115,7 +115,7 @@ class AurVotes extends BaseAurService {
{
title: 'AUR votes',
namedParams: { packageName: 'yaourt' },
staticExample: this.render({ votes: '3029' }),
staticPreview: this.render({ votes: '3029' }),
},
]
}
Expand Down Expand Up @@ -151,7 +151,7 @@ class AurVersion extends BaseAurService {
{
title: 'AUR version',
namedParams: { packageName: 'yaourt' },
staticExample: this.render({ version: 'v1.9-1', outOfDate: null }),
staticPreview: this.render({ version: 'v1.9-1', outOfDate: null }),
},
]
}
Expand Down
4 changes: 2 additions & 2 deletions services/azure-devops/azure-devops-build.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module.exports = class AzureDevOpsBuild extends BaseSvgService {
projectId: '8cf3ec0e-d0c2-4fcd-8206-ad204f254a96',
definitionId: '2',
},
staticExample: render({ status: 'succeeded' }),
staticPreview: render({ status: 'succeeded' }),
keywords,
documentation,
},
Expand All @@ -69,7 +69,7 @@ module.exports = class AzureDevOpsBuild extends BaseSvgService {
definitionId: '2',
branch: 'master',
},
staticExample: render({ status: 'succeeded' }),
staticPreview: render({ status: 'succeeded' }),
keywords,
documentation,
},
Expand Down
4 changes: 2 additions & 2 deletions services/azure-devops/azure-devops-coverage.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module.exports = class AzureDevOpsCoverage extends AzureDevOpsBase {
project: 'opensource',
definitionId: '25',
},
staticExample: this.render({ coverage: 100 }),
staticPreview: this.render({ coverage: 100 }),
keywords,
documentation,
},
Expand All @@ -86,7 +86,7 @@ module.exports = class AzureDevOpsCoverage extends AzureDevOpsBase {
definitionId: '25',
branch: 'master',
},
staticExample: this.render({ coverage: 100 }),
staticPreview: this.render({ coverage: 100 }),
keywords,
documentation,
},
Expand Down
2 changes: 1 addition & 1 deletion services/azure-devops/azure-devops-release.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module.exports = class AzureDevOpsRelease extends BaseSvgService {
definitionId: '1',
environmentId: '1',
},
staticExample: render({ status: 'succeeded' }),
staticPreview: render({ status: 'succeeded' }),
keywords,
documentation,
},
Expand Down
8 changes: 4 additions & 4 deletions services/azure-devops/azure-devops-tests.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ module.exports = class AzureDevOpsTests extends AzureDevOpsBase {
project: 'azuredevops-powershell',
definitionId: '1',
},
staticExample: this.render({
staticPreview: this.render({
passed: 20,
failed: 1,
skipped: 1,
Expand All @@ -115,7 +115,7 @@ module.exports = class AzureDevOpsTests extends AzureDevOpsBase {
definitionId: '1',
branch: 'master',
},
staticExample: this.render({
staticPreview: this.render({
passed: 20,
failed: 1,
skipped: 1,
Expand All @@ -136,7 +136,7 @@ module.exports = class AzureDevOpsTests extends AzureDevOpsBase {
compact_message: null,
},
keywords: ['vso', 'vsts', 'azure-devops'],
staticExample: this.render({
staticPreview: this.render({
passed: 20,
failed: 1,
skipped: 1,
Expand All @@ -159,7 +159,7 @@ module.exports = class AzureDevOpsTests extends AzureDevOpsBase {
failed_label: 'bad',
skipped_label: 'n/a',
},
staticExample: this.render({
staticPreview: this.render({
passed: 20,
failed: 1,
skipped: 1,
Expand Down
3 changes: 1 addition & 2 deletions services/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class BaseService {
*
* The preferred way to specify an example is with `namedParams` which are
* substitued into the service's compiled route pattern. The rendered badge
* is specified with `staticExample`.
* is specified with `staticPreview`.
*
* For services which use a route `format`, the `pattern` can be specified as
* part of the example.
Expand All @@ -105,7 +105,6 @@ class BaseService {
* `render()`: an object containing `message` and optional `label` and
* `color`. This is usually generated by invoking `this.render()` with some
* explicit props.
* staticExample: Deprecated. An alias for `staticPreview`.
* previewUrl: Deprecated. An explicit example which is rendered as part of
* the badge listing.
* keywords: Additional keywords, other than words in the title. This helps
Expand Down
6 changes: 3 additions & 3 deletions services/base.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ class DummyService extends BaseService {
{
pattern: ':world',
namedParams: { world: 'World' },
staticExample: this.render({ namedParamA: 'foo', queryParamA: 'bar' }),
staticPreview: this.render({ namedParamA: 'foo', queryParamA: 'bar' }),
keywords: ['hello'],
},
{
namedParams: { namedParamA: 'World' },
staticExample: this.render({ namedParamA: 'foo', queryParamA: 'bar' }),
staticPreview: this.render({ namedParamA: 'foo', queryParamA: 'bar' }),
keywords: ['hello'],
},
{
pattern: ':world',
namedParams: { world: 'World' },
queryParams: { queryParamA: '!!!' },
staticExample: this.render({ namedParamA: 'foo', queryParamA: 'bar' }),
staticPreview: this.render({ namedParamA: 'foo', queryParamA: 'bar' }),
keywords: ['hello'],
},
]
Expand Down
2 changes: 1 addition & 1 deletion services/beerpay/beerpay.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = class Beerpay extends BaseJsonService {
{
title: 'Beerpay',
namedParams: { user: 'hashdog', project: 'scrapfy-chrome-extension' },
staticExample: this.render({ totalAmount: 10 }),
staticPreview: this.render({ totalAmount: 10 }),
},
]
}
Expand Down
2 changes: 1 addition & 1 deletion services/bintray/bintray.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = class Bintray extends BaseJsonService {
return [
{
title: 'Bintray',
staticExample: renderVersionBadge({ version: '1.6.0' }),
staticPreview: renderVersionBadge({ version: '1.6.0' }),
namedParams: {
subject: 'asciidoctor',
repo: 'maven',
Expand Down
2 changes: 1 addition & 1 deletion services/bitbucket/bitbucket-issues.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function issueClassGenerator(raw) {
user: 'atlassian',
repo: 'python-bitbucket',
},
staticExample: this.render({ issues: 33 }),
staticPreview: this.render({ issues: 33 }),
},
]
}
Expand Down
4 changes: 2 additions & 2 deletions services/bitbucket/bitbucket-pipelines.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ module.exports = class BitbucketPipelines extends BaseJsonService {
user: 'atlassian',
repo: 'adf-builder-javascript',
},
staticExample: this.render({ status: 'SUCCESSFUL' }),
staticPreview: this.render({ status: 'SUCCESSFUL' }),
},
{
title: 'Bitbucket Pipelines branch',
Expand All @@ -103,7 +103,7 @@ module.exports = class BitbucketPipelines extends BaseJsonService {
repo: 'adf-builder-javascript',
branch: 'task/SECO-2168',
},
staticExample: this.render({ status: 'SUCCESSFUL' }),
staticPreview: this.render({ status: 'SUCCESSFUL' }),
},
]
}
Expand Down
2 changes: 1 addition & 1 deletion services/bitbucket/bitbucket-pull-request.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function pullRequestClassGenerator(raw) {
user: 'atlassian',
repo: 'python-bitbucket',
},
staticExample: this.render({ prs: 22 }),
staticPreview: this.render({ prs: 22 }),
},
]
}
Expand Down
2 changes: 1 addition & 1 deletion services/bitrise/bitrise.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = class Bitrise extends LegacyService {
pattern: ':appId/:branch',
namedParams: { appId: 'cde737473028420d', branch: 'master' },
queryParams: { token: 'GCIdEzacE4GW32jLVrZb7A' },
staticExample: {
staticPreview: {
label: 'bitrise',
message: 'success',
color: 'brightgreen',
Expand Down
2 changes: 1 addition & 1 deletion services/bountysource/bountysource.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.exports = class Bountysource extends BaseJsonService {
{
title: 'Bountysource',
namedParams: { team: 'mozilla-core' },
staticExample: this.render({ total: 53000 }),
staticPreview: this.render({ total: 53000 }),
},
]
}
Expand Down
4 changes: 2 additions & 2 deletions services/bower/bower-version.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ module.exports = class BowerVersion extends BaseBowerService {
title: 'Bower',
namedParams: { vtype: 'v', packageName: 'bootstrap' },
pattern: 'v/:packageName',
staticExample: renderVersionBadge({ version: '4.2.1' }),
staticPreview: renderVersionBadge({ version: '4.2.1' }),
},
{
title: 'Bower Pre Release',
namedParams: { vtype: 'vpre', packageName: 'bootstrap' },
pattern: 'vpre/:packageName',
staticExample: renderVersionBadge({ version: '4.2.1' }),
staticPreview: renderVersionBadge({ version: '4.2.1' }),
},
]
}
Expand Down
2 changes: 1 addition & 1 deletion services/cdnjs/cdnjs.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module.exports = class Cdnjs extends BaseJsonService {
return [
{
namedParams: { library: 'jquery' },
staticExample: this.render({ version: '1.5.2' }),
staticPreview: this.render({ version: '1.5.2' }),
},
]
}
Expand Down
Loading

0 comments on commit 89113ee

Please sign in to comment.