Skip to content

Commit

Permalink
feat: sponsor banner link (HTML report, command line help, website)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielweck committed Dec 1, 2024
1 parent 49d8437 commit 10d549c
Show file tree
Hide file tree
Showing 9 changed files with 131 additions and 8 deletions.
10 changes: 8 additions & 2 deletions packages/ace-cli-shared/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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] <input>
Expand All @@ -32,7 +34,11 @@ const meowHelpMessage = `
-l, --lang <language> 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,
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions packages/ace-report/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

const builders = require('./report-builders');
const Report = require('./report');
const { localizer } = require('./l10n/localize');

module.exports = {
builders,
Report,
localizer,
};
3 changes: 3 additions & 0 deletions packages/ace-report/src/l10n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:",
Expand Down
49 changes: 48 additions & 1 deletion packages/ace-report/src/report-template.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -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%;
}
</style>

<title>{{#localize "doctitle"}}{{/localize}}</title>
Expand All @@ -221,6 +253,21 @@

<h1>{{#localize "doctopheading"}}{{/localize}}</h1>
<p class="font-italic">{{#generatedBy}}{{/generatedBy}}</p>
<div id="sponsorship">
<span>{{#localize "sponsorship_prompt"}}{{/localize}}</span>
<a target="_BLANK" href="https://daisy.org/AceCLSponsor">{{#localize "sponsorship_link"}}{{/localize}}</a>
<input onclick="document.getElementById('sponsorship').remove();localStorage.setItem('DAISY-ACE-SPONSOR-HIDE', new Date().toISOString())" type="button" value="X" aria-label="{{#localize "sponsorship_close"}}{{/localize}}" title="{{#localize "sponsorship_close"}}{{/localize}}">
</div>
<script type="text/javascript">
const dateStr = localStorage.getItem('DAISY-ACE-SPONSOR-HIDE');
if (dateStr) {
if ((new Date().getTime() - new Date(dateStr).getTime()) > (24*60*60*1000)) { // 24h
localStorage.removeItem('DAISY-ACE-SPONSOR-HIDE');
} else {
setTimeout(()=>{document.getElementById('sponsorship').remove()}, 0);
}
}
</script>
<p><span class="font-weight-bold">{{#localize "title"}}{{/localize}}</span> {{earl:testSubject.metadata.dc:title}}</p>
<p>(EPUB {{earl:testSubject.epubVersion}})</p>
</header>
Expand Down Expand Up @@ -426,7 +473,7 @@
<!-- OUTLINES TAB -->
<div id="outlines" role="tabpanel">
<h2>{{#localize "outlines"}}{{/localize}}</h2>
<p class="sectionnav">{{#localize "goto"}}{{/localize}} <a href="#toc-outline">{{#localize "tocoutline"}}{{/localize}}</a> | <a href="#headings-outline">{{#localize "headsoutline"}}{{/localize}}</a> | <a href="#html-outline">{{#localize "htmloutline"}}{{/localize}}</a> </p>
<p class="sectionnav">{{#localize "goto"}}{{/localize}} <a href="#toc-outline">{{#localize "tocoutline"}}{{/localize}}</a> | <a href="#headings-outline">{{#localize "headsoutline"}}{{/localize}}</a> </p> <!-- | <a href="#html-outline">{{#localize "htmloutline"}}{{/localize}}</a> -->

<div class="row">

Expand Down
9 changes: 7 additions & 2 deletions tests/__tests__/__snapshots__/cli.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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`] = `
Expand Down Expand Up @@ -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
"
`;
Expand All @@ -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
"
`;
5 changes: 4 additions & 1 deletion website/content/docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -76,6 +76,9 @@ Ace by DAISY, an Accessibility Checker for EPUB
-l, --lang <language> 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
Expand Down
4 changes: 2 additions & 2 deletions website/content/getting-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]({{<relref "contributing/notes.md">}}). 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]({{<relref "contributing/notes.md">}}). 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:

Expand Down
42 changes: 42 additions & 0 deletions website/layouts/partials/head/scripts.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,45 @@
gtag('js', new Date());
gtag('config', 'UA-327448-5');
</script>
<style>
#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: 1.5em;
margin-bottom: 0.5em;
}
#sponsorship > span {
margin: 0;
padding: 0;
color: black;
font-weight: bold;
}
#sponsorship > a {
margin: 0;
padding: 0;
font-weight: bold;
color: blue;
}
#sponsorship > input {
margin: 0;
padding: 0;
padding: 0.2em;
margin-left: auto;
border: 1px solid grey;
border-radius: 6px;
background-color: lightgrey;
font-weight: bold;
font-size: 90%;
}
</style>
15 changes: 15 additions & 0 deletions website/themes/daisy/layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@
<main id="main">
<h1>{{ .Title }}</h1>
{{ .Content }}
<div id="sponsorship">
<span>If you find DAISY Ace useful, please help us by donating to support its ongoing maintenance.</span>
<a target="_BLANK" href="https://daisy.org/AceCLSponsor">Support our work</a>
<input onclick="document.getElementById('sponsorship').remove();localStorage.setItem('DAISY-ACE-SPONSOR-HIDE', new Date().toISOString())" type="button" value="X" aria-label="Close" title="Close">
</div>
<script type="text/javascript">
const dateStr = localStorage.getItem('DAISY-ACE-SPONSOR-HIDE');
if (dateStr) {
if ((new Date().getTime() - new Date(dateStr).getTime()) > (7*24*60*60*1000)) { // 24h * 7
localStorage.removeItem('DAISY-ACE-SPONSOR-HIDE');
} else {
setTimeout(()=>{document.getElementById('sponsorship').remove()}, 0);
}
}
</script>
<ul class="pages-list">
{{ range $.Site.Sections.ByWeight }}
<li>
Expand Down

0 comments on commit 10d549c

Please sign in to comment.