Skip to content

Commit e9a7d17

Browse files
author
Jelte Lagendijk
committed
Update files
1 parent fefb1d6 commit e9a7d17

File tree

9 files changed

+209
-239
lines changed

9 files changed

+209
-239
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 4
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ test/.project
1212
settings/
1313
node_modules/
1414
dist/
15+
*DS_Store*

Gruntfile.js

Lines changed: 185 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,195 @@
1-
'use strict';
1+
// Generated on 2016-01-04 using generator-mendix 1.1.0 :: http://github.com/git+https://github.com/mendix/generator-mendix.git
2+
/*jshint -W069*/
3+
/*global module*/
4+
"use strict";
5+
6+
var path = require("path"),
7+
mendixApp = require("node-mendix-modeler-path"),
8+
base64 = require("node-base64-image"),
9+
semver = require("semver"),
10+
xml2js = require("xml2js"),
11+
parser = new xml2js.Parser(),
12+
builder = new xml2js.Builder({
13+
renderOpts: { pretty: true, indent: " ", newline: "\n" },
14+
xmldec: { standalone: null, encoding: "utf-8" }
15+
}),
16+
shelljs = require("shelljs");
217

318
// In case you seem to have trouble starting Mendix through `grunt start-mendix`, you might have to set the path to the Mendix application.
419
// If it works, leave MODELER_PATH at null
520
var MODELER_PATH = null;
6-
var MODELER_ARGS = '/file:{path}';
7-
8-
var path = require('path'),
9-
mendixApp = require('node-mendix-modeler-path'),
10-
shelljs = require('shelljs');
21+
var MODELER_ARGS = "/file:{path}";
1122

1223
// In case you have a different path to the test project (currently in ./test/Test.mpr) point TEST_PATH to the Test-project (full path). Otherwise, leave at null
13-
var TEST_PATH = path.join(shelljs.pwd(), './test/Test.mpr');
24+
var TEST_PATH = null;
25+
// Use this example if you want to point it to a different subfolder and specific Test project Name:
26+
// var TEST_PATH = path.join(shelljs.pwd(), "./<custom folder>/<Custom Test Project Name>.mpr");
1427

