Skip to content

Commit 60b3250

Browse files
Migrated to WebPack, toasts module integration, fixes to seed string specify
1 parent 7010c15 commit 60b3250

File tree

7 files changed

+56
-26
lines changed

7 files changed

+56
-26
lines changed

Diff for: gulpfile.babel.js

+29-12
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import gulp from "gulp";
22
import rimraf from "gulp-rimraf";
3+
import webpack from "webpack";
34
import preprocess from "gulp-preprocess";
45
import cssMin from "gulp-cssmin";
5-
import browserify from "browserify";
6-
import to5ify from "6to5ify";
7-
import streamify from "gulp-streamify";
8-
import source from "vinyl-source-stream";
96
import scss from "gulp-sass";
107
import fs from "fs";
118
import mime from "mime-types";
@@ -18,6 +15,28 @@ const
1815
STATIC_DATA_FILE = `${ SOURCE_DIR }/cls/${ APP_NAME }/StaticData.cls`,
1916
context = {
2017
package: pkg
18+
},
19+
webpackConfig = {
20+
context: `${ __dirname }`,
21+
entry: {
22+
"index": `${ SOURCE_DIR }/static/js/index.js`
23+
},
24+
output: {
25+
path: `${ BUILD_DIR }/static/js`,
26+
filename: `[name].js`
27+
},
28+
module: {
29+
loaders: [
30+
{
31+
test: /\.js$/,
32+
exclude: /node_modules/,
33+
loader: `babel-loader`,
34+
query: {
35+
presets: [`es2015`]
36+
}
37+
}
38+
]
39+
}
2140
};
2241

2342
function getAllFiles (dir) {
@@ -66,14 +85,12 @@ gulp.task("etc", ["clean"], () => {
6685
.pipe(gulp.dest(BUILD_DIR + "/static"));
6786
});
6887

69-
gulp.task("js", ["clean"], () => {
70-
return browserify(`${ SOURCE_DIR }/static/js/index.js`, { debug: true })
71-
.transform(to5ify)
72-
.bundle()
73-
.on(`error`, (err) => { console.error(err); })
74-
.pipe(source("index.js"))
75-
.pipe(streamify(preprocess({ context: context })))
76-
.pipe(gulp.dest(`${ BUILD_DIR }/static/js`));
88+
gulp.task("js", ["clean"], (done) => {
89+
webpack(webpackConfig, (err, stats) => {
90+
if (err) throw new Error(err);
91+
console.log(stats.toString());
92+
done(err);
93+
});
7794
});
7895

7996
gulp.task("css", ["clean"], () => {

Diff for: package.json

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "iknow-entity-browser",
3-
"version": "1.0.0",
3+
"version": "1.1.1",
44
"description": "Visualizer for iKnow entities",
55
"main": "gulpfile.babel.js",
66
"scripts": {
@@ -14,18 +14,17 @@
1414
"author": "ZitRo",
1515
"license": "MIT",
1616
"devDependencies": {
17-
"6to5ify": "^4.1.1",
1817
"babel": "^6.23.0",
1918
"babel-core": "^6.23.1",
19+
"babel-loader": "^6.4.1",
2020
"babel-preset-es2015": "^6.22.0",
21-
"browserify": "^14.1.0",
2221
"gulp": "^3.9.1",
2322
"gulp-cssmin": "^0.1.7",
2423
"gulp-preprocess": "^2.0.0",
2524
"gulp-rimraf": "^0.2.0",
2625
"gulp-sass": "^3.1.0",
27-
"gulp-streamify": "^1.0.2",
2826
"mime-types": "^2.1.15",
29-
"vinyl-source-stream": "^1.1.0"
27+
"toaster-js": "^1.0.4",
28+
"webpack": "^2.3.2"
3029
}
3130
}

Diff for: src/static/index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ <h1>Tabular View Settings</h1>
194194
<button id="settings.resetSettings">Reset Settings</button>
195195
</div>
196196
<div class="footer">
197-
iKnow Entity Browser v<!-- @echo package.version -->
197+
iKnow Entity Browser v<!-- @echo package.version --> by
198+
<a target="_blank" href="https://zitros.tk">Nikita</a>
198199
</div>
199200
</div>
200201
<div id="preservedToolbar">

Diff for: src/static/js/model/index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { getData } from "../source";
33
import { getOption } from "../settings/values";
44
import { toggleLoader } from "../utils";
55
import * as history from "./history";
6+
import { Toast } from "toaster-js";
67

78
let SIZE_CRITERIA = "frequency",
89
FOLDING_CRITERIA = "frequency",
@@ -119,7 +120,7 @@ export function update () {
119120
getData(data => {
120121
toggleLoader(false);
121122
if (data.error || !data.graph) {
122-
alert(data.error || `No graph data returned`);
123+
new Toast(data.error || `No graph data returned`, Toast.TYPE_ERROR);
123124
} else {
124125
graph = preprocess(data.graph);
125126
dataUpdated(true);
@@ -304,7 +305,7 @@ export function dropNodes (nodes) {
304305
if (i === -1) {
305306
console.error(
306307
`There is a mess occurred with the tree model structure while dropping nodes: `
307-
`node's parent is pointing to a node which doesn't have this node as a child.`
308+
+ `node's parent is pointing to a node which doesn't have this node as a child.`
308309
);
309310
continue;
310311
}

Diff for: src/static/js/settings/values.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,16 @@ export function setOption (options, value) {
106106
let preservedToolbarElement = null,
107107
querySettingElement = null,
108108
seedSettingElement = null,
109-
uiState = null;
109+
uiState = null,
110+
lastApply = "";
110111
export function applyFixedClasses () {
111-
let queryParent = !uiState.settingsToggled && settings["keepQueryTypeInView"]
112-
? preservedToolbarElement : querySettingElement,
113-
seedParent = !uiState.settingsToggled && settings["keepSeedInView"]
114-
? preservedToolbarElement : seedSettingElement;
112+
let qt = !uiState.settingsToggled && settings["keepQueryTypeInView"],
113+
s = !uiState.settingsToggled && settings["keepSeedInView"],
114+
queryParent = qt ? preservedToolbarElement : querySettingElement,
115+
seedParent = s ? preservedToolbarElement : seedSettingElement;
116+
if (`${ qt }|${ s }` === lastApply)
117+
return;
118+
lastApply = `${ qt }|${ s }`;
115119
queryParent.appendChild(document.getElementById("settings.queryType"));
116120
seedParent.appendChild(document.getElementById("settings.seed"));
117121
}

Diff for: src/static/scss/index.scss

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ html, body {
3535
@import "settings";
3636
@import "interface";
3737
@import "tooltip";
38-
@import "preservedToolbar";
38+
@import "preservedToolbar";
39+
@import "../../../node_modules/toaster-js/default.scss";

Diff for: src/static/scss/settings.scss

+7
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,17 @@
1818
}
1919

2020
.footer {
21+
2122
text-align: right;
2223
font-size: 8pt;
2324
color: gray;
2425
padding: 0 2px;
26+
27+
a {
28+
color: gray;
29+
text-decoration: underline;
30+
}
31+
2532
}
2633

2734
}

0 commit comments

Comments
 (0)