Grammalecte  Check-in [300f8ca77c]

Overview
Comment:[fx] WebExtension (beginning)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fx | webext
Files: files | file ages | folders
SHA3-256: 300f8ca77cc61164e1f90f4124ad2d7f07c99ba55a05d56207a55dfcd1238346
User & Date: olr on 2017-07-19 14:57:25
Other Links: branch diff | manifest | tags
Context
2017-07-20
15:07
[fx] All-in-one panel check-in: e1cf40b835 user: olr tags: fx, webext
2017-07-19
14:57
[fx] WebExtension (beginning) check-in: 300f8ca77c user: olr tags: fx, webext
07:44
[fx] gc_panel: title for buttons check-in: 5553427e15 user: olr tags: fx, trunk
Changes

Modified gc_lang/fr/build.py from [580d1c8153] to [d0e5942087].

     5      5   from distutils import dir_util, file_util
     6      6   
     7      7   import helpers
     8      8   
     9      9   
    10     10   def build (sLang, dVars, spLangPack):
    11     11       "complementary build launched from make.py"
    12         -    createFirefoxExtension(sLang, dVars)
    13         -    createThunderbirdExtension(sLang, dVars, spLangPack)
           12  +    #createFirefoxExtension(sLang, dVars)
           13  +    createWebExtension(sLang, dVars)
           14  +    #createThunderbirdExtension(sLang, dVars, spLangPack)
           15  +
           16  +
           17  +def createWebExtension (sLang, dVars):
           18  +    "create Web-extension"
           19  +    print("Building Web-extension")
           20  +    helpers.createCleanFolder("_build/webext/"+sLang)
           21  +    dir_util.copy_tree("gc_lang/"+sLang+"/webext/", "_build/webext/"+sLang)
           22  +    dir_util.copy_tree("grammalecte-js", "_build/webext/"+sLang+"/grammalecte")
           23  +    with helpers.cd("_build/webext/"+sLang):
           24  +        os.system("web-ext build")
    14     25   
    15     26   
    16     27   def createFirefoxExtension (sLang, dVars):
    17     28       "create extension for Firefox"
    18     29       print("Building extension for Firefox")
    19     30       helpers.createCleanFolder("_build/xpi/"+sLang)
    20     31       dir_util.copy_tree("gc_lang/"+sLang+"/xpi/", "_build/xpi/"+sLang)

Modified gc_lang/fr/config.ini from [94e5221453] to [77819114c8].

    26     26   unopkg = C:/Program Files/LibreOffice 5/program/unopkg.com
    27     27   oxt_version = 6.1
    28     28   oxt_identifier = French.linguistic.resources.from.Dicollecte.by.OlivierR
    29     29   
    30     30   # Firefox
    31     31   fx_identifier = French-GC@grammalecte.net
    32     32   fx_name = Grammalecte [fr]
           33  +
           34  +fx_nightly_path = C:\Program Files (x86)\Nightly\firefox.exe
    33     35   
    34     36   # Thunderbird
    35     37   tb_identifier = French-GC-TB@grammalecte.net
    36     38   tb_name = Grammalecte [fr]
    37     39   tb_debug_extension_path = _build/tb-debug.profile/extensions/French-GC-TB@grammalecte.net
    38     40   # Set Thunderbird folder in your PATH variable
    39     41   # Create a local profile:

Added gc_lang/fr/webext/README.md version [efab56acd9].

            1  +# Grammalecte
            2  +
            3  +**French Grammar Checker**
            4  +
            5  +écrit en JavaScript ES6/ES7
            6  +par Olivier R.
            7  +
            8  +## Fonctionnalités ##
            9  +
           10  +* correcteur grammatical
           11  +* conjugueur
           12  +* formateur de texte
           13  +* lexicographe
           14  +
           15  +## Site web ##
           16  +
           17  +https://grammalecte.net
           18  +
           19  +## Licence ##
           20  +
           21  +GNU GPL 3.0+
           22  +http://www.gnu.org/copyleft/gpl.html

