Combine some badge examples using drop-downs, tweak some titles (#3037)

This updates several badges to take advantage of the change from #2882.
This commit is contained in:
Paul Melnikow
2019-02-18 23:04:25 -05:00
committed by GitHub
parent ed7aa31808
commit 24bc7bcfc3
8 changed files with 51 additions and 255 deletions

View File

@@ -4,8 +4,6 @@ const prettyBytes = require('pretty-bytes')
const { makeBadgeData: getBadgeData } = require('../../lib/badge-data')
const LegacyService = require('../legacy-service')
const keywords = ['node']
// This legacy service should be rewritten to use e.g. BaseJsonService.
//
// Tips for rewriting:
@@ -27,26 +25,15 @@ module.exports = class Bundlephobia extends LegacyService {
static get examples() {
return [
{
title: 'npm bundle size (minified)',
pattern: 'min/:packageName',
namedParams: { packageName: 'react' },
title: 'npm bundle size',
pattern: ':format(min|minzip)/:packageName',
namedParams: { format: 'minzip', packageName: 'react' },
staticPreview: {
label: 'minified size',
message: '6.06 kB',
color: 'blue',
},
keywords,
},
{
title: 'npm bundle size (minified + gzip)',
pattern: 'minzip/:packageName',
namedParams: { packageName: 'react' },
staticPreview: {
label: 'minzipped size',
message: '2.57 kB',
color: 'blue',
},
keywords,
keywords: ['node'],
},
]
}

View File

@@ -23,43 +23,20 @@ module.exports = class GithubCommitActivity extends LegacyService {
static get route() {
return {
base: 'github/commit-activity',
pattern: ':interval(y|4w|w)/:user/:repo',
pattern: ':interval(y|m|4w|w)/:user/:repo',
}
}
static get examples() {
return [
{
title: 'GitHub commit activity the past year',
pattern: 'y/:user/:repo',
namedParams: { user: 'eslint', repo: 'eslint' },
title: 'GitHub commit activity',
// Override the pattern to omit the deprecated interval "4w".
pattern: ':interval(y|m|w)/:user/:repo',
namedParams: { interval: 'm', user: 'eslint', repo: 'eslint' },
staticPreview: {
label: 'commit activity',
message: '457/year',
color: 'blue',
},
keywords: ['commits'],
documentation,
},
{
title: 'GitHub commit activity the past month',
pattern: 'm/:user/:repo',
namedParams: { user: 'eslint', repo: 'eslint' },
staticPreview: {
label: 'commit activity',
message: '38/month',
color: 'blue',
},
keywords: ['commits'],
documentation,
},
{
title: 'GitHub commit activity the past week',
pattern: 'w/:user/:repo',
namedParams: { user: 'eslint', repo: 'eslint' },
staticPreview: {
label: 'commit activity',
message: '9/week',
message: '457/month',
color: 'blue',
},
keywords: ['commits'],

View File

@@ -29,7 +29,7 @@ module.exports = class GithubCommitsSince extends LegacyService {
static get examples() {
return [
{
title: 'GitHub commits',
title: 'GitHub commits since tagged version',
namedParams: {
user: 'SubtitleEdit',
repo: 'subtitleedit',
@@ -43,7 +43,7 @@ module.exports = class GithubCommitsSince extends LegacyService {
documentation,
},
{
title: 'GitHub commits (since latest release)',
title: 'GitHub commits since latest release',
namedParams: {
user: 'SubtitleEdit',
repo: 'subtitleedit',

View File

@@ -15,11 +15,6 @@ const {
checkErrorResponse: githubCheckErrorResponse,
} = require('./github-helpers')
const commonExampleAttrs = {
keywords: ['pullrequest', 'detail'],
documentation,
}
// This legacy service should be rewritten to use e.g. BaseJsonService.
//
// Tips for rewriting:
@@ -35,16 +30,18 @@ module.exports = class GithubIssueDetail extends LegacyService {
return {
base: 'github/issues/detail',
pattern:
':which(s|title|u|label|comments|age|last-update)/:user/:repo/:number(0-9+)',
':which(s|state|title|u|author|label|comments|age|last-update)/:user/:repo/:number(0-9+)',
}
}
static get examples() {
return [
{
title: 'GitHub issue/pull request state',
pattern: 's/:user/:repo/:number',
title: 'GitHub issue/pull request detail',
pattern:
':which(state|title|author|label|comments|age|last-update)/:user/:repo/:number',
namedParams: {
which: 'state',
user: 'badges',
repo: 'shields',
number: '979',
@@ -54,97 +51,16 @@ module.exports = class GithubIssueDetail extends LegacyService {
message: 'closed',
color: 'red',
},
...commonExampleAttrs,
},
{
title: 'GitHub issue/pull request title',
pattern: 'title/:user/:repo/:number',
namedParams: {
user: 'badges',
repo: 'shields',
number: '1290',
},
staticPreview: {
label: 'issue 1290',
message: 'Node 9 support',
color: 'lightgrey',
},
...commonExampleAttrs,
},
{
title: 'GitHub issue/pull request author',
pattern: 'u/:user/:repo/:number',
namedParams: {
user: 'badges',
repo: 'shields',
number: '979',
},
staticPreview: {
label: 'author',
message: 'paulmelnikow',
color: 'lightgrey',
},
...commonExampleAttrs,
},
{
title: 'GitHub issue/pull request label',
pattern: 'label/:user/:repo/:number',
namedParams: {
user: 'badges',
repo: 'shields',
number: '979',
},
staticPreview: {
label: 'label',
message: 'bug | developer-experience',
color: 'lightgrey',
},
...commonExampleAttrs,
},
{
title: 'GitHub issue/pull request comments',
pattern: 'comments/:user/:repo/:number',
namedParams: {
user: 'badges',
repo: 'shields',
number: '979',
},
staticPreview: {
label: 'comments',
message: '24',
color: 'yellow',
},
...commonExampleAttrs,
},
{
title: 'GitHub issue/pull request age',
pattern: 'age/:user/:repo/:number',
namedParams: {
user: 'badges',
repo: 'shields',
number: '979',
},
staticPreview: {
label: 'created',
message: 'april 2017',
color: 'orange',
},
...commonExampleAttrs,
},
{
title: 'GitHub issue/pull request last update',
pattern: 'last-update/:user/:repo/:number',
namedParams: {
user: 'badges',
repo: 'shields',
number: '979',
},
staticPreview: {
label: 'updated',
message: 'december 2017',
color: 'orange',
},
...commonExampleAttrs,
keywords: [
'state',
'title',
'author',
'label',
'comments',
'age',
'last update',
],
documentation,
},
]
}
@@ -183,7 +99,8 @@ module.exports = class GithubIssueDetail extends LegacyService {
queryParams
)
switch (which) {
case 's': {
case 's':
case 'state': {
const state = (badgeData.text[1] = parsedData.state)
badgeData.colorscheme = undefined
badgeData.colorB = queryParams.colorB || githubStateColor(state)
@@ -193,6 +110,7 @@ module.exports = class GithubIssueDetail extends LegacyService {
badgeData.text[1] = parsedData.title
break
case 'u':
case 'author':
badgeData.text[0] = getLabel('author', queryParams)
badgeData.text[1] = parsedData.user.login
break

View File

@@ -63,8 +63,7 @@ module.exports = class MozillaObservatory extends BaseJsonService {
return [
{
title: 'Mozilla HTTP Observatory Grade',
pattern: 'grade/:host',
namedParams: { host: 'github.com' },
namedParams: { which: 'grade', host: 'github.com' },
staticPreview: this.render({
which: 'grade',
state: 'FINISHED',
@@ -74,19 +73,6 @@ module.exports = class MozillaObservatory extends BaseJsonService {
keywords: ['scanner', 'security'],
documentation,
},
{
title: 'Mozilla HTTP Observatory Grade (with score)',
pattern: 'grade-score/:host',
namedParams: { host: 'github.com' },
staticPreview: this.render({
which: 'grade-score',
state: 'FINISHED',
grade: 'A+',
score: 115,
}),
keywords: ['scanner', 'security'],
documentation,
},
]
}

View File

@@ -7,8 +7,6 @@ const {
downloadCount: downloadCountColor,
} = require('../../lib/color-formatters')
const keywords = ['PHP']
// This legacy service should be rewritten to use e.g. BaseJsonService.
//
// Tips for rewriting:
@@ -31,8 +29,8 @@ module.exports = class PackagistDownloads extends LegacyService {
return [
{
title: 'Packagist',
pattern: 'dm/:user/:repo',
namedParams: {
interval: 'dm',
user: 'doctrine',
repo: 'orm',
},
@@ -41,35 +39,7 @@ module.exports = class PackagistDownloads extends LegacyService {
message: '1M/month',
color: 'brightgreen',
},
keywords,
},
{
title: 'Packagist',
pattern: 'dd/:user/:repo',
namedParams: {
user: 'doctrine',
repo: 'orm',
},
staticPreview: {
label: 'downloads',
message: '49k/day',
color: 'brightgreen',
},
keywords,
},
{
title: 'Packagist',
pattern: 'dt/:user/:repo',
namedParams: {
user: 'doctrine',
repo: 'orm',
},
staticPreview: {
label: 'downloads',
message: '45M',
color: 'brightgreen',
},
keywords,
keywords: ['PHP'],
},
]
}

View File

@@ -33,8 +33,9 @@ module.exports = class Sourceforge extends LegacyService {
return [
{
title: 'SourceForge',
pattern: 'dm/:project',
pattern: ':interval(dt|dm|dw|dd)/:project',
namedParams: {
interval: 'dm',
project: 'sevenzip',
},
staticPreview: {
@@ -45,50 +46,15 @@ module.exports = class Sourceforge extends LegacyService {
},
{
title: 'SourceForge',
pattern: 'dw/:project',
namedParams: {
project: 'sevenzip',
},
staticPreview: {
label: 'downloads',
message: '52k/week',
color: 'brightgreen',
},
},
{
title: 'SourceForge',
pattern: 'dd/:project',
namedParams: {
project: 'sevenzip',
},
staticPreview: {
label: 'downloads',
message: '6k/day',
color: 'brightgreen',
},
},
{
title: 'SourceForge',
pattern: 'dt/:project',
namedParams: {
project: 'sevenzip',
},
staticPreview: {
label: 'downloads',
message: '416M',
color: 'brightgreen',
},
},
{
title: 'SourceForge',
pattern: 'dt/:project/:folder',
pattern: ':interval(dt|dm|dw|dd)/:project/:folder',
namedParams: {
interval: 'dm',
project: 'arianne',
folder: 'stendhal',
},
staticPreview: {
label: 'downloads',
message: '177k',
message: '550/month',
color: 'brightgreen',
},
},

View File

@@ -4,6 +4,13 @@ const VisualStudioMarketplaceBase = require('./visual-studio-marketplace-base')
const { metric } = require('../../lib/text-formatters')
const { downloadCount } = require('../../lib/color-formatters')
const documentation = `
<p>
This badge can show total installs, installs for Azure DevOps Services,
or on-premises installs for Azure DevOps Server.
</p>
`
// This service exists separately from the other Marketplace downloads badges (in ./visual-studio-marketplace-downloads.js)
// due differences in how the Marketplace tracks metrics for Azure DevOps extensions vs. other extension types.
// See https://github.com/badges/shields/pull/2748 for more information on the discussion and decision.
@@ -35,29 +42,14 @@ module.exports = class VisualStudioMarketplaceAzureDevOpsInstalls extends Visual
static get examples() {
return [
{
title:
'Visual Studio Marketplace - Azure DevOps Extension (Total Installs)',
pattern: 'total/:extensionId',
namedParams: { extensionId: 'swellaby.mirror-git-repository' },
title: 'Visual Studio Marketplace Installs - Azure DevOps Extension',
namedParams: {
measure: 'total',
extensionId: 'swellaby.mirror-git-repository',
},
staticPreview: this.render({ count: 651 }),
keywords: this.keywords,
},
{
title:
'Visual Studio Marketplace - Azure DevOps Extension (Services Installs)',
pattern: 'services/:extensionId',
namedParams: { extensionId: 'swellaby.mirror-git-repository' },
staticPreview: this.render({ count: 496 }),
keywords: this.keywords,
},
{
title:
'Visual Studio Marketplace - Azure DevOps Extension (OnPrem Installs)',
pattern: 'onprem/:extensionId',
namedParams: { extensionId: 'swellaby.mirror-git-repository' },
staticPreview: this.render({ count: 155 }),
keywords: this.keywords,
documentation,
},
]
}