diff options
author | Alexander Tkachev | 2016-07-19 13:41:25 +0600 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | da229dd84c5761f80b16c25edba7bfb738fc835f (patch) | |
tree | d52f1815a56e718675a0ff9298b99f6ab05ef939 | |
parent | e6caa482e1e7c0e6d9f8201331332b9f5425b79d (diff) | |
download | scummvm-rg350-da229dd84c5761f80b16c25edba7bfb738fc835f.tar.gz scummvm-rg350-da229dd84c5761f80b16c25edba7bfb738fc835f.tar.bz2 scummvm-rg350-da229dd84c5761f80b16c25edba7bfb738fc835f.zip |
CLOUD: Add "ajax" parameter for "/create" and "/upload"
If it's set, these redirect to "/filesAJAX" instead of "/files".
-rw-r--r-- | backends/networking/sdl_net/handlers/createdirectoryhandler.cpp | 4 | ||||
-rw-r--r-- | backends/networking/sdl_net/handlers/filesajaxpagehandler.cpp | 14 | ||||
-rw-r--r-- | backends/networking/sdl_net/uploadfileclienthandler.cpp | 8 | ||||
-rw-r--r-- | backends/networking/wwwroot.zip | bin | 241872 -> 241963 bytes | |||
-rw-r--r-- | backends/networking/wwwroot/.filesAJAX.html | 7 |
5 files changed, 26 insertions, 7 deletions
diff --git a/backends/networking/sdl_net/handlers/createdirectoryhandler.cpp b/backends/networking/sdl_net/handlers/createdirectoryhandler.cpp index 97d75fcf14..fc02b643c1 100644 --- a/backends/networking/sdl_net/handlers/createdirectoryhandler.cpp +++ b/backends/networking/sdl_net/handlers/createdirectoryhandler.cpp @@ -85,7 +85,9 @@ void CreateDirectoryHandler::handle(Client &client) { client.queryParameter("path").c_str(), _("Back to parent directory") ), - "/files?path=" + LocalWebserver::urlEncodeQueryParameterValue(client.queryParameter("path")) + + (client.queryParameter("ajax") == "true" ? "/filesAJAX?path=" : "/files?path=") + + LocalWebserver::urlEncodeQueryParameterValue(client.queryParameter("path")) ); } diff --git a/backends/networking/sdl_net/handlers/filesajaxpagehandler.cpp b/backends/networking/sdl_net/handlers/filesajaxpagehandler.cpp index 17be7faad2..df4482166a 100644 --- a/backends/networking/sdl_net/handlers/filesajaxpagehandler.cpp +++ b/backends/networking/sdl_net/handlers/filesajaxpagehandler.cpp @@ -33,6 +33,19 @@ FilesAjaxPageHandler::FilesAjaxPageHandler() {} FilesAjaxPageHandler::~FilesAjaxPageHandler() {} +namespace { +Common::String encodeDoubleQuotesAndSlashes(Common::String s) { + Common::String result = ""; + for (uint32 i = 0; i < s.size(); ++i) + if (s[i] == '"') { + result += "\\\""; + } else if (s[i] == '\\') { + result += "\\\\"; + } else result += s[i]; + return result; +} +} + void FilesAjaxPageHandler::handle(Client &client) { // load stylish response page from the archive Common::SeekableReadStream *const stream = HandlerUtils::getArchiveFile(FILES_PAGE_NAME); @@ -55,6 +68,7 @@ void FilesAjaxPageHandler::handle(Client &client) { replace(response, "{index_of}", _("Index of ")); replace(response, "{loading}", _("Loading...")); replace(response, "{error}", _("Error occurred")); + replace(response, "{start_path}", encodeDoubleQuotesAndSlashes(path)); LocalWebserver::setClientGetHandler(client, response); } diff --git a/backends/networking/sdl_net/uploadfileclienthandler.cpp b/backends/networking/sdl_net/uploadfileclienthandler.cpp index 7cbb11874c..7e93573ca5 100644 --- a/backends/networking/sdl_net/uploadfileclienthandler.cpp +++ b/backends/networking/sdl_net/uploadfileclienthandler.cpp @@ -159,9 +159,11 @@ void UploadFileClientHandler::handleBlockContent(Client *client) { _("Uploaded successfully!"), client->queryParameter("path").c_str(), _("Back to parent directory") - ), - "/files?path=" + LocalWebserver::urlEncodeQueryParameterValue(client->queryParameter("path")) - ); + ), + + (client->queryParameter("ajax") == "true" ? "/filesAJAX?path=" : "/files?path=") + + LocalWebserver::urlEncodeQueryParameterValue(client->queryParameter("path")) + ); _state = UFH_STOP; return; } diff --git a/backends/networking/wwwroot.zip b/backends/networking/wwwroot.zip Binary files differindex 7e53969589..6f821d9090 100644 --- a/backends/networking/wwwroot.zip +++ b/backends/networking/wwwroot.zip diff --git a/backends/networking/wwwroot/.filesAJAX.html b/backends/networking/wwwroot/.filesAJAX.html index 16a4b5417d..d648466d2c 100644 --- a/backends/networking/wwwroot/.filesAJAX.html +++ b/backends/networking/wwwroot/.filesAJAX.html @@ -19,13 +19,14 @@ <p>{create_directory_desc}</p> <form action="create" id="create_directory_form"> <input type="hidden" name="path" value="{path}"/> + <input type="hidden" name="ajax" value="true"/> <input type="text" name="directory_name" value=""/> <input type="submit" value="{create_directory_button}"/> </form> </div> <div id="upload_file" class="modal"> <p>{upload_file_desc}</p> - <form action="upload?path={path}" method="post" enctype="multipart/form-data" id="files_upload_form"> + <form action="upload?path={path}&ajax=true" method="post" enctype="multipart/form-data" id="files_upload_form"> <!-- we don't need "[]" in the name, as our webserver is not using PHP --> <!-- "allowdirs" is a proposal, not implemented yet --> <input type="file" name="upload_file-f" allowdirs multiple/> @@ -59,7 +60,7 @@ <script src="ajax.js"></script> <script> window.onload = function () { - showDirectory("/"); + showDirectory("{start_path}"); } function showDirectory(path) { @@ -112,7 +113,7 @@ function openDirectory(path, items) { // update path document.getElementById("create_directory_form").elements["path"].value = path; - document.getElementById("files_upload_form").action = "upload?path=" + path; + document.getElementById("files_upload_form").action = "upload?path=" + path + "&ajax=true"; // update table contents listDirectory(path, items); |