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("{");
pw.println("\t\"name\":\""+atlasProperties.getAtlasName()+"\"");
pw.println("\t,\"restricted\":"+atlasProperties.isRestricted());
pw.println("}");
FSEntry f = FSEntryBuffer.getPositionedBuffer("a/nunaliit.json", sw.toString());
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("\t,restricted: "+atlasProperties.isRestricted());
pw.println("};");
pw.println("if( typeof(exports) === 'object' ) {");
pw.println("\texports.name = n2atlas.name;");
pw.println("\texports.restricted = n2atlas.restricted;");
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);
}
}
// Nunaliit2 javascript library
{
File n2Dir = PathComputer.computeNunaliit2JavascriptDir(installDir);
if( null == n2Dir ) {
throw new Exception("Can not find nunaliit2 javascript library");
} else {
// Libraries
{
FSEntry f = FSEntryFile.getPositionedFile("a/_attachments/nunaliit2", n2Dir);
entries.add(f);
}
// Vendor file 'n2.couchUtils.js'
{
File file = new File(n2Dir,"n2.couchUtils.js");
FSEntry f = FSEntryFile.getPositionedFile("a/vendor/nunaliit2/n2.couchUtils.js", file);
entries.add(f);
}
// Vendor file 'n2.couchTiles.js'
{
File file = new File(n2Dir,"n2.couchTiles.js");
FSEntry f = FSEntryFile.getPositionedFile("a/vendor/nunaliit2/n2.couchTiles.js", file);
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);