Overview
Comment: | [build] build chrome extension |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | build |
Files: | files | file ages | folders |
SHA3-256: |
359d58c56b89e52db6ae16a9be7c7525 |
User & Date: | olr on 2020-04-08 10:11:18 |
Other Links: | manifest | tags |
Context
2020-04-08
| ||
12:39 | [graphspell] suggestions: phonetic and number improvements [fr] version 1.9.0 check-in: 0441dd2bd3 user: olr tags: fr, graphspell, trunk | |
10:11 | [build] build chrome extension check-in: 359d58c56b user: olr tags: build, trunk | |
08:50 | [fx] don’t rewrite text when rechecking paragraphs -> prevent bug of overlapping events check-in: 9d2f92044a user: olr tags: fx, trunk | |
Changes
Modified gc_lang/fr/build.py from [5f4b392f44] to [43a9cad18e].
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
..
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# Builder for French language import os import platform import zipfile from distutils import dir_util, file_util import helpers def build (sLang, dVars): "complementary build launched from make.py" createWebExtension(sLang, dVars) createMailExtension(sLang, dVars) createNodeJSPackage(sLang) def createWebExtension (sLang, dVars): "create Web-extension" print("Building WebExtension") 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 helpers.moveFolderContent("_build/webext/"+sLang+"/web-ext-artifacts", "_build", "fx-"+sLang+"-", True) def _createOptionsForWebExtension (dVars): sHTML = "" sLang = dVars['sDefaultUILang'] for sSection, lOpt in dVars['lStructOpt']: sHTML += f'\n<div id="subsection_{sSection}" class="opt_subsection">\n <h2 data-l10n-id="option_{sSection}">{dVars["dOptLabel"][sLang][sSection][0]}</h2>\n' ................................................................................ sHTML += f' <p><input type="checkbox" id="option_{sOpt}" class="gc_option" data-option="{sOpt}"/><label id="option_label_{sOpt}" for="option_{sOpt}" data-l10n-id="option_{sOpt}">{dVars["dOptLabel"][sLang][sOpt][0]}</label></p>\n' sHTML += '</div>\n' return sHTML def createMailExtension (sLang, dVars): "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) dVars = _createOptionsForThunderbird(dVars) helpers.addFolderToZipAndFileFile(hZip, "gc_lang/"+sLang+"/mailext", "", dVars, True) |
>
>
>
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
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
..
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# Builder for French language import os import platform import zipfile import shutil import json import traceback from distutils import dir_util, file_util import helpers def build (sLang, dVars): "complementary build launched from make.py" createWebExtension(sLang, dVars) convertWebExtensionForChrome(sLang, dVars) createMailExtension(sLang, dVars) createNodeJSPackage(sLang) def createWebExtension (sLang, dVars): "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 helpers.moveFolderContent("_build/webext/"+sLang+"/web-ext-artifacts", "_build", "firefox-", True) def convertWebExtensionForChrome (sLang, dVars): "Create the extension for Chrome" print("> Converting WebExtension for Chrome") try: with open(f"_build/webext/{sLang}/manifest.json", "r", encoding="utf-8") as hSrc: dManifest = json.load(hSrc) if "applications" in dManifest: del dManifest["applications"] if "chrome_settings_overrides" in dManifest: del dManifest["chrome_settings_overrides"] with open(f"_build/webext/{sLang}/manifest.json", "w", encoding="utf-8") as hDst: json.dump(dManifest, hDst, ensure_ascii=True, indent=2) shutil.make_archive(f"_build/chrome-grammalecte-{sLang}-v{dVars['version']}", 'zip', "_build/webext/"+sLang) except: traceback.print_exc() print(" Error. Converting the WebExtension for Chrome failed.") def _createOptionsForWebExtension (dVars): sHTML = "" sLang = dVars['sDefaultUILang'] for sSection, lOpt in dVars['lStructOpt']: sHTML += f'\n<div id="subsection_{sSection}" class="opt_subsection">\n <h2 data-l10n-id="option_{sSection}">{dVars["dOptLabel"][sLang][sSection][0]}</h2>\n' ................................................................................ sHTML += f' <p><input type="checkbox" id="option_{sOpt}" class="gc_option" data-option="{sOpt}"/><label id="option_label_{sOpt}" for="option_{sOpt}" data-l10n-id="option_{sOpt}">{dVars["dOptLabel"][sLang][sOpt][0]}</label></p>\n' sHTML += '</div>\n' return sHTML def createMailExtension (sLang, dVars): "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) dVars = _createOptionsForThunderbird(dVars) helpers.addFolderToZipAndFileFile(hZip, "gc_lang/"+sLang+"/mailext", "", dVars, True) |
Modified helpers.py from [9aa31c58b5] to [f66c7bb7d2].
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
def fileFile (spf, dVars): "return file <spf> as a text filed with variables from <dVars>" return Template(open(spf, "r", encoding="utf-8").read()).safe_substitute(dVars) def copyAndFileTemplate (spfSrc, spfDst, dVars): "write file <spfSrc> as <spfDst> with variables filed with <dVars>" s = Template(open(spfSrc, "r", encoding="utf-8").read()).safe_substitute(dVars) open(spfDst, "w", encoding="utf-8", newline="\n").write(s) def addFolderToZipAndFileFile (hZip, spSrc, spDst, dVars, bRecursive): "add folder content to zip archive and file files with <dVars>" # recursive function spSrc = spSrc.strip("/ ") spDst = spDst.strip("/ ") |
| | |
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
def fileFile (spf, dVars): "return file <spf> as a text filed with variables from <dVars>" return Template(open(spf, "r", encoding="utf-8").read()).safe_substitute(dVars) 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 addFolderToZipAndFileFile (hZip, spSrc, spDst, dVars, bRecursive): "add folder content to zip archive and file files with <dVars>" # recursive function spSrc = spSrc.strip("/ ") spDst = spDst.strip("/ ") |