removed: ezn patterns for rawcontent and ajaxcontent:

index_rawcontent.html, index_ajaxcontent.html
         now we have out_streams in Request and some special
         keyword in ezc templates for sending content to the 
         specified streams
changed: the way how winix answers to the client's browsers:
         info from Request class:
	                                   winix answer send to the client's browser
	                                                       |
	                                                       |
	                                          depending on send_bin_stream
	                               -------------------------------------------------
	                               |                                               |
	                          text answer                                     binary answer
	                               |                                               |
	                   depending on return_json                          sending out_bin_stream
	             ------------------------------------
	             |                                  |
	       normal request                     ajax request
	             |                                  |
	   sending out_streams[0]           depending on return_info_only
	                              ------------------------------------------------------
	                              |                                                    |
	                 generating JSON object from:                   generating JSON object only from info
	                 out_streams and info, e.g.:                    e.g.:
	                 {                                              { info object serialized here }
	                  "stream_1": "some html content",
	                  "stream_2": "some other html content",
	                  "info": { info object serialized here }
	                 }
	                 note that out_streams[0] is not sent
	                 in JSON answers
	
	




git-svn-id: svn://ttmath.org/publicrep/winix/trunk@937 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2013-11-14 20:59:23 +00:00
parent d801f53154
commit 3af3ac3f6f
15 changed files with 303 additions and 115 deletions

View File

@@ -44,20 +44,100 @@ struct Request
// headers, page and debug
//std::ostringstream headers, page, debug;
TextStream<std::string> headers;
HtmlTextStream page, debug;
TextStream<std::wstring> ajaxpage;
// !! IMPROVE ME change headers to some kind of a map, may PT::Space ?
TextStream<std::string> headers;
HtmlTextStream debug;
// binary page
BinaryPage binary_page;
// a compressed page ready to send to the client
BinaryPage compressed_page;
// winix can return either a text answer or a binary answer
// if send_bin_stream is true then the binary answer is sent (out_bin_stream)
// or if send_bin_stream is false then the text answer is sent
// default: false
//
//
//
// winix answer send to the client's browser
// |
// |
// depending on send_bin_stream
// -------------------------------------------------
// | |
// text answer binary answer
// | |
// depending on return_json sending out_bin_stream
// ------------------------------------
// | |
// normal request ajax request
// | |
// sending out_streams[0] depending on return_info_only
// ------------------------------------------------------
// | |
// generating JSON object from: generating JSON object only from info
// out_streams and info, e.g.: e.g.:
// { { info object serialized here }
// "stream_1": "some html content",
// "stream_2": "some other html content",
// "info": { info object serialized here }
// }
// note that out_streams[0] is not sent
// in JSON answers
//
//
bool send_bin_stream;
// -------------------------------------------------------------------------------------
// binary answer
//
// binary page sent to the client if send_bin_stream is true
BinaryPage out_bin_stream;
//
// -------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------
// text answer
//
// when returning the text answer we can either return the whole html page (normal requests)
// or a JSON object (for requests generated from AJAX)
// if return_json is false then we return the whole html page (which is in out_streams[0])
// if return_json is true we are creating an JSON object from out_streams
// (zero stream is ignored) and from info space (see above picture)
// (or just only from info if return_info_only is true)
// default: false
// return_json is set to true by App at the beginning of a request
// if reqtype:json parameter is present (in the url)
// note: return_json is only valid if send_bin_stream is false
bool return_json;
// main text output streams where the html otput is generated from ezc templates
// the zero stream (out_streams[0]) is used as the main stream
// to which the whole html page (with doctype, head, body) is generated
// the rest streams can be only used in ajax requests (send in JSON format to the client)
// in ezc templates you can use [ezc stream ...] keyword
// to switch between streams e.g. [ezc stream "0" "2"]
std::vector<HtmlTextStream> out_streams;
// if true the JSON object is generated only from info (out_streams are not used)
// default: false
bool return_info_only;
// additional info added when sending the JSON answer
PT::Space info;
// info serializer
// if not set then the json_generic_serializer from App will be used
// default: null (json_generic_serializer used)
PT::SpaceToJSON * info_serializer;
//
// -------------------------------------------------------------------------------------
// if true then either page or ajaxpage will be sent to the client
// if false then binary_page is sent
// default: true
bool use_text_page;
// if set to true then the standard template system will not be generated
// default: false
@@ -67,6 +147,10 @@ struct Request
// default: true
bool use_html_filter;
// raw parameters
PostTab post_tab;
PostFileTab post_file_tab;
@@ -157,15 +241,6 @@ struct Request
// subdomain = HTTP_HOST environment variable - config->base_url
std::wstring subdomain;
// used as a JSON output (when ajax_serializer is defined)
// it will be serialized and have at least:
// 'content' string - the whole html content
// 'http_status' integer - http status code (e.g. 200) !! FIXME this is not added at the moment
PT::Space ajax;
// if not null then the request will have a JSON as an output
PT::SpaceToJSON * ajax_serializer;
// if this variable is true then winix always return 200 OK header
// when the status would be 404 (not found) or 403 (permission denied)
// default: false
@@ -222,7 +297,7 @@ private:
// used in ParamValue() and PostVar() when there is no such a param
const std::wstring str_empty;
void ClearAjax();
void ClearOutputStreams();
};