Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - PR merge 40+42 (l10n + Axe runner Electron adapter) #43

Merged
merged 70 commits into from
May 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
2775760
initial commit for localization l10n, translated message strings EN d…
danielweck Mar 7, 2019
d849adb
persistent store (simple JSON), live dynamic menu language switch, ru…
danielweck Mar 7, 2019
efa1686
language select options in preference dialog
danielweck Mar 7, 2019
ad7cf26
translated preferences dialog
danielweck Mar 7, 2019
72a67a9
sidebar is now translated (dynamic / live language update, no need to…
danielweck Mar 7, 2019
f118664
translated English French splash
danielweck Mar 8, 2019
89b8f1c
translated image section in report, added boilerplate code for live/i…
danielweck Mar 8, 2019
6c5b8ef
enhanced table translated
danielweck Mar 8, 2019
18e0d81
paginated table customization for multi language support
danielweck Mar 8, 2019
2ad412e
translation for accessibility metadata report
danielweck Mar 8, 2019
8256097
report outlines translated
danielweck Mar 8, 2019
8e06c5e
summary report section now translated
danielweck Mar 8, 2019
060ffec
translated violations report
danielweck Mar 8, 2019
6c8ff28
yarn upgrade i18next + removed package-lock.json (keep only yarn.lock)
danielweck Apr 26, 2019
916b2dd
i18next semver in package.json
danielweck Apr 26, 2019
b9f7f4d
temp build script to replace proper Ace NPM packages with copied arte…
danielweck Apr 26, 2019
7acdcf4
concurrent i18next instances
danielweck Apr 26, 2019
c0a36f7
further localization
danielweck Apr 26, 2019
b1dc048
another localization pass (last I think)
danielweck Apr 26, 2019
1239f44
FR l10n typo
danielweck Apr 26, 2019
e4782f0
translated severity
danielweck Apr 26, 2019
4cb4d20
Winston logging for AceCore
danielweck Apr 27, 2019
f5266a7
added build script for staging app test artefacts
danielweck Apr 27, 2019
ffdf398
latest i18next centralized localizer from Ace core, added translated …
danielweck Apr 30, 2019
d864f34
french typo
danielweck Apr 30, 2019
e282ada
extra render step so that filter selects do update dynamically when l…
danielweck Apr 30, 2019
d3e543c
Merge branch 'master' into feature/l10n
danielweck May 2, 2019
f32e776
removed menu item in KB window menu bar
danielweck May 2, 2019
794547f
first pass for Electron Axe runner
danielweck May 2, 2019
49ad140
working Electron Axe runner (comparing with Puppeteer now ... )
danielweck May 2, 2019
ce1c22e
with XHTML content type the Electron Axe runner now matches exactly t…
danielweck May 2, 2019
e1c68c2
Merge branch 'feature/axe-runner' into pr-merge/40+42
danielweck May 3, 2019
e16819b
removed console log
danielweck May 3, 2019
dcf8a97
Merge branch 'feature/l10n' into pr-merge/40+42
danielweck May 3, 2019
9ad2a31
ensure nodeIntegration in BrowserWindows
danielweck May 3, 2019
e6febcf
Working build with local Ace package dependencies, and Electron5 for …
danielweck May 3, 2019
248363e
Windows path handling (URL parse host/hostname is lowercase drive let…
danielweck May 5, 2019
5eb75dd
code cleanup for default JSON locale export (module export), see http…
danielweck May 5, 2019
17a4afa
FR fix, see https://github.com/daisy/ace-gui/pull/40#discussion_r2810…
danielweck May 5, 2019
bc70c20
FR fix, https://github.com/daisy/ace-gui/pull/40#discussion_r281003339
danielweck May 5, 2019
e59e566
FR fix: https://github.com/daisy/ace-gui/pull/40#discussion_r281003349
danielweck May 5, 2019
f28aaf2
FR fix: https://github.com/daisy/ace-gui/pull/40#discussion_r281003343
danielweck May 5, 2019
f6759f6
FR fix https://github.com/daisy/ace-gui/pull/40#discussion_r281003333
danielweck May 5, 2019
fa707a1
FR fix https://github.com/daisy/ace-gui/pull/40#discussion_r281003596
danielweck May 5, 2019
05fb26c
FR fix https://github.com/daisy/ace-gui/pull/40#discussion_r281003625
danielweck May 5, 2019
c4caed5
FR fix https://github.com/daisy/ace-gui/pull/40#discussion_r281003636
danielweck May 5, 2019
0959801
FR fix https://github.com/daisy/ace-gui/pull/40#discussion_r281003657
danielweck May 5, 2019
d493806
FR fix: removed unused labels
danielweck May 5, 2019
3971e84
FR fix https://github.com/daisy/ace-gui/pull/40#discussion_r281003373
danielweck May 5, 2019
4466eb6
FR fix https://github.com/daisy/ace-gui/pull/40#discussion_r281003382
danielweck May 5, 2019
41c0411
FR fix https://github.com/daisy/ace-gui/pull/40#discussion_r281003420
danielweck May 5, 2019
7d8f174
FR fix https://github.com/daisy/ace-gui/pull/40#discussion_r281003436
danielweck May 5, 2019
4476137
FR fix https://github.com/daisy/ace-gui/pull/40#discussion_r281003462
danielweck May 5, 2019
5421d24
FR fix https://github.com/daisy/ace-gui/pull/40#discussion_r281003477
danielweck May 5, 2019
e71c708
FR fix https://github.com/daisy/ace-gui/pull/40#discussion_r281003524
danielweck May 5, 2019
56be1b5
FR fix https://github.com/daisy/ace-gui/pull/40#discussion_r281003540
danielweck May 5, 2019
b0d009e
FR fix https://github.com/daisy/ace-gui/pull/40#discussion_r281003550
danielweck May 5, 2019
9029589
FR fix https://github.com/daisy/ace-gui/pull/40#discussion_r281003566
danielweck May 5, 2019
d4ce615
FR fix https://github.com/daisy/ace-gui/pull/40#discussion_r281003576
danielweck May 5, 2019
2a9c6f4
FR fix https://github.com/daisy/ace-gui/pull/40#discussion_r281003578
danielweck May 5, 2019
191da98
FR fix https://github.com/daisy/ace-gui/pull/40#discussion_r281003587
danielweck May 5, 2019
0725074
Merge branch 'feature/l10n' into pr-merge/40+42
danielweck May 5, 2019
61f2e75
Yarn install / upgrade
danielweck May 5, 2019
1a0113f
FR fix https://github.com/daisy/ace/pull/223#discussion_r281033199
danielweck May 5, 2019
00f449c
Merge branch 'feature/l10n' into pr-merge/40+42
danielweck May 5, 2019
82a9940
Merge branch 'master' into feature/axe-runner
danielweck May 5, 2019
a490364
Merge branch 'feature/axe-runner' into pr-merge/40+42
danielweck May 5, 2019
4f640be
Merge branch 'master' into pr-merge/40+42
danielweck May 5, 2019
e4ba762
fixed merge bug
danielweck May 5, 2019
9fcfa29
yarn restored
danielweck May 5, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,20 @@ Please read our [code of conduct](CODE_OF_CONDUCT.md) and [contributing guidelin
## License

This project is licensed under the MIT License - see the [license file](LICENSE.md) for details

## Clean slate build for Electron

* `yarn run clean`
* `rm -rf dist`
* `rm -rf node_modules`
* `yarn cache clean`
* `git branch`
* `git status`
* `git pull`
* `rm yarn.lock`
* `yarn install`
* `open node_modules/@daisy`
* `yarn build`
* `yarn start`


16 changes: 5 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,18 @@
},
"@daisy/ace-core": "^1.0.2",
"dependencies": {
"@daisy/ace-config": "^1.0.0",
"@daisy/ace-logger": "^1.0.1",
"@daisy/ace-report": "^1.0.1",
"@daisy/ace-report-axe": "^1.0.1",
"@daisy/epub-utils": "^1.0.2",
"@daisy/ace-core": "file:../ace/packages/ace-core",
"@daisy/ace-localize": "file:../ace/packages/ace-localize",
"@daisy/ace-logger": "file:../ace/packages/ace-logger",
"@material-ui/core": "^3.0.0",
"@material-ui/icons": "^3.0.0",
"@mrmlnc/readdir-enhanced": "^2.2.1",
"about-window": "^1.12.1",
"axe-core": "~2.6.1",
"electron-debug": "^2.0.0",
"electron-redux": "^1.3.1",
"electron-store": "^2.0.0",
"electron-store": "^3.2.0",
"express": "^4.16.4",
"file-url": "^2.0.2",
"fs-jetpack": "^2.1.0",
"h5o": "^0.11.3",
"handlebars": "^4.1.2",
"jszip": "^3.1.5",
"p-map": "^1.2.0",
"portfinder": "^1.0.20",
Expand Down Expand Up @@ -95,7 +89,7 @@
"cross-env": "^5.2.0",
"css-loader": "^1.0.0",
"devtron": "^1.4.0",
"electron": "2.0.7",
"electron": "^5.0.0",
"electron-builder": "^20.28.3",
"electron-react-devtools": "^0.5.3",
"file-loader": "^2.0.0",
Expand Down
42 changes: 30 additions & 12 deletions src/main/axe-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,18 @@ export function axeRunnerInitEvents() {
ipcMain.on('AXE_RUNNER_RUN', (event, arg) => {

const basedir = arg.basedir;
const u = arg.url;
const uarel = arg.url;
const scripts = arg.scripts;
const scriptContents = arg.scriptContents;

if (LOG_DEBUG) console.log(`${AXE_LOG_PREFIX} axeRunner running ... ${basedir} ${u}`);
if (LOG_DEBUG) console.log(`${AXE_LOG_PREFIX} axeRunner running ... ${basedir} ${uarel}`);

function doRun() {

const p = decodeURI(url.parse(u).pathname);
const httpUrl = rootUrl + p.replace(basedir, "");
// windows! file://C:\aa\bb\chapter.xhtml
const uarelObj = url.parse(uarel.replace(/\\/g, "/"));
const windowsDrive = uarelObj.hostname ? `${uarelObj.hostname.toUpperCase()}:` : "";
const httpUrl = rootUrl + (windowsDrive + decodeURI(uarelObj.pathname)).replace(basedir.replace(/\\/g, "/"), "");

let replySent = false;

Expand All @@ -173,16 +176,24 @@ new Promise((resolve, reject) => {
browserWindow.webContents.executeJavaScript(js, true)
.then((ok) => {
if (LOG_DEBUG) console.log(`${AXE_LOG_PREFIX} axeRunner done.`);
// console.log(ok);
// console.log(JSON.stringify(ok, null, " "));
if (replySent) {
if (LOG_DEBUG) console.log(`${AXE_LOG_PREFIX} axeRunner WAS TIMEOUT!`);
return;
}
replySent = true;

event.sender.send("AXE_RUNNER_RUN_", {
ok
});
})
.catch((err) => {
if (LOG_DEBUG) console.log(`${AXE_LOG_PREFIX} axeRunner fail!`);
if (replySent) {
if (LOG_DEBUG) console.log(`${AXE_LOG_PREFIX} axeRunner WAS TIMEOUT!`);
return;
}
replySent = true;

event.sender.send("AXE_RUNNER_RUN_", {
err
});
Expand All @@ -202,11 +213,11 @@ new Promise((resolve, reject) => {
event.sender.send("AXE_RUNNER_RUN_", {
err: "Timeout :("
});
}, 3000);
}, 10000);
}

if (!httpServer) { // lazy init
startAxeServer(basedir, scripts).then(() => {
startAxeServer(basedir, scripts, scriptContents).then(() => {
if (LOG_DEBUG) console.log(`${AXE_LOG_PREFIX} server started`);

browserWindow = new BrowserWindow({
Expand Down Expand Up @@ -252,11 +263,18 @@ new Promise((resolve, reject) => {
});
}

export function startAxeServer(epubRootPath, scripts) {
export function startAxeServer(basedir, scripts, scriptContents) {

return new Promise((resolve, reject) => {

let scriptsMarkup = "";
scriptContents.forEach((scriptCode) => {
scriptsMarkup += `<script data-ace="" type="text/javascript">
// <![CDATA[
${scriptCode}
// ]]>
</script>`;
});
scripts.forEach((scriptPath) => {
const filename = path.basename(scriptPath);
scriptsMarkup += `<script data-ace="" src="/${HTTP_QUERY_PARAM}/${filename}"> </script>`;
Expand Down Expand Up @@ -290,7 +308,7 @@ export function startAxeServer(epubRootPath, scripts) {
if (req.query[HTTP_QUERY_PARAM]) {
if (LOG_DEBUG) console.log(`${AXE_LOG_PREFIX} HTTP intercept ${req.url}`);

let html = fs.readFileSync(path.join(epubRootPath, url.parse(req.url).pathname), { encoding: "utf8" });
let html = fs.readFileSync(path.join(basedir, url.parse(req.url).pathname), { encoding: "utf8" });

if (html.match(/<\/head>/)) {
html = html.replace(/<\/head>/, `${scriptsMarkup}</head>`);
Expand Down Expand Up @@ -324,8 +342,8 @@ export function startAxeServer(epubRootPath, scripts) {
// setResponseCORS(res);
// },
};
if (LOG_DEBUG) console.log(`${AXE_LOG_PREFIX} HTTP static path ${epubRootPath}`);
expressApp.use("/", express.static(epubRootPath, staticOptions));
if (LOG_DEBUG) console.log(`${AXE_LOG_PREFIX} HTTP static path ${basedir}`);
expressApp.use("/", express.static(basedir, staticOptions));

const startHttp = function () {
generateSelfSignedData().then((certData) => {
Expand Down
15 changes: 14 additions & 1 deletion src/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,20 @@ function openTopLevelDevTools() {
let win;
function createWindow() {

win = new BrowserWindow({ show: false });
win = new BrowserWindow(
{
show: false,
webPreferences: {
allowRunningInsecureContent: false,
contextIsolation: false,
nodeIntegration: true,
nodeIntegrationInWorker: false,
sandbox: false,
webSecurity: true,
webviewTag: false,
}
}
);
win.maximize();
let sz = win.getSize();
const sz0 = sz[0];
Expand Down
2 changes: 1 addition & 1 deletion src/shared/actions/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function runAce(inputPath) {
if (outdir.success) {
const language = getCurrentLanguage();

ace(inputPath, {outdir: outdir.value, lang: language, verbose: true, silent: false, initLogger: true}, axeRunner)
ace(inputPath, {outdir: outdir.value, lang: language, verbose: true, silent: false, initLogger: false}, axeRunner)
.then(() => {
dispatch(addMessage(localize("message.checkcomplete")));
let reportPath = outdir.value + '/report.json';
Expand Down
3 changes: 2 additions & 1 deletion src/shared/axe-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const axeRunner = {
// ipcRenderer.send('AXE_RUNNER_CLOSE', {});
// });
},
run: function (url, scripts, basedir) {
run: function (url, scripts, scriptContents, basedir) {
if (LOG_DEBUG) console.log(`${AXE_LOG_PREFIX} axeRunner will run ...`);

return new Promise((resolve, reject) => {
Expand All @@ -54,6 +54,7 @@ export const axeRunner = {
ipcRenderer.send('AXE_RUNNER_RUN', {
url,
scripts,
scriptContents,
basedir,
});
});
Expand Down
11 changes: 11 additions & 0 deletions src/shared/helpers/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ module.exports = {
copyright: 'Copyright (c) 2018 DAISY Consortium',
package_json_dir: __dirname,
open_devtools: isDev,
win_options: {
webPreferences: {
allowRunningInsecureContent: false,
contextIsolation: false,
nodeIntegration: true,
nodeIntegrationInWorker: false,
sandbox: false,
webSecurity: true,
webviewTag: false,
}
}
});
},
};
6 changes: 2 additions & 4 deletions src/shared/l10n/localize.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
const { newLocalizer } = require('@daisy/ace-localize');

// import * as enJson from "./locales/en.json";
// import * as frJson from "./locales/fr.json";
const enJson = require("./locales/en.json");
const frJson = require("./locales/fr.json");

export const localizer = newLocalizer({
en: {
name: "English",
default: true,
translation: enJson, // enJson.default || enJson,
translation: enJson,
},
fr: {
name: "Français",
translation: frJson, // frJson.default || frJson,
translation: frJson,
},
});
Loading