diff --git a/Documentation/Books/codeBlockReader.py b/Documentation/Books/codeBlockReader.py index d334bc0a3e..44311027b6 100644 --- a/Documentation/Books/codeBlockReader.py +++ b/Documentation/Books/codeBlockReader.py @@ -31,15 +31,20 @@ def example_content(filepath, fh, tag): """ Fetches an example file and inserts it using code """ - first = True arangosh = False - showdots = True + curl = False + first = True lastline = None - short = "" - shortLines = 0 long = "" longLines = 0 + short = "" + shortLines = 0 shortable = False + showdots = True + + CURL_STATE_CMD = 1 + CURL_STATE_HEADER = 2 + CURL_STATE_BODY = 3 # read in the context, split into long and short infile = open(filepath, 'r') @@ -47,6 +52,7 @@ def example_content(filepath, fh, tag): for line in infile: if first: arangosh = line.startswith("arangosh>") + curl = line.startswith("shell> curl") first = False if arangosh: @@ -57,11 +63,15 @@ def example_content(filepath, fh, tag): lastline = None short = short + line + shortLines = shortLines + 1 showdots = True else: if showdots: if lastline == None: - lastline = line + # lastline = line + shortable = True + showdots = False + lastline = None else: # short = short + "~~~hidden~~~\n" # shortLines = shortLines + 1 @@ -69,12 +79,26 @@ def example_content(filepath, fh, tag): showdots = False lastline = None + if curl: + if line.startswith("shell> curl"): + curlState = CURL_STATE_CMD + elif curlState == CURL_STATE_CMD and line.startswith("HTTP/1.1 "): + curlState = CURL_STATE_HEADER + elif curlState == CURL_STATE_HEADER and line.startswith("{"): + curlState = CURL_STATE_BODY + + if curlState == CURL_STATE_CMD or curlState == CURL_STATE_HEADER: + short = short + line + shortLines = shortLines + 1 + else: + shortable = True + long = long + line longLines = longLines + 1 - # if lastline != None: - # short = short + lastline - # shortLines = shortLines + 1 + if lastline != None: + short = short + lastline + shortLines = shortLines + 1 infile.close() @@ -109,7 +133,14 @@ def example_content(filepath, fh, tag): fh.write("```\n") fh.write("%s" % short) fh.write("```\n") - fh.write("
show execution results
\n") + + if arangosh: + fh.write("
show execution results
\n") + elif curl: + fh.write("
show response body
\n") + else: + fh.write("
show
\n") + fh.write("\n") fh.write("\n") diff --git a/js/apps/system/aardvark/frontend/js/client/bootstrap/module-internal.js b/js/apps/system/aardvark/frontend/js/client/bootstrap/module-internal.js index 187f4e920d..0b5abdf7b0 100644 --- a/js/apps/system/aardvark/frontend/js/client/bootstrap/module-internal.js +++ b/js/apps/system/aardvark/frontend/js/client/bootstrap/module-internal.js @@ -160,10 +160,12 @@ var i; if (typeof body !== 'string') { - body = JSON.stringify(body); + internal.startCaptureMode(); + print(body); + body = internal.stopCaptureMode(); } - curl = "unix> curl "; + curl = "shell> curl "; if (method === 'POST') { response = internal.arango.POST_RAW(url, body, headers); diff --git a/js/client/bootstrap/module-internal.js b/js/client/bootstrap/module-internal.js index 187f4e920d..0b5abdf7b0 100644 --- a/js/client/bootstrap/module-internal.js +++ b/js/client/bootstrap/module-internal.js @@ -160,10 +160,12 @@ var i; if (typeof body !== 'string') { - body = JSON.stringify(body); + internal.startCaptureMode(); + print(body); + body = internal.stopCaptureMode(); } - curl = "unix> curl "; + curl = "shell> curl "; if (method === 'POST') { response = internal.arango.POST_RAW(url, body, headers); diff --git a/js/server/modules/org/arangodb/foxx/model.js b/js/server/modules/org/arangodb/foxx/model.js index afb265afd0..e1bfecacc9 100644 --- a/js/server/modules/org/arangodb/foxx/model.js +++ b/js/server/modules/org/arangodb/foxx/model.js @@ -102,6 +102,7 @@ Model = function (attributes) { this.attributes = whitelistProperties(attributes, this.constructor.attributes, true); this.attributes = fillInDefaults(this.attributes, this.constructor.attributes); + this.whitelistedAttributes = whitelistProperties(this.attributes, this.constructor.attributes); }; Model.fromClient = function (attributes) { @@ -269,8 +270,7 @@ _.extend(Model.prototype, { forClient: function () { 'use strict'; - var result = whitelistProperties(this.attributes, this.constructor.attributes); - return result; + return this.whitelistedAttributes; } });