Refactor readthedocs reddit redmine repology services (#5641)

Co-authored-by: Caleb Cartwright <calebcartwright@users.noreply.github.com>
This commit is contained in:
Thakur Karthik
2020-10-03 20:40:16 +05:30
committed by GitHub
parent a0313437b6
commit 2fa69ba359
5 changed files with 98 additions and 142 deletions

View File

@@ -13,40 +13,32 @@ const schema = Joi.object({
}).required()
module.exports = class ReadTheDocs extends BaseSvgScrapingService {
static get category() {
return 'build'
static category = 'build'
static route = {
base: 'readthedocs',
pattern: ':project/:version?',
}
static get route() {
return {
base: 'readthedocs',
pattern: ':project/:version?',
}
}
static examples = [
{
title: 'Read the Docs',
pattern: ':packageName',
namedParams: { packageName: 'pip' },
staticPreview: this.render({ status: 'passing' }),
keywords,
},
{
title: 'Read the Docs (version)',
pattern: ':packageName/:version',
namedParams: { packageName: 'pip', version: 'stable' },
staticPreview: this.render({ status: 'passing' }),
keywords,
},
]
static get examples() {
return [
{
title: 'Read the Docs',
pattern: ':packageName',
namedParams: { packageName: 'pip' },
staticPreview: this.render({ status: 'passing' }),
keywords,
},
{
title: 'Read the Docs (version)',
pattern: ':packageName/:version',
namedParams: { packageName: 'pip', version: 'stable' },
staticPreview: this.render({ status: 'passing' }),
keywords,
},
]
}
static get defaultBadgeData() {
return {
label: 'docs',
}
static defaultBadgeData = {
label: 'docs',
}
static render({ status }) {

View File

@@ -12,37 +12,29 @@ const schema = Joi.object({
}).required()
module.exports = class RedditSubredditSubscribers extends BaseJsonService {
static get category() {
return 'social'
static category = 'social'
static route = {
base: 'reddit/subreddit-subscribers',
pattern: ':subreddit',
}
static get route() {
return {
base: 'reddit/subreddit-subscribers',
pattern: ':subreddit',
}
}
static get examples() {
return [
{
title: 'Subreddit subscribers',
namedParams: { subreddit: 'drums' },
staticPreview: {
label: 'follow r/drums',
message: '77k',
color: 'red',
style: 'social',
},
static examples = [
{
title: 'Subreddit subscribers',
namedParams: { subreddit: 'drums' },
staticPreview: {
label: 'follow r/drums',
message: '77k',
color: 'red',
style: 'social',
},
]
}
},
]
static get defaultBadgeData() {
return {
label: 'reddit',
namedLogo: 'reddit',
}
static defaultBadgeData = {
label: 'reddit',
namedLogo: 'reddit',
}
static render({ subreddit, subscribers }) {

View File

@@ -13,37 +13,29 @@ const schema = Joi.object({
}).required()
module.exports = class RedditUserKarma extends BaseJsonService {
static get category() {
return 'social'
static category = 'social'
static route = {
base: 'reddit/user-karma',
pattern: ':variant(link|comment|combined)/:user',
}
static get route() {
return {
base: 'reddit/user-karma',
pattern: ':variant(link|comment|combined)/:user',
}
}
static get examples() {
return [
{
title: 'Reddit User Karma',
namedParams: { variant: 'combined', user: 'example' },
staticPreview: {
label: 'combined karma',
message: 56,
color: 'red',
style: 'social',
},
static examples = [
{
title: 'Reddit User Karma',
namedParams: { variant: 'combined', user: 'example' },
staticPreview: {
label: 'combined karma',
message: 56,
color: 'red',
style: 'social',
},
]
}
},
]
static get defaultBadgeData() {
return {
label: 'reddit karma',
namedLogo: 'reddit',
}
static defaultBadgeData = {
label: 'reddit karma',
namedLogo: 'reddit',
}
static render({ variant, karma, user }) {

View File

@@ -12,9 +12,7 @@ const schema = Joi.object({
})
class BaseRedminePluginRating extends BaseXmlService {
static get category() {
return 'rating'
}
static category = 'rating'
static render({ rating }) {
throw new Error(`render() function not implemented for ${this.name}`)
@@ -33,26 +31,20 @@ class BaseRedminePluginRating extends BaseXmlService {
}
class RedminePluginRating extends BaseRedminePluginRating {
static get route() {
return {
base: 'redmine/plugin/rating',
pattern: ':plugin',
}
static route = {
base: 'redmine/plugin/rating',
pattern: ':plugin',
}
static get examples() {
return [
{
title: 'Plugin on redmine.org',
namedParams: { plugin: 'redmine_xlsx_format_issue_exporter' },
staticPreview: this.render({ rating: 5 }),
},
]
}
static examples = [
{
title: 'Plugin on redmine.org',
namedParams: { plugin: 'redmine_xlsx_format_issue_exporter' },
staticPreview: this.render({ rating: 5 }),
},
]
static get defaultBadgeData() {
return { label: 'redmine' }
}
static defaultBadgeData = { label: 'redmine' }
static render({ rating }) {
return {
@@ -64,22 +56,18 @@ class RedminePluginRating extends BaseRedminePluginRating {
}
class RedminePluginStars extends BaseRedminePluginRating {
static get route() {
return {
base: 'redmine/plugin/stars',
pattern: ':plugin',
}
static route = {
base: 'redmine/plugin/stars',
pattern: ':plugin',
}
static get examples() {
return [
{
title: 'Plugin on redmine.org',
namedParams: { plugin: 'redmine_xlsx_format_issue_exporter' },
staticPreview: this.render({ rating: 5 }),
},
]
}
static examples = [
{
title: 'Plugin on redmine.org',
namedParams: { plugin: 'redmine_xlsx_format_issue_exporter' },
staticPreview: this.render({ rating: 5 }),
},
]
static render({ rating }) {
return {

View File

@@ -10,32 +10,24 @@ const schema = Joi.object({
}).required()
module.exports = class RepologyRepositories extends BaseSvgScrapingService {
static get category() {
return 'platform-support'
static category = 'platform-support'
static route = {
base: 'repology/repositories',
pattern: ':projectName',
}
static get route() {
return {
base: 'repology/repositories',
pattern: ':projectName',
}
}
static examples = [
{
title: 'Repology - Repositories',
namedParams: { projectName: 'starship' },
staticPreview: this.render({ repositoryCount: '18' }),
},
]
static get examples() {
return [
{
title: 'Repology - Repositories',
namedParams: { projectName: 'starship' },
staticPreview: this.render({ repositoryCount: '18' }),
},
]
}
static get defaultBadgeData() {
return {
label: 'repositories',
color: 'blue',
}
static defaultBadgeData = {
label: 'repositories',
color: 'blue',
}
static render({ repositoryCount }) {