Start music plugin
- New plugin music - Moved imports and util functions - Pass base=0 to disable all base options
This commit is contained in:
@@ -28,12 +28,14 @@
|
||||
lines:"Lines of code changed",
|
||||
habits:"Coding habits",
|
||||
selfskip:"Skip metrics commits",
|
||||
music:"Music plugin",
|
||||
"base.header":"Header",
|
||||
"base.activity":"Account activity",
|
||||
"base.community":"Community stats",
|
||||
"base.repositories":"Repositories metrics",
|
||||
"base.metadata":"Metadata",
|
||||
},
|
||||
options:{},
|
||||
},
|
||||
templates:{
|
||||
list:templates,
|
||||
@@ -59,13 +61,17 @@
|
||||
},
|
||||
//Endpoint to use for computed metrics
|
||||
url() {
|
||||
const plugins = Object.entries(this.plugins.enabled)
|
||||
.flatMap(([key, value]) => key === "base" ? Object.entries(value).map(([key, value]) => [`base.${key}`, value]) : [[key, value]])
|
||||
.filter(([key, value]) => /^base[.]\w+$/.test(key) ? !value : value)
|
||||
.map(([key, value]) => `${key}=${+value}`)
|
||||
const params = [...(this.templates.selected !== templates[0] ? [`template=${this.templates.selected}`] : []), ...plugins].join("&")
|
||||
return `${window.location.protocol}//${window.location.host}/${this.user}${params.length ? `?${params}` : ""}`
|
||||
},
|
||||
//Plugins enabled
|
||||
const plugins = Object.entries(this.plugins.enabled)
|
||||
.flatMap(([key, value]) => key === "base" ? Object.entries(value).map(([key, value]) => [`base.${key}`, value]) : [[key, value]])
|
||||
.filter(([key, value]) => /^base[.]\w+$/.test(key) ? !value : value)
|
||||
.map(([key, value]) => `${key}=${+value}`)
|
||||
//Template
|
||||
const template = (this.templates.selected !== templates[0]) ? [`template=${this.templates.selected}`] : []
|
||||
//Generated url
|
||||
const params = [...template, ...plugins, ...options].join("&")
|
||||
return `${window.location.protocol}//${window.location.host}/${this.user}${params.length ? `?${params}` : ""}`
|
||||
},
|
||||
//Embedded generated code
|
||||
embed() {
|
||||
return `[](https://github.com/lowlighter/metrics)`
|
||||
@@ -144,6 +150,7 @@
|
||||
licenses:{favorite:`########`},
|
||||
plugins:Object.fromEntries(Object.entries(this.plugins.enabled).filter(([key, enabled]) => (key !== "base")&&(enabled)).map(([key]) => {
|
||||
return [key, proxify({
|
||||
music:{provider:"########", tracks:new Array(4).fill({name:"##########", artist:"######", artwork:"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mOcOnfpfwAGfgLYttYINwAAAABJRU5ErkJggg=="})},
|
||||
pagespeed:{scores:["Performance", "Accessibility", "Best Practices", "SEO"].map(title => ({title, score:NaN}))},
|
||||
followup:{issues:{count:0}, pr:{count:0}},
|
||||
habits:{indents:{style:`########`}},
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
import ejs from "ejs"
|
||||
import SVGO from "svgo"
|
||||
import imgb64 from "image-to-base64"
|
||||
import axios from "axios"
|
||||
import Plugins from "./plugins/index.mjs"
|
||||
import Templates from "./templates/index.mjs"
|
||||
import puppeteer from "puppeteer"
|
||||
|
||||
//Setup
|
||||
export default async function metrics({login, q}, {graphql, rest, plugins, conf}) {
|
||||
@@ -33,13 +35,15 @@
|
||||
|
||||
//Base parts
|
||||
data.base = {}
|
||||
if (("base" in q)&&(!q.base))
|
||||
conf.settings.plugins.base.parts.map(part => q[`base.${part}`] = false)
|
||||
for (const part of conf.settings.plugins.base.parts)
|
||||
data.base[part] = (`base.${part}` in q) ? !!q[`base.${part}`] : true
|
||||
|
||||
//Template
|
||||
console.debug(`metrics/compute/${login} > compute`)
|
||||
const computer = Templates[template].default || Templates[template]
|
||||
await computer({login, q}, {conf, data, rest, graphql, plugins}, {s, pending, imports:{plugins:Plugins, imgb64}})
|
||||
await computer({login, q}, {conf, data, rest, graphql, plugins}, {s, pending, imports:{plugins:Plugins, imgb64, axios, puppeteer, format, shuffle}})
|
||||
await Promise.all(pending)
|
||||
console.debug(`metrics/compute/${login} > compute > success`)
|
||||
|
||||
@@ -68,4 +72,19 @@
|
||||
//Generic error
|
||||
throw error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Formatter */
|
||||
function format(n) {
|
||||
for (const {u, v} of [{u:"b", v:10**9}, {u:"m", v:10**6}, {u:"k", v:10**3}])
|
||||
if (n/v >= 1)
|
||||
return `${(n/v).toFixed(2).substr(0, 4).replace(/[.]0*$/, "")}${u}`
|
||||
return n
|
||||
}
|
||||
|
||||
/** Array shuffler */
|
||||
function shuffle(array) {
|
||||
for (let i = array.length-1, j = Math.floor(Math.random()*(i+1)); i > 0; i--)
|
||||
[array[i], array[j]] = [array[j], array[i]]
|
||||
return array
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//Setup
|
||||
export default function ({login, data, computed, pending, q}, {enabled = false} = {}) {
|
||||
export default function ({login, imports, data, computed, pending, q}, {enabled = false} = {}) {
|
||||
//Check if plugin is enabled and requirements are met
|
||||
if (!enabled)
|
||||
return computed.plugins.followup = null
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//Setup
|
||||
export default function ({login, rest, computed, pending, q}, {enabled = false, from = 100} = {}) {
|
||||
export default function ({login, imports, rest, computed, pending, q}, {enabled = false, from:_from = 100} = {}) {
|
||||
//Check if plugin is enabled and requirements are met
|
||||
if (!enabled)
|
||||
return computed.plugins.habits = null
|
||||
@@ -7,11 +7,10 @@
|
||||
return computed.plugins.habits = null
|
||||
console.debug(`metrics/compute/${login}/plugins > habits`)
|
||||
|
||||
//Parameter override
|
||||
if (typeof q["habits.from"] === "number") {
|
||||
from = Math.max(0, Math.min(from, q["habits.from"]))
|
||||
//Parameters override
|
||||
//Events
|
||||
const from = Math.max(1, Math.min(100, "habits.from" in q ? Number(q["habits.from"])||0 : _from))
|
||||
console.debug(`metrics/compute/${login}/plugins > habits > events = ${from}`)
|
||||
}
|
||||
|
||||
//Plugin execution
|
||||
pending.push(new Promise(async solve => {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import habits from "./habits/index.mjs"
|
||||
import languages from "./languages/index.mjs"
|
||||
import lines from "./lines/index.mjs"
|
||||
import music from "./music/index.mjs"
|
||||
import pagespeed from "./pagespeed/index.mjs"
|
||||
import selfskip from "./selfskip/index.mjs"
|
||||
import traffic from "./traffic/index.mjs"
|
||||
@@ -13,6 +14,7 @@
|
||||
habits,
|
||||
languages,
|
||||
lines,
|
||||
music,
|
||||
pagespeed,
|
||||
selfskip,
|
||||
traffic,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//Setup
|
||||
export default function ({login, data, computed, pending, q}, {enabled = false} = {}) {
|
||||
export default function ({login, imports, data, computed, pending, q}, {enabled = false} = {}) {
|
||||
//Check if plugin is enabled and requirements are met
|
||||
if (!enabled)
|
||||
return computed.plugins.languages = null
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
//Formatter
|
||||
function format(n) {
|
||||
for (const {u, v} of [{u:"b", v:10**9}, {u:"m", v:10**6}, {u:"k", v:10**3}])
|
||||
if (n/v >= 1)
|
||||
return `${(n/v).toFixed(2).substr(0, 4).replace(/[.]0*$/, "")}${u}`
|
||||
return n
|
||||
}
|
||||
|
||||
//Setup
|
||||
export default function ({login, repositories = [], rest, computed, pending, q}, {enabled = false} = {}) {
|
||||
export default function ({login, imports, repositories = [], rest, computed, pending, q}, {enabled = false} = {}) {
|
||||
//Check if plugin is enabled and requirements are met
|
||||
if (!enabled)
|
||||
return computed.plugins.lines = null
|
||||
@@ -33,8 +25,8 @@
|
||||
contributor.weeks.forEach(({a, d}) => (lines.added += a, lines.deleted += d))
|
||||
})
|
||||
//Format values
|
||||
lines.added = format(lines.added)
|
||||
lines.deleted = format(lines.deleted)
|
||||
lines.added = imports.format(lines.added)
|
||||
lines.deleted = imports.format(lines.deleted)
|
||||
//Save results
|
||||
computed.plugins.lines = {...lines}
|
||||
console.debug(`metrics/compute/${login}/plugins > lines > success`)
|
||||
|
||||
184
src/plugins/music/index.mjs
Normal file
184
src/plugins/music/index.mjs
Normal file
@@ -0,0 +1,184 @@
|
||||
//Supported providers
|
||||
const providers = {
|
||||
apple:"Apple Music",
|
||||
spotify:"Spotify",
|
||||
}
|
||||
|
||||
//Supported modes
|
||||
const modes = {
|
||||
playlist:"Suggested tracks",
|
||||
recent:"Recently played",
|
||||
}
|
||||
|
||||
//Setup
|
||||
export default function ({login, imports, rest, computed, pending, q}, {enabled = false, token = ""} = {}) {
|
||||
//Check if plugin is enabled and requirements are met
|
||||
if (!enabled)
|
||||
return computed.plugins.music = null
|
||||
if (!q.music)
|
||||
return computed.plugins.music = null
|
||||
console.debug(`metrics/compute/${login}/plugins > music`)
|
||||
|
||||
//Parameters override and checks
|
||||
//Provider
|
||||
const provider = q["music.provider"]||""
|
||||
if (!(provider in providers))
|
||||
return computed.plugins.music = {error:provider ? `Unsupported provider "${provider}"` : `Missing provider`, mode:"Unconfigured music plugin"}
|
||||
console.debug(`metrics/compute/${login}/plugins > music > provider "${provider}"`)
|
||||
//Mode
|
||||
const mode = q["music.mode"]||""
|
||||
if (!(mode in modes))
|
||||
return computed.plugins.music = {error:mode ? `Unsupported mode "${mode}"` : `Missing mode`, provider:providers[provider], mode:"Unconfigured music plugin"}
|
||||
console.debug(`metrics/compute/${login}/plugins > music > mode "${mode}"`)
|
||||
//Playlist mode
|
||||
const playlist = q["music.playlist"]||""
|
||||
if (mode === "playlist") {
|
||||
if (!playlist)
|
||||
return computed.plugins.music = {error:`Missing playlist url`, provider:providers[provider], mode:modes[mode]}
|
||||
if ((provider === "spotify")&&(!/^https:..open.spotify.com.embed.playlist/.test(playlist)))
|
||||
return computed.plugins.music = {error:`Unsupported playlist url format`, provider:providers[provider], mode:modes[mode]}
|
||||
if ((provider === "apple")&&(!/^https:..embed.music.apple.com.\w+.playlist/.test(playlist)))
|
||||
return computed.plugins.music = {error:`Unsupported playlist url format`, provider:providers[provider], mode:modes[mode]}
|
||||
console.debug(`metrics/compute/${login}/plugins > music > playlist = ${playlist}`)
|
||||
}
|
||||
//Limit
|
||||
const limit = Math.max(1, Math.min(100, "music.limit" in q ? Number(q["music.limit"])||0 : 4))
|
||||
console.debug(`metrics/compute/${login}/plugins > music > limit = ${limit}`)
|
||||
|
||||
//Plugin execution
|
||||
pending.push(new Promise(async solve => {
|
||||
//Retrieve music data
|
||||
try {
|
||||
//Initialization
|
||||
let tracks = null
|
||||
//Handle mode
|
||||
switch (mode) {
|
||||
//Playlist mode
|
||||
case "playlist":{
|
||||
//Start puppeteer and navigate to playlist
|
||||
console.debug(`metrics/compute/${login}/plugins > music > starting browser`)
|
||||
const browser = await imports.puppeteer.launch()
|
||||
const page = await browser.newPage()
|
||||
console.debug(`metrics/compute/${login}/plugins > music > loading page`)
|
||||
await page.goto(playlist)
|
||||
const frame = page.mainFrame()
|
||||
//Handle provider
|
||||
switch (provider) {
|
||||
//Apple music
|
||||
case "apple":{
|
||||
//Parse tracklist
|
||||
await frame.waitForSelector(".tracklist.playlist")
|
||||
tracks = [...await frame.evaluate(() => [...document.querySelectorAll(".tracklist li")].map(li => ({
|
||||
name:li.querySelector(".tracklist__track__name").innerText,
|
||||
artist:li.querySelector(".tracklist__track__sub").innerText,
|
||||
artwork:li.querySelector(".tracklist__track__artwork img").src
|
||||
})))]
|
||||
break
|
||||
}
|
||||
//Spotify
|
||||
case "spotify":{
|
||||
//Parse tracklist
|
||||
await frame.waitForSelector("table")
|
||||
tracks = [...await frame.evaluate(() => [...document.querySelectorAll("table tr")].map(tr => ({
|
||||
name:tr.querySelector("td:nth-child(2) div:nth-child(1)").innerText,
|
||||
artist:tr.querySelector("td:nth-child(2) div:nth-child(2)").innerText,
|
||||
//Spotify doesn't provide artworks so we fallback on playlist artwork instead
|
||||
artwork:window.getComputedStyle(document.querySelector("button[title=Play]").parentNode, null).backgroundImage.match(/^url\("(https:...+)"\)$/)[1]
|
||||
})))]
|
||||
break
|
||||
}
|
||||
//Unsupported
|
||||
default:{
|
||||
throw {status:`Unsupported mode "${mode}" for provider "${provider}"`}
|
||||
}
|
||||
}
|
||||
//Close browser
|
||||
console.debug(`metrics/compute/${login}/plugins > music > closing browser`)
|
||||
await browser.close()
|
||||
//Format tracks
|
||||
if (Array.isArray(tracks)) {
|
||||
//Tracks
|
||||
console.debug(`metrics/compute/${login}/plugins > music > found ${tracks.length} tracks`)
|
||||
console.debug(JSON.stringify(tracks))
|
||||
//Shuffle tracks
|
||||
tracks = imports.shuffle(tracks)
|
||||
}
|
||||
break
|
||||
}
|
||||
//Recently played
|
||||
case "recent":{
|
||||
//Initialisation
|
||||
const timestamp = Date.now()-24*60*60*1000
|
||||
//Handle provider
|
||||
switch (provider) {
|
||||
//Spotify
|
||||
case "spotify":{
|
||||
//API call and parse tracklist
|
||||
try {
|
||||
tracks = (await imports.axios(`https://api.spotify.com/v1/me/player/recently-played?limit=${limit}&after=${timestamp}`, {headers:{
|
||||
"Accept":"application/json",
|
||||
"Content-Type":"application/json",
|
||||
"Authorization":`Bearer ${token}`}
|
||||
})).data.items.map(({track}) => ({
|
||||
name:track.name,
|
||||
artist:track.artists[0].name,
|
||||
artwork:track.album.images[0].url,
|
||||
}))
|
||||
}
|
||||
//Handle errors
|
||||
catch (error) {
|
||||
console.debug(error)
|
||||
if ((error.response)&&(error.response.status))
|
||||
throw {status:`API call returned ${error.response.status}`}
|
||||
}
|
||||
break
|
||||
}
|
||||
//Unsupported
|
||||
default:{
|
||||
throw {status:`Unsupported mode "${mode}" for provider "${provider}"`}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
//Unsupported
|
||||
default:{
|
||||
throw {status:`Unsupported mode "${mode}"`}
|
||||
}
|
||||
}
|
||||
//Format tracks
|
||||
if (Array.isArray(tracks)) {
|
||||
//Limit tracklist
|
||||
if (limit > 0) {
|
||||
console.debug(`metrics/compute/${login}/plugins > music > keeping only ${limit} tracks`)
|
||||
tracks = tracks.slice(0, limit)
|
||||
}
|
||||
//Convert artworks to base64
|
||||
console.debug(`metrics/compute/${login}/plugins > music > loading artworks`)
|
||||
for (const track of tracks) {
|
||||
console.debug(`metrics/compute/${login}/plugins > music > processing ${track.name}`)
|
||||
track.artwork = await imports.imgb64(track.artwork)
|
||||
}
|
||||
//Save results
|
||||
console.debug(`metrics/compute/${login}/plugins > music > success`)
|
||||
computed.plugins.music = {provider:providers[provider], mode:modes[mode], tracks}
|
||||
solve()
|
||||
return
|
||||
}
|
||||
//Unhandled error
|
||||
throw {status:`An error occured (unhandled)`}
|
||||
}
|
||||
catch (error) {
|
||||
//Plugin error
|
||||
if (error.status) {
|
||||
computed.plugins.music = {provider:providers[provider], mode:modes[mode], error:error.status}
|
||||
console.debug(`metrics/compute/${login}/plugins > music > error > ${error.status}`)
|
||||
return solve()
|
||||
}
|
||||
//Generic error
|
||||
computed.plugins.music = {provider:providers[provider], mode:modes[mode], error:`An error occured`}
|
||||
console.debug(`metrics/compute/${login}/plugins > music > error`)
|
||||
console.debug(error)
|
||||
solve()
|
||||
}
|
||||
}))
|
||||
}
|
||||
@@ -1,8 +1,5 @@
|
||||
//Imports
|
||||
import axios from "axios"
|
||||
|
||||
//Setup
|
||||
export default function ({login, url, computed, pending, q}, {enabled = false, token = null} = {}) {
|
||||
export default function ({login, imports, url, computed, pending, q}, {enabled = false, token = null} = {}) {
|
||||
//Check if plugin is enabled and requirements are met
|
||||
if (!enabled)
|
||||
return computed.plugins.pagespeed = null
|
||||
@@ -21,7 +18,7 @@
|
||||
//Load scores from API
|
||||
const scores = new Map()
|
||||
await Promise.all(["performance", "accessibility", "best-practices", "seo"].map(async category => {
|
||||
const {score, title} = (await axios.get(`https://www.googleapis.com/pagespeedonline/v5/runPagespeed?category=${category}&url=${url}&key=${token}`)).data.lighthouseResult.categories[category]
|
||||
const {score, title} = (await imports.axios.get(`https://www.googleapis.com/pagespeedonline/v5/runPagespeed?category=${category}&url=${url}&key=${token}`)).data.lighthouseResult.categories[category]
|
||||
scores.set(category, {score, title})
|
||||
}))
|
||||
//Save results
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//Setup
|
||||
export default function ({login, rest, computed, pending, q}, {enabled = false} = {}) {
|
||||
export default function ({login, imports, rest, computed, pending, q}, {enabled = false} = {}) {
|
||||
//Check if plugin is enabled and requirements are met
|
||||
if (!enabled)
|
||||
return computed.plugins.selfskip = null
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
//Formatter
|
||||
function format(n) {
|
||||
for (const {u, v} of [{u:"b", v:10**9}, {u:"m", v:10**6}, {u:"k", v:10**3}])
|
||||
if (n/v >= 1)
|
||||
return `${(n/v).toFixed(2).substr(0, 4).replace(/[.]0*$/, "")}${u}`
|
||||
return n
|
||||
}
|
||||
|
||||
//Setup
|
||||
export default function ({login, repositories = [], rest, computed, pending, q}, {enabled = false} = {}) {
|
||||
export default function ({login, imports, repositories = [], rest, computed, pending, q}, {enabled = false} = {}) {
|
||||
//Check if plugin is enabled and requirements are met
|
||||
if (!enabled)
|
||||
return computed.plugins.traffic = null
|
||||
@@ -24,8 +16,8 @@
|
||||
//Compute views
|
||||
response.filter(({data}) => data).map(({data:{count, uniques}}) => (views.count += count, views.uniques += uniques))
|
||||
//Format values
|
||||
views.count = format(views.count)
|
||||
views.uniques = format(views.uniques)
|
||||
views.count = imports.format(views.count)
|
||||
views.uniques = imports.format(views.uniques)
|
||||
//Save results
|
||||
computed.plugins.traffic = {views}
|
||||
console.debug(`metrics/compute/${login}/plugins > traffic > success`)
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
+ (!!computed.plugins.pagespeed)*126
|
||||
+ (!!computed.plugins.habits)*68
|
||||
+ (!!computed.plugins.languages)*96
|
||||
+ (!!computed.plugins.music)*64 + (computed.plugins.music ? computed.plugins.music.tracks ? 14+Math.max(0, computed.plugins.music.tracks.length-1)*36 : 0 : 0)
|
||||
%>">
|
||||
|
||||
<defs><style><%= fonts %></style></defs>
|
||||
@@ -351,6 +352,50 @@
|
||||
</section>
|
||||
<% } %>
|
||||
|
||||
<% if (computed.plugins.music) { %>
|
||||
<section>
|
||||
<h2 class="field">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0zM8 0a8 8 0 100 16A8 8 0 008 0zM6.379 5.227A.25.25 0 006 5.442v5.117a.25.25 0 00.379.214l4.264-2.559a.25.25 0 000-.428L6.379 5.227z"></path></svg>
|
||||
<%= computed.plugins.music.mode %>
|
||||
</h2>
|
||||
<div class="row fill-width">
|
||||
<section>
|
||||
<% if (computed.plugins.music.provider) { %>
|
||||
<div class="field">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M2.002 2.725a.75.75 0 01.797-.699C8.79 2.42 13.58 7.21 13.974 13.201a.75.75 0 11-1.497.098 10.502 10.502 0 00-9.776-9.776.75.75 0 01-.7-.798zM2 13a1 1 0 112 0 1 1 0 01-2 0zm.84-5.95a.75.75 0 00-.179 1.489c2.509.3 4.5 2.291 4.8 4.8a.75.75 0 101.49-.178A7.003 7.003 0 002.838 7.05z"></path></svg>
|
||||
From <%= computed.plugins.music.provider %>
|
||||
</div>
|
||||
<% } %>
|
||||
<% if (computed.plugins.music.error) { %>
|
||||
<div class="field error">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M4.47.22A.75.75 0 015 0h6a.75.75 0 01.53.22l4.25 4.25c.141.14.22.331.22.53v6a.75.75 0 01-.22.53l-4.25 4.25A.75.75 0 0111 16H5a.75.75 0 01-.53-.22L.22 11.53A.75.75 0 010 11V5a.75.75 0 01.22-.53L4.47.22zm.84 1.28L1.5 5.31v5.38l3.81 3.81h5.38l3.81-3.81V5.31L10.69 1.5H5.31zM8 4a.75.75 0 01.75.75v3.5a.75.75 0 01-1.5 0v-3.5A.75.75 0 018 4zm0 8a1 1 0 100-2 1 1 0 000 2z"></path></svg>
|
||||
<%= computed.plugins.music.error %>
|
||||
</div>
|
||||
<% } else { %>
|
||||
<% if (computed.plugins.music.tracks.length) { %>
|
||||
<div class="tracklist">
|
||||
<% for (const {name = "", artist = "", artwork = ""} of computed.plugins.music.tracks) { %>
|
||||
<div class="track">
|
||||
<img src="data:image/png;base64,<%= artwork %>" width="32" height="32" alt=""/>
|
||||
<div class="infos">
|
||||
<div class="name"><%= name %></div>
|
||||
<div class="artist"><%= artist %></div>
|
||||
</div>
|
||||
</div>
|
||||
<% } %>
|
||||
</div>
|
||||
<% } else { %>
|
||||
<div class="field">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M1.75 1.5a.25.25 0 00-.25.25v9.5c0 .138.112.25.25.25h2a.75.75 0 01.75.75v2.19l2.72-2.72a.75.75 0 01.53-.22h6.5a.25.25 0 00.25-.25v-9.5a.25.25 0 00-.25-.25H1.75zM0 1.75C0 .784.784 0 1.75 0h12.5C15.216 0 16 .784 16 1.75v9.5A1.75 1.75 0 0114.25 13H8.06l-2.573 2.573A1.457 1.457 0 013 14.543V13H1.75A1.75 1.75 0 010 11.25v-9.5zM9 9a1 1 0 11-2 0 1 1 0 012 0zm-.25-5.25a.75.75 0 00-1.5 0v2.5a.75.75 0 001.5 0v-2.5z"></path></svg>
|
||||
No music recently listened
|
||||
</div>
|
||||
<% } %>
|
||||
<% } %>
|
||||
</section>
|
||||
</div>
|
||||
</section>
|
||||
<% } %>
|
||||
|
||||
<% if (base.metadata) { %>
|
||||
<footer>
|
||||
<span>These metrics <%= !computed.token.scopes.includes("repo") ? "does not include" : "includes" %> private contributions</span>
|
||||
|
||||
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 38 KiB |
@@ -189,6 +189,34 @@
|
||||
}
|
||||
}
|
||||
|
||||
/* Music plugin */
|
||||
.tracklist {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
margin-left: 28px;
|
||||
margin-top: 4px;
|
||||
width: 100%;
|
||||
}
|
||||
.track {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.track img {
|
||||
margin: 0 10px;
|
||||
border-radius: 7px;
|
||||
}
|
||||
.track .name {
|
||||
font-size: 14px;
|
||||
line-height: 14px;
|
||||
}
|
||||
.track .artist {
|
||||
font-size: 12px;
|
||||
opacity: .7;
|
||||
}
|
||||
|
||||
/* Fade animation */
|
||||
.af {
|
||||
opacity: 0;
|
||||
|
||||
@@ -7,13 +7,14 @@
|
||||
|
||||
//Plugins
|
||||
if (data.user.websiteUrl)
|
||||
imports.plugins.pagespeed({login, url:data.user.websiteUrl, computed, pending, q}, plugins.pagespeed)
|
||||
imports.plugins.lines({login, repositories:data.user.repositories.nodes.map(({name}) => name), rest, computed, pending, q}, plugins.lines)
|
||||
imports.plugins.traffic({login, repositories:data.user.repositories.nodes.map(({name}) => name), rest, computed, pending, q}, plugins.traffic)
|
||||
imports.plugins.habits({login, rest, computed, pending, q}, plugins.habits)
|
||||
imports.plugins.selfskip({login, rest, computed, pending, q}, plugins.selfskip)
|
||||
imports.plugins.languages({login, data, computed, pending, q}, plugins.languages)
|
||||
imports.plugins.followup({login, data, computed, pending, q}, plugins.followup)
|
||||
imports.plugins.pagespeed({login, imports, url:data.user.websiteUrl, computed, pending, q}, plugins.pagespeed)
|
||||
imports.plugins.music({login, imports, data, computed, pending, q}, plugins.music)
|
||||
imports.plugins.lines({login, imports, repositories:data.user.repositories.nodes.map(({name}) => name), rest, computed, pending, q}, plugins.lines)
|
||||
imports.plugins.traffic({login, imports, repositories:data.user.repositories.nodes.map(({name}) => name), rest, computed, pending, q}, plugins.traffic)
|
||||
imports.plugins.habits({login, imports, rest, computed, pending, q}, plugins.habits)
|
||||
imports.plugins.selfskip({login, imports, rest, computed, pending, q}, plugins.selfskip)
|
||||
imports.plugins.languages({login, imports, data, computed, pending, q}, plugins.languages)
|
||||
imports.plugins.followup({login, imports, data, computed, pending, q}, plugins.followup)
|
||||
|
||||
//Iterate through user's repositories
|
||||
for (const repository of data.user.repositories.nodes) {
|
||||
|
||||
Reference in New Issue
Block a user