Added gc_lang/fr/webext/content_scripts/modify_page.js version [7e16bf9b14].

            1  +
            2  +function do_something (request, sender, sendResponse) {
            3  +  //removeEverything();
            4  +  change(request.myparam);
            5  +  console.log("DONE!!");
            6  +  browser.runtime.onMessage.removeListener(do_something);
            7  +}
            8  +
            9  +function removeEverything () {
           10  +  while (document.body.firstChild) {
           11  +    document.body.firstChild.remove();
           12  +  }
           13  +}
           14  +
           15  +function change (param) {
           16  +  document.getElementById("title").setAttribute("background-color", "#809060");
           17  +  console.log("param: " + param);
           18  +  document.getElementById("title").setAttribute("background-color", "#FF0000");
           19  +}
           20  +
           21  +
           22  +/*
           23  +  Assign do_something() as a listener for messages from the extension.
           24  +*/
           25  +browser.runtime.onMessage.addListener(do_something);

Added gc_lang/fr/webext/img/logo-16.png version [dcb1bf8ae0].

cannot compute difference between binary files

Added gc_lang/fr/webext/img/logo-32.png version [99fca9dafd].

cannot compute difference between binary files

Added gc_lang/fr/webext/img/logo-48.png version [73a119e8c1].

cannot compute difference between binary files

Added gc_lang/fr/webext/img/logo-64.png version [53bd99349a].

cannot compute difference between binary files

Added gc_lang/fr/webext/img/logo-96.png version [67db0fb78e].

cannot compute difference between binary files

Added gc_lang/fr/webext/manifest.json version [337f5c63b7].

            1  +{
            2  +  "manifest_version": 2,
            3  +  "name": "Grammalecte [fr]",
            4  +  "short_name": "Grammalecte [fr]",
            5  +  "version": "0.6",
            6  +
            7  +  "applications": {
            8  +    "gecko": {
            9  +      "id": "French-GC@grammalecte.net",
           10  +      "strict_min_version": "54.0"
           11  +    }
           12  +  },
           13  +
           14  +  "author": "Olivier R.",
           15  +  "homepage_url": "https://grammalecte.net",
           16  +  "offline_enabled": true,
           17  +
           18  +  "description": "Correcteur grammatical pour le français.",
           19  +
           20  +  "icons": { "16": "img/logo-16.png",
           21  +             "32": "img/logo-32.png",
           22  +             "48": "img/logo-48.png",
           23  +             "64": "img/logo-64.png",
           24  +             "96": "img/logo-96.png" },
           25  +
           26  +  "browser_action": {
           27  +    "default_icon": "img/logo-32.png",
           28  +    "default_popup": "panel/main.html",
           29  +    "default_title": "Grammalecte [fr]",
           30  +    "browser_style": false
           31  +  },
           32  +  "web_accessible_resources": [
           33  +    "beasts/frog.jpg",
           34  +    "beasts/turtle.jpg",
           35  +    "beasts/snake.jpg"
           36  +  ],
           37  +  "permissions": [
           38  +    "activeTab"
           39  +  ]
           40  +}

