diff --git a/PageCompiler/doc/PageCompilerUserGuide.page b/PageCompiler/doc/PageCompilerUserGuide.page index 12b42a908..f9ccde85f 100644 --- a/PageCompiler/doc/PageCompilerUserGuide.page +++ b/PageCompiler/doc/PageCompilerUserGuide.page @@ -4,8 +4,8 @@ POCO PageCompiler !!!Introduction PageCompiler is a command line tool that translates HTML files (and other kinds of files) into C++ code, more precisely, subclasses of Poco::Net::HTTPRequestHandler. -The source files can contain special directives that allow embedding of C++ code. -The syntax of these directives is based on the syntax used for +The source files can contain special directives that allow embedding of C++ code. +The syntax of these directives is based on the syntax used for Java Server Pages (JSP) and Active Server Pages (ASP). The following introductory sample shows the code for a simple page that displays the @@ -16,13 +16,13 @@ current date and time. #include "Poco/DateTime.h" #include "Poco/DateTimeFormatter.h" #include "Poco/DateTimeFormat.h" - - + + using Poco::DateTime; using Poco::DateTimeFormatter; using Poco::DateTimeFormat; %> - + <% DateTime now; std::string dt(DateTimeFormatter::format(now, DateTimeFormat::SORTABLE_FORMAT)); @@ -36,14 +36,14 @@ current date and time.

<%= dt %>

----- +---- Sending the above code to the page compiler will generate two files, a header file (<[TimeHandler.h]>) and an implementation file (<[TimeHandler.cpp]>). The files define a subclass of Poco::Net::HTTPRequestHandler named <[TimeHandler]>. The generated <[handleRequest]> member function contains code to send the HTML -code contained in the source file to the client, as well as the C++ code fragments found -in between the Scriptlet tags. +code contained in the source file to the client, as well as the C++ code fragments found +in between the Scriptlet tags. !!!C++ Server Page Syntax @@ -124,12 +124,17 @@ Example: return response.redirect("/"); } %> - + !!Include Directive Another CPSP file can be included into the current file using the Include Directive. + <%@ include file="" %> +---- + +Alternatively, this can also be written as: + <%@ include page="" %> ---- @@ -140,7 +145,7 @@ Include a C++ header file in the generated header file. This corresponds to: <%!! #include "" %> - + A variant of this directive is: <%@ header sinclude="" %> @@ -155,7 +160,7 @@ Include a C++ header file in the generated implementation file. This corresponds to: <%! #include "" %> - + A variant of this directive is: <%@ impl sinclude="" %> @@ -185,7 +190,7 @@ No namespace will be used if omitted. !baseClass -Specifies the name of the class used as the base class for the generated +Specifies the name of the class used as the base class for the generated request handler class. Defaults to Poco::Net::HTTPRequestHandler. Do not forget to add a Header Declaration containing an <[#include]> directive for the header file containing the definition @@ -204,7 +209,7 @@ Cannot be used together with <[ctorArg]>. Allows to specify the type of a single argument being passed to the constructor of the generated request handler class. Can only be used together with <[baseClass]>. -The argument is passed on to the constructor of the base class, therefore, one of the +The argument is passed on to the constructor of the base class, therefore, one of the constructors of the base class must also accept a single argument of the specified type. Cannot be used together with <[context]>. @@ -224,9 +229,9 @@ Set the value to <[false]> to disable form handling. !formPartHandler -Allows you to pass a Poco::Net::PartHandler object to the form object for +Allows you to pass a Poco::Net::PartHandler object to the form object for processing file uploads. A subclass of Poco::Net::PartHandler must be -defined (using an Implementation Declaration), and the constructor of the part +defined (using an Implementation Declaration), and the constructor of the part handler must take a (const) reference to the request handler instance as argument. !contentType @@ -236,7 +241,7 @@ Allows you to specify the MIME content type for the page. Defaults to text/html. !contentLanguage Allows to specify a language tag (e.g., "en") that will be sent in the -response Content-Language header if the client sends an Accept-Language +response Content-Language header if the client sends an Accept-Language header in the request. !chunked @@ -250,7 +255,7 @@ Set the value to <[false]> to disable chunked transfer encoding. Enables or disables response body compression. If set to <[true]>, and the client supports the "gzip" content encoding (indicated by the "Accept-Encoding" header), the response body will be compressed using the "gzip" format and the -"Content-Encoding" header will be set accordingly. +"Content-Encoding" header will be set accordingly. Defaults to <[false]>. Cannot be enabled together with response buffering. !compressionLevel @@ -264,7 +269,7 @@ Enables or disables response buffering. Response buffering is disabled by defaul Set to <[true]> to enable buffering, or to <[false]> to disable it. If response buffering is enabled, everything written to the response stream is actually written to a string stream (<[std::ostringstream]>). -Sending of the HTTP response back to the client is deferred to +Sending of the HTTP response back to the client is deferred to when the page is complete. !session (OSP only) @@ -290,10 +295,10 @@ and the timeout value is read from the respective bundle property. For use with the POCO Open Service Platform only. -If set to <[true]>, which is the default if the attribute is not specified, +If set to <[true]>, which is the default if the attribute is not specified, a new session will be created if the request does not contain a (valid) session cookie. If set to <[false]> and there is no existing session that matches the session -cookie. the <[session]> variable will be null. +cookie. the <[session]> variable will be null. !precondition @@ -368,7 +373,7 @@ system (e.g., <[/help]> on Windows, <[--help]> or <[-h]> on Unix). !!Configuration Properties The Page Compiler supports one configuration property, named -<[PageCompiler.fileHeader]>, to optionally specify a header that is +<[PageCompiler.fileHeader]>, to optionally specify a header that is included in every generated file. The file header can contain references to other configuration properties, diff --git a/PageCompiler/src/PageReader.cpp b/PageCompiler/src/PageReader.cpp index 67fd92d4a..c480ded0c 100644 --- a/PageCompiler/src/PageReader.cpp +++ b/PageCompiler/src/PageReader.cpp @@ -309,7 +309,7 @@ void PageReader::nextToken(std::istream& istr, std::string& token) void PageReader::handleAttribute(const std::string& name, const std::string& value) { - if (name == "include.page") + if (name == "include.page" || name == "include.file") { include(value); } @@ -341,14 +341,14 @@ void PageReader::include(const std::string& path) Poco::Path currentPath(_path); Poco::Path includePath(path); currentPath.resolve(includePath); - + _page.handler() << "\t// begin include " << currentPath.toString() << "\n"; - + Poco::FileInputStream includeStream(currentPath.toString()); PageReader includeReader(*this, currentPath.toString()); includeReader.emitLineDirectives(_emitLineDirectives); includeReader.parse(includeStream); - + _page.handler() << "\t// end include " << currentPath.toString() << "\n"; }