Commit 2f8a52e8 authored by Ludan Stoecklé's avatar Ludan Stoecklé

1.14.0

parent e162653b
......@@ -19,7 +19,7 @@ stages:
# variables etc.
variables:
ROSAENLG_VERSION: 1.13.0
ROSAENLG_VERSION: 1.14.0
DOCKER_REGISTRY: registry.gitlab.com/rosaenlg-projects/rosaenlg
DOCKER_CLI_ROOT: ${DOCKER_REGISTRY}/cli
DOCKER_SERVER_ROOT: ${DOCKER_REGISTRY}/server
......
......@@ -13,7 +13,7 @@ console.log(`browser-ide-demo: using RosaeNLG version ${rosaeNlgVersion}`);
function init(cb) {
const folders = ['dist'];
folders.forEach(dir => {
folders.forEach((dir) => {
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
console.log('📁 folder created:', dir);
......@@ -35,6 +35,7 @@ function copyStaticElts() {
`../rosaenlg/dist/rollup/rosaenlg_tiny_de_DE_${rosaeNlgVersion}_comp.js`,
`../rosaenlg/dist/rollup/rosaenlg_tiny_it_IT_${rosaeNlgVersion}_comp.js`,
`../rosaenlg/dist/rollup/rosaenlg_tiny_OTHER_${rosaeNlgVersion}_comp.js`,
'../rosaenlg-packager/dist/rosaenlg-packager-bundle.js',
'lib/vue.min.js',
'src/app.css',
]).pipe(dest('dist/'));
......@@ -102,7 +103,7 @@ function publishS3() {
`dist/rosaenlg_tiny_OTHER_${rosaeNlgVersion}_comp.js`,
])
.pipe(
rename(function(path) {
rename(function (path) {
path.dirname = destFolder + path.dirname;
}),
)
......@@ -119,7 +120,7 @@ function publishS3() {
return merge(gzip, plain)
.pipe(
rename(function(path) {
rename(function (path) {
path.dirname = destFolder + path.dirname;
}),
)
......
{
"name": "browser-ide-demo",
"version": "1.13.0",
"version": "1.14.0",
"description": "Client side demo of NLG templates compilation and rendering using RosaeNLG",
"main": "index.js",
"scripts": {
......@@ -33,7 +33,8 @@
"gulp-inject-string": "^1.1.2",
"gulp-rename": "^2.0.0",
"merge-stream": "^2.0.0",
"rosaenlg": "1.13.0",
"rosaenlg": "1.14.0",
"rosaenlg-packager": "0.1.0",
"vue-codemirror": "^4.0.6"
}
}
......@@ -103,60 +103,81 @@ window.onload = function () {
this.userDownload(`${this.exampleName}.pug`, textFileAsBlob);
},
package() {
// could use some share code like gulp-rosaenlg but is practical like this
const name = this.exampleName.replace(/[^\w]/gi, '');
getCleanName() {
return this.exampleName.replace(/[^\w]/gi, '');
},
packageJson() {
const name = this.getCleanName();
const packaged = {
templateId: name,
const package = {
src: {
templateId: name,
entryTemplate: `${name}.pug`,
templates: {},
compileInfo: {
activate: false,
activate: true,
compileDebug: false,
language: language,
},
templates: {},
},
};
packaged.src.templates[`${name}.pug`] = this.code;
package.src.templates[`${name}.pug`] = this.code;
const contentAsBlob = new Blob([JSON.stringify(packaged)], { type: 'application/json' });
rosaenlgPackager.completePackagedTemplateJson(package, this.getFctsHolder());
const contentAsBlob = new Blob([JSON.stringify(package)], { type: 'application/json' });
this.userDownload(`${name}.json`, contentAsBlob);
},
packageJs() {
const name = this.getCleanName();
const staticFs = {};
staticFs[`${name}.pug`] = this.code;
const compiled = rosaenlgPackager.compileTemplateToJsString(
`${name}.pug`,
language,
staticFs,
this.getFctsHolder(),
);
const contentAsBlob = new Blob([compiled], {
type: 'text/javascript',
});
this.userDownload(`${name}.js`, contentAsBlob);
},
getFctsHolder() {
switch (language) {
case 'fr_FR': {
// eslint-disable-next-line @typescript-eslint/camelcase
return rosaenlg_fr_FR;
}
case 'de_DE': {
// eslint-disable-next-line @typescript-eslint/camelcase
return rosaenlg_de_DE;
}
case 'it_IT': {
// eslint-disable-next-line @typescript-eslint/camelcase
return rosaenlg_it_IT;
}
case 'en_US': {
// eslint-disable-next-line @typescript-eslint/camelcase
return rosaenlg_en_US;
}
case 'OTHER': {
// eslint-disable-next-line @typescript-eslint/camelcase
return rosaenlg_OTHER;
}
}
},
compileRender() {
pugTemplate = this.code;
try {
let renderFct;
switch (language) {
case 'fr_FR': {
// eslint-disable-next-line @typescript-eslint/camelcase
renderFct = rosaenlg_fr_FR;
break;
}
case 'de_DE': {
// eslint-disable-next-line @typescript-eslint/camelcase
renderFct = rosaenlg_de_DE;
break;
}
case 'it_IT': {
// eslint-disable-next-line @typescript-eslint/camelcase
renderFct = rosaenlg_it_IT;
break;
}
case 'en_US': {
// eslint-disable-next-line @typescript-eslint/camelcase
renderFct = rosaenlg_en_US;
break;
}
case 'OTHER': {
// eslint-disable-next-line @typescript-eslint/camelcase
renderFct = rosaenlg_OTHER;
break;
}
}
const rendered = renderFct.render(pugTemplate, {
const fctsHolder = this.getFctsHolder();
const rendered = fctsHolder.render(pugTemplate, {
language: language,
});
this.errors = '';
......
......@@ -15,9 +15,12 @@
<script src="javascript.js"></script>
<script>
const language = '$lang$';
const rosaenlg = rosaenlg_$lang$;
// window.rosaenlg = rosaenlg_$lang$; // rosaenlg-packager needs it; and "const rosaenlg = ..." is not good enough
</script>
<script src="app.min.js"></script>
<script src="rosaenlg-packager-bundle.js"></script>
<link rel="stylesheet" href="app.css">
......@@ -36,9 +39,11 @@
<div class="block">
<codemirror v-model="code" :options="cmOption"></codemirror>
</div>
<button v-on:click="compileRender()">Compile and render</button>
<button v-on:click="compileRender()">Compile and render</button>
<br />
<button v-on:click="save()">Save</button>
<button v-on:click="package()">Package</button>
<button v-on:click="packageJson()">Package JSON</button>
<button v-on:click="packageJs()">Package compiled JavaScript</button>
<span id="langlinks">
<a href="demo_en_US.html">English</a>
<a href="demo_fr_FR.html">French</a>
......
{
"name": "english-a-an-list",
"version": "0.5.0",
"version": "0.6.0",
"description": "English words and adjectives that are preceded by the indefinite article 'an', based on WordNet",
"main": "dist/aan.json",
"scripts": {
......
{
"name": "english-a-an",
"version": "0.5.0",
"version": "0.6.0",
"description": "English a/an indefinite articles, based on WordNet",
"main": "dist/index.js",
"scripts": {
......@@ -13,7 +13,7 @@
"url": "[email protected]:rosaenlg-projects/rosaenlg.git"
},
"devDependencies": {
"english-a-an-list": "0.5.0",
"english-a-an-list": "0.6.0",
"mocha": "^7.1.1",
"typescript": "^3.7.2"
},
......
{
"name": "english-determiners",
"version": "2.13.0",
"version": "2.14.0",
"description": "English determiners",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "english-plurals-list",
"version": "0.5.0",
"version": "0.6.0",
"description": "English irregular plurals list, based on WordNet",
"main": "dist/plurals.json",
"scripts": {
......
{
"name": "english-plurals",
"version": "0.5.0",
"version": "0.6.0",
"description": "English plural of words",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......@@ -45,7 +45,7 @@
}
},
"devDependencies": {
"english-plurals-list": "0.5.0",
"english-plurals-list": "0.6.0",
"mocha": "^7.1.1",
"nyc": "^15.0.0",
"typescript": "^3.7.2"
......
{
"name": "english-verbs-gerunds",
"version": "0.5.0",
"version": "0.6.0",
"description": "English irregular gerunds list (-ing), based on WordNet",
"main": "dist/gerunds.json",
"scripts": {
......
{
"name": "english-verbs-helper",
"version": "0.5.0",
"version": "0.6.0",
"description": "English verbs conjugation",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......@@ -45,8 +45,8 @@
}
},
"devDependencies": {
"english-verbs-gerunds": "0.5.0",
"english-verbs-irregular": "0.5.0",
"english-verbs-gerunds": "0.6.0",
"english-verbs-irregular": "0.6.0",
"mocha": "^7.1.1",
"nyc": "^15.0.0",
"typescript": "^3.7.2"
......
{
"name": "english-verbs-irregular",
"version": "0.5.0",
"version": "0.6.0",
"description": "English irregular verbs list (JSON)",
"main": "dist/verbs.json",
"scripts": {
......
{
"name": "french-adjectives",
"version": "2.13.0",
"version": "2.14.0",
"description": "Agreement of adjectives in French",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......@@ -46,7 +46,7 @@
},
"dependencies": {
"debug": "^4.1.1",
"french-h-muet-aspire": "2.13.0"
"french-h-muet-aspire": "2.14.0"
},
"keywords": [
"french",
......
{
"name": "french-determiners",
"version": "2.13.0",
"version": "2.14.0",
"description": "French determiners",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "french-h-muet-aspire",
"version": "2.13.0",
"version": "2.14.0",
"description": "List of French words that are 'aspiré' (vs. 'muet')",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "french-ordinals",
"version": "2.13.0",
"version": "2.14.0",
"description": "Ordinal numbers in French: 12 => douzième",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "french-verbs-intransitive",
"version": "0.6.0",
"version": "0.7.0",
"description": "list of intransitive French verbs",
"main": "dist/intransitive.json",
"scripts": {
......
{
"name": "french-verbs-lefff",
"version": "0.6.0",
"version": "0.7.0",
"description": "French verbs conjugation data, based on the Lefff content",
"main": "dist/conjugations.json",
"scripts": {
......
{
"name": "french-verbs-transitive",
"version": "0.6.0",
"version": "0.7.0",
"description": "French transitive verbs, based on Wikipedia",
"main": "dist/transitive.json",
"scripts": {
......
{
"name": "french-verbs",
"version": "2.13.0",
"version": "2.14.0",
"description": "French verbs conjugation",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......@@ -46,11 +46,11 @@
},
"dependencies": {
"debug": "^4.1.1",
"french-h-muet-aspire": "2.13.0",
"french-verbs-transitive": "0.6.0"
"french-h-muet-aspire": "2.14.0",
"french-verbs-transitive": "0.7.0"
},
"devDependencies": {
"french-verbs-lefff": "0.6.0",
"french-verbs-lefff": "0.7.0",
"mocha": "^7.1.1",
"nyc": "^15.0.0",
"typescript": "^3.7.2"
......
{
"name": "french-words-gender-lefff",
"version": "0.6.0",
"version": "0.7.0",
"description": "French words gender, based on the Lefff content",
"main": "dist/words.json",
"scripts": {
......
{
"name": "french-words-gender",
"version": "2.13.0",
"version": "2.14.0",
"description": "Gender of French words",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......@@ -48,7 +48,7 @@
"debug": "^4.1.1"
},
"devDependencies": {
"french-words-gender-lefff": "0.6.0",
"french-words-gender-lefff": "0.7.0",
"gulp": "^4.0.2",
"mocha": "^7.1.1",
"nyc": "^15.0.0",
......
{
"name": "german-adjectives-dict",
"version": "0.6.0",
"version": "0.7.0",
"description": "German adjectives dictionnary, based on the german-pos-dict content",
"main": "dist/adjectives.json",
"scripts": {
......
{
"name": "german-adjectives",
"version": "2.13.0",
"version": "2.14.0",
"description": "German adjectives agreement",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......@@ -45,7 +45,7 @@
}
},
"devDependencies": {
"german-adjectives-dict": "0.6.0",
"german-adjectives-dict": "0.7.0",
"mocha": "^7.1.1",
"nyc": "^15.0.0",
"typescript": "^3.7.2"
......
{
"name": "german-determiners",
"version": "2.13.0",
"version": "2.14.0",
"description": "German determiners",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "german-dict-helper",
"version": "2.13.0",
"version": "2.14.0",
"description": "Helper functions on an included database derived from german-pos-dict",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "german-ordinals",
"version": "2.13.0",
"version": "2.14.0",
"description": "Ordinal numbers in German: 12 => zwölfte",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......
{
"name": "german-verbs-dict",
"version": "0.6.0",
"version": "0.7.0",
"description": "German verbs dictionnary, based on the german-pos-dict content",
"main": "dist/verbs.json",
"scripts": {
......
{
"name": "german-verbs",
"version": "2.13.0",
"version": "2.14.0",
"description": "German verbs, based on german-pos-dict",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......@@ -45,7 +45,7 @@
}
},
"devDependencies": {
"german-verbs-dict": "0.6.0",
"german-verbs-dict": "0.7.0",
"nyc": "^15.0.0",
"typescript": "^3.7.2"
},
......
{
"name": "german-words-dict",
"version": "0.6.0",
"version": "0.7.0",
"description": "German words dictionnary, based on the german-pos-dict content",
"main": "dist/words.json",
"scripts": {
......
{
"name": "german-words",
"version": "2.13.0",
"version": "2.14.0",
"description": "Gender and case of German words",
"main": "dist/index.js",
"types": "dist/index.d.ts",
......@@ -48,7 +48,7 @@
}
},
"devDependencies": {
"german-words-dict": "0.6.0",
"german-words-dict": "0.7.0",
"mocha": "^7.1.1",
"nyc": "^15.0.0",
"typescript": "^3.7.2"
......
const gulpRosaeNLG = require('./dist/index.js');
const fs = require('fs');
const tmpFile = 'tmp.js';
const os = gulpRosaeNLG.compileTemplates(
[{ source: 'test/test.pug', name: 'test' }],
'en_US',
tmpFile,
'templates_holder',
);
os.on('finish', function() {
console.log('DONE');
const compiledString = fs.readFileSync(tmpFile, 'utf-8');
//console.log(compiledString);
console.log(`done: ${compiledString.length}`);
// fs.unlinkSync(tmpFile);
});