Add activity plugin (#41)
This commit is contained in:
@@ -141,6 +141,7 @@
|
||||
tweets:{enabled:input.bool("plugin_tweets")},
|
||||
stars:{enabled:input.bool("plugin_stars")},
|
||||
stargazers:{enabled:input.bool("plugin_stargazers")},
|
||||
activity:{enabled:input.bool("plugin_activity")},
|
||||
}
|
||||
let q = Object.fromEntries(Object.entries(plugins).filter(([key, plugin]) => plugin.enabled).map(([key]) => [key, true]))
|
||||
info("Plugins enabled", Object.entries(plugins).filter(([key, plugin]) => plugin.enabled).map(([key]) => key))
|
||||
@@ -215,6 +216,13 @@
|
||||
for (const option of ["limit"])
|
||||
info(`Stars ${option}`, q[`stars.${option}`] = input.number(`plugin_stars_${option}`))
|
||||
}
|
||||
//Activity
|
||||
if (plugins.activity.enabled) {
|
||||
for (const option of ["limit", "days"])
|
||||
info(`Activity ${option}`, q[`activity.${option}`] = input.number(`plugin_activity_${option}`))
|
||||
for (const option of ["filter"])
|
||||
info(`Activity ${option}`, q[`activity.${option}`] = input.array(`plugin_activity_${option}`))
|
||||
}
|
||||
|
||||
//Repositories to use
|
||||
const repositories = input.number("repositories")
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
console.debug(`metrics/compute/${login} > render`)
|
||||
let rendered = await ejs.render(image, {...data, s, style, fonts}, {async:true})
|
||||
//Apply resizing
|
||||
const {resized, mime} = await svgresize(rendered, {padding:q["config.padding"], convert})
|
||||
const {resized, mime} = await svgresize(rendered, {paddings:q["config.padding"], convert})
|
||||
rendered = resized
|
||||
|
||||
//Additional SVG transformations
|
||||
@@ -180,16 +180,16 @@
|
||||
}
|
||||
|
||||
/** Render svg */
|
||||
async function svgresize(svg, {padding = "6%", convert} = {}) {
|
||||
async function svgresize(svg, {paddings = "6%", convert} = {}) {
|
||||
//Instantiate browser if needed
|
||||
if (!svgresize.browser) {
|
||||
svgresize.browser = await puppeteer.launch({headless:true, executablePath:process.env.PUPPETEER_BROWSER_PATH, args:["--no-sandbox", "--disable-extensions", "--disable-setuid-sandbox", "--disable-dev-shm-usage"]})
|
||||
console.debug(`metrics/svgresize > started ${await svgresize.browser.version()}`)
|
||||
}
|
||||
//Format padding
|
||||
padding = ((Number(`${padding}`.substring(0, padding.length-1))||0)/100)
|
||||
console.debug(`metrics/svgresize > padding ${(100*padding).toFixed(2)}%`)
|
||||
padding += 1
|
||||
const [pw = 1, ph] = paddings.split(",").map(padding => `${padding}`.substring(0, padding.length-1)).map(value => 1+Number(value)/100)
|
||||
const padding = {width:pw, height:ph ?? pw}
|
||||
console.debug(`metrics/svgresize > padding width*${padding.width}, height*${padding.height}`)
|
||||
//Render through browser and resize height
|
||||
const page = await svgresize.browser.newPage()
|
||||
await page.setContent(svg, {waitUntil:"load"})
|
||||
@@ -201,8 +201,8 @@
|
||||
document.querySelector("svg").classList.add("no-animations")
|
||||
//Get bounds and resize
|
||||
let {y:height, width} = document.querySelector("svg #metrics-end").getBoundingClientRect()
|
||||
height = Math.ceil(height*padding)
|
||||
width = Math.ceil(width)
|
||||
height = Math.ceil(height*padding.height)
|
||||
width = Math.ceil(width*padding.width)
|
||||
//Resize svg
|
||||
document.querySelector("svg").setAttribute("height", height)
|
||||
//Enable animations
|
||||
@@ -270,6 +270,7 @@
|
||||
projects:{list:[...new Array(2).fill(null).map(() => ({name:"########", updated:"########", progress:{enabled:true, todo:"##", doing:"##", done:"##", total:"##"}}))]},
|
||||
tweets:{profile:{username:"########", verified:false}, list:[...new Array(2).fill(null).map(() => ({text:"###### ###### ####### ######".repeat(4), created_at:Date.now()}))]},
|
||||
stars:{repositories:[...new Array(2).fill({node:{nameWithOwner:"########/########", description:"###### ###### ####### ######".repeat(4)}})]},
|
||||
activity:{events:[{type:"comment", on:"pr"}, {type:"public"}, {type:"release"}, {type:"issue"}]}
|
||||
}[key]??{})]
|
||||
)),
|
||||
})
|
||||
|
||||
@@ -434,32 +434,316 @@
|
||||
status:"200 OK",
|
||||
"x-oauth-scopes":"repo",
|
||||
},
|
||||
data:page < 1 ? new Array(10).fill(null).map(() =>
|
||||
(false ? {
|
||||
id:"10000000001",
|
||||
type:"IssueCommentEvent",
|
||||
} : {
|
||||
data:page < 1 ? [] : [
|
||||
{
|
||||
id:"10000000000",
|
||||
type:"PushEvent",
|
||||
type:"CommitCommentEvent",
|
||||
actor:{
|
||||
id:22963968,
|
||||
login:"lowlighter",
|
||||
},
|
||||
repo: {
|
||||
id:293860197,
|
||||
repo:{
|
||||
name:"lowlighter/metrics",
|
||||
},
|
||||
payload: {
|
||||
ref:"refs/heads/master",
|
||||
commits: [
|
||||
payload:{
|
||||
comment:{
|
||||
user:{
|
||||
login:"lowlighter",
|
||||
},
|
||||
path:"README.md",
|
||||
commit_id:"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
body:"This is a commit comment",
|
||||
}
|
||||
},
|
||||
created_at:new Date(Date.now()-Math.floor(-Math.random()*14)*Math.floor(-Math.random()*24)*60*60*1000).toISOString(),
|
||||
},
|
||||
{
|
||||
id:"10000000001",
|
||||
type:"PullRequestReviewCommentEvent",
|
||||
actor:{
|
||||
login:"lowlighter",
|
||||
},
|
||||
repo:{
|
||||
name:"lowlighter/metrics",
|
||||
},
|
||||
payload:{
|
||||
action:"created",
|
||||
comment:{
|
||||
user:{
|
||||
login:"lowlighter",
|
||||
},
|
||||
body:"This is pull request review comment",
|
||||
},
|
||||
pull_request:{
|
||||
title:"Pull request example",
|
||||
number:1,
|
||||
user:{
|
||||
login:"lowlighter",
|
||||
},
|
||||
body:"",
|
||||
}
|
||||
},
|
||||
created_at:new Date(Date.now()-Math.floor(-Math.random()*14)*Math.floor(-Math.random()*24)*60*60*1000).toISOString(),
|
||||
},
|
||||
{
|
||||
id:"10000000002",
|
||||
type:"IssuesEvent",
|
||||
actor:{
|
||||
login:"lowlighter",
|
||||
},
|
||||
repo:{
|
||||
name:"lowlighter/metrics",
|
||||
},
|
||||
payload:{
|
||||
action:"closed",
|
||||
issue:{
|
||||
number:2,
|
||||
title:"Issue example",
|
||||
user:{
|
||||
login:"lowlighter",
|
||||
},
|
||||
body:"Hello this is an example",
|
||||
performed_via_github_app: null
|
||||
}
|
||||
},
|
||||
created_at:new Date(Date.now()-Math.floor(-Math.random()*14)*Math.floor(-Math.random()*24)*60*60*1000).toISOString(),
|
||||
},
|
||||
{
|
||||
id:"10000000003",
|
||||
type:"GollumEvent",
|
||||
actor:{
|
||||
login:"lowlighter",
|
||||
},
|
||||
repo:{
|
||||
name:"lowlighter/lowlighter",
|
||||
},
|
||||
payload:{
|
||||
pages:[
|
||||
{
|
||||
url:"https://api.github.com/repos/lowlighter/metrics/commits/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||
page_name:"Home",
|
||||
title:"Home",
|
||||
summary:null,
|
||||
action:"created",
|
||||
sha:"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
}
|
||||
]
|
||||
},
|
||||
created_at:new Date(Date.now()-Math.floor(-Math.random()*14)*Math.floor(-Math.random()*24)*60*60*1000).toISOString()
|
||||
})
|
||||
) : []
|
||||
created_at:new Date(Date.now()-Math.floor(-Math.random()*14)*Math.floor(-Math.random()*24)*60*60*1000).toISOString(),
|
||||
},
|
||||
{
|
||||
id:"10000000004",
|
||||
type:"IssueCommentEvent",
|
||||
actor:{
|
||||
login:"lowlighter",
|
||||
},
|
||||
repo:{
|
||||
name:"lowlighter/metrics",
|
||||
},
|
||||
payload:{
|
||||
action:"created",
|
||||
issue:{
|
||||
number:3,
|
||||
title:"Issue example",
|
||||
user:{
|
||||
login:"lowlighter",
|
||||
},
|
||||
labels:[
|
||||
{
|
||||
name:"question",
|
||||
color:"d876e3",
|
||||
}
|
||||
],
|
||||
state:"open",
|
||||
},
|
||||
comment:{
|
||||
body:"Hello world !",
|
||||
performed_via_github_app: null
|
||||
}
|
||||
},
|
||||
created_at:new Date(Date.now()-Math.floor(-Math.random()*14)*Math.floor(-Math.random()*24)*60*60*1000).toISOString(),
|
||||
},
|
||||
{
|
||||
id:"10000000005",
|
||||
type:"ForkEvent",
|
||||
actor:{
|
||||
login:"lowlighter",
|
||||
},
|
||||
repo:{
|
||||
id:327522930,
|
||||
name:"lowlighter/gracidea",
|
||||
},
|
||||
payload:{
|
||||
forkee:{
|
||||
name:"gracidea",
|
||||
full_name:"lowlighter/gracidea",
|
||||
}
|
||||
},
|
||||
created_at:new Date(Date.now()-Math.floor(-Math.random()*14)*Math.floor(-Math.random()*24)*60*60*1000).toISOString(),
|
||||
},
|
||||
{
|
||||
id:"10000000006",
|
||||
type:"PullRequestReviewEvent",
|
||||
actor:{
|
||||
login:"lowlighter",
|
||||
},
|
||||
repo:{
|
||||
name:"lowlighter/metrics",
|
||||
},
|
||||
payload:{
|
||||
action:"created",
|
||||
review:{
|
||||
user:{
|
||||
login:"lowlighter",
|
||||
},
|
||||
state:"approved",
|
||||
},
|
||||
pull_request:{
|
||||
state:"open",
|
||||
number:4,
|
||||
locked:false,
|
||||
title:"Pull request example",
|
||||
user:{
|
||||
login:"user",
|
||||
},
|
||||
}
|
||||
},
|
||||
created_at:new Date(Date.now()-Math.floor(-Math.random()*14)*Math.floor(-Math.random()*24)*60*60*1000).toISOString(),
|
||||
},
|
||||
{
|
||||
id:"10000000007",
|
||||
type:"ReleaseEvent",
|
||||
actor:{
|
||||
login:"lowlighter",
|
||||
},
|
||||
repo:{
|
||||
name:"lowlighter/metrics",
|
||||
},
|
||||
payload:{
|
||||
action:"published",
|
||||
release:{
|
||||
tag_name:"v3.1",
|
||||
name:"Version 3.1",
|
||||
draft: false,
|
||||
prerelease: true,
|
||||
}
|
||||
},
|
||||
created_at:new Date(Date.now()-Math.floor(-Math.random()*14)*Math.floor(-Math.random()*24)*60*60*1000).toISOString(),
|
||||
},
|
||||
{
|
||||
id:"10000000008",
|
||||
type:"CreateEvent",
|
||||
actor:{
|
||||
login:"lowlighter",
|
||||
},
|
||||
repo:{
|
||||
name:"lowlighter/metrics",
|
||||
},
|
||||
payload:{
|
||||
ref:"feat-new-plugin",
|
||||
ref_type:"branch",
|
||||
master_branch:"master",
|
||||
},
|
||||
created_at:new Date(Date.now()-Math.floor(-Math.random()*14)*Math.floor(-Math.random()*24)*60*60*1000).toISOString(),
|
||||
},
|
||||
{
|
||||
id:"100000000009",
|
||||
type:"WatchEvent",
|
||||
actor:{
|
||||
login:"lowlighter",
|
||||
},
|
||||
repo:{
|
||||
name:"lowlighter/gracidea",
|
||||
},
|
||||
payload:{action:"started"},
|
||||
created_at:new Date(Date.now()-Math.floor(-Math.random()*14)*Math.floor(-Math.random()*24)*60*60*1000).toISOString(),
|
||||
},
|
||||
{
|
||||
id:"10000000010",
|
||||
type:"DeleteEvent",
|
||||
actor:{
|
||||
login:"lowlighter",
|
||||
},
|
||||
repo:{
|
||||
name:"lowlighter/metrics",
|
||||
},
|
||||
payload:{
|
||||
ref:"feat-plugin-merged",
|
||||
ref_type:"branch",
|
||||
},
|
||||
created_at:new Date(Date.now()-Math.floor(-Math.random()*14)*Math.floor(-Math.random()*24)*60*60*1000).toISOString(),
|
||||
},
|
||||
{
|
||||
id:"10000000011",
|
||||
type:"PushEvent",
|
||||
actor:{
|
||||
login:"lowlighter",
|
||||
},
|
||||
repo:{
|
||||
name:"lowlighter/metrics",
|
||||
},
|
||||
payload:{
|
||||
size:1,
|
||||
ref:"refs/heads/master",
|
||||
commits:[
|
||||
{
|
||||
sha:"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
message:"Commit example",
|
||||
}
|
||||
]
|
||||
},
|
||||
created_at:new Date(Date.now()-Math.floor(-Math.random()*14)*Math.floor(-Math.random()*24)*60*60*1000).toISOString(),
|
||||
},
|
||||
{
|
||||
id:"10000000012",
|
||||
type:"PullRequestEvent",
|
||||
actor:{
|
||||
login:"lowlighter",
|
||||
},
|
||||
repo:{
|
||||
name:"lowlighter/metrics",
|
||||
},
|
||||
payload:{
|
||||
action:"opened",
|
||||
number:5,
|
||||
pull_request:{
|
||||
state:"open",
|
||||
title:"Pull request example",
|
||||
additions:210,
|
||||
deletions:126,
|
||||
changed_files:10,
|
||||
}
|
||||
},
|
||||
created_at:new Date(Date.now()-Math.floor(-Math.random()*14)*Math.floor(-Math.random()*24)*60*60*1000).toISOString(),
|
||||
},
|
||||
{
|
||||
id:"10000000013",
|
||||
type:"MemberEvent",
|
||||
actor:{
|
||||
login:"lowlighter",
|
||||
},
|
||||
repo:{
|
||||
name:"lowlighter/metrics",
|
||||
},
|
||||
payload:{
|
||||
member:{
|
||||
login:"botlighter",
|
||||
},
|
||||
action:"added"
|
||||
},
|
||||
created_at:new Date(Date.now()-Math.floor(-Math.random()*14)*Math.floor(-Math.random()*24)*60*60*1000).toISOString(),
|
||||
},
|
||||
{
|
||||
id:"10000000014",
|
||||
type:"PublicEvent",
|
||||
actor:{
|
||||
login:"lowlighter",
|
||||
},
|
||||
repo:{
|
||||
name:"lowlighter/metrics",
|
||||
},
|
||||
payload:{},
|
||||
created_at:new Date(Date.now()-Math.floor(-Math.random()*14)*Math.floor(-Math.random()*24)*60*60*1000).toISOString(),
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
@@ -72,6 +72,7 @@
|
||||
const actions = {flush:new Map()}
|
||||
app.get("/", limiter, (req, res) => res.sendFile(`${conf.statics}/index.html`))
|
||||
app.get("/index.html", limiter, (req, res) => res.sendFile(`${conf.statics}/index.html`))
|
||||
app.get("/favicon.ico", limiter, (req, res) => res.sendFile(`${conf.statics}/favicon.png`))
|
||||
app.get("/.favicon.png", limiter, (req, res) => res.sendFile(`${conf.statics}/favicon.png`))
|
||||
app.get("/.opengraph.png", limiter, (req, res) => res.sendFile(`${conf.statics}/opengraph.png`))
|
||||
app.get("/.version", limiter, (req, res) => res.status(200).send(conf.package.version))
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
tweets:"🐤 Latest tweets",
|
||||
stars:"🌟 Recently starred repositories",
|
||||
stargazers:"✨ Stargazers over last weeks",
|
||||
activity:"📰 Recent activity",
|
||||
"base.header":`
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M0 8a8 8 0 1116 0v5.25a.75.75 0 01-1.5 0V8a6.5 6.5 0 10-13 0v5.25a.75.75 0 01-1.5 0V8zm5.5 4.25a.75.75 0 01.75-.75h3.5a.75.75 0 010 1.5h-3.5a.75.75 0 01-.75-.75zM3 6.75C3 5.784 3.784 5 4.75 5h6.5c.966 0 1.75.784 1.75 1.75v1.5A1.75 1.75 0 0111.25 10h-6.5A1.75 1.75 0 013 8.25v-1.5zm1.47-.53a.75.75 0 011.06 0l.97.97.97-.97a.75.75 0 011.06 0l.97.97.97-.97a.75.75 0 111.06 1.06l-1.5 1.5a.75.75 0 01-1.06 0L8 7.81l-.97.97a.75.75 0 01-1.06 0l-1.5-1.5a.75.75 0 010-1.06z"></path></svg>
|
||||
Header`,
|
||||
@@ -95,6 +96,7 @@
|
||||
"topics.limit":12,
|
||||
"tweets.limit":2,
|
||||
"stars.limit":4,
|
||||
"activity.limit":5,
|
||||
},
|
||||
},
|
||||
templates:{
|
||||
|
||||
@@ -112,7 +112,7 @@
|
||||
</div>
|
||||
|
||||
<!-- Plugins options -->
|
||||
<div class="step" v-if="(plugins.enabled.tweets)||(plugins.enabled.music)||(plugins.enabled.pagespeed)||(plugins.enabled.languages)||(plugins.enabled.habits)||(plugins.enabled.posts)||(plugins.enabled.isocalendar)||(plugins.enabled.projects)||(plugins.enabled.topics)">
|
||||
<div class="step" v-if="(plugins.enabled.tweets)||(plugins.enabled.music)||(plugins.enabled.pagespeed)||(plugins.enabled.languages)||(plugins.enabled.habits)||(plugins.enabled.posts)||(plugins.enabled.isocalendar)||(plugins.enabled.projects)||(plugins.enabled.topics)||(plugins.enabled.activity)">
|
||||
<h2>🔧 Configure plugins</h2>
|
||||
<div class="options">
|
||||
<div class="options-group" v-if="plugins.enabled.tweets">
|
||||
@@ -231,6 +231,13 @@
|
||||
<input type="text" v-model="plugins.options['projects.repositories']" @change="load" :disabled="generated.pending">
|
||||
</label>
|
||||
</div>
|
||||
<div class="options-group" v-if="plugins.enabled.activity">
|
||||
<h4>{{ plugins.descriptions.activity }}</h4>
|
||||
<label>
|
||||
Number of activity events to display
|
||||
<input type="number" v-model="plugins.options['activity.limit']" min="1" max="10" @change="load" :disabled="generated.pending">
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user