Added gc_lang/fr/webext/panel/main.css version [f2d9056e4e].

            1  +/*
            2  +    flexbox:
            3  +    https://css-tricks.com/snippets/css/a-guide-to-flexbox/
            4  +*/
            5  +
            6  +
            7  +/* Cleaner */
            8  +
            9  +* { margin: 0; padding: 0; }
           10  +img { border: none; }
           11  +
           12  +
           13  +/* Generic classes */
           14  +
           15  +.fleft { float: left; }
           16  +.fright { float: right; }
           17  +.fleftm { float: left; margin-right: 10px; }
           18  +.frightm { float: right; margin-left: 10px; }
           19  +.clearer { clear: both; font-size: 0; height: 0; }
           20  +.center { text-align: center; }
           21  +
           22  +
           23  +a:link, a:visited {
           24  +    color: hsl(210, 70%, 40%);
           25  +    /*text-decoration: none;*/
           26  +}
           27  +a:hover, a:active {
           28  +    text-shadow: 0 0 2px hsl(210, 80%, 60%);
           29  +}
           30  +
           31  +a.extlink:hover:after {
           32  +    content: " >";
           33  +}
           34  +
           35  +::-moz-selection {
           36  +    background-color: hsl(210, 50%, 60%);
           37  +    color: hsl(210, 20%, 100%);
           38  +    text-shadow: 0 0 2px hsl(210, 80%, 20%);
           39  +    border-radius: 2px;
           40  +}
           41  +::selection {
           42  +    background-color: hsl(210, 50%, 60%);
           43  +    color: hsl(210, 20%, 100%);
           44  +    text-shadow: 0 0 2px hsl(210, 80%, 20%);
           45  +    border-radius: 2px;
           46  +}
           47  +
           48  +
           49  +/* Main classes */
           50  +
           51  +html {
           52  +    box-sizing: border-box;
           53  +    width: 530px;
           54  +    height: 600px;
           55  +    font-family: "Trebuchet MS", "Liberation Sans", sans-serif;
           56  +}
           57  +body {
           58  +    width: 530px;
           59  +    height: 600px;
           60  +}
           61  +
           62  +#main {
           63  +    display: flex;
           64  +    flex-direction: row;
           65  +    flex-wrap: nowrap;
           66  +    align-items: stretch;
           67  +    background-color: hsl(210, 0%, 100%);
           68  +    min-height: 100%;
           69  +}
           70  +#left {
           71  +    width: 30px;
           72  +    padding: 20px;
           73  +    background-color: hsl(210, 10%, 96%);
           74  +    border-right: solid 1px hsl(210, 0%, 70%);
           75  +    color: hsl(210, 10%, 96%);
           76  +}
           77  +
           78  +#page {
           79  +    background-color: hsl(210, 0%, 100%);
           80  +    padding: 10px;
           81  +}
           82  +
           83  +#page p {
           84  +    margin: 10px 0 5px 0;
           85  +}
           86  +#page h2 {
           87  +    margin: 20px 0 10px 0;
           88  +    color: hsl(210, 70%, 70%);
           89  +    font: bold 42px 'Yanone Kaffeesatz', "Liberation Sans Narrow", sans-serif;
           90  +}

Added gc_lang/fr/webext/panel/main.html version [452168138b].

            1  +<!DOCTYPE html>
            2  +
            3  +<html>
            4  +  <head>
            5  +    <meta charset="utf-8">
            6  +    <link rel="stylesheet" href="main.css"/>
            7  +  </head>
            8  +
            9  +  <body>
           10  +    <div id="main">
           11  +
           12  +      <header id="left">
           13  +        <nav id="menu">
           14  +          <header id="title">
           15  +            <img src="../img/logo-32.png">
           16  +          </header>
           17  +          <ul>
           18  +            <li><a href="#home" onclick="loadHtml('home');"><i class="fa fa-home icon"></i> 1.</a></li>
           19  +            <li><a href="#conj" onclick="loadHtml('conj');"><i class="fa fa-star icon"></i> CJ</a></li>
           20  +            <li><a href="#tf" onclick="loadHtml('tf');"><i class="fa fa-photo icon"></i> TF</a></li>
           21  +            <li><a href="#cg" onclick="loadHtml('cg');"><i class="fa fa-question-circle icon"></i> CG</a></li>
           22  +            <li><a href="#op1" onclick="loadHtml('op1');"><i class="fa fa-coffee icon"></i> OP1</a></li>
           23  +            <li><a href="#op2" onclick="loadHtml('op2');"><i class="fa fa-keyboard-o icon"></i> OP2</a></li>
           24  +            <li><a href="#lxg" onclick="loadHtml('lxg');"><i class="fa fa-keyboard-o icon"></i> LXG</a></li>
           25  +            <li><a href="#tests" onclick="loadHtml('lxg');"><i class="fa fa-keyboard-o icon"></i> TST</a></li>
           26  +          </ul>
           27  +        </nav>
           28  +      </header> <!-- #left -->
           29  +
           30  +
           31  +      <div id="page">
           32  +        <article id="loadedpage">
           33  +          <!-- here goes the page loaded via JS -->
           34  +        </article>
           35  +      </div> <!-- #page -->
           36  +
           37  +    </div> <!-- #main -->
           38  +
           39  +    <script src="main.js"></script>
           40  +  </body>
           41  +
           42  +</html>

