-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
127 lines (102 loc) · 3.22 KB
/
server.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
var docpadInstanceConfiguration = {
port: 5000,
plugins: {
ghpages: {
deployRemote: 'github',
deployBranch: 'gh-pages'
}
},
templateData: {
site: {
subtitle : "Sport and the City",
styles : ['css/default.css'],
scripts: [
'js/vendor/jquery-2.0.0.js',
'js/vendor/jquery.transform2d.js',
'js/vendor/jquery.nicescroll.js',
'js/vendor/bootstrap-modal.js',
'js/vendor/bootstrap-modalmanager.js',
'js/vendor/ResponsiveSlides.js',
'js/vendor/history.js',
'js/lib/util.js',
'js/lib/resizer.js',
'js/lib/grid.js',
'js/app.js'
]
},
getPreparedTitle: function() {
if (this.document.title) {
return "" + this.document.title + " | " + this.site.subtitle;
} else {
return this.site.title;
}
},
normalizeURL: function (path, language) {
var _language = language || this.document.language || 'en';
var _path = path || this.document.url || '/index.html';
var _url;
// Remove language part from start of a path
_path = _path.replace(/(\/en\/|\/ua\/)/, '/');
_url = '/' + _language + _path;
return _url;
},
baseUrl: function (url) {
var level = this.document.url.replace(/^\s+|^\/|\/$|\s+$/g, '').split('/').length - 1;
var base = './';
for(; level > 0; level--) {
base += '../';
}
return base + url.replace(/^\//, '');
},
mapStylePath: function (styles) {
var that = this;
return styles.map(function (value) { return '<link rel="stylesheet" href="' + that.baseUrl(value) + '" />'; });
},
mapScriptPath: function (scripts) {
var that = this;
return scripts.map(function (value) { return '<script defer="defer" src="' + that.baseUrl(value) + '"></script>'; });
}
}
};
function trim(str, charlist) {
// discuss at: http://phpjs.org/functions/trim/
var whitespace, l = 0,
i = 0;
str += '';
if (!charlist) {
// default list
whitespace =
' \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000';
} else {
// preg_quote custom list
charlist += '';
whitespace = charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '$1');
}
l = str.length;
for (i = 0; i < l; i++) {
if (whitespace.indexOf(str.charAt(i)) === -1) {
str = str.substring(i);
break;
}
}
l = str.length;
for (i = l - 1; i >= 0; i--) {
if (whitespace.indexOf(str.charAt(i)) === -1) {
str = str.substring(0, i + 1);
break;
}
}
return whitespace.indexOf(str.charAt(0)) === -1 ? str : '';
}
var docpadInstance = require('docpad').createInstance(docpadInstanceConfiguration, function(err) {
if (err) {
return console.log(err, err.stack);
}
return docpadInstance.action('generate server watch', function(err) {
if (err) {
return console.log('[docpad-error]', err, err.stack);
}
return console.log("Running on localhost:" + docpadInstanceConfiguration.port);
});
});
module.export = docpadInstanceConfiguration;