summaryrefslogtreecommitdiff
path: root/project2/cgi
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2011-07-18 18:46:18 +0000
committerrandomdan <randomdan@localhost>2011-07-18 18:46:18 +0000
commitca713add1f0a044e9f9bd3b8946fae97b9fd3075 (patch)
tree2713d8909eb14f0dd28b830454e9b501f678b819 /project2/cgi
parentAutomatically sort the order of the MailParts to make life carefree and fix t... (diff)
downloadproject2-ca713add1f0a044e9f9bd3b8946fae97b9fd3075.tar.bz2
project2-ca713add1f0a044e9f9bd3b8946fae97b9fd3075.tar.xz
project2-ca713add1f0a044e9f9bd3b8946fae97b9fd3075.zip
Allow references to scripts deep in the tree
Diffstat (limited to 'project2/cgi')
-rw-r--r--project2/cgi/cgiEnvironment.cpp15
-rw-r--r--project2/cgi/cgiStageCustomError.cpp4
-rw-r--r--project2/cgi/cgiStageCustomNotFound.cpp4
-rw-r--r--project2/cgi/cgiStageInitial.cpp4
-rw-r--r--project2/cgi/cgiStagePresent.cpp12
-rw-r--r--project2/cgi/cgiStageRequest.cpp6
6 files changed, 25 insertions, 20 deletions
diff --git a/project2/cgi/cgiEnvironment.cpp b/project2/cgi/cgiEnvironment.cpp
index 2bc3b02..21799db 100644
--- a/project2/cgi/cgiEnvironment.cpp
+++ b/project2/cgi/cgiEnvironment.cpp
@@ -3,18 +3,23 @@
#include "../exceptions.h"
#include <map>
#include <cgicc/Cgicc.h>
-#include <boost/tokenizer.hpp>
-template <class X, class Y>
-std::vector<X>makeVector(const Y & y)
+std::vector<std::string>
+makeVector(const boost::filesystem::path & y)
{
- return std::vector<X>(y.begin(), y.end());
+ std::vector<std::string> r;
+ boost::filesystem::path::iterator p = y.begin();
+ p++;
+ while(p != y.end()) {
+ r.push_back((p++)->string());
+ }
+ return r;
}
CgiEnvironment::CgiEnvironment(cgicc::Cgicc * c) :
Environment(0, NULL),
cgicc::CgiEnvironment(c->getEnvironment()),
- elems(makeVector<std::string>(boost::tokenizer<boost::char_separator<char> >(getRedirectURL(), boost::char_separator<char>("/")))),
+ elems(makeVector(boost::filesystem::path(getRedirectURL()))),
cgi(c)
{
}
diff --git a/project2/cgi/cgiStageCustomError.cpp b/project2/cgi/cgiStageCustomError.cpp
index fb2f0de..26fdf51 100644
--- a/project2/cgi/cgiStageCustomError.cpp
+++ b/project2/cgi/cgiStageCustomError.cpp
@@ -5,8 +5,8 @@
CgiApplicationEngine::CustomErrorStage::CustomErrorStage(const CgiEnvironment * env, const std::exception & ex) :
CgiApplicationEngine::ResponseStage(env),
- ::XmlScriptParser(env->errorPresentRoot, env->onErrorPresent, false),
- ::CheckHost(env->errorPresentRoot, env->onErrorPresent),
+ ::XmlScriptParser(e->resolveScript(env->errorPresentRoot, env->onErrorPresent), false),
+ ::CheckHost(e->resolveScript(env->errorPresentRoot, env->onErrorPresent)),
CgiApplicationEngine::DefaultErrorStage(env, ex),
CgiApplicationEngine::PresentStage(env, env->errorPresentRoot, env->onErrorPresent)
{
diff --git a/project2/cgi/cgiStageCustomNotFound.cpp b/project2/cgi/cgiStageCustomNotFound.cpp
index 7c08a9f..4f06c2e 100644
--- a/project2/cgi/cgiStageCustomNotFound.cpp
+++ b/project2/cgi/cgiStageCustomNotFound.cpp
@@ -5,8 +5,8 @@
CgiApplicationEngine::CustomNotFoundStage::CustomNotFoundStage(const CgiEnvironment * env, const ::XmlScriptParser::NotFound & notfound) :
CgiApplicationEngine::ResponseStage(env),
- ::XmlScriptParser(env->errorPresentRoot, env->notFoundPresent, false),
- ::CheckHost(env->errorPresentRoot, env->notFoundPresent),
+ ::XmlScriptParser(e->resolveScript(env->errorPresentRoot, env->notFoundPresent), false),
+ ::CheckHost(e->resolveScript(env->errorPresentRoot, env->notFoundPresent)),
CgiApplicationEngine::DefaultNotFoundStage(env, notfound),
CgiApplicationEngine::PresentStage(env, env->errorPresentRoot, env->notFoundPresent)
{
diff --git a/project2/cgi/cgiStageInitial.cpp b/project2/cgi/cgiStageInitial.cpp
index 1db8f8f..7c7b198 100644
--- a/project2/cgi/cgiStageInitial.cpp
+++ b/project2/cgi/cgiStageInitial.cpp
@@ -16,10 +16,10 @@ CgiApplicationEngine::InitialStage::run()
if (e->elems.empty()) {
throw EmptyRequestURL();
}
- return NextStage(new RequestStage(e, e->elems[0]));
+ return NextStage(new RequestStage(e, e->getRedirectURL()));
}
else {
- return NextStage(new PresentStage(e, e->elems.empty() ? e->defaultPresent : e->elems[0]));
+ return NextStage(new PresentStage(e, e->elems.empty() ? e->defaultPresent : e->getRedirectURL()));
}
}
diff --git a/project2/cgi/cgiStagePresent.cpp b/project2/cgi/cgiStagePresent.cpp
index 6091ed8..4920623 100644
--- a/project2/cgi/cgiStagePresent.cpp
+++ b/project2/cgi/cgiStagePresent.cpp
@@ -6,17 +6,17 @@
CgiApplicationEngine::PresentStage::PresentStage(const CgiEnvironment * e, const std::string & id) :
CgiApplicationEngine::ResponseStage(e),
- XmlScriptParser(e->presentRoot, id, false),
- CheckHost(e->presentRoot, id),
- ViewHost(e->presentRoot, id)
+ XmlScriptParser(e->resolveScript(e->presentRoot, id), false),
+ CheckHost(e->resolveScript(e->presentRoot, id)),
+ ViewHost(e->resolveScript(e->presentRoot, id))
{
}
CgiApplicationEngine::PresentStage::PresentStage(const CgiEnvironment * e, const std::string & group, const std::string & id) :
CgiApplicationEngine::ResponseStage(e),
- XmlScriptParser(group, id, false),
- CheckHost(group, id),
- ViewHost(group, id)
+ XmlScriptParser(e->resolveScript(group, id), false),
+ CheckHost(e->resolveScript(group, id)),
+ ViewHost(e->resolveScript(group, id))
{
}
diff --git a/project2/cgi/cgiStageRequest.cpp b/project2/cgi/cgiStageRequest.cpp
index ee72b81..c53a172 100644
--- a/project2/cgi/cgiStageRequest.cpp
+++ b/project2/cgi/cgiStageRequest.cpp
@@ -5,10 +5,10 @@
#include <boost/foreach.hpp>
CgiApplicationEngine::RequestStage::RequestStage(const CgiEnvironment * e, const std::string & id) :
- XmlScriptParser(e->requestRoot, id, false),
- ::CheckHost(e->requestRoot, id),
+ XmlScriptParser(e->resolveScript(e->requestRoot, id), false),
+ ::CheckHost(e->resolveScript(e->requestRoot, id)),
CgiApplicationEngine::ResponseStage(e),
- ::TaskHost(e->requestRoot, id)
+ ::TaskHost(e->resolveScript(e->requestRoot, id))
{
xmlpp::Element * requestRoot = get_document()->get_root_node();
present = requestRoot->get_attribute_value("present");