Skip to content

Commit e85241a

Browse files
author
Jelte Lagendijk
committed
Add development files, styling and patch version
1 parent fd31b82 commit e85241a

File tree

9 files changed

+331
-144
lines changed

9 files changed

+331
-144
lines changed

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,9 @@ test/.project
77
*.lock
88
*.bak
99
.idea/
10-
*.mws
10+
*.mws
11+
12+
node_modules/
13+
*DS_Store*
14+
.vscode/
15+
dist/

Gruntfile.js

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
// Generated on 2015-11-02 using generator-mendix 1.0.0 :: http://github.com/JelteMX/generator-mendix
2+
'use strict';
3+
4+
var path = require('path'),
5+
mendixApp = require('node-mendix-modeler-path'),
6+
base64 = require('node-base64-image'),
7+
fs = require('fs'),
8+
xml2js = require('xml2js'),
9+
parser = new xml2js.Parser(),
10+
builder = new xml2js.Builder(),
11+
shelljs = require('shelljs');
12+
13+
// In case you seem to have trouble starting Mendix through `grunt start-mendix`, you might have to set the path to the Mendix application.
14+
// If it works, leave MODELER_PATH at null
15+
var MODELER_PATH = null;
16+
var MODELER_ARGS = '/file:{path}';
17+
18+
var TEST_PATH = path.join(shelljs.pwd(), './test/[Test] DocumentViewer.mpr');
19+
20+
module.exports = function (grunt) {
21+
var pkg = grunt.file.readJSON("package.json");
22+
grunt.verbose;
23+
grunt.initConfig({
24+
watch: {
25+
autoDeployUpdate: {
26+
"files": [ "./src/**/*" ],
27+
"tasks": [ "newer:copy", "compress" ],
28+
options: {
29+
debounceDelay: 250,
30+
livereload: true
31+
}
32+
}
33+
},
34+
compress: {
35+
makezip: {
36+
options: {
37+
archive: "./dist/" + pkg.name + ".mpk",
38+
mode: "zip"
39+
},
40+
files: [{
41+
expand: true,
42+
date: new Date(),
43+
store: false,
44+
cwd: "./src",
45+
src: ["**/*"]
46+
}]
47+
}
48+
},
49+
copy: {
50+
deployment: {
51+
files: [
52+
{ dest: "./test/deployment/web/widgets", cwd: "./src/", src: ["**/*"], expand: true }
53+
]
54+
},
55+
mpks: {
56+
files: [
57+
{ dest: "./test/widgets", cwd: "./dist/", src: [ pkg.name + ".mpk"], expand: true }
58+
]
59+
}
60+
},
61+
clean: {
62+
build: [
63+
"./dist/" + pkg.name + "/*",
64+
"./test/deployment/web/widgets/" + pkg.name + "/*",
65+
"./test/widgets/" + pkg.name + ".mpk"
66+
]
67+
}
68+
});
69+
70+
grunt.loadNpmTasks("grunt-contrib-compress");
71+
grunt.loadNpmTasks("grunt-contrib-clean");
72+
grunt.loadNpmTasks("grunt-contrib-watch");
73+
grunt.loadNpmTasks("grunt-contrib-copy");
74+
grunt.loadNpmTasks("grunt-newer");
75+
76+
grunt.registerTask("start-mendix", function () {
77+
var done = this.async(),
78+
testProjectPath = TEST_PATH !== null ? TEST_PATH : path.join(shelljs.pwd(), '/test/Test.mpr');
79+
80+
if (MODELER_PATH !== null || (mendixApp.err === null && mendixApp.output !== null && mendixApp.output.cmd && mendixApp.output.arg)) {
81+
grunt.util.spawn({
82+
cmd: MODELER_PATH || mendixApp.output.cmd,
83+
args: [
84+
(MODELER_PATH !== null ? MODELER_ARGS : mendixApp.output.arg).replace('{path}', testProjectPath)
85+
]
86+
}, function () {
87+
done();
88+
});
89+
} else {
90+
console.error('Cannot start Modeler, see error:');
91+
console.log(mendixApp.err);
92+
done();
93+
}
94+
});
95+
96+
grunt.registerTask("generate-icon", function () {
97+
var iconPath = path.join(shelljs.pwd(), '/ico.png'),
98+
widgetXml = path.join(shelljs.pwd(), '/src/', pkg.name, '/', pkg.name+'.xml'),
99+
options = {localFile: true, string: true},
100+
done = this.async();
101+
102+
grunt.log.writeln('Processing icon');
103+
104+
if (!grunt.file.exists(iconPath) || !grunt.file.exists(widgetXml)) {
105+
grunt.log.error("can't generate icon");
106+
return done();
107+
}
108+
109+
base64.base64encoder(iconPath, options, function (err, image) {
110+
if (!err) {
111+
var xmlOld = grunt.file.read(widgetXml);
112+
parser.parseString(xmlOld, function (err, result) {
113+
if (!err) {
114+
if (result && result.widget && result.widget.icon) {
115+
result.widget.icon[0] = image;
116+
}
117+
var xmlString = builder.buildObject(result);
118+
grunt.file.write(widgetXml, xmlString);
119+
done();
120+
}
121+
});
122+
}
123+
});
124+
});
125+
126+
grunt.registerTask(
127+
"default",
128+
"Watches for changes and automatically creates an MPK file, as well as copying the changes to your deployment folder",
129+
[ "watch" ]
130+
);
131+
132+
grunt.registerTask(
133+
"clean build",
134+
"Compiles all the assets and copies the files to the build directory.",
135+
[ "clean", "compress", "copy" ]
136+
);
137+
138+
grunt.registerTask(
139+
"build",
140+
[ "clean build" ]
141+
);
142+
};

