Skip to content

Commit 88c8b0e

Browse files
authored
More example urls and static examples [apm waffle] (#2478)
1 parent d74568b commit 88c8b0e

27 files changed

+289
-82
lines changed

services/apm/apm.service.js

+24-24
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ const BaseJsonService = require('../base-json')
88
const { InvalidResponse } = require('../errors')
99
const { nonNegativeInteger } = require('../validators')
1010

11-
const apmSchema = Joi.object({
11+
const keywords = ['atom']
12+
13+
const schema = Joi.object({
1214
downloads: nonNegativeInteger,
1315
releases: Joi.object({
1416
latest: Joi.string().required(),
@@ -19,10 +21,10 @@ const apmSchema = Joi.object({
1921
})
2022

2123
class BaseAPMService extends BaseJsonService {
22-
async fetch({ repo }) {
24+
async fetch({ packageName }) {
2325
return this._requestJson({
24-
schema: apmSchema,
25-
url: `https://atom.io/api/packages/${repo}`,
26+
schema,
27+
url: `https://atom.io/api/packages/${packageName}`,
2628
errorMessages: { 404: 'package not found' },
2729
})
2830
}
@@ -37,8 +39,8 @@ class APMDownloads extends BaseAPMService {
3739
return { message: metric(downloads), color: 'green' }
3840
}
3941

40-
async handle({ repo }) {
41-
const json = await this.fetch({ repo })
42+
async handle({ packageName }) {
43+
const json = await this.fetch({ packageName })
4244
return this.constructor.render({ downloads: json.downloads })
4345
}
4446

@@ -53,17 +55,17 @@ class APMDownloads extends BaseAPMService {
5355
static get route() {
5456
return {
5557
base: 'apm/dm',
56-
pattern: ':repo',
58+
pattern: ':packageName',
5759
}
5860
}
5961

6062
static get examples() {
6163
return [
6264
{
63-
exampleUrl: 'vim-mode',
64-
pattern: ':package',
65+
title: 'APM',
66+
namedParams: { packageName: 'vim-mode' },
6567
staticExample: this.render({ downloads: '60043' }),
66-
keywords: ['atom'],
68+
keywords,
6769
},
6870
]
6971
}
@@ -74,8 +76,8 @@ class APMVersion extends BaseAPMService {
7476
return renderVersionBadge({ version })
7577
}
7678

77-
async handle({ repo }) {
78-
const json = await this.fetch({ repo })
79+
async handle({ packageName }) {
80+
const json = await this.fetch({ packageName })
7981

8082
const version = json.releases.latest
8183
if (!version)
@@ -92,18 +94,17 @@ class APMVersion extends BaseAPMService {
9294
static get route() {
9395
return {
9496
base: 'apm/v',
95-
format: '(.+)',
96-
capture: ['repo'],
97+
pattern: ':packageName',
9798
}
9899
}
99100

100101
static get examples() {
101102
return [
102103
{
103-
exampleUrl: 'vim-mode',
104-
pattern: ':package',
104+
title: 'APM',
105+
namedParams: { packageName: 'vim-mode' },
105106
staticExample: this.render({ version: '0.6.0' }),
106-
keywords: ['atom'],
107+
keywords,
107108
},
108109
]
109110
}
@@ -114,8 +115,8 @@ class APMLicense extends BaseAPMService {
114115
return renderLicenseBadge({ license })
115116
}
116117

117-
async handle({ repo }) {
118-
const json = await this.fetch({ repo })
118+
async handle({ packageName }) {
119+
const json = await this.fetch({ packageName })
119120

120121
const license = json.metadata.license
121122
if (!license)
@@ -136,18 +137,17 @@ class APMLicense extends BaseAPMService {
136137
static get route() {
137138
return {
138139
base: 'apm/l',
139-
format: '(.+)',
140-
capture: ['repo'],
140+
pattern: ':packageName',
141141
}
142142
}
143143

144144
static get examples() {
145145
return [
146146
{
147-
exampleUrl: 'vim-mode',
148-
pattern: ':package',
147+
title: 'APM',
148+
namedParams: { packageName: 'vim-mode' },
149149
staticExample: this.render({ license: 'MIT' }),
150-
keywords: ['atom'],
150+
keywords,
151151
},
152152
]
153153
}

services/bower/bower-license.service.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,16 @@ module.exports = class BowerLicense extends LegacyService {
1212
static get route() {
1313
return {
1414
base: 'bower/l',
15+
pattern: ':packageName',
1516
}
1617
}
1718

1819
static get examples() {
1920
return [
2021
{
2122
title: 'Bower',
22-
previewUrl: 'bootstrap',
23+
namedParams: { packageName: 'bootstrap' },
24+
staticPreview: { label: 'license', message: 'MIT', color: 'blue' },
2325
},
2426
]
2527
}

services/cocoapods/cocoapods-license.service.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ module.exports = class CocoapodsLicense extends LegacyService {
1010
static get route() {
1111
return {
1212
base: 'cocoapods/l',
13+
pattern: ':packageName',
1314
}
1415
}
1516

1617
static get examples() {
1718
return [
1819
{
1920
title: 'Cocoapods',
20-
previewUrl: 'AFNetworking',
21+
namedParams: { packageName: 'AFNetworking' },
22+
staticPreview: { label: 'license', message: 'MIT', color: '000' },
2123
},
2224
]
2325
}

services/cocoapods/cocoapods-platform.service.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,20 @@ module.exports = class CocoapodsPlatform extends LegacyService {
1010
static get route() {
1111
return {
1212
base: 'cocoapods/p',
13+
pattern: ':packageName',
1314
}
1415
}
1516

1617
static get examples() {
1718
return [
1819
{
1920
title: 'Cocoapods',
20-
previewUrl: 'AFNetworking',
21+
namedParams: { packageName: 'AFNetworking' },
22+
staticPreview: {
23+
label: 'platform',
24+
message: 'ios | osx | watchos | tvos',
25+
color: 'lightgrey',
26+
},
2127
},
2228
]
2329
}

services/cpan/cpan-license.service.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ module.exports = class CpanLicense extends LegacyService {
1010
static get route() {
1111
return {
1212
base: 'cpan/l',
13+
pattern: ':packageName',
1314
}
1415
}
1516

1617
static get examples() {
1718
return [
1819
{
1920
title: 'CPAN',
20-
previewUrl: 'Config-Augeas',
21+
namedParams: { packageName: 'Config-Augeas' },
22+
staticPreview: { label: 'CPAN', message: 'lgpl_2_1', color: 'blue' },
2123
keywords: ['perl'],
2224
},
2325
]

services/cran/cran.service.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,20 @@ class CranLicense extends LegacyService {
1616
static get route() {
1717
return {
1818
base: 'cran/l',
19+
pattern: ':packageName',
1920
}
2021
}
2122

2223
static get examples() {
2324
return [
2425
{
2526
title: 'CRAN/METACRAN',
26-
previewUrl: 'devtools',
27+
namedParams: { packageName: 'devtools' },
28+
staticPreview: {
29+
label: 'license',
30+
message: 'GPL (>= 2)',
31+
color: 'blue',
32+
},
2733
keywords: ['R'],
2834
},
2935
]

services/dub/dub-license-version.service.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@ class DubVersion extends LegacyService {
1717
static get route() {
1818
return {
1919
base: 'dub/v',
20+
pattern: ':packageName',
2021
}
2122
}
2223

2324
static get examples() {
2425
return [
2526
{
2627
title: 'DUB',
27-
previewUrl: 'vibe-d',
28-
keywords: ['dub'],
28+
namedParams: { packageName: 'vibe-d' },
29+
staticPreview: { label: 'version', message: 'v0.8.4', color: 'orange' },
2930
},
3031
]
3132
}
@@ -41,15 +42,16 @@ class DubLicense extends LegacyService {
4142
static get route() {
4243
return {
4344
base: 'dub/l',
45+
pattern: ':packageName',
4446
}
4547
}
4648

4749
static get examples() {
4850
return [
4951
{
5052
title: 'DUB',
51-
previewUrl: 'vibe-d',
52-
keywords: ['dub'],
53+
namedParams: { packageName: 'vibe-d' },
54+
staticPreview: { label: 'license', message: 'MIT', color: 'blue' },
5355
},
5456
]
5557
}

services/github/github-commit-activity.service.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ module.exports = class GithubCommitActivity extends LegacyService {
2626
return [
2727
{
2828
title: 'GitHub commit activity the past week, 4 weeks, year',
29-
previewUrl: 'y/eslint/eslint',
29+
pattern: 'y/:user/:repo',
30+
namedParams: { user: 'eslint', repo: 'eslint' },
31+
staticPreview: {
32+
label: 'commit activity',
33+
message: '457/year',
34+
color: 'blue',
35+
},
3036
keywords: ['GitHub', 'commit', 'commits', 'activity'],
3137
documentation,
3238
},

services/github/github-commit-status.service.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,18 @@ module.exports = class GithubCommitStatus extends LegacyService {
2222
return [
2323
{
2424
title: 'GitHub commit merge status',
25-
previewUrl:
26-
'badges/shields/master/5d4ab86b1b5ddfb3c4a70a70bd19932c52603b8c',
25+
pattern: ':user/:repo/:branch/:commit',
26+
namedParams: {
27+
user: 'badges',
28+
repo: 'shields',
29+
branch: 'master',
30+
commit: '5d4ab86b1b5ddfb3c4a70a70bd19932c52603b8c',
31+
},
32+
staticPreview: {
33+
label: 'commits since 3.4.7',
34+
message: '4225',
35+
color: 'blue',
36+
},
2737
keywords: ['GitHub', 'commit', 'branch', 'merge'],
2838
documentation,
2939
},

services/github/github-commits-since.service.js

+25-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ const {
88
} = require('../../lib/badge-data')
99
const { documentation } = require('./github-helpers')
1010

11+
const keywords = ['GitHub', 'commit']
12+
1113
module.exports = class GithubCommitsSince extends LegacyService {
1214
static get category() {
1315
return 'activity'
@@ -16,21 +18,40 @@ module.exports = class GithubCommitsSince extends LegacyService {
1618
static get route() {
1719
return {
1820
base: 'github/commits-since',
21+
pattern: ':user/:repo/:version',
1922
}
2023
}
2124

2225
static get examples() {
2326
return [
2427
{
2528
title: 'GitHub commits',
26-
previewUrl: 'SubtitleEdit/subtitleedit/3.4.7',
27-
keywords: ['GitHub', 'commit'],
29+
namedParams: {
30+
user: 'SubtitleEdit',
31+
repo: 'subtitleedit',
32+
version: '3.4.7',
33+
},
34+
staticPreview: {
35+
label: 'commits since 3.4.7',
36+
message: '4225',
37+
color: 'blue',
38+
},
39+
keywords,
2840
documentation,
2941
},
3042
{
3143
title: 'GitHub commits (since latest release)',
32-
previewUrl: 'SubtitleEdit/subtitleedit/latest',
33-
keywords: ['GitHub', 'commit'],
44+
namedParams: {
45+
user: 'SubtitleEdit',
46+
repo: 'subtitleedit',
47+
version: 'latest',
48+
},
49+
staticPreview: {
50+
label: 'commits since 3.5.7',
51+
message: '157',
52+
color: 'blue',
53+
},
54+
keywords,
3455
documentation,
3556
},
3657
]

services/github/github-contributors.service.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,16 @@ module.exports = class GithubContributors extends LegacyService {
2626
return [
2727
{
2828
title: 'GitHub contributors',
29-
previewUrl: 'contributors/cdnjs/cdnjs',
29+
pattern: 'contributors/:user/:repo',
30+
namedParams: {
31+
user: 'cdnjs',
32+
repo: 'cdnjs',
33+
},
34+
staticPreview: {
35+
label: 'contributors',
36+
message: '397',
37+
color: 'blue',
38+
},
3039
keywords: ['GitHub', 'contributor'],
3140
documentation,
3241
},

0 commit comments

Comments
 (0)