List<FSEntry> entries = new Vector<FSEntry>();
// Force identifier
{
FSEntry f = FSEntryBuffer.getPositionedBuffer("a/_id.txt", "_design/atlas");
entries.add(f);
}
// Create atlas designator
{
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
pw.println("var n2atlas = {");
pw.println("\tname: \""+atlasProperties.getAtlasName()+"\"");
pw.println("};");
pw.println("if( typeof(exports) === 'object' ) {");
pw.println("\texports.name = n2atlas.name;");
pw.println("};");
FSEntry f = FSEntryBuffer.getPositionedBuffer("a/vendor/nunaliit2/atlas.js", sw.toString());
entries.add(f);
f = FSEntryBuffer.getPositionedBuffer("a/_attachments/lib/atlas.js", sw.toString());
entries.add(f);
}
// Atlas design template
{
File atlasDesignDir = PathComputer.computeAtlasDesignDir(installDir);
if( null == atlasDesignDir ) {
throw new Exception("Can not find _design/atlas template");
} else {
FSEntryFile f = new FSEntryFile(atlasDesignDir);
entries.add(f);
}
// Vendor files
{
File utilsFile = new File(atlasDesignDir,"vendor/nunaliit2/utils.js");
if( utilsFile.exists() ) {
FSEntry f = FSEntryFile.getPositionedFile("a/_attachments/lib/utils.js", utilsFile);
entries.add(f);
}
}
{
File tilesFile = new File(atlasDesignDir,"vendor/nunaliit2/tiles.js");
if( tilesFile.exists() ) {
FSEntry f = FSEntryFile.getPositionedFile("a/_attachments/lib/tiles.js", tilesFile);
entries.add(f);
}
}
}
// Nunaliit2 javascript library
{
File n2Dir = PathComputer.computeNunaliit2JavascriptDir(installDir);
if( null == n2Dir ) {
throw new Exception("Can not find nunaliit2 javascript library");
} else {
FSEntry f = FSEntryFile.getPositionedFile("a/_attachments/nunaliit2", n2Dir);
entries.add(f);
}
}
// External javascript library
{
File externalDir = PathComputer.computeExternalJavascriptDir(installDir);
if( null == externalDir ) {
throw new Exception("Can not find external javascript library");
} else {
FSEntry f = FSEntryFile.getPositionedFile("a/_attachments/js-external", externalDir);
entries.add(f);
}
}
// Install language
{
FSEntry f = FSEntryBuffer.getPositionedBuffer("a/language.txt", "javascript");
entries.add(f);
}
// Create FSEntry to load document
FSEntryMerged mergedEntry = new FSEntryMerged(entries);