package.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "FileDocumentViewer",
3+
"version": "1.7.0",
4+
"description": "This widget lets you view file documents.",
5+
"private": true,
6+
"dependencies": {},
7+
"devDependencies": {
8+
"grunt": "0.4.5",
9+
"grunt-contrib-clean": "^0.6.0",
10+
"grunt-contrib-compress": "^0.14.0",
11+
"grunt-contrib-copy": "^0.8.2",
12+
"grunt-contrib-watch": "^0.6.1",
13+
"grunt-newer": "^1.1.1",
14+
"node-base64-image": "^0.1.0",
15+
"node-mendix-modeler-path": "https://github.com/JelteMX/node-mendix-modeler-path/archive/v1.0.0.tar.gz",
16+
"shelljs": "^0.5.3",
17+
"xml2js": "^0.4.15"
18+
},
19+
"repository": {
20+
"type": "git",
21+
"url": "http://github.com/mendix/FileDocumentViewer"
22+
},
23+
"engines": {
24+
"node": ">=0.12.0"
25+
},
26+
"scripts": {
27+
"test": "grunt test"
28+
}
29+
}
Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
<?xml version="1.0" encoding="utf-8" ?>
22
<widget id="FileDocumentViewer.widget.FileDocumentViewer" needsEntityContext="true" xmlns="http://www.mendix.com/widget/1.0/">
3-
<name>File Document Viewer</name>
4-
<description>A File Document Viewer. Should be used in a FileDocument based dataview</description>
5-
<icon>R0lGODlhEgASAKIHAHd3d8zMzO7u7qqqqoiIiLu7u////////yH5BAEAAAcALAAAAAASABIAAANL
3+
<name>File Document Viewer</name>
4+
<description>A File Document Viewer. Should be used in a FileDocument based dataview</description>
5+
<icon>R0lGODlhEgASAKIHAHd3d8zMzO7u7qqqqoiIiLu7u////////yH5BAEAAAcALAAAAAASABIAAANL
66
eLrcHSXK4VgxOBdaz83YxTkf+I0WiA1EiyqlihGknAl0E8t5ahu4mk2wEcpOOlus57ENQMyYAGh4
77
GgDJqRaII7AYrJZ4jP12OqwEADs=</icon>
88

9-
<properties>
10-
<!-- make literal or attribute target conditional -->
11-
<property key="headertitle" type="attribute" required="true">
12-
<caption>Title</caption>
13-
<category>Appearance</category>
14-
<description>The caption of the viewer.</description>
15-
<attributeTypes>
9+
<properties>
10+
<!-- make literal or attribute target conditional -->
11+
<property key="headertitle" type="attribute" required="true">
12+
<caption>Title</caption>
13+
<category>Appearance</category>
14+
<description>The caption of the viewer.</description>
15+
<attributeTypes>
1616
<attributeType name="String"/>
17-
</attributeTypes>
18-
</property>
17+
</attributeTypes>
18+
</property>
1919
<property key="width" type="integer" defaultValue="0">
20-
<caption>Width</caption>
21-
<category>Appearance</category>
22-
<description>Width of the viewer in pixels. Use '0' for auto. The height will depend on the contents. </description>
23-
</property>
20+
<caption>Width</caption>
21+
<category>Appearance</category>
22+
<description>Width of the viewer in pixels. Use '0' for auto. The height will depend on the contents. </description>
23+
</property>
2424
<property key="height" type="integer" defaultValue="400">
25-
<caption>Height</caption>
26-
<category>Appearance</category>
27-
<description>Height of the viewer in pixels. Use '0' to determine the width automatically. This will use any remaining space.</description>
28-
</property>
25+
<caption>Height</caption>
26+
<category>Appearance</category>
27+
<description>Height of the viewer in pixels. Use '0' to determine the width automatically. This will use any remaining space.</description>
28+
</property>
2929
<property key="showheader" type="boolean" defaultValue="true">
30-
<caption>Show header</caption>
31-
<category>Appearance</category>
32-
<description>If true, a header including a 'pop out' and 'enlarge' button will be shown</description>
30+
<caption>Show header</caption>
31+
<category>Appearance</category>
32+
<description>If true, a header including a 'pop out' and 'enlarge' button will be shown</description>
3333
</property>
3434
</properties>
3535
</widget>

0 commit comments

Comments
 (0)