diff --git a/.github/config/label.yml b/.github/config/label.yml
index bbba6ab1..f4f16be4 100644
--- a/.github/config/label.yml
+++ b/.github/config/label.yml
@@ -2,7 +2,7 @@
- source/app/action/**
- source/app/web/**
✨ metrics insights:
- - source/app/web/statics/about/**
+ - source/app/web/statics/insights/**
🧩 plugins:
- source/plugins/**
diff --git a/.github/readme/partials/templated/introduction.md b/.github/readme/partials/templated/introduction.md
index 89473dbe..bbe2c3ef 100644
--- a/.github/readme/partials/templated/introduction.md
+++ b/.github/readme/partials/templated/introduction.md
@@ -79,8 +79,8 @@ Generate metrics that can be embedded everywhere, including your GitHub profile
|
diff --git a/.github/readme/partials/templated/plugins.community.md b/.github/readme/partials/templated/plugins.community.md
index 45c398c2..24f76243 100644
--- a/.github/readme/partials/templated/plugins.community.md
+++ b/.github/readme/partials/templated/plugins.community.md
@@ -220,7 +220,8 @@ export default async function(
},
//Settings and tokens
{
- enabled = false
+ enabled = false,
+ extras = false,
} = {}) {
//Plugin execution
try {
@@ -241,7 +242,7 @@ export default async function(
}
//Handle errors
catch (error) {
- throw {error:{message:"An error occured", instance:error}}
+ throw imports.format.error(error)
}
}
```
diff --git a/.github/scripts/preview.mjs b/.github/scripts/preview.mjs
index e7021115..8763bec7 100644
--- a/.github/scripts/preview.mjs
+++ b/.github/scripts/preview.mjs
@@ -9,14 +9,12 @@ const __metrics = paths.join(paths.dirname(url.fileURLToPath(import.meta.url)),
const __templates = paths.join(paths.join(__metrics, "source/templates/"))
const __node_modules = paths.join(paths.join(__metrics, "node_modules"))
const __web = paths.join(paths.join(__metrics, "source/app/web/statics"))
-const __web_about = paths.join(paths.join(__web, "about"))
const __preview = paths.join(paths.join(__web, "preview"))
const __preview_js = paths.join(__preview, ".js")
const __preview_css = paths.join(__preview, ".css")
const __preview_templates = paths.join(__preview, ".templates")
const __preview_templates_ = paths.join(__preview, ".templates_")
-const __preview_about = paths.join(__preview, "about/.statics")
//Extract from web server
const {conf, Templates} = await setup({log: false})
@@ -34,7 +32,6 @@ await fs.mkdir(__preview_js, {recursive: true})
await fs.mkdir(__preview_css, {recursive: true})
await fs.mkdir(__preview_templates, {recursive: true})
await fs.mkdir(__preview_templates_, {recursive: true})
-await fs.mkdir(__preview_about, {recursive: true})
//Web
fs.copyFile(paths.join(__web, "index.html"), paths.join(__preview, "index.html"))
@@ -81,9 +78,15 @@ fs.copyFile(paths.join(__node_modules, "clipboard/dist/clipboard.min.js"), paths
//Meta
fs.writeFile(paths.join(__preview, ".version"), JSON.stringify(`${conf.package.version}-preview`))
fs.writeFile(paths.join(__preview, ".hosted"), JSON.stringify({by: "metrics", link: "https://github.com/lowlighter/metrics"}))
-//About
-fs.copyFile(paths.join(__web, "about", "index.html"), paths.join(__preview, "about", "index.html"))
-for (const file of await fs.readdir(__web_about)) {
- if (file !== ".statics")
- fs.copyFile(paths.join(__web_about, file), paths.join(__preview_about, file))
-}
+//Insights
+for (const insight of ["insights", "about"]) {
+ const __web_insights = paths.join(paths.join(__web, insight))
+ const __preview_insights = paths.join(__preview, `${insight}/.statics`)
+ await fs.mkdir(__preview_insights, {recursive: true})
+
+ fs.copyFile(paths.join(__web, insight, "index.html"), paths.join(__preview, insight, "index.html"))
+ for (const file of await fs.readdir(__web_insights)) {
+ if (file !== ".statics")
+ fs.copyFile(paths.join(__web_insights, file), paths.join(__preview_insights, file))
+ }
+}
\ No newline at end of file
diff --git a/.github/scripts/quickstart/plugin/index.mjs b/.github/scripts/quickstart/plugin/index.mjs
index defb82a8..7f956c21 100644
--- a/.github/scripts/quickstart/plugin/index.mjs
+++ b/.github/scripts/quickstart/plugin/index.mjs
@@ -1,15 +1,15 @@
//Setup
-export default async function({login, q, imports, data, computed, rest, graphql, queries, account}, {enabled = false} = {}) {
+export default async function({login, q, imports, data, computed, rest, graphql, queries, account}, {enabled = false, extras = false} = {}) {
//Plugin execution
try {
//Check if plugin is enabled and requirements are met
- if ((!enabled)||(!q.<%= name %>))
+ if ((!enabled) || (!q.<%= name %>) || (!imports.metadata.plugins.<%= name %>.extras("enabled", {extras})))
return null
//Results
return {}
}
//Handle errors
catch (error) {
- throw {error:{message:"An error occured", instance:error}}
+ throw imports.format.error(error)
}
}
\ No newline at end of file
diff --git a/source/app/metrics/index.mjs b/source/app/metrics/index.mjs
index 463191ce..e1f07278 100644
--- a/source/app/metrics/index.mjs
+++ b/source/app/metrics/index.mjs
@@ -24,7 +24,7 @@ export default async function metrics({login, q}, {graphql, rest, plugins, conf,
//Initialization
const pending = []
const {queries} = conf
- const extras = {css: (conf.settings.extras?.css ?? conf.settings.extras?.default) ? q["extras.css"] ?? "" : "", js: (conf.settings.extras?.js ?? conf.settings.extras?.default) ? q["extras.js"] ?? "" : ""}
+ const extras = {css: imports.metadata.plugins.core.extras("extras_css", {...conf.settings, error:false}) ? q["extras.css"] ?? "" : "", js: imports.metadata.plugins.core.extras("extras_js", {...conf.settings, error:false}) ? q["extras.js"] ?? "" : ""}
const data = {q, animated: true, large: false, base: {}, config: {}, errors: [], plugins: {}, computed: {}, extras, postscripts: []}
const imports = {
plugins: Plugins,
@@ -184,7 +184,7 @@ export default async function metrics({login, q}, {graphql, rest, plugins, conf,
if ((conf.settings?.optimize === true) || (conf.settings?.optimize?.includes?.("svg")))
rendered = await imports.svg.optimize.svg(rendered, q, experimental)
//Verify svg
- if (verify) {
+ if ((verify)&&(imports.metadata.plugins.core.extras("verify", {...conf.settings, error:false}))) {
console.debug(`metrics/compute/${login} > verify SVG`)
let libxmljs = null
try {
@@ -281,9 +281,9 @@ metrics.insights.output = async function({login, imports, conf}, {graphql, rest,
console.debug(`metrics/compute/${login} > insights > generating data`)
const result = await metrics.insights({login}, {graphql, rest, conf}, {Plugins, Templates})
const json = JSON.stringify(result)
- await page.goto(`${server}/about/${login}?embed=1&localstorage=1`)
+ await page.goto(`${server}/insights/${login}?embed=1&localstorage=1`)
await page.evaluate(async json => localStorage.setItem("local.metrics", json), json) //eslint-disable-line no-undef
- await page.goto(`${server}/about/${login}?embed=1&localstorage=1`)
+ await page.goto(`${server}/insights/${login}?embed=1&localstorage=1`)
await page.waitForSelector(".container .user", {timeout: 10 * 60 * 1000})
//Rendering
@@ -297,7 +297,7 @@ metrics.insights.output = async function({login, imports, conf}, {graphql, rest,
${await page.evaluate(() => document.querySelector("main").outerHTML)}
- ${(await Promise.all([".css/style.vars.css", ".css/style.css", "about/.statics/style.css"].map(path => utils.axios.get(`${server}/${path}`)))).map(({data: style}) => ``).join("\n")}
+ ${(await Promise.all([".css/style.vars.css", ".css/style.css", "insights/.statics/style.css"].map(path => utils.axios.get(`${server}/${path}`)))).map(({data: style}) => ``).join("\n")}
|