forked from liferay/alloyui.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docpad.js
210 lines (176 loc) · 5.24 KB
/
docpad.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
module.exports = {
prompts: false,
/* =================================
* Template Data
*/
// These are variables will be accessible via our templates
templateData: {
/* -----------------------------
* AlloyUI Information
*/
alloy: {
// AlloyUI version
version: '3.0.1',
// CDN domain
cdnDomain: 'http://cdn.alloyui.com'
},
/* -----------------------------
* Site Information
*/
site: {
// Website version
version: '3.0.x',
isLastVersion: true,
// Production URL
url: 'http://alloyui.com',
// Github branch
githubUrl: 'https://github.com/liferay/alloy-ui/',
// Basic info
title: 'AlloyUI',
description: 'AlloyUI is a framework built on top of YUI3 (JavaScript) that uses Bootstrap (HTML/CSS) to provide a simple API for building high scalable applications.'
},
/* -----------------------------
* Helpers
*/
// Get the prepared site/document title
getPreparedTitle: function() {
// if we have a document title, then we should use that and suffix the site's title into it
if (this.document.title) {
if (this.document.category) {
return "" + this.document.category + " - " + this.document.title + " | " + this.site.title;
} else {
return "" + this.document.title + " | " + this.site.title;
}
} // if our document does not have it's own title, then we should just use the site's title
else {
return this.site.title;
}
},
// Get the prepared site/document description
getPreparedDescription: function() {
// if we have a document description, then we should use that, otherwise use the site's description
return this.document.description || this.site.description;
},
// Get the Bootstrap CSS file for this Alloy version
getBootstrapCSS: function() {
return "" + this.alloy.cdnDomain + "/" + this.alloy.version + "/aui-css/css/bootstrap.min.css";
},
// Get the CDN path for this Alloy version
getCdnPath: function() {
return "" + this.alloy.cdnDomain + "/" + this.alloy.version;
},
// Get the CDN seed file for this Alloy version
getCdnSeed: function() {
return "" + this.alloy.cdnDomain + "/" + this.alloy.version + "/aui/aui-min.js";
},
// Get the download URL for this Alloy version
getDownloadUrl: function() {
return "https://github.com/liferay/alloy-ui/releases/download/" + this.alloy.version + "/alloy-" + this.alloy.version + ".zip";
},
// Get the absolute URL of the website
getSiteUrl: function() {
if (this.site.isLastVersion) {
return "" + this.site.url;
} else {
return "" + this.site.url + "/versions/" + this.site.version;
}
},
// Get the absolute URL of the assets folder
getAssetsUrl: function() {
if (this.site.isLastVersion) {
return "" + this.site.url + "/website";
} else {
return "" + this.site.url + "/versions/" + this.site.version + "/website";
}
},
// Read File
readFile: function(relativePath) {
var fsUtil, path, result;
fsUtil = require('fs');
path = this.document.fullDirPath + '/' + relativePath;
result = fsUtil.readFileSync(path);
if (result instanceof Error) {
throw result;
} else {
return result.toString();
}
},
// Code File
codeFile: function(relativePath, language) {
var contents;
contents = this.readFile(relativePath);
return "<pre><code class=\"" + language + "\">" + contents + "</code></pre>";
}
},
/* =================================
* Collections
*/
collections: {
// Get all tutorials sorted by type & alphabetical order
tutorials: function() {
return this.getCollection("documents").findAllLive({
url: {
$startsWith: '/tutorials'
}
}, [
{
type: 1,
order: 1,
title: 1
}
]);
},
// Get all examples sorted by category & alphabetical order
examples: function() {
return this.getCollection("documents").findAllLive({
url: {
$startsWith: '/examples'
}
}, [
{
category: 1,
title: 1
}
]);
},
// Get all examples that contains featuringOrder attribute
featuring: function(database) {
return database.findAllLive({
featuringOrder: {
$exists: true
}
}, [
{
featuringOrder: 1
}
]);
}
},
/* =================================
* Environments
*/
environments: {
development: {
templateData: {
/* -----------------------------
* Site Information
*/
// Development URL
site: {
url: 'http://localhost:9778'
},
/* -----------------------------
* Helpers
*/
// Get the absolute Development URL of the website
getSiteUrl: function() {
return "" + this.site.url;
},
// Get the absolute Development URL of the assets folder
getAssetsUrl: function() {
return "" + this.site.url + "/website";
}
}
}
}
};