From 97c6a5d184b8e8c14689ddb99951ad4d71204002 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Mon, 5 Dec 2011 10:50:07 +0100 Subject: Change how script code is stored to the Script objects. The std::string code member is there for a reason you know... --- server/src/macroparser.cc | 2 +- server/src/transactionhandler.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'server/src') diff --git a/server/src/macroparser.cc b/server/src/macroparser.cc index d1604b2..7d3f367 100644 --- a/server/src/macroparser.cc +++ b/server/src/macroparser.cc @@ -114,7 +114,7 @@ void MacroParser::characterData(std::string &data) if(state == SCRIPT) { assert(current_script); // No script present! - current_script->attributes["code"].append(data); + current_script->code.append(data); } } diff --git a/server/src/transactionhandler.cc b/server/src/transactionhandler.cc index 5203ee2..ef112ee 100644 --- a/server/src/transactionhandler.cc +++ b/server/src/transactionhandler.cc @@ -244,7 +244,7 @@ static std::string handleRequest(Request &request, Environment &env, answer +="\n-- END INCLUDE: '"+spi->attributes["src"]+"'\n"; } } else { - answer += xml_encode(spi->attributes["code"]); + answer += xml_encode(spi->code); } answer += "\n"; spi++; -- cgit v1.2.3 From 5e0afb2c9239fd8695ff338f92fe113d593b2bf0 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Mon, 5 Dec 2011 15:46:44 +0100 Subject: Prepare for template scripts. --- server/src/template.h | 2 ++ server/src/templateparser.cc | 49 ++++++++++++++++++++++++++++++++++++++++++++ server/src/templateparser.h | 3 +++ 3 files changed, 54 insertions(+) (limited to 'server/src') diff --git a/server/src/template.h b/server/src/template.h index a069cff..e549ef3 100644 --- a/server/src/template.h +++ b/server/src/template.h @@ -84,6 +84,8 @@ public: class Template { public: + std::vector< Script > scripts; + std::vector< Macro > macros; std::string name; diff --git a/server/src/templateparser.cc b/server/src/templateparser.cc index b9c65f5..704b215 100644 --- a/server/src/templateparser.cc +++ b/server/src/templateparser.cc @@ -81,6 +81,10 @@ TemplateParser::~TemplateParser() void TemplateParser::characterData(std::string &data) { + if(state == SCRIPT) { + assert(current_script); // No script present! + current_script->code.append(data); + } } void TemplateParser::startTag(std::string name, attributes_t &attr) @@ -127,6 +131,39 @@ void TemplateParser::startTag(std::string name, attributes_t &attr) return; } + // Enable script parsing + if(name == "scripts") { + if(state != MACRO) error("scripts found outside macro."); + state = SCRIPTS; + + assert(t); // No template is currently available, cannot create maps! + + return; + } + + // Create script + if(name == "script") { + + assert(t); // No template is currently available, cannot create script! + + switch(state) { + case SCRIPTS: + { + state = SCRIPT; + + Script s; + s.attributes = attr; + t->scripts.push_back(s); + current_script = &(t->scripts.back()); + } + break; + default: + error("\n"; + si++; + } + xml += " \n"; + + xml += " \n"; + } xml += " \n"; i++; diff --git a/server/src/template.h b/server/src/template.h index e549ef3..853db3d 100644 --- a/server/src/template.h +++ b/server/src/template.h @@ -67,6 +67,7 @@ public: maps_t maps; std::vector< Script > scripts; std::vector< Script > resume_scripts; + std::vector< Script > commit_scripts; Widget widgets; Resume resume; diff --git a/server/src/templateparser.cc b/server/src/templateparser.cc index 704b215..8fc3eff 100644 --- a/server/src/templateparser.cc +++ b/server/src/templateparser.cc @@ -133,7 +133,7 @@ void TemplateParser::startTag(std::string name, attributes_t &attr) // Enable script parsing if(name == "scripts") { - if(state != MACRO) error("scripts found outside macro."); + if(state != TEMPLATE) error("scripts found outside template."); state = SCRIPTS; assert(t); // No template is currently available, cannot create maps! @@ -158,7 +158,7 @@ void TemplateParser::startTag(std::string name, attributes_t &attr) } break; default: - error("