The term “url” is overloaded in services, to refer to the Shields route and also the API URL. Calling the Shields URL a “route” is on the whole more descriptive, and makes it clearer and more obvious which one of these we’re talking about. It’s a small thing, though seems like an improvement. We have a few functions called `buildUrl`. I’ve renamed them to `buildRoute` when they refer to routes, and left them as `buildUrl` when they refer to API URLs. I included a minor style tweak and some formatting cleanup in `TUTORIAL.md`.
61 lines
1.3 KiB
JavaScript
61 lines
1.3 KiB
JavaScript
'use strict'
|
|
|
|
const BaseWordpress = require('./wordpress-base')
|
|
const { addv } = require('../../lib/text-formatters')
|
|
const { version: versionColor } = require('../../lib/color-formatters')
|
|
|
|
function VersionForExtensionType(extensionType) {
|
|
const { capt, exampleSlug } = {
|
|
plugin: {
|
|
capt: 'Plugin',
|
|
exampleSlug: 'bbpress',
|
|
},
|
|
theme: {
|
|
capt: 'Theme',
|
|
exampleSlug: 'twentyseventeen',
|
|
},
|
|
}[extensionType]
|
|
|
|
return class WordpressPluginVersion extends BaseWordpress {
|
|
static get extensionType() {
|
|
return extensionType
|
|
}
|
|
|
|
static render({ response }) {
|
|
return {
|
|
message: addv(response.version),
|
|
color: versionColor(response.version),
|
|
}
|
|
}
|
|
|
|
static get category() {
|
|
return 'version'
|
|
}
|
|
|
|
static get defaultBadgeData() {
|
|
return { label: extensionType }
|
|
}
|
|
|
|
static get route() {
|
|
return {
|
|
base: `wordpress/${extensionType}/v`,
|
|
pattern: ':slug',
|
|
}
|
|
}
|
|
|
|
static get examples() {
|
|
return [
|
|
{
|
|
title: `Wordpress ${capt} Version`,
|
|
exampleUrl: exampleSlug,
|
|
urlPattern: ':slug',
|
|
staticExample: this.render({ response: { version: 2.5 } }),
|
|
keywords: ['wordpress'],
|
|
},
|
|
]
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = ['theme', 'plugin'].map(VersionForExtensionType)
|