Fix svg height, add conversion options and options to use differents data from GitHub account (#35)

* Display all features on web instance but disable them when they're not enabled

* Resize dynamically SVG output and add support to convert images to jpeg/png

* Disable animations when computing height

* Add option to disable animations

* Add options to specify different data from used GitHub account

* Update tests
This commit is contained in:
Simon Lecoq
2021-01-02 01:31:04 +01:00
committed by GitHub
parent 93839c6285
commit b649d4811e
19 changed files with 266 additions and 129 deletions

View File

@@ -6,11 +6,10 @@
if ((!enabled)||(!q.pagespeed)||(!data.user.websiteUrl))
return null
//Parameters override
let {"pagespeed.detailed":detailed = false, "pagespeed.screenshot":screenshot = false} = q
let {"pagespeed.detailed":detailed = false, "pagespeed.screenshot":screenshot = false, "pagespeed.url":url = data.user.websiteUrl} = q
//Duration in days
detailed = !!detailed
//Format url if needed
let url = data.user.websiteUrl
if (!/^https?:[/][/]/.test(url))
url = `https://${url}`
const result = {url, detailed, scores:[], metrics:{}}

View File

@@ -1,13 +1,12 @@
//Setup
export default async function ({imports, data, q}, {enabled = false} = {}) {
export default async function ({login, imports, q}, {enabled = false} = {}) {
//Plugin execution
try {
//Check if plugin is enabled and requirements are met
if ((!enabled)||(!q.posts))
return null
//Parameters override
const login = data.user.login
let {"posts.source":source = "", "posts.limit":limit = 4} = q
let {"posts.source":source = "", "posts.limit":limit = 4, "posts.user":user = login} = q
//Limit
limit = Math.max(1, Math.min(30, Number(limit)))
//Retrieve posts
@@ -17,7 +16,7 @@
//Dev.to
case "dev.to":{
console.debug(`metrics/compute/${login}/plugins > posts > querying api`)
posts = (await imports.axios.get(`https://dev.to/api/articles?username=${login}&state=fresh`)).data.map(({title, readable_publish_date:date}) => ({title, date}))
posts = (await imports.axios.get(`https://dev.to/api/articles?username=${user}&state=fresh`)).data.map(({title, readable_publish_date:date}) => ({title, date}))
break
}
//Unsupported

View File

@@ -6,11 +6,10 @@
if ((!enabled)||(!q.tweets))
return null
//Parameters override
let {"tweets.limit":limit = 2} = q
let {"tweets.limit":limit = 2, "tweets.user":username = data.user.twitterUsername} = q
//Limit
limit = Math.max(1, Math.min(10, Number(limit)))
//Load user profile
const username = data.user.twitterUsername
console.debug(`metrics/compute/${login}/plugins > tweets > loading twitter profile (@${username})`)
const {data:{data:profile = null}} = await imports.axios.get(`https://api.twitter.com/2/users/by/username/${username}?user.fields=profile_image_url,verified`, {headers:{Authorization:`Bearer ${token}`}})
//Load tweets