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: trunk, fx
Changes

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

1
2
3
4
5
6
7
8
9
10
11
12
13













14
15
16
17
18
19
20
1
2
3
4
5
6
7
8
9
10
11


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31











-
-
+
+
+
+
+
+
+
+
+
+
+
+
+







# Builder for French language

import os
import zipfile
from distutils import dir_util, file_util

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")
    helpers.createCleanFolder("_build/xpi/"+sLang)
    dir_util.copy_tree("gc_lang/"+sLang+"/xpi/", "_build/xpi/"+sLang)

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

26
27
28
29
30
31
32


33
34
35
36
37
38
39
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41







+
+







unopkg = C:/Program Files/LibreOffice 5/program/unopkg.com
oxt_version = 6.1
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
# Set Thunderbird folder in your PATH variable
# Create a local profile:

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























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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 version [7e16bf9b14].


























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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 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
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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 version [f2d9056e4e].



























































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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 version [452168138b].











































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="main.css"/>
  </head>

  <body>
    <div id="main">

      <header id="left">
        <nav id="menu">
          <header id="title">
            <img src="../img/logo-32.png">
          </header>
          <ul>
            <li><a href="#home" onclick="loadHtml('home');"><i class="fa fa-home icon"></i> 1.</a></li>
            <li><a href="#conj" onclick="loadHtml('conj');"><i class="fa fa-star icon"></i> CJ</a></li>
            <li><a href="#tf" onclick="loadHtml('tf');"><i class="fa fa-photo icon"></i> TF</a></li>
            <li><a href="#cg" onclick="loadHtml('cg');"><i class="fa fa-question-circle icon"></i> CG</a></li>
            <li><a href="#op1" onclick="loadHtml('op1');"><i class="fa fa-coffee icon"></i> OP1</a></li>
            <li><a href="#op2" onclick="loadHtml('op2');"><i class="fa fa-keyboard-o icon"></i> OP2</a></li>
            <li><a href="#lxg" onclick="loadHtml('lxg');"><i class="fa fa-keyboard-o icon"></i> LXG</a></li>
            <li><a href="#tests" onclick="loadHtml('lxg');"><i class="fa fa-keyboard-o icon"></i> TST</a></li>
          </ul>
        </nav>
      </header> <!-- #left -->


      <div id="page">
        <article id="loadedpage">
          <!-- here goes the page loaded via JS -->
        </article>
      </div> <!-- #page -->

    </div> <!-- #main -->

    <script src="main.js"></script>
  </body>

</html>

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































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
);

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

284
285
286
287
288
289
290

291
292
293
294
295
296
297
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298







+







    xParser.add_argument("-ba", "--build_data_after", help="launch build_data.py (only part 2: before dictionary building)", action="store_true")
    xParser.add_argument("-d", "--dict", help="generate FSA dictionary", action="store_true")
    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:
        xArgs.build_data_before = True
        xArgs.build_data_after = True
347
348
349
350
351
352
353




354
355
356
357
358
359
360
361
362
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367







+
+
+
+









                        tests.perf(sVersion, hDst)

            # 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()