1528
module.exports = function (grunt) {
16-
var pkg = grunt.file.readJSON("package.json");
17-
grunt.verbose;
18-
grunt.initConfig({
19-
watch: {
20-
autoDeployUpdate: {
21-
"files": [ "./src/**/*" ],
22-
"tasks": [ "newer:copy", "compress" ],
23-
options: {
24-
debounceDelay: 250,
25-
livereload: true
26-
}
27-
}
28-
},
29-
compress: {
30-
makezip: {
31-
options: {
32-
archive: "./dist/" + pkg.name + ".mpk",
33-
mode: "zip"
29+
var pkg = grunt.file.readJSON("package.json");
30+
var widgetXml = path.join(shelljs.pwd(), "/src/", pkg.name, "/", pkg.name + ".xml");
31+
var packageXml = path.join(shelljs.pwd(), "/src/package.xml");
32+
33+
grunt.initConfig({
34+
watch: {
35+
autoDeployUpdate: {
36+
"files": [ "./src/**/*" ],
37+
"tasks": [ "compress", "newer:copy" ],
38+
options: {
39+
debounceDelay: 250,
40+
livereload: true
41+
}
42+
}
43+
},
44+
compress: {
45+
makezip: {
46+
options: {
47+
archive: "./dist/" + pkg.name + ".mpk",
48+
mode: "zip"
49+
},
50+
files: [{
51+
expand: true,
52+
date: new Date(),
53+
store: false,
54+
cwd: "./src",
55+
src: ["**/*"]
56+
}]
57+
}
58+
},
59+
copy: {
60+
deployment: {
61+
files: [
62+
{ dest: "./test/deployment/web/widgets", cwd: "./src/", src: ["**/*"], expand: true }
63+
]
64+
},
65+
mpks: {
66+
files: [
67+
{ dest: "./test/widgets", cwd: "./dist/", src: [ pkg.name + ".mpk"], expand: true }
68+
]
69+
}
3470
},
35-
files: [{
36-
expand: true,
37-
date: new Date(),
38-
store: false,
39-
cwd: "./src",
40-
src: ["**/*"]
41-
}]
42-
}
43-
},
44-
copy: {
45-
deployment: {
46-
files: [
47-
{ dest: "./test/deployment/web/widgets", cwd: "./src/", src: ["**/*"], expand: true }
48-
]
49-
},
50-
mpks: {
51-
files: [
52-
{ dest: "./test/widgets", cwd: "./dist/", src: [ pkg.name + ".mpk"], expand: true }
53-
]
54-
}
55-
},
56-
clean: {
57-
build: [
58-
"./dist/" + pkg.name + "/*",
59-
"./test/deployment/web/widgets/" + pkg.name + "/*",
60-
"./test/widgets/" + pkg.name + ".mpk"
61-
]
62-
}
63-
});
64-
65-
grunt.loadNpmTasks("grunt-contrib-compress");
66-
grunt.loadNpmTasks("grunt-contrib-clean");
67-
grunt.loadNpmTasks("grunt-contrib-watch");
68-
grunt.loadNpmTasks("grunt-contrib-copy");
69-
grunt.loadNpmTasks("grunt-newer");
70-
71-
grunt.registerTask("start-modeler", function () {
72-
var done = this.async(),
73-
testProjectPath = TEST_PATH !== null ? TEST_PATH : path.join(shelljs.pwd(), '/test/Test.mpr');
74-
75-
if (MODELER_PATH !== null || (mendixApp.err === null && mendixApp.output !== null && mendixApp.output.cmd && mendixApp.output.arg)) {
76-
grunt.util.spawn({
77-
cmd: MODELER_PATH || mendixApp.output.cmd,
78-
args: [
79-
(MODELER_PATH !== null ? MODELER_ARGS : mendixApp.output.arg).replace('{path}', testProjectPath)
80-
]
81-
}, function () {
82-
done();
83-
});
84-
} else {
85-
console.error('Cannot start Modeler, see error:');
86-
console.log(mendixApp.err);
87-
done();
88-
}
89-
});
90-
91-
grunt.registerTask(
92-
"default",
93-
"Watches for changes and automatically creates an MPK file, as well as copying the changes to your deployment folder",
94-
[ "watch" ]
95-
);
96-
97-
grunt.registerTask(
98-
"clean build",
99-
"Compiles all the assets and copies the files to the build directory.",
100-
[ "clean", "compress", "copy" ]
101-
);
102-
103-
grunt.registerTask(
104-
"build",
105-
[ "clean build" ]
106-
);
71+
clean: {
72+
build: [
73+
"./dist/" + pkg.name + "/*",
74+
"./test/deployment/web/widgets/" + pkg.name + "/*",
75+
"./test/widgets/" + pkg.name + ".mpk"
76+
]
77+
}
78+
});
79+
80+
grunt.loadNpmTasks("grunt-contrib-compress");
81+
grunt.loadNpmTasks("grunt-contrib-clean");
82+
grunt.loadNpmTasks("grunt-contrib-watch");
83+
grunt.loadNpmTasks("grunt-contrib-copy");
84+
grunt.loadNpmTasks("grunt-newer");
85+
86+
grunt.registerTask("start-modeler", function () {
87+
var done = this.async(),
88+
testProjectPath = TEST_PATH !== null ? TEST_PATH : path.join(shelljs.pwd(), "/test/Test.mpr");
89+
90+
if (MODELER_PATH !== null || (mendixApp.err === null && mendixApp.output !== null && mendixApp.output.cmd && mendixApp.output.arg)) {
91+
grunt.util.spawn({
92+
cmd: MODELER_PATH || mendixApp.output.cmd,
93+
args: [
94+
(MODELER_PATH !== null ? MODELER_ARGS : mendixApp.output.arg).replace("{path}", testProjectPath)
95+
]
96+
}, function () {
97+
done();
98+
});
99+
} else {
100+
console.error("Cannot start Modeler, see error:");
101+
console.log(mendixApp.err);
102+
done();
103+
}
104+
});
105+
106+
grunt.registerTask("version", function (version) {
107+
var done = this.async();
108+
if (!grunt.file.exists(packageXml)) {
109+
grunt.log.error("Cannot find " + packageXml);
110+
return done();
111+
}
112+
113+
var xml = grunt.file.read(packageXml);
114+
parser.parseString(xml, function (err, res) {
115+
if (err) {
116+
grunt.log.error(err);
117+
return done();
118+
}
119+
if (res.package.clientModule[0]["$"]["version"]) {
120+
var currentVersion = res.package.clientModule[0]["$"]["version"];
121+
if (!version) {
122+
grunt.log.writeln("\nCurrent version is " + currentVersion);
123+
grunt.log.writeln("Set new version by running 'grunt version:x.y.z'");
124+
done();
125+
} else {
126+
if (!semver.valid(version) || !semver.satisfies(version, ">= 1.0.0")) {
127+
grunt.log.error("\nPlease provide a valid version that is higher than 1.0.0. Current version: " + currentVersion);
128+
done();
129+
} else {
130+
res.package.clientModule[0]["$"]["version"] = version;
131+
pkg.version = version;
132+
var xmlString = builder.buildObject(res);
133+
grunt.file.write(packageXml, xmlString);
134+
grunt.file.write("package.json", JSON.stringify(pkg, null, 2));
135+
done();
136+
}
137+
}
138+
} else {
139+
grunt.log.error("Cannot find current version number");
140+
}
141+
});
142+
143+
});
144+
145+
grunt.registerTask("generate-icon", function () {
146+
var iconPath = path.join(shelljs.pwd(), "/icon.png"),
147+
options = {localFile: true, string: true},
148+
done = this.async();
149+
150+
grunt.log.writeln("Processing icon");
151+
152+
if (!grunt.file.exists(iconPath) || !grunt.file.exists(widgetXml)) {
153+
grunt.log.error("can\'t generate icon");
154+
return done();
155+
}
156+
157+
base64.base64encoder(iconPath, options, function (err, image) {
158+
if (!err) {
159+
var xmlOld = grunt.file.read(widgetXml);
160+
parser.parseString(xmlOld, function (err, result) {
161+
if (!err) {
162+
if (result && result.widget && result.widget.icon) {
163+
result.widget.icon[0] = image;
164+
}
165+
var xmlString = builder.buildObject(result);
166+
grunt.file.write(widgetXml, xmlString);
167+
done();
168+
}
169+
});
170+
} else {
171+
grunt.log.error("can\'t generate icon");
172+
return done();
173+
}
174+
});
175+
});
176+
177+
grunt.registerTask("start-mendix", [ "start-modeler" ]);
178+
179+
grunt.registerTask(
180+
"default",
181+
"Watches for changes and automatically creates an MPK file, as well as copying the changes to your deployment folder",
182+
[ "watch" ]
183+
);
184+
185+
grunt.registerTask(
186+
"clean build",
187+
"Compiles all the assets and copies the files to the build directory.",
188+
[ "clean", "compress", "copy" ]
189+
);
190+
191+
grunt.registerTask(
192+
"build",
193+
[ "clean build" ]
194+
);
107195
};

package.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "HTMLSnippet",
3-
"version": "1.3.0",
4-
"description": "This widget is useful to add a piece of HTML or JavaScript to a form. For example to embed a YouTube or Flash object. Furthermore it can be used to enhance styling by adding arbitrary HTML elements. ",
3+
"version": "3.6.0",
4+
"description": "",
55
"private": true,
66
"dependencies": {
77
},
@@ -12,9 +12,16 @@
1212
"grunt-contrib-copy": "^0.8.2",
1313
"grunt-contrib-watch": "^0.6.1",
1414
"grunt-newer": "^1.1.1",
15+
"node-base64-image": "^0.1.0",
1516
"shelljs": "^0.5.3",
17+
"xml2js": "^0.4.15",
18+
"semver": "^5.1.0",
1619
"node-mendix-modeler-path": "https://github.com/JelteMX/node-mendix-modeler-path/archive/v1.0.0.tar.gz"
1720
},
21+
"repository": {
22+
"type": "git",
23+
"url": "http://github.com/mendix/HTMLSnippet"
24+
},
1825
"engines": {
1926
"node": ">=0.12.0"
2027
},

src/HTMLSnippet/widget/HTMLSnippet.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ require([
3939
});
4040

4141
domAttr.set(this.domNode, "style", this.style); // might override height and width
42-
var n = domConstruct.create("div", { innerHTML: this.contents });
43-
domConstruct.place(n, this.domNode, "only");
42+
var domNode = domConstruct.create("div", { innerHTML: this.contents });
43+
domConstruct.place(domNode, this.domNode, "only");
4444
}
4545
break;
4646

test/javasource/appcloudservices/actions/GenerateRandomPassword.java

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)