Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
feat(w3c/headers): add Feedback header (speced#3770)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoscaceres authored Oct 1, 2021
1 parent 65cd92b commit dc87c16
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/core/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ export async function run(conf) {
repoURL: ghURL.href,
apiBase: githubAPI,
fullName: `${org}/${repo}`,
issuesURL: issueBase,
pullsURL: newProps.pullBase,
newIssuesURL: new URL("./new/choose", issueBase).href,
commitHistoryURL: commitHistoryURL.href,
};
resolveGithubPromise(normalizedGHObj);
Expand Down
53 changes: 53 additions & 0 deletions src/w3c/templates/headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ export default (conf, options) => {
${showPeople(conf, "authors")}
`
: ""}
${renderFeedback(conf)}
${conf.otherLinks ? conf.otherLinks.map(showLink) : ""}
</dl>
</details>
Expand Down Expand Up @@ -274,6 +275,58 @@ export default (conf, options) => {
</div>`;
};

function renderFeedback(conf) {
if (!conf.github && !conf.wgPublicList) return;
const definitions = [];

// Github feedback...
if (conf.github) {
const { repoURL, issuesURL, newIssuesURL, pullsURL, fullName } =
conf.github;
definitions.push(
html`<dd>
<a href="${repoURL}">GitHub ${fullName}</a>
(<a href="${pullsURL}">pull requests</a>,
<a href="${newIssuesURL}">new issue</a>,
<a href="${issuesURL}">open issues</a>)
</dd>`
);
}

// The <a href="mailto:list?subject"> link for the public list
if (conf.wgPublicList) {
const mailToURL = new URL(`mailto:${conf.wgPublicList}@w3.org`);
const subject =
conf.subjectPrefix ?? `[${conf.shortName}] ${l10n.your_topic_here}`;
const mailingListLink = html`<a
href="${mailToURL.href}?subject=${encodeURIComponent(subject)}"
>${mailToURL.pathname}</a
>`;

// The subject line...
const subjectLine =
conf.subjectPrefix ||
html`[${conf.shortName}] <em>${l10n.message_topic}</em>`;
const emailSubject = html`${l10n.with_subject_line}${" "}
<kbd>${subjectLine}</kbd>`;

// Archives link
const archiveURL = new URL(
conf.wgPublicList,
"https://lists.w3.org/Archives/Public/"
);
const archiveLink = html`(<a href="${archiveURL}" rel="discussion"
>${l10n.archives}</a
>)`;

definitions.push(
html`<dd>${mailingListLink} ${emailSubject} ${archiveLink}</dd>`
);
}
return html`<dt>${l10n.feedback}</dt>
${definitions}`;
}

function renderHistory(conf) {
if (!conf.historyURI && !conf.github) return;
const ddElements = [];
Expand Down
48 changes: 48 additions & 0 deletions tests/spec/w3c/headers-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2252,6 +2252,54 @@ describe("W3C — Headers", () => {
});
});

describe("Feedback", () => {
it("includes a Feedback: with a <dd> to github issues", async () => {
const doc = await makeRSDoc(
makeStandardOps({ github: "w3c/respec", specStatus: "WD" })
);
const [dt] = contains(doc, ".head dt", "Feedback:");
const dd = dt.nextElementSibling;
expect(dd.querySelector("a[href^='https://github.com/']")).toBeTruthy();
});

it("includes links for to new issue, pull requests, open issues", async () => {
const doc = await makeRSDoc(makeStandardOps({ github: "w3c/respec" }));
const [prLink] = contains(
doc,
".head a[href='https://github.com/w3c/respec/pulls/']",
"pull requests"
);
expect(prLink).toBeTruthy();
const [openIssue] = contains(
doc,
".head a[href='https://github.com/w3c/respec/issues/']",
"open issues"
);
expect(openIssue).toBeTruthy();
const [newIssue] = contains(
doc,
".head a[href='https://github.com/w3c/respec/issues/new/choose']",
"new issue"
);
expect(newIssue).toBeTruthy();
});

it("includes a Feedback: with a <dd> for mailing list, when mailing list is supplied", async () => {
const opts = makeStandardOps({
wgPublicList: "public-webapps",
});
const doc = await makeRSDoc(opts);
const [dd] = contains(doc, ".head dd", "public-webapps@w3.org");

// Check the archive link
const archive = dd.querySelector(
"a[rel='discussion'][href^='https://lists.w3.org/']"
);
expect(archive).toBeTruthy();
expect(archive.textContent.trim()).toBe("archives");
});
});

describe("History", () => {
it("shows the publication history of the spec", async () => {
const ops = makeStandardOps({ shortName: "test", specStatus: "WD" });
Expand Down

0 comments on commit dc87c16

Please sign in to comment.