Skip to content

Commit d3e7e57

Browse files
committed
blocks map fixes
1 parent 4f8e62e commit d3e7e57

5 files changed

Lines changed: 56 additions & 44 deletions

File tree

Blocks/Router.cls.xml

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,15 @@
88
<XData name="UrlMap">
99
<Data><![CDATA[
1010
<Routes>
11-
<Route Url="/dblist" Method="GET" Call="DBList"/>
12-
<Route Url="/block/:block" Method="GET" Call="BlockInfo"/>
13-
<Route Url="/block/:block" Method="POST" Call="BlockInfo"/>
11+
<Route Url="(?:/rest)?/dblist" Method="GET" Call="DBList"/>
12+
<Route Url="(?:/rest)?/block/:block" Method="GET" Call="BlockInfo"/>
13+
<Route Url="(?:/rest)?/block/:block" Method="POST" Call="BlockInfo"/>
1414
<Route Url="/websocket" Method="GET" Call="WebSocket"/>
1515
<Route Url="/((?!rest/).*)" Method="GET" Call="GetStatic"/>
1616
</Routes>
1717
]]></Data>
1818
</XData>
1919

20-
<Method name="Page">
21-
<ClassMethod>1</ClassMethod>
22-
<ReturnType>%Status</ReturnType>
23-
<Implementation><![CDATA[
24-
if (%request.GetCgiEnv("HTTP_CONNECTION") = "Upgrade") {
25-
quit ##class(Blocks.WebSocket).Page()
26-
}
27-
28-
quit ##super()
29-
]]></Implementation>
30-
</Method>
31-
3220
<Method name="WebSocket">
3321
<ClassMethod>1</ClassMethod>
3422
<ReturnType>%Status</ReturnType>

Blocks/WebSocket.cls.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
<Method name="SendBlocksData">
7676
<ReturnType>%Status</ReturnType>
7777
<Implementation><![CDATA[
78-
;do ..Write("error", "test0" _ ..Event)
7978
set st = $$$OK
8079
8180
quit:..Event="" $$$OK

gulpfile.js

Lines changed: 50 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ var gulp = require('gulp')
22
var gutil = require('gulp-util')
33
var clean = require('gulp-clean')
44
var cheerio = require('gulp-cheerio')
5+
var wrapper = require('gulp-wrapper')
6+
var rename = require('gulp-rename')
57
var htmlReplace = require('gulp-html-replace')
68
var fs = require('fs')
79
var path = require('path')
@@ -34,56 +36,77 @@ gulp.task('webpack', ['clean'], function (callback) {
3436
});
3537
})
3638

39+
gulp.task('csp', ['webpack'], function () {
40+
return gulp.src([
41+
'./build/**/*',
42+
'!./build/xml',
43+
'!./build/**/*.xml'
44+
])
45+
.pipe(wrapper({
46+
header: '<?xml version="1.0" encoding="UTF-8"?>\n<Export generator="Cache" version="24">\n<CSP name="${filename}" application="/blocks/" default="1"><![CDATA[',
47+
footer: ']]></CSP>\n</Export>'
48+
}))
49+
.pipe(rename(function(path ){
50+
path.extname += '.xml'
51+
}))
52+
.pipe(gulp.dest('./build/xml/'))
53+
});
54+
3755
gulp.task('xml', ['clean', 'webpack'], function () {
3856
return gulp.src([
3957
'./BlocksExplorer.prj.xml',
4058
'./Blocks/**/*.xml'
4159
])
4260
.pipe(cheerio({
4361
run: function ($, file) {
44-
var staticFiles = fs.readdirSync('./build/')
45-
46-
staticFiles.map(function (fileName) {
47-
try {
48-
fullName = path.join('./build/', fileName)
49-
if (!fs.statSync(fullName).isDirectory()) {
50-
$('Class[name="Blocks.Router"]').append($('<XData>')
51-
.attr('name', fileName.replace(/\./g, '_'))
52-
.append('<Description>*base64*</Description>')
53-
.append(
54-
$('<Data><![CDATA[ <data>' + (fs.readFileSync(fullName, {
55-
encoding: 'base64'
56-
})).replace(/[\n\r]/g, '') + '</data> ]]> </Data>')
57-
)
58-
)
59-
}
60-
} catch (err) {
61-
console.log(err)
62-
}
63-
})
62+
// var staticFiles = fs.readdirSync('./build/')
63+
64+
// staticFiles.map(function (fileName) {
65+
// try {
66+
// fullName = path.join('./build/', fileName)
67+
// if (!fs.statSync(fullName).isDirectory()) {
68+
// $('Project>Items').append(
69+
// $('<ProjectItem>')
70+
// .attr('type', 'CSP')
71+
// .attr('name', fileName)
72+
// );
73+
// // $('Class[name="Blocks.Router"]').append($('<XData>')
74+
// // .attr('name', fileName.replace(/\./g, '_'))
75+
// // .append('<Description>*base64*</Description>')
76+
// // .append(
77+
// // $('<Data><![CDATA[ <data>' + (fs.readFileSync(fullName, {
78+
// // encoding: 'base64'
79+
// // })).replace(/[\n\r]/g, '') + '</data> ]]> </Data>')
80+
// // )
81+
// // )
82+
// }
83+
// } catch (err) {
84+
// console.log(err)
85+
// }
86+
// })
6487

6588
},
6689
parserOptions: {
6790
xmlMode: true,
6891
prettify: true
6992
}
7093
}))
71-
.pipe(gulp.dest('./build/src/'))
94+
.pipe(gulp.dest('./build/xml/'))
7295
})
7396

74-
gulp.task('project', ['clean', 'xml', 'webpack'], function () {
97+
gulp.task('project', ['clean', 'xml', 'csp'], function () {
7598
return gulp.src([
76-
'./build/src/BlocksExplorer.prj.xml',
77-
'./build/src/**/*.xml',
78-
'!./build/src/**/*Installer.cls.xml'
99+
'./build/xml/BlocksExplorer.prj.xml',
100+
'./build/xml/**/*.xml',
101+
'!./build/xml/**/*Installer.cls.xml'
79102
])
80103
.pipe(cacheBuilder('CacheBlocksExplorerProject.xml'))
81104
.pipe(gulp.dest('./build/'))
82105
})
83106

84107
gulp.task('standalone', ['project'], function () {
85108
return gulp.src([
86-
'./build/src/StandaloneInstaller.cls.xml'
109+
'./build/xml/StandaloneInstaller.cls.xml'
87110
])
88111
.pipe(cheerio({
89112
run: function ($, file) {
@@ -145,7 +168,7 @@ gulp.task('serve', function (callback) {
145168
target: 'http://localhost:57774/blocks'
146169
},
147170
'/websocket': {
148-
target: 'ws://localhost:57774/blocks/rest',
171+
target: 'ws://localhost:57774/blocks',
149172
changeOrigin: true,
150173
ws: true
151174
}

js/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var App = function () {
2828
}
2929

3030
var wsUrl = ((window.location.protocol == "https:") ? "wss:" : "ws:" + "//" + window.location.host)
31-
wsUrl += window.location.pathname + 'websocket'
31+
wsUrl += window.location.pathname + 'Blocks.WebSocket.cls'
3232
this.ws = new FancyWebSocket(wsUrl)
3333

3434
this.ws.bind('error', function (data) {

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@
2424
"gulp-html-replace": "^1.6.1",
2525
"gulp-minify-css": "^1.2.4",
2626
"gulp-postcss": "^6.2.0",
27+
"gulp-rename": "^1.2.2",
2728
"gulp-replace": "^0.5.4",
2829
"gulp-uglify": "^2.0.0",
2930
"gulp-util": "^3.0.7",
31+
"gulp-wrapper": "^1.0.0",
3032
"html-loader": "^0.4.4",
3133
"html-webpack-plugin": "^2.22.0",
3234
"postcss-loader": "^0.13.0",

0 commit comments

Comments
 (0)