-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
140 lines (106 loc) · 3.75 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
var
es = require('event-stream'),
gulp = require('gulp'),
// fn = require('gulp-fn'),
util = require('gulp-util'),
clean = require('gulp-clean'),
prompt = require('gulp-prompt'),
ftp = require('gulp-ftp'),
uglify = require('gulp-uglify'),
debug = require('gulp-debug');
var all = '**/*';
var
path_utils = "./web/utils/",
path_sparqlJsonConverter = path_utils + "commonjs-sparql-json-converter", // converts the JSON from the Virtuoso SPARQL Endpoint into a compact JSON
path_dataMerger = path_utils + "commonjs-dummy-json-merger", // combines atti-index with atti-info into atti.json
path_attiTermsSplitter = path_utils + "commonjs-atti-terms-splitter"; // splits the terms into multiple json file (one for each atto) in order to be visualized using the d3 graph
var
path_data_input = "./it.camera.hackathon.textmining/output/json/",
path_data_output = "data/", // dati rispetto alla root del sito
path_tmp = "./tmp/",
path_website = "./web/deploy/",
path_remote_output = "/",
path_local_data_output = path_website + path_data_output,
path_remote_data_output = path_remote_output + path_data_output,
file_data_attiInfo = "./web/deploy/data/atti-info.json",
file_data_attiTerms = path_data_input + "atti-terms.json",
file_data_clusterIndex = path_data_input + "clusters/clusters-index.json",
file_data_clusterGraph = path_data_input + "clusters/*-graph.json";
var
ftp_host = "ftp.code4italy.altervista.org",
ftp_user = "code4italy",
ftp_password = undefined; // ASKS FTP PASSWORD EVERY TIME IF NULL OR UNDEFINED
var
attiDataMerger = require(path_dataMerger),
attiTermsSplitter = require(path_attiTermsSplitter);
// #TODO BUILD data from Virtuoso SPARQL endpoint (in order to generate atti-info.json)
function buildDataAtti() {
data_attiInfo = require(file_data_attiInfo);
data_attiTerms = require(file_data_attiTerms);
attiDataMerger(data_attiInfo, data_attiTerms, path_tmp);
}
buildDataAtti();
function buildDataAtto() {
data_attiTerms = require(file_data_attiTerms);
attiTermsSplitter(data_attiTerms, path_tmp);
}
// creates atti.json
gulp.task('build-data-Atti', function() {
buildDataAtti();
});
// creates atto-index.json & atto-*.json
gulp.task('build-data-Atto', function() {
buildDataAtto();
});
gulp.task('build-atti-data', function() {
buildDataAtti();
buildDataAtto();
});
gulp.task('build-cluster-data', function() {
return gulp.src([file_data_clusterIndex, file_data_clusterGraph])
.pipe(gulp.dest(path_tmp)); // copy all requested data in the build folder
})
gulp.task('build-data-uncleaned', ['build-atti-data', 'build-cluster-data'], function() {
gulp.src(path_tmp + all)
.pipe(gulp.dest(path_local_data_output));
});
gulp.task('build-data', ['build-data-uncleaned'], function() {
gulp.src(path_tmp + all)
.pipe(clean()); // cleans tmp folder
});
gulp.task('build-data-and-ask-ftp-password', ['build-data'], function() {
if(ftp_password != null)
return;
return gulp.src("")
.pipe(prompt.prompt({
type: 'password',
name: 'pass',
message: 'Please enter your ftp password'
}, function(res){
ftp_password = res.pass;
}));
})
// DEPLOY ONLY THE DATA
gulp.task('deploy-data', ['build-data-and-ask-ftp-password'], function() {
if(ftp_password == null)
return;
return gulp.src(path_local_data_output + all)
.pipe(ftp({
host: ftp_host,
user: ftp_user,
pass: ftp_password,
remotePath: path_remote_data_output
}));
});
// DEPLOY THE WHOLE WEBSITE
gulp.task('deploy-all', ['build-data-and-ask-ftp-password'], function() {
if(ftp_password == null)
return;
return gulp.src(path_website + all)
.pipe(ftp({
host: ftp_host,
user: ftp_user,
pass: ftp_password,
remotePath: path_remote_output
}));
});