Overview
| Comment: | [tb][fx] update for MailExtension |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | tb | fx | mailext |
| Files: | files | file ages | folders |
| SHA3-256: |
05b48840da9e18692ccedfcf53c72588 |
| User & Date: | olr on 2020-07-05 09:35:32 |
| Other Links: | branch diff | manifest | tags |
Context
|
2020-07-06
| ||
| 18:45 | [tb][fx] update for MailExtension check-in: bc93713e8f user: olr tags: tb, fx, mailext | |
|
2020-07-05
| ||
| 09:35 | [tb][fx] update for MailExtension check-in: 05b48840da user: olr tags: tb, fx, mailext | |
|
2020-07-04
| ||
| 17:54 | [tb][fx][build] update WebExtension and build for MailExtension check-in: 0f4799907d user: olr tags: build, tb, fx, mailext | |
Changes
Modified gc_lang/fr/build.py from [1abca1cab7] to [78914808d1].
| ︙ | ︙ | |||
68 69 70 71 72 73 74 |
"create extension for Thunderbird (as MailExtension)"
print("> Building extension for Thunderbird (MailExtension)")
spfZip = "_build/" + dVars['tb_identifier'] + "-v" + dVars['version'] + '.mailext.xpi'
hZip = zipfile.ZipFile(spfZip, mode='w', compression=zipfile.ZIP_DEFLATED)
_copyGrammalecteJSPackageInZipFile(hZip, sLang)
for spf in ["LICENSE.txt", "LICENSE.fr.txt"]:
hZip.write(spf)
| | > | | 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
"create extension for Thunderbird (as MailExtension)"
print("> Building extension for Thunderbird (MailExtension)")
spfZip = "_build/" + dVars['tb_identifier'] + "-v" + dVars['version'] + '.mailext.xpi'
hZip = zipfile.ZipFile(spfZip, mode='w', compression=zipfile.ZIP_DEFLATED)
_copyGrammalecteJSPackageInZipFile(hZip, sLang)
for spf in ["LICENSE.txt", "LICENSE.fr.txt"]:
hZip.write(spf)
helpers.addFolderToZipAndFileFile(hZip, "gc_lang/"+sLang+"/mailext", "", dVars, True)
helpers.addFileToZipAndFileFile(hZip, "gc_lang/"+sLang+"/webext/gce_worker.js", "gce_worker.js", dVars)
helpers.addFileToZipAndFileFile(hZip, "gc_lang/"+sLang+"/webext/README.md", "README.md", dVars)
helpers.addFolderToZipAndFileFile(hZip, "gc_lang/"+sLang+"/webext/3rd", "3rd", dVars, True)
helpers.addFolderToZipAndFileFile(hZip, "gc_lang/"+sLang+"/webext/_locales", "_locales", dVars, True)
helpers.addFolderToZipAndFileFile(hZip, "gc_lang/"+sLang+"/webext/content_scripts", "content_scripts", dVars, True)
helpers.addFolderToZipAndFileFile(hZip, "gc_lang/"+sLang+"/webext/fonts", "fonts", dVars, True)
helpers.addFolderToZipAndFileFile(hZip, "gc_lang/"+sLang+"/webext/img", "img", dVars, True)
helpers.addFolderToZipAndFileFile(hZip, "gc_lang/"+sLang+"/webext/panel", "panel", dVars, True)
hZip.close()
|
| ︙ | ︙ |
Modified gc_lang/fr/mailext/background.js from [f5c6b4e1ae] to [05f690bf98].
| ︙ | ︙ | |||
263 264 265 266 267 268 269 |
if (oDetails.reason == "update" || oDetails.reason == "installed") {
// todo
//browser.tabs.create({url: "http://grammalecte.net"});
}
});
| < < < < < < < < | 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
if (oDetails.reason == "update" || oDetails.reason == "installed") {
// todo
//browser.tabs.create({url: "http://grammalecte.net"});
}
});
/*
Messages from the extension (not the Worker)
*/
function handleMessage (oRequest, xSender, sendResponse) {
// message from panels
//console.log(xSender);
let {sCommand, oParam, oInfo} = oRequest;
|
| ︙ | ︙ | |||
315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
}
//sendResponse({response: "response from background script"});
}
browser.runtime.onMessage.addListener(handleMessage);
function handleConnexion (xPort) {
// Messages from tabs
let iPortId = xPort.sender.tab.id; // identifier for the port: each port can be found at dConnx[iPortId]
dConnx.set(iPortId, xPort);
xPort.onMessage.addListener(function (oRequest) {
let {sCommand, oParam, oInfo} = oRequest;
switch (sCommand) {
| > > > > > | 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 |
}
//sendResponse({response: "response from background script"});
}
browser.runtime.onMessage.addListener(handleMessage);
/*
Ports from content-scripts
*/
let dConnx = new Map();
function handleConnexion (xPort) {
// Messages from tabs
let iPortId = xPort.sender.tab.id; // identifier for the port: each port can be found at dConnx[iPortId]
dConnx.set(iPortId, xPort);
xPort.onMessage.addListener(function (oRequest) {
let {sCommand, oParam, oInfo} = oRequest;
switch (sCommand) {
|
| ︙ | ︙ | |||
362 363 364 365 366 367 368 369 370 371 372 373 374 375 |
});
//xPort.postMessage({sActionDone: "newId", result: iPortId});
xPort.postMessage({sActionDone: "init", sUrl: browser.extension.getURL("")});
}
browser.runtime.onConnect.addListener(handleConnexion);
/*
Context Menu
(not for MailExtension)
*/
if (!bThunderbird) {
// Analyze
| > > > > > > > > > > > > > > > > | 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 |
});
//xPort.postMessage({sActionDone: "newId", result: iPortId});
xPort.postMessage({sActionDone: "init", sUrl: browser.extension.getURL("")});
}
browser.runtime.onConnect.addListener(handleConnexion);
/*
ComposeAction
(Thunderbird only)
*/
if (bThunderbird) {
console.log("[Grammalecte] Thunderbird: listening compose action...");
browser.composeAction.onClicked.addListener(function (xTab, xData) {
console.log("ComposeAction clicked");
console.log(xTab);
console.log(xData);
browser.tabs.sendMessage(xTab.id, {sActionRequest: "grammar_checker_compose_window"});
});
}
/*
Context Menu
(not for MailExtension)
*/
if (!bThunderbird) {
// Analyze
|
| ︙ | ︙ |
Modified gc_lang/fr/mailext/manifest.json from [7d69dce83d] to [57c89d52e2].
| ︙ | ︙ | |||
21 22 23 24 25 26 27 |
"48": "img/logo-48.png",
"64": "img/logo-64.png",
"80": "img/logo-80.png",
"96": "img/logo-96.png" },
"browser_action": {
"default_icon": "img/logo-32.png",
| | | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
"48": "img/logo-48.png",
"64": "img/logo-64.png",
"80": "img/logo-80.png",
"96": "img/logo-96.png" },
"browser_action": {
"default_icon": "img/logo-32.png",
"default_title": "Grammalecte",
"default_popup": "panel/main.html",
"browser_style": false
},
"compose_action": {
"default_area": "maintoolbar",
"default_icon": "img/logo-32.png",
|
| ︙ | ︙ | |||
56 57 58 59 60 61 62 63 64 |
"lexicon_editor": {
"suggested_key": { "default": "Ctrl+Shift+7" },
"description": "Ouvre l’éditeur lexical"
}
},
"permissions": [
"compose",
"downloads",
| > | > | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
"lexicon_editor": {
"suggested_key": { "default": "Ctrl+Shift+7" },
"description": "Ouvre l’éditeur lexical"
}
},
"permissions": [
"activeTab",
"compose",
"downloads",
"storage",
"tabs"
]
}
|
Modified gc_lang/fr/webext/content_scripts/init.js from [689258b9fa] to [4a92e9c4a9].
| ︙ | ︙ | |||
23 24 25 26 27 28 29 |
// https://browserext.github.io/browserext/
let bChrome = false;
let bThunderbird = false;
if (typeof(browser) !== "object") {
var browser = chrome;
bChrome = true;
}
| | > > > > | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
// https://browserext.github.io/browserext/
let bChrome = false;
let bThunderbird = false;
if (typeof(browser) !== "object") {
var browser = chrome;
bChrome = true;
}
if (typeof(messenger) === "object" || browser.hasOwnProperty("composeAction")) {
// JS sucks again.
// In Thunderbird, <browser> exists in content-scripts, but not <messenger>
// <browner> has property <composeAction> but is undefined...
bThunderbird = true;
//console.log("[Grammalecte] Thunderbird...");
}
/*
function loadImage (sContainerClass, sImagePath) {
let xRequest = new XMLHttpRequest();
xRequest.open('GET', browser.extension.getURL("")+sImagePath, false);
xRequest.responseType = "arraybuffer";
|
| ︙ | ︙ | |||
465 466 467 468 469 470 471 472 473 474 475 476 477 478 |
if (document.activeElement.tagName == "IFRAME") {
//console.log(document.activeElement.id); frameId given by result is different than frame.id
oGrammalecte.startGCPanel(document.activeElement);
} else {
oGrammalecte.showMessage("Erreur. Le cadre sur lequel vous avez cliqué n’a pas pu être identifié. Sélectionnez le texte à corriger et relancez le correcteur via le menu contextuel.");
}
break;
default:
console.log("[Grammalecte] Content-script. Unknown command: ", sActionDone);
}
}.bind(this));
},
/*
| > > > > > > > | 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 |
if (document.activeElement.tagName == "IFRAME") {
//console.log(document.activeElement.id); frameId given by result is different than frame.id
oGrammalecte.startGCPanel(document.activeElement);
} else {
oGrammalecte.showMessage("Erreur. Le cadre sur lequel vous avez cliqué n’a pas pu être identifié. Sélectionnez le texte à corriger et relancez le correcteur via le menu contextuel.");
}
break;
/*
composeAction
(Thunderbird only)
*/
case "grammar_checker_compose_window":
oGrammalecte.startGCPanel("__ThunderbirdComposeWindow__");
break;
default:
console.log("[Grammalecte] Content-script. Unknown command: ", sActionDone);
}
}.bind(this));
},
/*
|
| ︙ | ︙ | |||
500 501 502 503 504 505 506 |
}
}
oGrammalecteBackgroundPort.start();
| < < < < < < < < < < < < < < < < < < | 511 512 513 514 515 516 517 518 519 520 521 522 523 524 |
}
}
oGrammalecteBackgroundPort.start();
/*
Callable API for the webpage.
(Not for Thunderbird)
*/
if (!bThunderbird) {
document.addEventListener("GrammalecteCall", function (xEvent) {
|
| ︙ | ︙ |
Modified helpers.py from [793a89e669] to [36dfdf0199].
| ︙ | ︙ | |||
117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
def copyAndFileTemplate (spfSrc, spfDst, dVars):
"write file <spfSrc> as <spfDst> with variables filed with <dVars>"
sText = Template(open(spfSrc, "r", encoding="utf-8").read()).safe_substitute(dVars)
open(spfDst, "w", encoding="utf-8", newline="\n").write(sText)
def addFileToZipAndFileFile (hZip, spfSrc, spfDst, dVars):
if spfSrc.endswith((".py", ".js", ".json", ".html", ".htm", ".css", ".xcu", ".xul", ".rdf", ".dtd", ".properties")):
hZip.writestr(spfDst, fileFile(spfSrc, dVars))
else:
hZip.write(spfSrc, spfDst)
def addFolderToZipAndFileFile (hZip, spSrc, spDst, dVars, bRecursive):
| > | 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
def copyAndFileTemplate (spfSrc, spfDst, dVars):
"write file <spfSrc> as <spfDst> with variables filed with <dVars>"
sText = Template(open(spfSrc, "r", encoding="utf-8").read()).safe_substitute(dVars)
open(spfDst, "w", encoding="utf-8", newline="\n").write(sText)
def addFileToZipAndFileFile (hZip, spfSrc, spfDst, dVars):
"add a file to zip archive and file it with <dVars>"
if spfSrc.endswith((".py", ".js", ".json", ".html", ".htm", ".css", ".xcu", ".xul", ".rdf", ".dtd", ".properties")):
hZip.writestr(spfDst, fileFile(spfSrc, dVars))
else:
hZip.write(spfSrc, spfDst)
def addFolderToZipAndFileFile (hZip, spSrc, spDst, dVars, bRecursive):
|
| ︙ | ︙ |