Index: gc_lang/fr/build.py ================================================================== --- gc_lang/fr/build.py +++ gc_lang/fr/build.py @@ -11,10 +11,11 @@ import helpers def build (sLang, dVars): "complementary build launched from make.py" + dVars['webextOptionsHTML'] = _createOptionsForWebExtension(dVars) createWebExtension(sLang, dVars) convertWebExtensionForChrome(sLang, dVars) createMailExtension(sLang, dVars) createNodeJSPackage(sLang) @@ -23,11 +24,10 @@ "create Web-extension" print("> Building WebExtension for Firefox") helpers.createCleanFolder("_build/webext/"+sLang) dir_util.copy_tree("gc_lang/"+sLang+"/webext/", "_build/webext/"+sLang) dir_util.copy_tree("grammalecte-js", "_build/webext/"+sLang+"/grammalecte") - dVars['webextOptionsHTML'] = _createOptionsForWebExtension(dVars) helpers.copyAndFileTemplate("_build/webext/"+sLang+"/manifest.json", "_build/webext/"+sLang+"/manifest.json", dVars) helpers.copyAndFileTemplate("_build/webext/"+sLang+"/panel/main.html", "_build/webext/"+sLang+"/panel/main.html", dVars) with helpers.CD("_build/webext/"+sLang): os.system("web-ext build") # Copy Firefox zip extension to _build @@ -70,38 +70,32 @@ 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) - dVars = _createOptionsForThunderbird(dVars) helpers.addFolderToZipAndFileFile(hZip, "gc_lang/"+sLang+"/mailext", "", dVars, True) + helpers.addFileToZipAndFileFile(hZip, "gc_lang/"+sLang+"/webext/background.js", "background.js", dVars) + 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() - #spExtension = dVars['win_tb_debug_extension_path'] if platform.system() == "Windows" else dVars['linux_tb_debug_extension_path'] - #if os.path.isdir(spExtension): - # file_util.copy_file(spfZip, spExtension + "/" + dVars['tb_identifier']+ ".xpi") # Filename for TB is just - # print(f"TB extension copied in <{spExtension}>") - #spExtension = dVars['win_tb_beta_extension_path'] if platform.system() == "Windows" else dVars['linux_tb_beta_extension_path'] - #if os.path.isdir(spExtension): - # print(f"TB extension copied in <{spExtension}>") - # file_util.copy_file(spfZip, spExtension + "/" + dVars['tb_identifier']+ ".xpi") # Filename for TB is just - - -def _createOptionsForThunderbird (dVars): - dVars['sXULTabs'] = "" - dVars['sXULTabPanels'] = "" - # dialog options - for sSection, lOpt in dVars['lStructOpt']: - dVars['sXULTabs'] += ' \n' - dVars['sXULTabPanels'] += ' \n \n' - # translation data - for sLang in dVars['dOptLabel'].keys(): - dVars['gc_options_labels_'+sLang] = "\n".join( [ "' for sOpt in dVars['dOptLabel'][sLang] ] ) - return dVars + # Note about copying Thunderbird extension directly into the profile: + # In Options > Configuration editor (about:config), deactivate option + # If is changed, you must reinstall the extension manually + spExtension = dVars['win_tb_debug_extension_path'] if platform.system() == "Windows" else dVars['linux_tb_debug_extension_path'] + if os.path.isdir(spExtension): + file_util.copy_file(spfZip, f"{spExtension}/{dVars['tb_identifier']}.xpi") # Filename for TB is just + print(f"Thunderbird extension copied in <{spExtension}>") + spExtension = dVars['win_tb_beta_extension_path'] if platform.system() == "Windows" else dVars['linux_tb_beta_extension_path'] + if os.path.isdir(spExtension): + file_util.copy_file(spfZip, f"{spExtension}/{dVars['tb_identifier']}.xpi") # Filename for TB is just + print(f"Thunderbird extension copied in <{spExtension}>") def _copyGrammalecteJSPackageInZipFile (hZip, sLang, sAddPath=""): for sf in os.listdir("grammalecte-js"): if not os.path.isdir("grammalecte-js/"+sf): Index: gc_lang/fr/config.ini ================================================================== --- gc_lang/fr/config.ini +++ gc_lang/fr/config.ini @@ -57,11 +57,10 @@ tb_name = Grammalecte [fr] win_tb_path = C:\Program Files\Mozilla Thunderbird\thunderbird.exe win_tb_beta_path = C:\Program Files\Thunderbird Daily\thunderbird.exe linux_tb_path = /usr/bin/thunderbird linux_tb_beta_path = /usr/bin/thunderbird -# useless now win_tb_debug_extension_path = D:\_temp\tb-debug.profile\extensions linux_tb_debug_extension_path = ~/tb-debug.profile/extensions win_tb_beta_extension_path = D:\_temp\tb-beta.profile\extensions linux_tb_beta_extension_path = ~/tb-beta.profile/extensions # Set Thunderbird folder in your PATH variable DELETED gc_lang/fr/mailext/README.txt Index: gc_lang/fr/mailext/README.txt ================================================================== --- gc_lang/fr/mailext/README.txt +++ /dev/null @@ -1,14 +0,0 @@ - -= GRAMMALECTE = - -French grammar checker -By Olivier R. (olivier /at/ grammalecte /dot/ net) - -Website: https://grammalecte.net/ - -License: GPL 3 -- http://www.gnu.org/copyleft/gpl.html - -Grammalecte for Firefox is a derivative tool born from the version -for LibreOffice written in Python. - -Written in JavaScript ES6/ES7. DELETED gc_lang/fr/mailext/background.js Index: gc_lang/fr/mailext/background.js ================================================================== --- gc_lang/fr/mailext/background.js +++ /dev/null @@ -1,202 +0,0 @@ -// Background - -"use strict"; - -// Draft for later - -const oWorkerHandler = { - xGCEWorker: null, - - nLastTimeWorkerResponse: 0, // milliseconds since 1970-01-01 - - oTask: {}, - - start: function () { - this.xGCEWorker = new Worker("gce_worker.js"); - this.xGCEWorker.onmessage = function (e) { - // Messages received from the Worker - // https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent - try { - this.nLastTimeWorkerResponse = Date.now(); - let {sActionDone, result, oInfo, bEnd, bError} = e.data; - if (bError) { - console.log(result); - console.log(oInfo); - return; - } - switch (sActionDone) { - case "init": - storeGCOptions(result); - break; - case "parse": - case "parseAndSpellcheck": - case "parseAndSpellcheck1": - case "parseFull": - case "getListOfTokens": - case "getSpellSuggestions": - case "getVerb": - // send result to content script - if (typeof(oInfo.iReturnPort) === "number") { - let xPort = dConnx.get(oInfo.iReturnPort); - xPort.postMessage(e.data); - } else { - console.log("[background] don’t know where to send results"); - console.log(e.data); - } - break; - case "textToTest": - case "fullTests": - // send result to panel - browser.runtime.sendMessage(e.data); - break; - case "getOptions": - case "getDefaultOptions": - case "resetOptions": - // send result to panel - storeGCOptions(result); - browser.runtime.sendMessage(e.data); - break; - case "setOptions": - case "setOption": - storeGCOptions(result); - break; - case "setDictionary": - case "setDictionaryOnOff": - //console.log("[background] " + sActionDone + ": " + result); - break; - default: - console.log("[background] Unknown command: " + sActionDone); - console.log(e.data); - } - } - catch (error) { - showError(error); - console.log(e.data); - } - }; - }, - - getTimeSinceLastResponse: function () { - // result in seconds - return Math.floor((Date.now() - this.nLastTimeWorkerResponse) / 1000); - }, - - restart: function (nDelay=5) { - if (this.getTimeSinceLastResponse() <= nDelay) { - console.log("Worker not restarted. Worked ", nDelay, " seconds ago."); - return false; - } - if (this.xGCEWorker) { - this.xGCEWorker.terminate(); - } - this.start(); - oInitHandler.initGrammarChecker(); - sendCommandToAllTabs("workerRestarted"); - console.log("Worker restarted."); - return true; - }, - - addTask: function () { - // - }, - - closeTask: function () { - // - } -} - - -const oInitHandler = { - - initUIOptions: function () { - browser.storage.local.get("ui_options").then(this._initUIOptions, showError); - browser.storage.local.get("autorefresh_option").then(this._initUIOptions, showError); - }, - - initGrammarChecker: function () { - browser.storage.local.get("gc_options").then(this._initGrammarChecker, showError); - browser.storage.local.get("personal_dictionary").then(this._setSpellingDictionaries, showError); - browser.storage.local.get("community_dictionary").then(this._setSpellingDictionaries, showError); - browser.storage.local.get("sc_options").then(this._initSCOptions, showError); - }, - - _initUIOptions: function (oSavedOptions) { - if (!oSavedOptions.hasOwnProperty("ui_options")) { - browser.storage.local.set({"ui_options": { - textarea: true, - editablenode: true - }}); - } - if (!oSavedOptions.hasOwnProperty("autorefresh_option")) { - browser.storage.local.set({"autorefresh_option": true}); - } - }, - - _initGrammarChecker: function (oSavedOptions) { - try { - let dOptions = (oSavedOptions.hasOwnProperty("gc_options")) ? oSavedOptions.gc_options : null; - if (dOptions !== null && Object.getOwnPropertyNames(dOptions).length == 0) { - console.log("# Error: the saved options was an empty object."); - dOptions = null; - } - oWorkerHandler.xGCEWorker.postMessage({ - sCommand: "init", - oParam: {sExtensionPath: browser.extension.getURL(""), dOptions: dOptions, sContext: "Firefox"}, - oInfo: {} - }); - } - catch (e) { - console.log("initGrammarChecker failed"); - showError(e); - } - }, - - _setSpellingDictionaries: function (oData) { - if (oData.hasOwnProperty("community_dictionary")) { - oWorkerHandler.xGCEWorker.postMessage({ sCommand: "setDictionary", oParam: { sDictionary: "community", oDict: oData["community_dictionary"] }, oInfo: {} }); - } - if (oData.hasOwnProperty("personal_dictionary")) { - oWorkerHandler.xGCEWorker.postMessage({ sCommand: "setDictionary", oParam: { sDictionary: "personal", oDict: oData["personal_dictionary"] }, oInfo: {} }); - } - }, - - _initSCOptions: function (oData) { - if (!oData.hasOwnProperty("sc_options")) { - browser.storage.local.set({"sc_options": { - community: true, - personal: true - }}); - oWorkerHandler.xGCEWorker.postMessage({ sCommand: "setDictionaryOnOff", oParam: { sDictionary: "community", bActivate: true }, oInfo: {} }); - oWorkerHandler.xGCEWorker.postMessage({ sCommand: "setDictionaryOnOff", oParam: { sDictionary: "personal", bActivate: true }, oInfo: {} }); - } else { - oWorkerHandler.xGCEWorker.postMessage({ sCommand: "setDictionaryOnOff", oParam: { sDictionary: "community", bActivate: oData.sc_options["community"] }, oInfo: {} }); - oWorkerHandler.xGCEWorker.postMessage({ sCommand: "setDictionaryOnOff", oParam: { sDictionary: "personal", bActivate: oData.sc_options["personal"] }, oInfo: {} }); - } - } -} - -// start the Worker for the GC -oWorkerHandler.start(); - -// init the options stuff and start the GC -oInitHandler.initUIOptions(); -oInitHandler.initGrammarChecker(); - - - -/* - Actions -*/ - -function storeGCOptions (dOptions) { - if (dOptions instanceof Map) { - dOptions = helpers.mapToObject(dOptions); - } - browser.storage.local.set({"gc_options": dOptions}); -} - - -function showError (e) { - console.error(e); - //console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message); -} DELETED gc_lang/fr/mailext/chrome.manifest Index: gc_lang/fr/mailext/chrome.manifest ================================================================== --- gc_lang/fr/mailext/chrome.manifest +++ /dev/null @@ -1,9 +0,0 @@ -# https://developer.mozilla.org/en-US/docs/Chrome_Registration -content grammarchecker content/ -content promiseworker ./worker/ -resource grammalecte ./grammalecte/ -locale grammarchecker fr locale/fr/ -locale grammarchecker en locale/en/ -skin grammarchecker classic/1.0 skin/ -overlay chrome://messenger/content/messengercompose/messengercompose.xul chrome://grammarchecker/content/overlay.xul -style chrome://messenger/content/customizeToolbar.xul chrome://grammarchecker/content/overlay.css DELETED gc_lang/fr/mailext/content/about.css Index: gc_lang/fr/mailext/content/about.css ================================================================== --- gc_lang/fr/mailext/content/about.css +++ /dev/null @@ -1,46 +0,0 @@ -/* CSS */ - -.descr { - font-size: 18px; - font-weight: bold; - text-align: center; -} - -.stdlabel { - font-size: 16px; - text-align: center; -} - -#website { - font-size: 16px; - font-weight: bold; - color: hsl(210, 50%, 50%); - text-align: center; - cursor: pointer; -} - -#contrib { - font-size: 16px; - text-align: center; - color: hsl(210, 50%, 50%); - cursor: pointer; -} - - -/* - TB Next: fix dialogheaders -*/ -dialogheader { - -moz-binding: url("chrome://messenger/content/generalBindings.xml#dialogheader"); - margin: 0 5px 5px; - border: 1px solid ThreeDDarkShadow; - padding: 5px 8px; - background-color: Highlight; - color: HighlightText; -} - -.dialogheader-title { - margin: 0 !important; - font-size: larger; - font-weight: bold; -} DELETED gc_lang/fr/mailext/content/about.js Index: gc_lang/fr/mailext/content/about.js ================================================================== --- gc_lang/fr/mailext/content/about.js +++ /dev/null @@ -1,35 +0,0 @@ -// JavaScript - -const Cc = Components.classes; -const Ci = Components.interfaces; -//const Cu = Components.utils; - - -function openInBrowserURL (sURL) { - // method found in S3.Google.Translator - try { - openURL(sURL); - // Works in overlay.js, but not here… Seems there is no documentation available about this feature on Mozilla.org - } - catch (e) { - console.error(e); - //Cu.reportError(e); - } -} - -function openInTabURL (sURL) { - // method found in S3.Google.Translator - try { - let xWM = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator); - let xWin = xWM.getMostRecentWindow("mail:3pane"); - let xTabmail = xWin.document.getElementById('tabmail'); - xWin.focus(); - if (xTabmail) { - xTabmail.openTab('contentTab', { contentPage: sURL }); - } - } - catch (e) { - console.error(e); - //Cu.reportError(e); - } -} DELETED gc_lang/fr/mailext/content/about.xul Index: gc_lang/fr/mailext/content/about.xul ================================================================== --- gc_lang/fr/mailext/content/about.xul +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - -