1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.millscript.millscript.conf;
23
24 import org.millscript.commons.util.list.ELinkedList;
25 import org.millscript.commons.vfs.VFile;
26 import org.millscript.commons.vfs.VFolder;
27 import org.millscript.millscript.Resources;
28 import org.millscript.millscript.URLSource;
29 import org.millscript.millscript.vm.Engine;
30 import org.millscript.millscript.vm.Package;
31
32 /**
33 * This class is the basis of a website configuration.
34 */
35 public class WebsiteConf extends AbstractConfiguration {
36
37 /**
38 * Contains the location of the websites ".website" folder.
39 */
40 private final VFolder dotWebsiteFolder = cwd.getVFolder( DOT_WEBSITE_NAME );
41
42 /**
43 * Contains the location of the MillScript installation.
44 */
45 private final VFolder millscriptFolder = cwd.resolveAsFolder( System.getProperty( "millscript.dir" ) );
46
47 /**
48 * File representing the version independant root of the millscript system.
49 * e.g. millscript/system
50 */
51 private final VFolder millscriptSystemRootFolder = millscriptFolder.getVFolder( "system" );
52
53 /**
54 * File representing this versions millscript system folder.
55 * e.g. millscript/system/9.6.1
56 */
57 private final VFolder millscriptSystemFolder = millscriptSystemRootFolder.getVFolder( Resources.getMessage( "version" ) );
58
59 /**
60 * File representing the user configuration folder.
61 * e.g. millscript/conf
62 */
63 private final VFolder standardConfFolder = millscriptFolder.getVFolder( CONF_NAME );
64
65 /**
66 * File representing the user configuration file
67 * e.g. millscript/conf/millscript.global.conf
68 */
69 private final VFile standardConfigurationFile = standardConfFolder.getVFile( USER_CONF_FILE );
70
71 /**
72 * File representing the standard inventory folder.
73 * e.g. millscript/system/9.6.1/inventory
74 */
75 private final VFolder standardInventoryFolder = millscriptSystemFolder.getVFolder( INVENTORY_NAME );
76
77 /**
78 * File representing the standard library folder.
79 * e.g. millscript/system/9.6.1/classes
80 */
81 private final VFolder standardLibFolder = millscriptSystemFolder.getVFolder( LIB_NAME );
82
83 /**
84 * File representing the website cache folder.
85 * e.g. .website/cache
86 */
87 private final VFolder websiteCacheFolder = dotWebsiteFolder.getVFolder( CACHE_NAME );
88
89 /**
90 * File representing the website configuration folder.
91 * e.g. .website/conf
92 */
93 private final VFolder websiteConfFolder = dotWebsiteFolder.getVFolder( CONF_NAME );
94
95 /**
96 * File representing the website configuration file.
97 * e.g. .website/conf/website.conf
98 */
99 private final VFile websiteConfigurationFile = websiteConfFolder.getVFile( WEBSITE_CONF_FILE );
100
101 /**
102 * File representing the website inventory folder.
103 * e.g. inventory
104 */
105 private final VFolder websiteInventoryFolder = cwd.getVFolder( INVENTORY_NAME );
106
107 /**
108 * File representing the website library folder.
109 * e.g. .website/classes
110 */
111 private final VFolder websiteLibFolder = dotWebsiteFolder.getVFolder( LIB_NAME );
112
113 /**
114 * File representing the website output folder.
115 * e.g. output
116 */
117 private final VFolder websiteOutputFolder = cwd.getVFolder( OUTPUT_NAME );
118
119 /**
120 * File representing the website var folder.
121 * e.g. .website/var
122 */
123 private final VFolder websiteVarFolder = dotWebsiteFolder.getVFolder( VAR_NAME );
124
125 /**
126 * File representing the website failure file.
127 * e.g. .website/var/dirty.log
128 */
129 private final VFile websiteFailureFile = websiteVarFolder.getVFile( WEBSITE_FAILURE_FILE );
130
131 /**
132 * File representing the website lock file.
133 * e.g. .website/var/mill.pid
134 */
135 private final VFile websiteLockFile = websiteVarFolder.getVFile( WEBSITE_LOCK_FILE );
136
137 /**
138 * File representing the website success file.
139 * e.g. .website/var/done.log
140 */
141 private final VFile websiteSuccessFile = websiteVarFolder.getVFile( WEBSITE_SUCCESSS_FILE );
142
143 /**
144 * @see org.millscript.millscript.conf.Configuration#getInteractivePrompt()
145 */
146 public String getInteractivePrompt() {
147 return ";-) ";
148 }
149
150 /**
151 * @see org.millscript.millscript.conf.Configuration#getStandardConfFolder()
152 */
153 public final VFolder getStandardConfFolder() {
154 return standardConfFolder;
155 }
156
157 /**
158 * @see org.millscript.millscript.conf.Configuration#getStandardConfigurationFile()
159 */
160 public VFile getStandardConfigurationFile() {
161 return standardConfigurationFile;
162 }
163
164 /**
165 * @see org.millscript.millscript.conf.Configuration#getStandardEngine()
166 */
167 @Override
168 public Engine getStandardEngine() {
169
170 final Engine engine = super.getStandardEngine();
171
172
173 engine.addInventory( this.getWebsiteInventoryFolder() );
174
175
176 engine.addInventory( this.getStandardInventoryFolder() );
177
178 return engine;
179 }
180
181 /**
182 * @see org.millscript.millscript.conf.Configuration#getStandardInventoryFolder()
183 */
184 public final VFolder getStandardInventoryFolder() {
185 return standardInventoryFolder;
186 }
187
188 /**
189 * @see org.millscript.millscript.conf.Configuration#getStandardLibFolder()
190 */
191 public final VFolder getStandardLibFolder() {
192 return standardLibFolder;
193 }
194
195 /**
196 * @see org.millscript.millscript.conf.Configuration#getStandardPackage(org.millscript.millscript.vm.Engine)
197 */
198 @Override
199 public Package getStandardPackage( final Engine engine ) {
200 final Package standardPackage = super.getStandardPackage( engine );
201
202 standardPackage.bindProtectedConst(
203 "homeDir",
204 this.getCurrentWorkingFolder()
205 );
206
207 standardPackage.bindProtectedVar( "folder", new ELinkedList() );
208
209 standardPackage.loadConf(
210 new URLSource(
211 Configuration.class.getResource(
212 "/org/millscript/millscript/conf/website_functions.conf"
213 )
214 )
215 );
216
217
218
219 standardPackage.addInventory( this.getStandardInventoryFolder() );
220
221 return standardPackage;
222 }
223
224 /**
225 * @see org.millscript.millscript.conf.Configuration#getWebsiteCacheFolder()
226 */
227 public final VFolder getWebsiteCacheFolder() {
228 return websiteCacheFolder;
229 }
230
231 /**
232 * @see org.millscript.millscript.conf.Configuration#getWebsiteConfFolder()
233 */
234 public final VFolder getWebsiteConfFolder() {
235 return websiteConfFolder;
236 }
237
238 /**
239 * @see org.millscript.millscript.conf.Configuration#getWebsiteConfigurationFile()
240 */
241 public VFile getWebsiteConfigurationFile() {
242 return websiteConfigurationFile;
243 }
244
245 /**
246 * @see org.millscript.millscript.conf.Configuration#getWebsiteFailureFile()
247 */
248 public VFile getWebsiteFailureFile() {
249 return websiteFailureFile;
250 }
251
252 /**
253 * @see org.millscript.millscript.conf.Configuration#getWebsiteInventoryFolder()
254 */
255 public final VFolder getWebsiteInventoryFolder() {
256 return websiteInventoryFolder;
257 }
258
259 /**
260 * @see org.millscript.millscript.conf.Configuration#getWebsiteLibFolder()
261 */
262 public final VFolder getWebsiteLibFolder() {
263 return websiteLibFolder;
264 }
265
266 /**
267 * @see org.millscript.millscript.conf.Configuration#getWebsiteOutputFolder()
268 */
269 public final VFolder getWebsiteOutputFolder() {
270 return websiteOutputFolder;
271 }
272
273 /**
274 * @see org.millscript.millscript.conf.Configuration#getWebsiteLockFile()
275 */
276 public VFile getWebsiteLockFile() {
277 return websiteLockFile;
278 }
279
280 /**
281 * @see org.millscript.millscript.conf.Configuration#getWebsiteSuccessFile()
282 */
283 public VFile getWebsiteSuccessFile() {
284 return websiteSuccessFile;
285 }
286
287 /**
288 * @see org.millscript.millscript.conf.Configuration#getWebsiteVarFolder()
289 */
290 public final VFolder getWebsiteVarFolder() {
291 return websiteVarFolder;
292 }
293
294 }