Move more badge examples into services/ (#2247)
Continuing the work from #2234, this creates additional, empty LegacyServices to hold the badge examples for conda and cocoapods. It's an approach we could take to finish emptying out all-badge-examples while the refactoring continues. On the website badge, even the first URL path component is variable. I didn't think it could be moved, but it can!
This commit is contained in:
@@ -2,68 +2,6 @@
|
||||
|
||||
const { loadServiceClasses } = require('../services')
|
||||
|
||||
const websiteDoc = `
|
||||
<p>
|
||||
The badge is of the form
|
||||
<code>https://img.shields.io/website[OPTIONS]/PROTOCOL/URLREST.svg</code>,
|
||||
the simplest case being
|
||||
<code>https://img.shields.io/website/http/example.com.svg</code>.
|
||||
More options are described below.
|
||||
</p>
|
||||
<p>
|
||||
The whole URL is obtained by concatenating the <code>PROTOCOL</code>
|
||||
(<code>http</code> or <code>https</code>, for example) with the
|
||||
<code>URLREST</code> (separating them with <code>://</code>).
|
||||
</p>
|
||||
<p>
|
||||
The existence of a specific path on the server can be checked by appending
|
||||
a path after the domain name, e.g.
|
||||
<code>https://img.shields.io/website/http/www.website.com/path/to/page.html.svg</code>.
|
||||
</p>
|
||||
<p>
|
||||
The URLREST should be URLEncoded:
|
||||
<br>
|
||||
<input type="text" id="websiteDocUrlField" placeholder="Paste your URL (without the protocol) here" /><br>
|
||||
<button onclick="(function(el) { el.value = encodeURIComponent(el.value); })(document.getElementById('websiteDocUrlField'))">Encode</button>
|
||||
<button onclick="(function(el) { el.value = decodeURIComponent(el.value); })(document.getElementById('websiteDocUrlField'))">Decode</button>
|
||||
</p>
|
||||
<p>
|
||||
<code>[OPTIONS]</code> can be:
|
||||
<ul>
|
||||
<li>
|
||||
Nothing:
|
||||
<code>…/website/…</code>
|
||||
</li>
|
||||
<li>
|
||||
Online and offline text:
|
||||
<code>…/website-up-down/…</code>
|
||||
</li>
|
||||
<li>
|
||||
Online and offline text, then online and offline colors:
|
||||
<code>…/website-up-down-green-orange/…</code></li>
|
||||
</li>
|
||||
</ul>
|
||||
<table class="centered"><tbody>
|
||||
<tr><td> Dashes <code>--</code>
|
||||
</td><td> →
|
||||
</td><td> <code>-</code> Dash
|
||||
</td></tr>
|
||||
<tr><td> Underscores <code>__</code>
|
||||
</td><td> →
|
||||
</td><td> <code>_</code> Underscore <br/>
|
||||
</td></tr>
|
||||
<tr><td> Slashes <code>//</code>
|
||||
</td><td> →
|
||||
</td><td> <code>/</code> Slash <br/>
|
||||
</td></tr>
|
||||
<tr><td> <code>_</code> or Space <code> </code>
|
||||
</td><td> →
|
||||
</td><td> <code> </code> Space
|
||||
</td></tr>
|
||||
</tbody></table>
|
||||
</p>
|
||||
`
|
||||
|
||||
const githubDoc = `
|
||||
<p>
|
||||
If your GitHub badge errors, it might be because you hit GitHub's rate limits.
|
||||
@@ -186,11 +124,6 @@ const allBadgeExamples = [
|
||||
title: 'PowerShell Gallery',
|
||||
previewUrl: '/powershellgallery/dt/ACMESharp.svg',
|
||||
},
|
||||
{
|
||||
title: 'Conda',
|
||||
previewUrl: '/conda/dn/conda-forge/python.svg',
|
||||
keywords: ['conda'],
|
||||
},
|
||||
{
|
||||
title: 'Crates.io',
|
||||
previewUrl: '/crates/d/rustc-serialize.svg',
|
||||
@@ -389,10 +322,6 @@ const allBadgeExamples = [
|
||||
title: 'Bower',
|
||||
previewUrl: '/bower/l/bootstrap.svg',
|
||||
},
|
||||
{
|
||||
title: 'CocoaPods',
|
||||
previewUrl: '/cocoapods/l/AFNetworking.svg',
|
||||
},
|
||||
{
|
||||
title: 'CPAN',
|
||||
previewUrl: '/cpan/l/Config-Augeas.svg',
|
||||
@@ -522,16 +451,6 @@ const allBadgeExamples = [
|
||||
name: 'Version',
|
||||
},
|
||||
examples: [
|
||||
{
|
||||
title: 'Conda',
|
||||
previewUrl: '/conda/v/conda-forge/python.svg',
|
||||
keywords: ['conda'],
|
||||
},
|
||||
{
|
||||
title: 'Conda (channel only)',
|
||||
previewUrl: '/conda/vn/conda-forge/python.svg',
|
||||
keywords: ['conda'],
|
||||
},
|
||||
{
|
||||
title: 'LuaRocks',
|
||||
previewUrl: '/luarocks/v/mpeterv/luacheck.svg',
|
||||
@@ -556,10 +475,6 @@ const allBadgeExamples = [
|
||||
previewUrl: '/packagist/vpre/symfony/symfony.svg',
|
||||
keywords: ['PHP'],
|
||||
},
|
||||
{
|
||||
title: 'CocoaPods',
|
||||
previewUrl: '/cocoapods/v/AFNetworking.svg',
|
||||
},
|
||||
{
|
||||
title: 'GitHub tag (latest SemVer)',
|
||||
previewUrl: '/github/tag/expressjs/express.svg',
|
||||
@@ -711,32 +626,14 @@ const allBadgeExamples = [
|
||||
id: 'platform-support',
|
||||
name: 'Platform & Version Support',
|
||||
},
|
||||
examples: [
|
||||
{
|
||||
title: 'Conda',
|
||||
previewUrl: '/conda/pn/conda-forge/python.svg',
|
||||
keywords: ['conda'],
|
||||
},
|
||||
{
|
||||
title: 'CocoaPods',
|
||||
previewUrl: '/cocoapods/p/AFNetworking.svg',
|
||||
},
|
||||
],
|
||||
examples: [],
|
||||
},
|
||||
{
|
||||
category: {
|
||||
id: 'monitoring',
|
||||
name: 'Monitoring',
|
||||
},
|
||||
examples: [
|
||||
{
|
||||
title: 'Website',
|
||||
previewUrl:
|
||||
'/website-up-down-green-red/http/shields.io.svg?label=my-website',
|
||||
keywords: ['website'],
|
||||
documentation: websiteDoc,
|
||||
},
|
||||
],
|
||||
examples: [],
|
||||
},
|
||||
{
|
||||
category: {
|
||||
@@ -859,18 +756,6 @@ const allBadgeExamples = [
|
||||
'latest release date',
|
||||
],
|
||||
},
|
||||
{
|
||||
title: 'CocoaPods',
|
||||
previewUrl: '/cocoapods/at/AFNetworking.svg',
|
||||
},
|
||||
{
|
||||
title: 'CocoaPods',
|
||||
previewUrl: '/cocoapods/aw/AFNetworking.svg',
|
||||
},
|
||||
{
|
||||
title: 'CocoaPods',
|
||||
previewUrl: '/cocoapods/metrics/doc-percent/AFNetworking.svg',
|
||||
},
|
||||
{
|
||||
title: 'StackExchange',
|
||||
previewUrl: '/stackexchange/stackoverflow/t/augeas.svg',
|
||||
|
||||
@@ -9,6 +9,29 @@ const {
|
||||
} = require('../../lib/color-formatters')
|
||||
|
||||
module.exports = class CocoapodsApps extends LegacyService {
|
||||
static get category() {
|
||||
return 'other'
|
||||
}
|
||||
|
||||
static get url() {
|
||||
return {
|
||||
base: 'cocoapods',
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Cocoapods apps',
|
||||
previewUrl: 'at/AFNetworking',
|
||||
},
|
||||
{
|
||||
title: 'Cocoapods apps',
|
||||
previewUrl: 'aw/AFNetworking',
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static registerLegacyRouteHandler({ camp, cache }) {
|
||||
camp.route(
|
||||
/^\/cocoapods\/(aw|at)\/(.*)\.(svg|png|gif|jpg|json)$/,
|
||||
|
||||
27
services/cocoapods/cocoapods-license.service.js
Normal file
27
services/cocoapods/cocoapods-license.service.js
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict'
|
||||
|
||||
const LegacyService = require('../legacy-service')
|
||||
|
||||
module.exports = class CocoapodsLicense extends LegacyService {
|
||||
static get category() {
|
||||
return 'license'
|
||||
}
|
||||
|
||||
static get url() {
|
||||
return {
|
||||
base: 'cocoapods/l',
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Cocoapods',
|
||||
previewUrl: 'AFNetworking',
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
// Legacy route handler is defined in cocoapods.service.js.
|
||||
static registerLegacyRouteHandler() {}
|
||||
}
|
||||
@@ -8,6 +8,25 @@ const {
|
||||
} = require('../../lib/color-formatters')
|
||||
|
||||
module.exports = class CocoapodsMetrics extends LegacyService {
|
||||
static get category() {
|
||||
return 'other'
|
||||
}
|
||||
|
||||
static get url() {
|
||||
return {
|
||||
title: 'Cocoapods doc percentage',
|
||||
base: 'cocoapods/metrics/doc-percent',
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
previewUrl: 'AFNetworking',
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static registerLegacyRouteHandler({ camp, cache }) {
|
||||
camp.route(
|
||||
/^\/cocoapods\/metrics\/doc-percent\/(.*)\.(svg|png|gif|jpg|json)$/,
|
||||
|
||||
27
services/cocoapods/cocoapods-platform.service.js
Normal file
27
services/cocoapods/cocoapods-platform.service.js
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict'
|
||||
|
||||
const LegacyService = require('../legacy-service')
|
||||
|
||||
module.exports = class CocoapodsPlatform extends LegacyService {
|
||||
static get category() {
|
||||
return 'platform-support'
|
||||
}
|
||||
|
||||
static get url() {
|
||||
return {
|
||||
base: 'cocoapods/p',
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Cocoapods',
|
||||
previewUrl: 'AFNetworking',
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
// Legacy route handler is defined in cocoapods.service.js.
|
||||
static registerLegacyRouteHandler() {}
|
||||
}
|
||||
27
services/cocoapods/cocoapods-version.service.js
Normal file
27
services/cocoapods/cocoapods-version.service.js
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict'
|
||||
|
||||
const LegacyService = require('../legacy-service')
|
||||
|
||||
module.exports = class CocoapodsVersion extends LegacyService {
|
||||
static get category() {
|
||||
return 'version'
|
||||
}
|
||||
|
||||
static get url() {
|
||||
return {
|
||||
base: 'cocoapods/v',
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Cocoapods',
|
||||
previewUrl: 'AFNetworking',
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
// Legacy route handler is defined in cocoapods.service.js.
|
||||
static registerLegacyRouteHandler() {}
|
||||
}
|
||||
27
services/conda/conda-downloads.service.js
Normal file
27
services/conda/conda-downloads.service.js
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict'
|
||||
|
||||
const LegacyService = require('../legacy-service')
|
||||
|
||||
module.exports = class CondaDownloads extends LegacyService {
|
||||
static get category() {
|
||||
return 'downloads'
|
||||
}
|
||||
|
||||
static get url() {
|
||||
return {
|
||||
base: 'conda',
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Conda',
|
||||
previewUrl: 'dn/conda-forge/python',
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
// Legacy route handler is defined in conda.service.js.
|
||||
static registerLegacyRouteHandler() {}
|
||||
}
|
||||
27
services/conda/conda-platform.service.js
Normal file
27
services/conda/conda-platform.service.js
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict'
|
||||
|
||||
const LegacyService = require('../legacy-service')
|
||||
|
||||
module.exports = class CondaPlatform extends LegacyService {
|
||||
static get category() {
|
||||
return 'platform-support'
|
||||
}
|
||||
|
||||
static get url() {
|
||||
return {
|
||||
base: 'conda',
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Conda',
|
||||
previewUrl: 'pn/conda-forge/python',
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
// Legacy route handler is defined in conda.service.js.
|
||||
static registerLegacyRouteHandler() {}
|
||||
}
|
||||
31
services/conda/conda-version.service.js
Normal file
31
services/conda/conda-version.service.js
Normal file
@@ -0,0 +1,31 @@
|
||||
'use strict'
|
||||
|
||||
const LegacyService = require('../legacy-service')
|
||||
|
||||
module.exports = class CondaDownloads extends LegacyService {
|
||||
static get category() {
|
||||
return 'version'
|
||||
}
|
||||
|
||||
static get url() {
|
||||
return {
|
||||
base: 'conda',
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
title: 'Conda',
|
||||
previewUrl: 'v/conda-forge/python',
|
||||
},
|
||||
{
|
||||
title: 'Conda (channel only)',
|
||||
previewUrl: 'vn/conda-forge/python',
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
// Legacy route handler is defined in conda.service.js.
|
||||
static registerLegacyRouteHandler() {}
|
||||
}
|
||||
@@ -7,8 +7,90 @@ const {
|
||||
} = require('../../lib/badge-data')
|
||||
const { escapeFormatSlashes } = require('../../lib/path-helpers')
|
||||
|
||||
// Test if a webpage is online.
|
||||
const documentation = `
|
||||
<p>
|
||||
The badge is of the form
|
||||
<code>https://img.shields.io/website[OPTIONS]/PROTOCOL/URLREST.svg</code>,
|
||||
the simplest case being
|
||||
<code>https://img.shields.io/website/http/example.com.svg</code>.
|
||||
More options are described below.
|
||||
</p>
|
||||
<p>
|
||||
The whole URL is obtained by concatenating the <code>PROTOCOL</code>
|
||||
(<code>http</code> or <code>https</code>, for example) with the
|
||||
<code>URLREST</code> (separating them with <code>://</code>).
|
||||
</p>
|
||||
<p>
|
||||
The existence of a specific path on the server can be checked by appending
|
||||
a path after the domain name, e.g.
|
||||
<code>https://img.shields.io/website/http/www.website.com/path/to/page.html.svg</code>.
|
||||
</p>
|
||||
<p>
|
||||
The URLREST should be URLEncoded:
|
||||
<br>
|
||||
<input type="text" id="websiteDocUrlField" placeholder="Paste your URL (without the protocol) here" /><br>
|
||||
<button onclick="(function(el) { el.value = encodeURIComponent(el.value); })(document.getElementById('websiteDocUrlField'))">Encode</button>
|
||||
<button onclick="(function(el) { el.value = decodeURIComponent(el.value); })(document.getElementById('websiteDocUrlField'))">Decode</button>
|
||||
</p>
|
||||
<p>
|
||||
<code>[OPTIONS]</code> can be:
|
||||
<ul>
|
||||
<li>
|
||||
Nothing:
|
||||
<code>…/website/…</code>
|
||||
</li>
|
||||
<li>
|
||||
Online and offline text:
|
||||
<code>…/website-up-down/…</code>
|
||||
</li>
|
||||
<li>
|
||||
Online and offline text, then online and offline colors:
|
||||
<code>…/website-up-down-green-orange/…</code></li>
|
||||
</li>
|
||||
</ul>
|
||||
<table class="centered"><tbody>
|
||||
<tr><td> Dashes <code>--</code>
|
||||
</td><td> →
|
||||
</td><td> <code>-</code> Dash
|
||||
</td></tr>
|
||||
<tr><td> Underscores <code>__</code>
|
||||
</td><td> →
|
||||
</td><td> <code>_</code> Underscore <br/>
|
||||
</td></tr>
|
||||
<tr><td> Slashes <code>//</code>
|
||||
</td><td> →
|
||||
</td><td> <code>/</code> Slash <br/>
|
||||
</td></tr>
|
||||
<tr><td> <code>_</code> or Space <code> </code>
|
||||
</td><td> →
|
||||
</td><td> <code> </code> Space
|
||||
</td></tr>
|
||||
</tbody></table>
|
||||
</p>
|
||||
`
|
||||
|
||||
module.exports = class Website extends LegacyService {
|
||||
static get category() {
|
||||
return 'monitoring'
|
||||
}
|
||||
|
||||
static get url() {
|
||||
return {
|
||||
base: '',
|
||||
}
|
||||
}
|
||||
|
||||
static get examples() {
|
||||
return [
|
||||
{
|
||||
previewUrl: 'website-up-down-green-red/https/shields.io',
|
||||
query: { label: 'my-website' },
|
||||
keywords: ['website'],
|
||||
documentation,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
static registerLegacyRouteHandler({ camp, cache }) {
|
||||
camp.route(
|
||||
/^\/website(-(([^-/]|--|\/\/)+)-(([^-/]|--|\/\/)+)(-(([^-/]|--|\/\/)+)-(([^-/]|--|\/\/)+))?)?\/([^/]+)\/(.+)\.(svg|png|gif|jpg|json)$/,
|
||||
|
||||
Reference in New Issue
Block a user