mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-05 10:59:47 -05:00
One Property Tree (#500)
* Organize properties in one single property tree * Update scenes to work with one property tree. Fix documentation issues.
This commit is contained in:
@@ -282,18 +282,7 @@ std::string DocumentationEngine::generateJson() const {
|
||||
|
||||
json << "]";
|
||||
|
||||
std::string jsonString = "";
|
||||
for (const char& c : json.str()) {
|
||||
switch (c) {
|
||||
case '\'':
|
||||
jsonString += "\\'";
|
||||
break;
|
||||
default:
|
||||
jsonString += c;
|
||||
}
|
||||
}
|
||||
|
||||
return jsonString;
|
||||
return json.str();
|
||||
}
|
||||
|
||||
void DocumentationEngine::addDocumentation(Documentation doc) {
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
|
||||
namespace {
|
||||
const char* HandlebarsFilename = "${WEB}/common/handlebars-v4.0.5.js";
|
||||
const char* BaseLibraryFilename = "${WEB}/common/base.js";
|
||||
const char* BootstrapFilename = "${WEB}/common/bootstrap.min.css";
|
||||
const char* CssFilename = "${WEB}/common/style.css";
|
||||
} // namespace
|
||||
@@ -70,6 +71,14 @@ void DocumentationGenerator::writeDocumentation(const std::string& filename) {
|
||||
std::istreambuf_iterator<char>()
|
||||
);
|
||||
|
||||
std::ifstream baseLibarayInput;
|
||||
baseLibarayInput.exceptions(~std::ofstream::goodbit);
|
||||
baseLibarayInput.open(absPath(BaseLibraryFilename));
|
||||
const std::string baseLibraryContent = std::string(
|
||||
std::istreambuf_iterator<char>(baseLibarayInput),
|
||||
std::istreambuf_iterator<char>()
|
||||
);
|
||||
|
||||
std::ifstream jsInput;
|
||||
jsInput.exceptions(~std::ofstream::goodbit);
|
||||
jsInput.open(absPath(_javascriptFile));
|
||||
@@ -120,6 +129,8 @@ void DocumentationGenerator::writeDocumentation(const std::string& filename) {
|
||||
<< "</script>" << '\n';
|
||||
}
|
||||
|
||||
const std::string DataId = "data";
|
||||
|
||||
const std::string Version =
|
||||
"[" +
|
||||
std::to_string(OPENSPACE_VERSION_MAJOR) + "," +
|
||||
@@ -127,11 +138,19 @@ void DocumentationGenerator::writeDocumentation(const std::string& filename) {
|
||||
std::to_string(OPENSPACE_VERSION_PATCH) +
|
||||
"]";
|
||||
|
||||
file
|
||||
<< "\t" << "<script id=\"" << DataId
|
||||
<< "\" type=\"text/application/json\">" << '\n'
|
||||
<< json << '\n'
|
||||
<< "\t" << "</script>" << '\n';
|
||||
|
||||
|
||||
file
|
||||
<< "\t" << "<script>" << '\n'
|
||||
<< "\t\t" << "var " << _jsonName << " = JSON.parse('" << json << "');" << '\n'
|
||||
<< "\t\t" << "var " << _jsonName << " = parseJson('" << DataId << "');" << '\n'
|
||||
<< "\t\t" << "var version = " << Version << ";" << '\n'
|
||||
<< "\t\t" << handlebarsContent << '\n'
|
||||
<< "\t\t" << baseLibraryContent << '\n'
|
||||
<< "\t\t" << jsContent << '\n'
|
||||
<< "\t" << "</script>" << '\n'
|
||||
<< "\t" << "<style type=\"text/css\">" << '\n'
|
||||
@@ -150,21 +169,19 @@ std::string escapedJson(const std::string& text) {
|
||||
for (const char& c : text) {
|
||||
switch (c) {
|
||||
case '\t':
|
||||
jsonString += "\\t";
|
||||
jsonString += "\\t"; // Replace tab with \t.
|
||||
break;
|
||||
case '"':
|
||||
// The " character has to be double escaped as JSON.parse will remove a single
|
||||
// escape character, thus leaving only " behind that breaks the string
|
||||
jsonString += "\\\\\"";
|
||||
jsonString += "\\\""; // Replace " with \".
|
||||
break;
|
||||
case '\\':
|
||||
jsonString += "\\\\";
|
||||
jsonString += "\\\\"; // Replace \ with \\.
|
||||
break;
|
||||
case '\n':
|
||||
jsonString += "\\\\n";
|
||||
jsonString += "\\\\n"; // Replace newline with \n.
|
||||
break;
|
||||
case '\r':
|
||||
jsonString += "\\r";
|
||||
jsonString += "\\r"; // Replace carriage return with \r.
|
||||
break;
|
||||
default:
|
||||
jsonString += c;
|
||||
|
||||
Reference in New Issue
Block a user