### Setup and Data Fetching Scripts Source: https://context7.com/w3c/spec-dashboard/llms.txt Steps to set up the project by copying the configuration file and then fetching various data using Node.js scripts. The `--update-issues` flag is used for group-specs. ```bash # Setup steps: cp config.json.dist config.json # Edit config.json with your GitHub API token # Fetch all data: node fetch-data/groups.js node fetch-data/group-specs.js node fetch-data/group-repos.js --update-issues ``` -------------------------------- ### Create and Configure config.json Source: https://context7.com/w3c/spec-dashboard/llms.txt Create the config.json file from the distribution file and add your GitHub API token. This file is required for accessing W3C and GitHub APIs. ```json // config.json (create from config.json.dist) { "ethercalc": "https://ethercalc.example.com", "ghapitoken": "ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" } ``` -------------------------------- ### Build Repository Map Source: https://context7.com/w3c/spec-dashboard/llms.txt Generate a JSON file mapping repositories using a Node.js script. The output is redirected to repo-map.json. ```bash # Build repo map: node build-repo-map.js > repo-map.json ``` -------------------------------- ### Serve Dashboard Locally Source: https://context7.com/w3c/spec-dashboard/llms.txt Serve the dashboard locally using Python's built-in HTTP server on port 8000. Access the dashboard via http://localhost:8000/index.html. ```bash # Serve locally: python -m http.server 8000 # Open http://localhost:8000/index.html ``` -------------------------------- ### Fetch Specifications for Working Groups Source: https://context7.com/w3c/spec-dashboard/llms.txt Retrieves active specifications for each Working Group, including version history and editor's draft URLs, saving them into per-group JSON files. This script requires the 'groups.json' file to be pre-populated. ```javascript // fetch-data/group-specs.js const fs = require('fs/promises'), utils = require('../lib/utils'), activespecs = require('../lib/active-specs'), w3c = require('node-w3capi'); (async function() { const groups = await w3c.groups().fetch({embed:true}); const workinggroups = groups.filter(g => g.type === 'working group'); for (const wg of workinggroups) { const unfinishedSpecs = await activespecs({shortname: wg.shortname, type: "wg"}); if (!unfinishedSpecs || !unfinishedSpecs.length) { console.error("no spec found for " + wg.name); continue; } for (const s of unfinishedSpecs) { const datedversion = await w3c.specification(s.shortname) .version(utils.specDate(s)).fetch(); s.editorsdraft = datedversion ? datedversion["editor-draft"] : null; s.versions = await w3c.specification(s.shortname).versions().fetch({embed:true}); } fs.writeFile("./pergroup/" + wg.id + ".json", JSON.stringify(unfinishedSpecs, null, 2)); } fs.writeFile("./pergroup/spec-update.json", JSON.stringify(new Date())); })().catch(err => console.error(err)); // Run with: node fetch-data/group-specs.js // Output: pergroup/32061.json, pergroup/19480.json, etc. ``` -------------------------------- ### Fetch W3C Working Groups List Source: https://context7.com/w3c/spec-dashboard/llms.txt Retrieves all W3C Working Groups from the W3C API and saves essential metadata to a local JSON file. Run this script to populate the list of groups for subsequent data fetching. ```javascript // fetch-data/groups.js const fs = require('fs/promises'); (async function() { const workinggroups = await (await fetch("https://api.w3.org/groups/wg?embed=1")).json(); fs.writeFile("groups.json", JSON.stringify( workinggroups._embedded.groups.map(g => { return { id: g.id, shortname: g.shortname, start: g["start-date"], end: g["end-date"], name: g.name }; }).reduce((a, b) => { a[b.id] = b; return a; }, {}) , null, 2)); })(); // Run with: node fetch-data/groups.js // Output: groups.json containing: // { // "32061": { // "id": 32061, // "shortname": "css", // "start": "1997-02-28", // "end": "2027-03-17", // "name": "Cascading Style Sheets (CSS) Working Group" // }, // ... // } ``` -------------------------------- ### D3.js Specification Timeline Visualization Source: https://context7.com/w3c/spec-dashboard/llms.txt Visualizes W3C specification progress through recommendation stages using D3.js. It includes pan/zoom and color-coded status indicators. Requires 'groups.json' for data. ```javascript // plot.js - Dashboard visualization const recStages = ["FPWD", "WD", "WR/LC", "CR", "PR", "REC"]; // Status normalizer maps W3C API status to display stages const statusNormalizer = version => { switch(version.status) { case "Candidate Recommendation": case "Candidate Recommendation Draft": case "Candidate Recommendation Snapshot": return "CR"; case "Proposed Recommendation": return "PR"; case "Recommendation": return "REC"; case "Working Draft": return version._links["predecessor-version"] ? "WD" : "FPWD"; case "First Public Working Draft": return "FPWD"; } return version.status; }; // Duration color scheme: green (recent) -> yellow -> red (stale) var durationColorScheme = d3.scaleLinear() .domain([3, 6, 12, 24]) .range(["#afa", "white", "yellow", "red"]); // Load and display dashboard for a working group fetch("groups.json") .then(r => r.json()) .then(groups => { if (groupid) { dashboard(groupid, groups[groupid]); } }); // Access dashboard at: index.html?32061 (for CSS Working Group) // Each specification shows as a line with circles at each publication milestone ``` -------------------------------- ### Generate Cross-Group Repository Map Source: https://context7.com/w3c/spec-dashboard/llms.txt Consolidates GitHub repository mappings from individual group JSON files into a single map. Outputs a JSON object where keys are repository names and values are arrays of associated specifications. ```javascript // build-repo-map.js const fs = require("fs"); const repos = {}; fs.readdir('./pergroup/', (err, files) => { files.filter(f => f.match('[0-9]+-repo\.json')) .forEach(file => { const groupSpecs = JSON.parse(fs.readFileSync('./pergroup/' + file, 'utf-8')); Object.keys(groupSpecs).forEach(url => { const spec = groupSpecs[url]; const repo = spec.repo.owner + '/' + spec.repo.name; const specData = { title: spec.title, recTrack: spec.recTrack, url: url, group: parseInt(file.match(/^([0-9]+)/)[1], 10) }; if (!repos[repo]) { repos[repo] = []; } repos[repo].push(specData); }); }); console.log(JSON.stringify(repos, null, 2)); }); // Run with: node build-repo-map.js > repo-map.json // Output example: // { // "w3c/csswg-drafts": [ // {"title": "CSS Grid Layout", "recTrack": true, "url": "https://www.w3.org/TR/css-grid-1/", "group": 32061}, // {"title": "CSS Flexbox", "recTrack": true, "url": "https://www.w3.org/TR/css-flexbox-1/", "group": 32061} // ] // } ``` -------------------------------- ### D3.js GitHub Issue Tracking Visualization Source: https://context7.com/w3c/spec-dashboard/llms.txt Generates a D3.js stacked bar chart for GitHub issue lifecycles. It uses color-coding for issue age and supports toggling between stack and trail views. Requires repoinfo object. ```javascript // issue-plot.js - Issue tracking visualization function dashboard(repoinfo) { const issues = repoinfo.issues.filter(i => !i.isPullRequest); const repo = repoinfo.repo; // Duration color scheme for issue age var durations = { "-1": "issue closed during that month", 0: "issue raised during that month", 1: "1 month old", 6: "6 months old", 24: "2 years old" }; var durationColorScheme = d3.scaleLinear() .domain([-1, 0, 1, 6, 24]) .range(["#66f", "#afa", "white", "yellow", "red"]); // Build monthly issue counts var months = {}; issues.forEach(function(i) { const startMonth = i.created_at.slice(0,7); const endMonth = i.closed_at ? i.closed_at.slice(0,7) : currentMonth; // Track issue presence in each month let curMonth = startMonth; while (curMonth <= endMonth) { if (!months[curMonth]) months[curMonth] = []; months[curMonth].push(i.number); curMonth = nextMonth(curMonth); } }); // Render interactive chart with links to GitHub issues svg.selectAll("a.issue") .data(issues) .enter() .append("a") .attr("xlink:href", d => `https://github.com/${repo.owner}/${repo.name}/issues/${d.number}` ); } // Access at: issues.html?groupid=32061&shortname=css-grid-1 ``` -------------------------------- ### Parse GitHub Repository from Editor's Draft URL Source: https://context7.com/w3c/spec-dashboard/llms.txt Parses various URL formats (e.g., GitHub Pages, CSSWG drafts, WHATWG) to extract GitHub repository owner and name. Includes a custom issue filter for CSSWG drafts. ```javascript // fetch-data/group-repos.js const fs = require('fs'), config = require('../config.json'), ghrequest = require('gh-api-request'); ghrequest.ghToken = config.ghapitoken; ghrequest.userAgent = 'W3C spec dashboard https://github.com/w3c/spec-dashboard'; // URL parser to extract GitHub repo from editor's draft URL const urlToGHRepo = (url = "", tr_shortname) => { const nofilter = x => true; const versionless = s => s.replace(/-[0-9]*$/,''); // GitHub Pages pattern: https://user.github.io/repo/ const githubio = url.match(/^https?:\/\/([^\.]*)\.github\.io\/([^\/]*)\/?/); if (githubio) { return {owner: githubio[1], name: githubio[2], issuefilter: nofilter}; } // CSSWG drafts pattern: https://drafts.csswg.org/css-foo/ const csswg = url.match(/^https?:\/\/drafts.csswg.org\/([^\/]*)\/?/); if (csswg) { const cssIssueFilter = shortname => x => x.title.match(new RegExp("\^\[" + versionless(shortname) + "\]")); return {owner: 'w3c', name: 'csswg-drafts', issuefilter: cssIssueFilter(csswg[1])}; } // WHATWG pattern: https://foo.spec.whatwg.org/ const whatwg = url.match(/https:\/\/([^\.]*).spec.whatwg.org\//); if (whatwg) { return {owner: "whatwg", name: whatwg[1], issuefilter: nofilter}; } return undefined; }; // Run with: node fetch-data/group-repos.js // Run with issues update: node fetch-data/group-repos.js --update-issues // Output: pergroup/32061-repo.json, etc. ``` -------------------------------- ### Filter Active W3C Specifications Source: https://context7.com/w3c/spec-dashboard/llms.txt Filters W3C specifications to include only active ones, excluding 'Retired', 'Discontinued', 'Group Note', or 'Recommendation' statuses. Requires the 'node-w3capi' library. ```javascript // lib/active-specs.js const w3c = require('node-w3capi'), utils = require('./utils'); const relevantSpecStatus = status => !['Retired', 'Discontinued', 'Group Note', 'Recommendation'].includes(status); module.exports = async function(wgshortname, cb) { const specs = await w3c.group(wgshortname).specifications().fetch({embed: true}); // Filter: not superseded and not finished const unfinishedSpecs = specs.filter(s => s._links && !s._links['superseded-by'] && relevantSpecStatus(s._links['latest-version'].title) ).sort((s1, s2) => shortNamer(s1.shortlink).localeCompare(shortNamer(s2.shortlink)) ); return unfinishedSpecs; }; // Usage: // const activespecs = require('./lib/active-specs'); // const specs = await activespecs({shortname: 'css', type: 'wg'}); // Returns array of active CSS Working Group specifications ``` -------------------------------- ### W3C Specification Health Report Generator Source: https://context7.com/w3c/spec-dashboard/llms.txt Generates health reports for W3C specifications, identifying issues like late CR Snapshots, abandoned specs, long-running specs, and those without known repositories. Fetches data from 'groups.json' and per-group JSON files. ```javascript // report.js - Health report generation const monthFromNow = (n) => new Date(new Date().setMonth(new Date().getMonth() + n)); fetchJSON("groups.json") .then(groups => { return Promise.all(Object.keys(groups).map(gid => { const specDataPromise = fetchJSON("./pergroup/" + gid + ".json"); const repoDataPromise = fetchJSON("./pergroup/" + gid + "-repo.json"); return Promise.all([specDataPromise, repoDataPromise]) .then(([specData, repoData]) => { // Count specs count.textContent = parseInt(count.textContent, 10) + specData.length; // Identify problem specs Object.values(specData).filter(s => s.versions[0]["rec-track"]).forEach(spec => { // Late CR Snapshot: CRD published >24 months after last CRS if (spec.versions[0].status === "Candidate Recommendation Draft") { const crs = spec.versions.find(v => v.status === "Candidate Recommendation Snapshot"); if (new Date(crs.date) < monthFrom(-24, new Date(spec.versions[0].date))) { lateCRSnapshot.appendChild(specLink(spec)); } } // Abandoned: no update in >36 months if (new Date(spec.versions[0].date) < monthFromNow(-36)) { abandoned.appendChild(specLink(spec)); } // Long-running: FPWD >60 months ago if (new Date(last(spec.versions).date) < monthFromNow(-60)) { longRunning.appendChild(specLink(spec)); } // No known repo if (!repoData[spec.shortlink]) { noRepo.appendChild(specLink(spec)); } }); }); })); }); // Access at: report.html // Shows categorized lists of specs needing attention ``` -------------------------------- ### Highlight Spec Issue on Hover (CSS) Source: https://github.com/w3c/spec-dashboard/blob/gh-pages/issues.html Applies a red stroke to a rectangle when hovering over an issue element. Ensure the 'a.issue' selector targets the correct HTML element for this to function. ```css a.issue:hover rect { stroke: red; stroke-width: 3px; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.