Index: gc_lang/fr/build.py ================================================================== --- gc_lang/fr/build.py +++ gc_lang/fr/build.py @@ -7,12 +7,23 @@ import helpers def build (sLang, dVars, spLangPack): "complementary build launched from make.py" - createFirefoxExtension(sLang, dVars) - createThunderbirdExtension(sLang, dVars, spLangPack) + #createFirefoxExtension(sLang, dVars) + createWebExtension(sLang, dVars) + #createThunderbirdExtension(sLang, dVars, spLangPack) + + +def createWebExtension (sLang, dVars): + "create Web-extension" + print("Building Web-extension") + 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") + with helpers.cd("_build/webext/"+sLang): + os.system("web-ext build") def createFirefoxExtension (sLang, dVars): "create extension for Firefox" print("Building extension for Firefox") Index: gc_lang/fr/config.ini ================================================================== --- gc_lang/fr/config.ini +++ gc_lang/fr/config.ini @@ -28,10 +28,12 @@ oxt_identifier = French.linguistic.resources.from.Dicollecte.by.OlivierR # Firefox fx_identifier = French-GC@grammalecte.net fx_name = Grammalecte [fr] + +fx_nightly_path = C:\Program Files (x86)\Nightly\firefox.exe # Thunderbird tb_identifier = French-GC-TB@grammalecte.net tb_name = Grammalecte [fr] tb_debug_extension_path = _build/tb-debug.profile/extensions/French-GC-TB@grammalecte.net ADDED gc_lang/fr/webext/README.md Index: gc_lang/fr/webext/README.md ================================================================== --- gc_lang/fr/webext/README.md +++ gc_lang/fr/webext/README.md @@ -0,0 +1,22 @@ +# Grammalecte + +**French Grammar Checker** + +écrit en JavaScript ES6/ES7 +par Olivier R. + +## Fonctionnalités ## + +* correcteur grammatical +* conjugueur +* formateur de texte +* lexicographe + +## Site web ## + +https://grammalecte.net + +## Licence ## + +GNU GPL 3.0+ +http://www.gnu.org/copyleft/gpl.html ADDED gc_lang/fr/webext/content_scripts/modify_page.js Index: gc_lang/fr/webext/content_scripts/modify_page.js ================================================================== --- gc_lang/fr/webext/content_scripts/modify_page.js +++ gc_lang/fr/webext/content_scripts/modify_page.js @@ -0,0 +1,25 @@ + +function do_something (request, sender, sendResponse) { + //removeEverything(); + change(request.myparam); + console.log("DONE!!"); + browser.runtime.onMessage.removeListener(do_something); +} + +function removeEverything () { + while (document.body.firstChild) { + document.body.firstChild.remove(); + } +} + +function change (param) { + document.getElementById("title").setAttribute("background-color", "#809060"); + console.log("param: " + param); + document.getElementById("title").setAttribute("background-color", "#FF0000"); +} + + +/* + Assign do_something() as a listener for messages from the extension. +*/ +browser.runtime.onMessage.addListener(do_something); ADDED gc_lang/fr/webext/img/logo-16.png Index: gc_lang/fr/webext/img/logo-16.png ================================================================== --- gc_lang/fr/webext/img/logo-16.png +++ gc_lang/fr/webext/img/logo-16.png cannot compute difference between binary files ADDED gc_lang/fr/webext/img/logo-32.png Index: gc_lang/fr/webext/img/logo-32.png ================================================================== --- gc_lang/fr/webext/img/logo-32.png +++ gc_lang/fr/webext/img/logo-32.png cannot compute difference between binary files ADDED gc_lang/fr/webext/img/logo-48.png Index: gc_lang/fr/webext/img/logo-48.png ================================================================== --- gc_lang/fr/webext/img/logo-48.png +++ gc_lang/fr/webext/img/logo-48.png cannot compute difference between binary files ADDED gc_lang/fr/webext/img/logo-64.png Index: gc_lang/fr/webext/img/logo-64.png ================================================================== --- gc_lang/fr/webext/img/logo-64.png +++ gc_lang/fr/webext/img/logo-64.png cannot compute difference between binary files ADDED gc_lang/fr/webext/img/logo-96.png Index: gc_lang/fr/webext/img/logo-96.png ================================================================== --- gc_lang/fr/webext/img/logo-96.png +++ gc_lang/fr/webext/img/logo-96.png cannot compute difference between binary files ADDED gc_lang/fr/webext/manifest.json Index: gc_lang/fr/webext/manifest.json ================================================================== --- gc_lang/fr/webext/manifest.json +++ gc_lang/fr/webext/manifest.json @@ -0,0 +1,40 @@ +{ + "manifest_version": 2, + "name": "Grammalecte [fr]", + "short_name": "Grammalecte [fr]", + "version": "0.6", + + "applications": { + "gecko": { + "id": "French-GC@grammalecte.net", + "strict_min_version": "54.0" + } + }, + + "author": "Olivier R.", + "homepage_url": "https://grammalecte.net", + "offline_enabled": true, + + "description": "Correcteur grammatical pour le français.", + + "icons": { "16": "img/logo-16.png", + "32": "img/logo-32.png", + "48": "img/logo-48.png", + "64": "img/logo-64.png", + "96": "img/logo-96.png" }, + + "browser_action": { + "default_icon": "img/logo-32.png", + "default_popup": "panel/main.html", + "default_title": "Grammalecte [fr]", + "browser_style": false + }, + "web_accessible_resources": [ + "beasts/frog.jpg", + "beasts/turtle.jpg", + "beasts/snake.jpg" + ], + "permissions": [ + "activeTab" + ] +} ADDED gc_lang/fr/webext/panel/main.css Index: gc_lang/fr/webext/panel/main.css ================================================================== --- gc_lang/fr/webext/panel/main.css +++ gc_lang/fr/webext/panel/main.css @@ -0,0 +1,90 @@ +/* + flexbox: + https://css-tricks.com/snippets/css/a-guide-to-flexbox/ +*/ + + +/* Cleaner */ + +* { margin: 0; padding: 0; } +img { border: none; } + + +/* Generic classes */ + +.fleft { float: left; } +.fright { float: right; } +.fleftm { float: left; margin-right: 10px; } +.frightm { float: right; margin-left: 10px; } +.clearer { clear: both; font-size: 0; height: 0; } +.center { text-align: center; } + + +a:link, a:visited { + color: hsl(210, 70%, 40%); + /*text-decoration: none;*/ +} +a:hover, a:active { + text-shadow: 0 0 2px hsl(210, 80%, 60%); +} + +a.extlink:hover:after { + content: " >"; +} + +::-moz-selection { + background-color: hsl(210, 50%, 60%); + color: hsl(210, 20%, 100%); + text-shadow: 0 0 2px hsl(210, 80%, 20%); + border-radius: 2px; +} +::selection { + background-color: hsl(210, 50%, 60%); + color: hsl(210, 20%, 100%); + text-shadow: 0 0 2px hsl(210, 80%, 20%); + border-radius: 2px; +} + + +/* Main classes */ + +html { + box-sizing: border-box; + width: 530px; + height: 600px; + font-family: "Trebuchet MS", "Liberation Sans", sans-serif; +} +body { + width: 530px; + height: 600px; +} + +#main { + display: flex; + flex-direction: row; + flex-wrap: nowrap; + align-items: stretch; + background-color: hsl(210, 0%, 100%); + min-height: 100%; +} +#left { + width: 30px; + padding: 20px; + background-color: hsl(210, 10%, 96%); + border-right: solid 1px hsl(210, 0%, 70%); + color: hsl(210, 10%, 96%); +} + +#page { + background-color: hsl(210, 0%, 100%); + padding: 10px; +} + +#page p { + margin: 10px 0 5px 0; +} +#page h2 { + margin: 20px 0 10px 0; + color: hsl(210, 70%, 70%); + font: bold 42px 'Yanone Kaffeesatz', "Liberation Sans Narrow", sans-serif; +} ADDED gc_lang/fr/webext/panel/main.html Index: gc_lang/fr/webext/panel/main.html ================================================================== --- gc_lang/fr/webext/panel/main.html +++ gc_lang/fr/webext/panel/main.html @@ -0,0 +1,42 @@ + + + + + + + + + +
+ +
+ +
+ + +
+
+ +
+
+ +
+ + + + + ADDED gc_lang/fr/webext/panel/main.js Index: gc_lang/fr/webext/panel/main.js ================================================================== --- gc_lang/fr/webext/panel/main.js +++ gc_lang/fr/webext/panel/main.js @@ -0,0 +1,30 @@ + +function showError (e) { + console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message); +} + +function beastNameToURL(beastName) { + switch (beastName) { + case "Frog": + return browser.extension.getURL("beasts/frog.jpg"); + case "Snake": + return browser.extension.getURL("beasts/snake.jpg"); + case "Turtle": + return browser.extension.getURL("beasts/turtle.jpg"); + } +} + +window.addEventListener( + "click", + function (xEvent) { + let xElem = xEvent.target; + if (xElem.id) { + if (xElem.id) { + + } + } else if (xElem.tagName === "A") { + openURL(xElem.getAttribute("href")); + } + }, + false +); Index: make.py ================================================================== --- make.py +++ make.py @@ -286,10 +286,11 @@ xParser.add_argument("-t", "--tests", help="run unit tests", action="store_true") xParser.add_argument("-p", "--perf", help="run performance tests", action="store_true") xParser.add_argument("-pm", "--perf_memo", help="run performance tests and store results in perf_memo.txt", action="store_true") xParser.add_argument("-js", "--javascript", help="JavaScript build for Firefox", action="store_true") xParser.add_argument("-fx", "--firefox", help="Launch Firefox Nightly for XPI testing", action="store_true") + xParser.add_argument("-we", "--web_ext", help="Launch Firefox Nightly for WebExtension testing", action="store_true") xParser.add_argument("-tb", "--thunderbird", help="Launch Thunderbird", action="store_true") xParser.add_argument("-i", "--install", help="install the extension in Writer (path of unopkg must be set in config.ini)", action="store_true") xArgs = xParser.parse_args() if xArgs.build_data: @@ -349,14 +350,18 @@ # Firefox if xArgs.firefox: with helpers.cd("_build/xpi/"+sLang): os.system("jpm run -b nightly") + if xArgs.web_ext: + with helpers.cd("_build/webext/"+sLang): + os.system(r'web-ext run --firefox="' + dVars['fx_nightly_path'] + '" --browser-console') + # Thunderbird if xArgs.thunderbird: os.system("thunderbird -jsconsole -P debug") else: print("Folder not found: gc_lang/"+sLang) if __name__ == '__main__': main()