From 10d549c287af4942c58bd6be8e40e928b6fcbb09 Mon Sep 17 00:00:00 2001 From: Daniel Weck Date: Sun, 1 Dec 2024 19:09:43 +0000 Subject: [PATCH] feat: sponsor banner link (HTML report, command line help, website) --- packages/ace-cli-shared/src/index.js | 10 +++- packages/ace-report/src/index.js | 2 + packages/ace-report/src/l10n/locales/en.json | 3 ++ .../ace-report/src/report-template.handlebars | 49 ++++++++++++++++++- .../__tests__/__snapshots__/cli.test.js.snap | 9 +++- website/content/docs/cli.md | 5 +- .../content/getting-started/installation.md | 4 +- website/layouts/partials/head/scripts.html | 42 ++++++++++++++++ website/themes/daisy/layouts/index.html | 15 ++++++ 9 files changed, 131 insertions(+), 8 deletions(-) diff --git a/packages/ace-cli-shared/src/index.js b/packages/ace-cli-shared/src/index.js index 87a92dd3..c121895e 100755 --- a/packages/ace-cli-shared/src/index.js +++ b/packages/ace-cli-shared/src/index.js @@ -14,6 +14,8 @@ const cliConfig = config.get('cli', defaults.cli); const pkg = require('@daisy/ace-meta/package'); +const { localizer } = require('@daisy/ace-report'); + const meowHelpMessage = ` Usage: ace [options] @@ -32,7 +34,11 @@ const meowHelpMessage = ` -l, --lang language code for localized messages (e.g. "fr"), default is "en" Examples - $ ace -o out ~/Documents/book.epub`; + $ ace -o out ~/Documents/book.epub + + ${localizer.localize("sponsorship_prompt")} + ${localizer.localize("sponsorship_link")} https://daisy.org/AceCLSponsor`; + const meowOptions = { autoHelp: false, autoVersion: false, @@ -154,7 +160,7 @@ ${overrides.map(file => ` - ${file}`).join('\n')} .catch(async (err) => { winston.error(err.message ? err.message : err); if (err.stack) winston.debug(err.stack); - + const res = await winston.logAndWaitFinish('info', 'Closing logs.'); console.log('Re-run Ace using the --verbose option to enable full debug logging.'); quit(1); diff --git a/packages/ace-report/src/index.js b/packages/ace-report/src/index.js index 887287c8..7b837591 100644 --- a/packages/ace-report/src/index.js +++ b/packages/ace-report/src/index.js @@ -2,8 +2,10 @@ const builders = require('./report-builders'); const Report = require('./report'); +const { localizer } = require('./l10n/localize'); module.exports = { builders, Report, + localizer, }; diff --git a/packages/ace-report/src/l10n/locales/en.json b/packages/ace-report/src/l10n/locales/en.json index 48268d94..f7a14dfd 100644 --- a/packages/ace-report/src/l10n/locales/en.json +++ b/packages/ace-report/src/l10n/locales/en.json @@ -60,6 +60,9 @@ "ruleset": "Ruleset", "serious": "Serious", "snippet": "Snippet:", + "sponsorship_close": "Close", + "sponsorship_link": "Support our work", + "sponsorship_prompt": "If you find DAISY Ace useful, please help us by donating to support its ongoing maintenance.", "summaryviolations": "Summary of violations", "summaryviolationscaption": "Violation count, by ruleset and severity.", "title": "Title:", diff --git a/packages/ace-report/src/report-template.handlebars b/packages/ace-report/src/report-template.handlebars index b70c6092..ae3e9f59 100644 --- a/packages/ace-report/src/report-template.handlebars +++ b/packages/ace-report/src/report-template.handlebars @@ -208,6 +208,38 @@ padding-left: 0 !important; } + +#sponsorship { +display: flex; +width: 100%; +column-gap: 1em; +align-items: center; +background-color: rgb(255,255,240); +color: black; +font-size: 90%; +border:0; +border-top: 0.1rem solid lightgrey; +border-bottom: 0.1rem solid lightgrey; +padding: 0; +padding: 0.5em; +margin: 0; +margin-top: 0.5em; +margin-bottom: 0.5em; +} +#sponsorship > span { +color: black; +} +#sponsorship > a { +font-weight: bold; +} +#sponsorship > input { +margin-left: auto; +border: 1px solid grey; +border-radius: 6px; +background-color: lightgrey; +font-weight: bold; +font-size: 90%; +} {{#localize "doctitle"}}{{/localize}} @@ -221,6 +253,21 @@

{{#localize "doctopheading"}}{{/localize}}

{{#generatedBy}}{{/generatedBy}}

+
+ {{#localize "sponsorship_prompt"}}{{/localize}} + {{#localize "sponsorship_link"}}{{/localize}} + +
+

{{#localize "title"}}{{/localize}} {{earl:testSubject.metadata.dc:title}}

(EPUB {{earl:testSubject.epubVersion}})

@@ -426,7 +473,7 @@

{{#localize "outlines"}}{{/localize}}

-

{{#localize "goto"}}{{/localize}} {{#localize "tocoutline"}}{{/localize}} | {{#localize "headsoutline"}}{{/localize}} | {{#localize "htmloutline"}}{{/localize}}

+

{{#localize "goto"}}{{/localize}} {{#localize "tocoutline"}}{{/localize}} | {{#localize "headsoutline"}}{{/localize}}

diff --git a/tests/__tests__/__snapshots__/cli.test.js.snap b/tests/__tests__/__snapshots__/cli.test.js.snap index 12d953cc..506d584f 100644 --- a/tests/__tests__/__snapshots__/cli.test.js.snap +++ b/tests/__tests__/__snapshots__/cli.test.js.snap @@ -7,8 +7,7 @@ Re-run Ace using the --verbose option to enable full debug logging." exports[`Running the CLI on a non-existant document should fail 2`] = ` "error: Couldn’t find EPUB file 'unexisting.epub' -error: -" +error: \n" `; exports[`Running the CLI with -o pointing to an existing directory should fail 1`] = ` @@ -50,6 +49,9 @@ exports[`Running the CLI with no input should fail 2`] = ` Examples $ ace -o out ~/Documents/book.epub + If you find DAISY Ace useful, please help us by donating to support its ongoing maintenance. + Support our work https://daisy.org/AceCLSponsor + " `; @@ -76,5 +78,8 @@ exports[`Running the CLI with the -h option should print help 1`] = ` Examples $ ace -o out ~/Documents/book.epub + If you find DAISY Ace useful, please help us by donating to support its ongoing maintenance. + Support our work https://daisy.org/AceCLSponsor + " `; diff --git a/website/content/docs/cli.md b/website/content/docs/cli.md index f89293a7..1ef60fe5 100644 --- a/website/content/docs/cli.md +++ b/website/content/docs/cli.md @@ -35,7 +35,7 @@ info: Consolidating results... { "@type": "earl:report", "@context": "http://daisy.github.io/ace/ace-report-1.0.jsonld", - "dct:title": "Ace Report", + "dct:title": "Ace Report", ... } info: Done @@ -76,6 +76,9 @@ Ace by DAISY, an Accessibility Checker for EPUB -l, --lang language code for localized messages (e.g. "fr"), default is "en" Examples $ ace -o out ~/Documents/book.epub + +If you find DAISY Ace useful, please help us by donating to support its ongoing maintenance. +Support our work https://daisy.org/AceCLSponsor ``` ### version diff --git a/website/content/getting-started/installation.md b/website/content/getting-started/installation.md index 03417b33..42ab71d8 100644 --- a/website/content/getting-started/installation.md +++ b/website/content/getting-started/installation.md @@ -10,8 +10,8 @@ _Note: this documentation applies to the Ace by DAISY command line tool. For mor Operating systems: Microsoft Windows 10+, Apple MacOS High Sierra 10.13+, Linux 64-bit Ubuntu 14.04+, Debian 8+, openSUSE 13.3+, or Fedora Linux 24+ -Ace is a NodeJS / Javascript program that launches either Electron or Puppeteer to execute the accessibility tests in headless Chromium webviews, see -[implementation notes]({{}}). Ace has other software dependencies that require a modern NodeJS runtime, for security and performance reasons. NodeJS version 16+ is required, and NodeJS 18+ is recommended as v16 is scheduled to exit maintenance phase by the end of 2023. +Ace is a NodeJS / Javascript program that launches either Electron or Puppeteer to execute the accessibility tests in headless Chromium webviews, see +[implementation notes]({{}}). Ace has other software dependencies that require a modern NodeJS runtime, for security and performance reasons. NodeJS version 20 is required, and NodeJS 22 is recommended. Further information: diff --git a/website/layouts/partials/head/scripts.html b/website/layouts/partials/head/scripts.html index fbcde93e..9d495432 100644 --- a/website/layouts/partials/head/scripts.html +++ b/website/layouts/partials/head/scripts.html @@ -6,3 +6,45 @@ gtag('js', new Date()); gtag('config', 'UA-327448-5'); + diff --git a/website/themes/daisy/layouts/index.html b/website/themes/daisy/layouts/index.html index de2ae016..258d1786 100644 --- a/website/themes/daisy/layouts/index.html +++ b/website/themes/daisy/layouts/index.html @@ -4,6 +4,21 @@

{{ .Title }}

{{ .Content }} +
+ If you find DAISY Ace useful, please help us by donating to support its ongoing maintenance. + Support our work + +
+
    {{ range $.Site.Sections.ByWeight }}