From d285c1bdb79752ef23a7252c9c2d9f408f0c9f49 Mon Sep 17 00:00:00 2001 From: deva Date: Tue, 3 Aug 2010 12:29:39 +0000 Subject: New script-tag attribute that includes lua code from a file. --- server/src/transactionhandler.cc | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'server/src/transactionhandler.cc') 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 += " \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 += "\n"; spi++; } + answer += " \n"; } -- cgit v1.2.3