Add support for full year display in isocalendar (#10)
* fix(inst): base=0 flag combined with other base.part flags is now correctly handled * ref(plugins): Space adjustements in plugins code * feat(plugins/isocalendar): Add support for full year * feat(repo): Update package.json * fix(plugins/isocalendar): Isocalendar first row sometimes displayed 6 days instead of 7
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
//Check if plugin is enabled and requirements are met
|
||||
if ((!enabled)||(!q.gists))
|
||||
return null
|
||||
|
||||
//Retrieve contribution calendar from graphql api
|
||||
const {user:{gists}} = await graphql(`
|
||||
query Gists {
|
||||
@@ -27,7 +26,6 @@
|
||||
}
|
||||
`
|
||||
)
|
||||
|
||||
//Iterate through gists
|
||||
let stargazers = 0, forks = 0, comments = 0
|
||||
for (const gist of gists.nodes) {
|
||||
@@ -39,7 +37,6 @@
|
||||
forks += gist.forks.totalCount
|
||||
comments += gist.comments.totalCount
|
||||
}
|
||||
|
||||
//Results
|
||||
return {totalCount:gists.totalCount, stargazers, forks, comments}
|
||||
}
|
||||
|
||||
@@ -5,11 +5,14 @@
|
||||
//Check if plugin is enabled and requirements are met
|
||||
if ((!enabled)||(!q.isocalendar))
|
||||
return null
|
||||
//Compute start day (need to start on monday to ensure last row is complete)
|
||||
const from = new Date(Date.now()-180*24*60*60*1000)
|
||||
const day = from.getDay()||7
|
||||
if (day !== 1)
|
||||
from.setHours(-24*(day-1))
|
||||
//Parameters override
|
||||
let {"isocalendar.duration":duration = "half-year"} = q
|
||||
//Duration in days
|
||||
const leap = (new Date(new Date().getYear(), 1, 29).getDate() === 29)
|
||||
const days = {"half-year":180, "full-year":365 + leap}[duration] ?? 180
|
||||
//Compute start day (to ensure last row is complete, we'll retrieve one more week that we'll shift later)
|
||||
const from = new Date(Date.now()-days*24*60*60*1000)
|
||||
from.setHours(-24*7)
|
||||
//Retrieve contribution calendar from graphql api
|
||||
const {user:{calendar:{contributionCalendar:calendar}}} = await graphql(`
|
||||
query Calendar {
|
||||
@@ -29,6 +32,7 @@
|
||||
}
|
||||
`
|
||||
)
|
||||
calendar.weeks.shift()
|
||||
//Compute the highest contributions in a day, streaks and average commits per day
|
||||
let max = 0, streak = {max:0, current:0}, values = [], average = 0
|
||||
for (const week of calendar.weeks) {
|
||||
@@ -44,7 +48,7 @@
|
||||
const size = 6
|
||||
let i = 0, j = 0
|
||||
let svg = `
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" style="margin-top: -52px;" viewBox="0,0 480,170">
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" style="margin-top: -52px;" viewBox="0,0 480,${duration === "full-year" ? 270 : 170}">
|
||||
${[1, 2].map(k => `
|
||||
<filter id="brightness${k}">
|
||||
<feComponentTransfer>
|
||||
@@ -73,7 +77,7 @@
|
||||
}
|
||||
svg += `</g></svg>`
|
||||
//Results
|
||||
return {streak, max, average, svg}
|
||||
return {streak, max, average, svg, duration}
|
||||
}
|
||||
//Handle errors
|
||||
catch (error) {
|
||||
|
||||
@@ -23,14 +23,12 @@
|
||||
//Check if plugin is enabled and requirements are met
|
||||
if ((!enabled)||(!q.music))
|
||||
return null
|
||||
|
||||
//Initialization
|
||||
const raw = {
|
||||
get provider() { return providers[provider]?.name ?? "" },
|
||||
get mode() { return modes[mode] ?? "Unconfigured music plugin"},
|
||||
}
|
||||
let tracks = null
|
||||
|
||||
//Parameters override
|
||||
let {"music.provider":provider = "", "music.mode":mode = "", "music.playlist":playlist = null, "music.limit":limit = 4} = q
|
||||
//Auto-guess parameters
|
||||
@@ -57,7 +55,6 @@
|
||||
}
|
||||
//Limit
|
||||
limit = Math.max(1, Math.min(100, Number(limit)))
|
||||
|
||||
//Handle mode
|
||||
switch (mode) {
|
||||
//Playlist mode
|
||||
|
||||
@@ -5,13 +5,11 @@
|
||||
//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
|
||||
//Limit
|
||||
limit = Math.max(1, Math.min(30, Number(limit)))
|
||||
|
||||
//Retrieve posts
|
||||
let posts = null
|
||||
switch (source) {
|
||||
|
||||
Reference in New Issue
Block a user