summaryrefslogtreecommitdiff
path: root/server/src/transactionhandler.cc
diff options
context:
space:
mode:
authordeva <deva>2010-08-03 12:29:39 +0000
committerdeva <deva>2010-08-03 12:29:39 +0000
commitd285c1bdb79752ef23a7252c9c2d9f408f0c9f49 (patch)
tree7c65185cdddb37dc99cccca6c5b89a9799add6a9 /server/src/transactionhandler.cc
parent726742e53bcbb3fa31bcd55e6e7fe305da225455 (diff)
New script-tag attribute that includes lua code from a file.
Diffstat (limited to 'server/src/transactionhandler.cc')
-rw-r--r--server/src/transactionhandler.cc31
1 files changed, 25 insertions, 6 deletions
diff --git a/server/src/transactionhandler.cc b/server/src/transactionhandler.cc
index f549192..86f7853 100644
--- a/server/src/transactionhandler.cc
+++ b/server/src/transactionhandler.cc
@@ -66,11 +66,11 @@ static std::string handleCommits(Transaction &transaction, Environment &env,
mp.parse();
Macro *macro = mp.getMacro();
- std::string resume = resume_parser(macro->resume, commit);
+ std::string resume = resume_parser(*macro, commit);
commit.fields["journal.resume"] = resume;
db->commitTransaction(transaction.user, transaction.cpr, *macro,
commit.fields);
-
+
if(resume != "") {
TemplateParser tp(env.templatelist.getLatestVersion(commit.templ));
@@ -199,12 +199,31 @@ static std::string handleRequest(Transaction &transaction, Environment &env,
std::vector< Script >::iterator spi = m->scripts.begin();
while(spi != m->scripts.end()) {
answer += " <script language=\"" +
- spi->attributes["language"]
- + "\" name=\"" + spi->attributes["name"] + "\">\n";
- answer += xml_encode(spi->attributes["code"]);
- answer += "\n </script>\n";
+ spi->attributes["language"] + "\">";
+
+ if(spi->attributes.find("src") != spi->attributes.end()) {
+ std::string file =
+ Conf::xml_basedir + "/include/" + spi->attributes["src"];
+ FILE *fp = fopen(file.c_str(), "r");
+ if(fp) {
+ char buf[64];
+ size_t sz;
+ std::string inc;
+ while((sz = fread(buf, 1, sizeof(buf), fp)) != 0) {
+ inc.append(buf, sz);
+ }
+ fclose(fp);
+ answer += "\n-- BEGIN INCLUDE: '" + spi->attributes["src"] + "'\n";
+ answer += xml_encode(inc);
+ answer += "\n-- END INCLUDE: '" + spi->attributes["src"] + "'\n";
+ }
+ } else {
+ answer += xml_encode(spi->attributes["code"]);
+ }
+ answer += "</script>\n";
spi++;
}
+
answer += " </scripts>\n";
}