Added gc_lang/fr/webext/panel/main.js version [7589d020fd].

            1  +
            2  +function showError (e) {
            3  +  console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message);
            4  +}
            5  +
            6  +function beastNameToURL(beastName) {
            7  +  switch (beastName) {
            8  +    case "Frog":
            9  +      return browser.extension.getURL("beasts/frog.jpg");
           10  +    case "Snake":
           11  +      return browser.extension.getURL("beasts/snake.jpg");
           12  +    case "Turtle":
           13  +      return browser.extension.getURL("beasts/turtle.jpg");
           14  +  }
           15  +}
           16  +
           17  +window.addEventListener(
           18  +  "click",
           19  +  function (xEvent) {
           20  +    let xElem = xEvent.target;
           21  +    if (xElem.id) {
           22  +      if (xElem.id) {
           23  +
           24  +      }
           25  +    } else if (xElem.tagName === "A") {
           26  +      openURL(xElem.getAttribute("href"));
           27  +    }
           28  +  },
           29  +  false
           30  +);

Modified make.py from [14dcb35490] to [e6482fde8c].

   284    284       xParser.add_argument("-ba", "--build_data_after", help="launch build_data.py (only part 2: before dictionary building)", action="store_true")
   285    285       xParser.add_argument("-d", "--dict", help="generate FSA dictionary", action="store_true")
   286    286       xParser.add_argument("-t", "--tests", help="run unit tests", action="store_true")
   287    287       xParser.add_argument("-p", "--perf", help="run performance tests", action="store_true")
   288    288       xParser.add_argument("-pm", "--perf_memo", help="run performance tests and store results in perf_memo.txt", action="store_true")
   289    289       xParser.add_argument("-js", "--javascript", help="JavaScript build for Firefox", action="store_true")
   290    290       xParser.add_argument("-fx", "--firefox", help="Launch Firefox Nightly for XPI testing", action="store_true")
          291  +    xParser.add_argument("-we", "--web_ext", help="Launch Firefox Nightly for WebExtension testing", action="store_true")
   291    292       xParser.add_argument("-tb", "--thunderbird", help="Launch Thunderbird", action="store_true")
   292    293       xParser.add_argument("-i", "--install", help="install the extension in Writer (path of unopkg must be set in config.ini)", action="store_true")
   293    294       xArgs = xParser.parse_args()
   294    295   
   295    296       if xArgs.build_data:
   296    297           xArgs.build_data_before = True
   297    298           xArgs.build_data_after = True
................................................................................
   347    348                           tests.perf(sVersion, hDst)
   348    349   
   349    350               # Firefox
   350    351               if xArgs.firefox:
   351    352                   with helpers.cd("_build/xpi/"+sLang):
   352    353                       os.system("jpm run -b nightly")
   353    354   
          355  +            if xArgs.web_ext:
          356  +                with helpers.cd("_build/webext/"+sLang):
          357  +                    os.system(r'web-ext run --firefox="' + dVars['fx_nightly_path'] + '" --browser-console')            
          358  +
   354    359               # Thunderbird
   355    360               if xArgs.thunderbird:
   356    361                   os.system("thunderbird -jsconsole -P debug")
   357    362           else:
   358    363               print("Folder not found: gc_lang/"+sLang)
   359    364   
   360    365   
   361    366   if __name__ == '__main__':
   362    367       main()