[Scummvm-git-logs] scummvm master -> fa5a5bf865e86f02257f3b1bec84ba74e71319b1

criezy criezy at scummvm.org
Tue Sep 6 01:45:25 CEST 2016


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
fa5a5bf865 CLOUD: Move wwwroot archive to dists and script to devtools


Commit: fa5a5bf865e86f02257f3b1bec84ba74e71319b1
    https://github.com/scummvm/scummvm/commit/fa5a5bf865e86f02257f3b1bec84ba74e71319b1
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2016-09-06T00:43:25+01:00

Commit Message:
CLOUD: Move wwwroot archive to dists and script to devtools

Both the data used to generate the archive and the archive itself
were moved to dists/ instead of being in backends/.

The script was also improved to optionally take a path as a command
line argument to indicate where the wwwroot data are instead of
assuming they are in the working directory.

Finally a 'wwwroot' make target was also added to invoke the python script and generate the archive.
with the expected path to

Changed paths:
  A devtools/make-www-archive.py
  A dists/networking/wwwroot.zip
  A dists/networking/wwwroot/.files.html
  A dists/networking/wwwroot/.filesAJAX.html
  A dists/networking/wwwroot/.index.html
  A dists/networking/wwwroot/ajax.js
  A dists/networking/wwwroot/favicon.ico
  A dists/networking/wwwroot/icons/7z.png
  A dists/networking/wwwroot/icons/dir.png
  A dists/networking/wwwroot/icons/txt.png
  A dists/networking/wwwroot/icons/unk.png
  A dists/networking/wwwroot/icons/up.png
  A dists/networking/wwwroot/icons/zip.png
  A dists/networking/wwwroot/logo.png
  A dists/networking/wwwroot/style.css
  R backends/networking/make_archive.py
  R backends/networking/wwwroot.zip
  R backends/networking/wwwroot/.files.html
  R backends/networking/wwwroot/.filesAJAX.html
  R backends/networking/wwwroot/.index.html
  R backends/networking/wwwroot/ajax.js
  R backends/networking/wwwroot/favicon.ico
  R backends/networking/wwwroot/icons/7z.png
  R backends/networking/wwwroot/icons/dir.png
  R backends/networking/wwwroot/icons/txt.png
  R backends/networking/wwwroot/icons/unk.png
  R backends/networking/wwwroot/icons/up.png
  R backends/networking/wwwroot/icons/zip.png
  R backends/networking/wwwroot/logo.png
  R backends/networking/wwwroot/style.css
    Makefile.common
    devtools/module.mk
    dists/scummvm.rc
    dists/scummvm.rc.in



diff --git a/Makefile.common b/Makefile.common
index cbd87ed..a1f4312 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -247,7 +247,7 @@ DIST_FILES_THEMES:=$(addprefix $(srcdir)/gui/themes/,$(DIST_FILES_THEMES))
 # Networking files
 DIST_FILES_NETWORKING=
 ifdef USE_SDL_NET
-DIST_FILES_NETWORKING:=$(addprefix $(srcdir)/backends/networking/,wwwroot.zip)
+DIST_FILES_NETWORKING:=$(addprefix $(srcdir)/dists/networking/,wwwroot.zip)
 endif
 
 # Engine data files
diff --git a/backends/networking/make_archive.py b/backends/networking/make_archive.py
deleted file mode 100644
index 64d314b..0000000
--- a/backends/networking/make_archive.py
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/usr/bin/env python
-# encoding: utf-8
-import sys
-import re
-import os
-import zipfile
-
-ARCHIVE_FILE_EXTENSIONS = ('.html', '.css', '.js', '.ico', '.png')
-
-def buildArchive(archiveName):
-	if not os.path.isdir(archiveName):
-		print ("Invalid archive name: " + archiveName)
-		return
-
-	zf = zipfile.ZipFile(archiveName + ".zip", 'w')
-
-	print ("Building '" + archiveName + "' archive:")
-	os.chdir(archiveName)
-
-	directories = ['.', './icons']
-	for d in directories:
-		filenames = os.listdir(d)
-		filenames.sort()
-		for filename in filenames:
-			if os.path.isfile(d + '/' + filename) and filename.endswith(ARCHIVE_FILE_EXTENSIONS):
-				zf.write(d + '/' + filename, d + '/' + filename)
-				print ("    Adding file: " + d + '/' + filename)
-
-	os.chdir('../')
-
-	zf.close()
-
-def main():
-	buildArchive("wwwroot")
-
-if __name__ == "__main__":
-	sys.exit(main())
diff --git a/backends/networking/wwwroot.zip b/backends/networking/wwwroot.zip
deleted file mode 100644
index b767d7c..0000000
Binary files a/backends/networking/wwwroot.zip and /dev/null differ
diff --git a/backends/networking/wwwroot/.files.html b/backends/networking/wwwroot/.files.html
deleted file mode 100644
index f05c011..0000000
--- a/backends/networking/wwwroot/.files.html
+++ /dev/null
@@ -1,60 +0,0 @@
-<!doctype html>
-<html>
-	<head>
-		<title>ScummVM</title>
-		<meta charset="utf-8"/>
-		<link rel="stylesheet" type="text/css" href="style.css"/>
-	</head>
-	<body>
-		<div class="container">
-			<div class='header'>
-				<center><img src="logo.png"/></center>
-			</div>
-			<div class="controls">
-				<table class="buttons"><tr>
-					<td><a href="javascript:show('create_directory');">{create_directory_button}</a></td>
-					<td><a href="javascript:show('upload_file');">{upload_files_button}</a></td>
-				</tr></table>
-				<div id="create_directory" class="modal">
-					<p>{create_directory_desc}</p>
-					<form action="create">
-						<input type="hidden" name="path" value="{path}"/>
-						<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">
-						<!-- 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/>
-						<br/><br/>
-						<p>{or_upload_directory_desc}</p>
-						<!-- "directory"/"webkitdirectory" works in Chrome only yet, "multiple" is just in case here -->
-						<input type="file" name="upload_file-d" directory webkitdirectory multiple/>
-						<input type="submit" value="{upload_file_button}"/>
-					</form>
-				</div>
-			</div>
-			<div class="content">
-				<table class="files_list">
-					<td></td><td><b class="directory_name">{index_of_directory}</b></td><td></td>
-					{content}
-				</table>
-			</div>
-		</div>
-		<script>
-			function show(id) {
-				var e = document.getElementById(id);
-				var visible = (e.style.display == "block");
-				if (visible) id = ""; //hide
-
-				e = document.getElementById("create_directory");
-				e.style.display = (e.id == id ? "block" : "none");
-				e = document.getElementById("upload_file");
-				e.style.display = (e.id == id ? "block" : "none");
-			}
-		</script>
-	</body>
-</html>
\ No newline at end of file
diff --git a/backends/networking/wwwroot/.filesAJAX.html b/backends/networking/wwwroot/.filesAJAX.html
deleted file mode 100644
index d45c730..0000000
--- a/backends/networking/wwwroot/.filesAJAX.html
+++ /dev/null
@@ -1,240 +0,0 @@
-<!doctype html>
-<html>
-	<head>
-		<title>ScummVM</title>
-		<meta charset="utf-8"/>
-		<link rel="stylesheet" type="text/css" href="style.css"/>
-	</head>
-	<body>
-		<div class="container">
-			<div class='header'>
-				<center><img src="logo.png"/></center>
-			</div>
-			<div class="controls">
-				<table class="buttons"><tr>
-					<td><a href="javascript:show('create_directory');">{create_directory_button}</a></td>
-					<td><a href="javascript:show('upload_file');">{upload_files_button}</a></td>
-				</tr></table>
-				<div id="create_directory" class="modal">
-					<p>{create_directory_desc}</p>
-					<form action="create" id="create_directory_form" onsubmit="return createDirectory();">
-						<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}&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/>
-						<br/><br/>
-						<p>{or_upload_directory_desc}</p>
-						<!-- "directory"/"webkitdirectory" works in Chrome only yet, "multiple" is just in case here -->
-						<input type="file" name="upload_file-d" directory webkitdirectory multiple/>
-						<input type="submit" value="{upload_file_button}"/>
-					</form>
-				</div>
-			</div>
-			<div class="content">
-				<div id="loading_message">{loading}</div>
-				<div id="error_message">{error}</div>
-				<table class="files_list" id="files_list">
-				</table>
-			</div>
-		</div>
-		<script>
-			function show(id) {
-				var e = document.getElementById(id);
-				var visible = (e.style.display == "block");
-				if (visible) id = ""; //hide
-
-				e = document.getElementById("create_directory");
-				e.style.display = (e.id == id ? "block" : "none");
-				e = document.getElementById("upload_file");
-				e.style.display = (e.id == id ? "block" : "none");
-			}
-		</script>
-		<script src="ajax.js"></script>
-		<script>
-			window.onload = function () {
-				showDirectory("{start_path}");
-			}
-
-			function showDirectory(path) {
-				if (isLoading) return;
-				showLoading();
-				ajax.getAndParseJson("./list", {"path": path}, getCallback(path));
-			}
-
-			function getCallback(path) {
-				return function (jsonResponse) {
-					if (jsonResponse.type == "error") {
-						showError();
-						return;
-					}
-
-					openDirectory(path, jsonResponse.items);
-					hideLoading();
-				};
-			}
-
-			function createDirectory() {
-				if (isLoading) return;
-				showLoading();
-
-				var data = {"answer_json": "true"};
-				var elements = document.getElementById("create_directory_form").elements;
-				for (var el in elements)
-					data[elements[el].name] = elements[el].value;
-
-				ajax.getAndParseJson("./create", data, getCreateDirectoryCallback(data["path"]));
-				show("create_directory");
-				return false; // invalidate form, so it won't submit
-			}
-
-			function getCreateDirectoryCallback(path) {
-				return function (jsonResponse) {
-					console.log(jsonResponse);
-
-					if (jsonResponse.type == "error") {
-						showError();
-						return;
-					}
-
-					hideLoading();
-					showDirectory(path);
-				};
-			}
-
-			var isLoading = false;
-
-			function showLoading() {
-				isLoading = true;
-				var e = document.getElementById("loading_message");
-				e.style.display = "block";
-				e = document.getElementById("error_message");
-				e.style.display = "none";
-			}
-
-			function showError() {
-				isLoading = false;
-				var e = document.getElementById("loading_message");
-				e.style.display = "none";
-				e = document.getElementById("error_message");
-				e.style.display = "block";
-				//TODO: pass the actual message there?
-			}
-
-			function hideLoading() {
-				isLoading = false;
-				var e = document.getElementById("loading_message");
-				e.style.display = "none";
-				e = document.getElementById("error_message");
-				e.style.display = "none";
-			}
-
-			function openDirectory(path, items) {
-				// update path
-				document.getElementById("create_directory_form").elements["path"].value = path;
-				document.getElementById("files_upload_form").action = "upload?path=" + path + "&ajax=true";
-
-				// update table contents
-				listDirectory(path, items);
-			}
-
-			function makeBreadcrumb(name, path) {
-				var a = createElementWithContents("a", name);
-				a.onclick = function () { showDirectory(path); };
-				a.href = "javascript:void(0);";
-				return a;
-			}
-
-			function makeBreadcrumbs(path) {
-				var b = document.createElement("b");
-				b.className = "directory_name";
-
-				b.appendChild(createElementWithContents("span", "{index_of}"));
-				var slashes = true;
-				var crumb = "";
-				var currentPath = "";
-				path += ' '; //so the last slash is added
-				for (var i=0; i<path.length; ++i) {
-					if (path[i] == '/' || path[i] == '\\') {
-						if (!slashes) {
-							currentPath += crumb;
-							b.appendChild(makeBreadcrumb(crumb, currentPath+'/'));
-							slashes = true;
-						}
-					} else {
-						if (slashes) {
-							currentPath += "/";
-							if (currentPath == "/") { //make special '/' crumb here
-								b.appendChild(makeBreadcrumb('/', '/'));
-							} else {
-								b.appendChild(createElementWithContents("span", "/"));
-							}
-							slashes = false;
-							crumb = "";
-						}
-						crumb += path[i];
-					}
-				}
-				return b;
-			}
-
-			function listDirectory(path, items) {
-				// cleanup the list
-				var files_list = document.getElementById("files_list");
-				while (files_list.hasChildNodes())
-					files_list.removeChild(files_list.firstChild);
-				var tbody = document.createElement("tbody");
-
-				// add header item
-				var tr = document.createElement("tr");
-				tr.appendChild(createElementWithContents("td", ""));
-				var td = document.createElement("td");
-				td.appendChild(makeBreadcrumbs(path));
-				tr.appendChild(td);
-				tr.appendChild(createElementWithContents("td", ""));
-				tbody.appendChild(tr);
-
-				// add items
-				for (var i in items)
-					addItem(tbody, items[i]);
-
-				files_list.appendChild(tbody);
-			}
-
-			function addItem(tbody, item) {
-				var tr = document.createElement("tr");
-				var td = document.createElement("td");
-				var img = document.createElement("img");
-				img.src = "./icons/" + item.icon;
-				td.appendChild(img);
-				tr.appendChild(td);
-
-				td = document.createElement("td");
-				var a = createElementWithContents("a", item.name);
-				if (item.isDirectory) {
-					a.onclick = function () { showDirectory(item.path); };
-					a.href = "javascript:void(0);";
-				} else
-					a.href = "./download?path=" + encodeURIComponent(item.path);
-				td.appendChild(a);
-				tr.appendChild(td);
-
-				tr.appendChild(createElementWithContents("td", ""));
-				tbody.appendChild(tr);
-			}
-
-			function createElementWithContents(type, innerHTML) {
-				var e = document.createElement(type);
-				e.innerHTML = innerHTML;
-				return e;
-			}
-		</script>
-	</body>
-</html>
\ No newline at end of file
diff --git a/backends/networking/wwwroot/.index.html b/backends/networking/wwwroot/.index.html
deleted file mode 100644
index 2a3d9d3..0000000
--- a/backends/networking/wwwroot/.index.html
+++ /dev/null
@@ -1,18 +0,0 @@
-<!doctype html>
-<html>
-	<head>
-		<title>ScummVM</title>
-		<meta charset="utf-8"/>
-		<link rel="stylesheet" type="text/css" href="style.css"/>
-	</head>
-	<body>
-		<div class="container">
-			<div class='header'>
-				<center><img src="logo.png"/></center>
-			</div>
-			<div class="content">
-				<p>{message}</p>
-			</div>
-		</div>
-	</body>
-</html>
\ No newline at end of file
diff --git a/backends/networking/wwwroot/ajax.js b/backends/networking/wwwroot/ajax.js
deleted file mode 100644
index c01d7e9..0000000
--- a/backends/networking/wwwroot/ajax.js
+++ /dev/null
@@ -1,48 +0,0 @@
-// the following is snippet from http://stackoverflow.com/a/18078705
-// I changed a few things though
-
-var ajax = {};
-ajax.x = function () { return new XMLHttpRequest(); }; // "no one uses IE6"
-
-ajax.send = function (url, callback, errorCallback, method, data, async) {
-    if (async === undefined) async = true;
-
-    var x = ajax.x();
-    x.open(method, url, async);
-    x.onreadystatechange = function () {
-        if (x.readyState == XMLHttpRequest.DONE) {
-            if (x.status == 200)
-                callback(x.responseText);
-            else
-                errorCallback(x);
-        }
-    };
-    if (method == 'POST') {
-        x.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
-    }
-    x.send(data)
-};
-
-ajax.get = function (url, data, callback, errorCallback, async) {
-    var query = [];
-    for (var key in data) {
-        query.push(encodeURIComponent(key) + '=' + encodeURIComponent(data[key]));
-    }
-    ajax.send(url + (query.length ? '?' + query.join('&') : ''), callback, errorCallback, 'GET', null, async)
-};
-
-ajax.post = function (url, data, callback, errorCallback, async) {
-    var query = [];
-    for (var key in data) {
-        query.push(encodeURIComponent(key) + '=' + encodeURIComponent(data[key]));
-    }
-    ajax.send(url, callback, errorCallback, 'POST', query.join('&'), async)
-};
-
-ajax.getAndParseJson = function (url, data, callback) {
-    ajax.get(
-        url, data,
-        function (responseText) { callback(JSON.parse(responseText)); },
-        function (x) { console.log("error: " + x.status); }
-    );
-};
\ No newline at end of file
diff --git a/backends/networking/wwwroot/favicon.ico b/backends/networking/wwwroot/favicon.ico
deleted file mode 100644
index 0283e84..0000000
Binary files a/backends/networking/wwwroot/favicon.ico and /dev/null differ
diff --git a/backends/networking/wwwroot/icons/7z.png b/backends/networking/wwwroot/icons/7z.png
deleted file mode 100644
index 656e7e7..0000000
Binary files a/backends/networking/wwwroot/icons/7z.png and /dev/null differ
diff --git a/backends/networking/wwwroot/icons/dir.png b/backends/networking/wwwroot/icons/dir.png
deleted file mode 100644
index bcdec04..0000000
Binary files a/backends/networking/wwwroot/icons/dir.png and /dev/null differ
diff --git a/backends/networking/wwwroot/icons/txt.png b/backends/networking/wwwroot/icons/txt.png
deleted file mode 100644
index 023d2ee..0000000
Binary files a/backends/networking/wwwroot/icons/txt.png and /dev/null differ
diff --git a/backends/networking/wwwroot/icons/unk.png b/backends/networking/wwwroot/icons/unk.png
deleted file mode 100644
index 346eebe..0000000
Binary files a/backends/networking/wwwroot/icons/unk.png and /dev/null differ
diff --git a/backends/networking/wwwroot/icons/up.png b/backends/networking/wwwroot/icons/up.png
deleted file mode 100644
index 2dc3df0..0000000
Binary files a/backends/networking/wwwroot/icons/up.png and /dev/null differ
diff --git a/backends/networking/wwwroot/icons/zip.png b/backends/networking/wwwroot/icons/zip.png
deleted file mode 100644
index cdfc576..0000000
Binary files a/backends/networking/wwwroot/icons/zip.png and /dev/null differ
diff --git a/backends/networking/wwwroot/logo.png b/backends/networking/wwwroot/logo.png
deleted file mode 100644
index 9fdd2d0..0000000
Binary files a/backends/networking/wwwroot/logo.png and /dev/null differ
diff --git a/backends/networking/wwwroot/style.css b/backends/networking/wwwroot/style.css
deleted file mode 100644
index ba31587..0000000
--- a/backends/networking/wwwroot/style.css
+++ /dev/null
@@ -1,113 +0,0 @@
-html {
-	background: rgb(212, 117, 11);
-	background: linear-gradient(to bottom, rgb(212, 117, 11) 0%, rgb(212, 117, 11) 36%, rgb(239, 196, 24) 100%);
-	min-height: 100vh;
-}
-
-.container {
-	width: 80%;
-	margin: 0 auto;
-}
-
-.header {
-	padding: 10pt;
-	margin-bottom: 0;
-}
-
-.content {
-	padding: 8pt;
-	background: rgb(251, 241, 206);
-	font-family: Tahoma;
-	font-size: 16pt;
-}
-
-.content p { margin: 0 0 6pt 0; }
-
-.controls {
-	padding: 8pt;
-	background: #FFF;
-	font-family: Tahoma;
-	font-size: 16pt;
-}
-
-.controls .buttons {
-	width: 100%;
-	max-width: 500pt;
-	margin: -8pt auto;
-	border: 0;
-	border-spacing: 0;
-}
-
-.controls .buttons td {
-	width: 50%;
-	text-align: center;
-	margin: 0;
-	padding: 0;
-}
-
-.controls .buttons a {
-	display: block;
-	height: 40pt;
-	line-height: 38pt;
-	vertical-align: middle;
-	color: #000;
-	text-decoration: none;
-}
-
-.controls .buttons a:hover {
-	background: #F3F3F3;
-}
-
-.modal {
-	margin-top: 10pt;
-	display: none;
-}
-
-.modal p { margin: 0 0 6pt 0; }
-
-#create_directory input[type="text"], #upload_file input[type="file"] {
-	width: calc(100% - 2 * 5pt);
-}
-
-.modal input {
-	border: 1px solid #EEE;
-	padding: 5pt;
-	font-size: 12pt;
-}
-
-.modal input[type="submit"] {
-	display: block;
-	margin: 6pt auto;
-	background: #DDD;
-	border: 0;
-}
-
-.modal input[type="submit"]:hover {
-	background: #F3F3F3;
-	cursor: pointer;
-}
-
-td img { vertical-align: middle; height: 20px; }
-
-.directory_name {
-	display: block;
-	padding-bottom: 6px;
-}
-
-.directory_name a { color: black; }
-.directory_name a:hover { color: blue; }
-
-#loading_message, #error_message {
-	margin: -8pt;
-	margin-bottom: 5pt;
-	padding: 4pt;
-	text-align: center;
-}
-
-#loading_message {
-	background: #99FF99;
-}
-
-#error_message {
-	background: #FF9999;
-}
diff --git a/devtools/make-www-archive.py b/devtools/make-www-archive.py
new file mode 100755
index 0000000..95aeb15
--- /dev/null
+++ b/devtools/make-www-archive.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+# encoding: utf-8
+import sys
+import re
+import os
+import zipfile
+import argparse
+
+ARCHIVE_FILE_EXTENSIONS = ('.html', '.css', '.js', '.ico', '.png')
+
+def buildArchive(archiveName):
+	if not os.path.isdir(archiveName):
+		print ("Invalid archive name: " + archiveName)
+		return
+
+	zf = zipfile.ZipFile(archiveName + ".zip", 'w')
+
+	print ("Building '" + archiveName + "' archive:")
+	os.chdir(archiveName)
+
+	directories = ['.', './icons']
+	for d in directories:
+		filenames = os.listdir(d)
+		filenames.sort()
+		for filename in filenames:
+			if os.path.isfile(d + '/' + filename) and filename.endswith(ARCHIVE_FILE_EXTENSIONS):
+				zf.write(d + '/' + filename, d + '/' + filename)
+				print ("    Adding file: " + d + '/' + filename)
+
+	os.chdir('../')
+
+	zf.close()
+
+def main():
+	parser = argparse.ArgumentParser(description='Generates wwwroot archive')
+	parser.add_argument('path', nargs='?', help='path where the wwwroot source data can be found')
+	args = parser.parse_args()
+	if args.path != None:
+		if not os.path.isdir(args.path):
+			print ("Directory '" + args.path + "' does not exist!")
+			return
+		else:	
+			os.chdir(args.path)
+	
+	buildArchive("wwwroot")
+
+if __name__ == "__main__":
+	sys.exit(main())
diff --git a/devtools/module.mk b/devtools/module.mk
index 1d682cd..0f2d191 100644
--- a/devtools/module.mk
+++ b/devtools/module.mk
@@ -44,6 +44,11 @@ devtools/make-scumm-fontdata$(EXEEXT): $(srcdir)/devtools/make-scumm-fontdata.c
 	$(QUIET)$(MKDIR) devtools/$(DEPDIR)
 	$(QUIET_LINK)$(LD) $(CFLAGS) -Wall -o $@ $<
 
+# Rule to explicitly rebuild the wwwroot archive
+wwwroot:
+	$(srcdir)/devtools/make-www-archive.py $(srcdir)/dists/networking/
+	
+
 #
 # Rules to explicitly rebuild the credits / MD5 tables.
 # The rules for the files in the "web" resp. "docs" modules
diff --git a/dists/networking/wwwroot.zip b/dists/networking/wwwroot.zip
new file mode 100644
index 0000000..b767d7c
Binary files /dev/null and b/dists/networking/wwwroot.zip differ
diff --git a/dists/networking/wwwroot/.files.html b/dists/networking/wwwroot/.files.html
new file mode 100644
index 0000000..f05c011
--- /dev/null
+++ b/dists/networking/wwwroot/.files.html
@@ -0,0 +1,60 @@
+<!doctype html>
+<html>
+	<head>
+		<title>ScummVM</title>
+		<meta charset="utf-8"/>
+		<link rel="stylesheet" type="text/css" href="style.css"/>
+	</head>
+	<body>
+		<div class="container">
+			<div class='header'>
+				<center><img src="logo.png"/></center>
+			</div>
+			<div class="controls">
+				<table class="buttons"><tr>
+					<td><a href="javascript:show('create_directory');">{create_directory_button}</a></td>
+					<td><a href="javascript:show('upload_file');">{upload_files_button}</a></td>
+				</tr></table>
+				<div id="create_directory" class="modal">
+					<p>{create_directory_desc}</p>
+					<form action="create">
+						<input type="hidden" name="path" value="{path}"/>
+						<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">
+						<!-- 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/>
+						<br/><br/>
+						<p>{or_upload_directory_desc}</p>
+						<!-- "directory"/"webkitdirectory" works in Chrome only yet, "multiple" is just in case here -->
+						<input type="file" name="upload_file-d" directory webkitdirectory multiple/>
+						<input type="submit" value="{upload_file_button}"/>
+					</form>
+				</div>
+			</div>
+			<div class="content">
+				<table class="files_list">
+					<td></td><td><b class="directory_name">{index_of_directory}</b></td><td></td>
+					{content}
+				</table>
+			</div>
+		</div>
+		<script>
+			function show(id) {
+				var e = document.getElementById(id);
+				var visible = (e.style.display == "block");
+				if (visible) id = ""; //hide
+
+				e = document.getElementById("create_directory");
+				e.style.display = (e.id == id ? "block" : "none");
+				e = document.getElementById("upload_file");
+				e.style.display = (e.id == id ? "block" : "none");
+			}
+		</script>
+	</body>
+</html>
\ No newline at end of file
diff --git a/dists/networking/wwwroot/.filesAJAX.html b/dists/networking/wwwroot/.filesAJAX.html
new file mode 100644
index 0000000..d45c730
--- /dev/null
+++ b/dists/networking/wwwroot/.filesAJAX.html
@@ -0,0 +1,240 @@
+<!doctype html>
+<html>
+	<head>
+		<title>ScummVM</title>
+		<meta charset="utf-8"/>
+		<link rel="stylesheet" type="text/css" href="style.css"/>
+	</head>
+	<body>
+		<div class="container">
+			<div class='header'>
+				<center><img src="logo.png"/></center>
+			</div>
+			<div class="controls">
+				<table class="buttons"><tr>
+					<td><a href="javascript:show('create_directory');">{create_directory_button}</a></td>
+					<td><a href="javascript:show('upload_file');">{upload_files_button}</a></td>
+				</tr></table>
+				<div id="create_directory" class="modal">
+					<p>{create_directory_desc}</p>
+					<form action="create" id="create_directory_form" onsubmit="return createDirectory();">
+						<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}&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/>
+						<br/><br/>
+						<p>{or_upload_directory_desc}</p>
+						<!-- "directory"/"webkitdirectory" works in Chrome only yet, "multiple" is just in case here -->
+						<input type="file" name="upload_file-d" directory webkitdirectory multiple/>
+						<input type="submit" value="{upload_file_button}"/>
+					</form>
+				</div>
+			</div>
+			<div class="content">
+				<div id="loading_message">{loading}</div>
+				<div id="error_message">{error}</div>
+				<table class="files_list" id="files_list">
+				</table>
+			</div>
+		</div>
+		<script>
+			function show(id) {
+				var e = document.getElementById(id);
+				var visible = (e.style.display == "block");
+				if (visible) id = ""; //hide
+
+				e = document.getElementById("create_directory");
+				e.style.display = (e.id == id ? "block" : "none");
+				e = document.getElementById("upload_file");
+				e.style.display = (e.id == id ? "block" : "none");
+			}
+		</script>
+		<script src="ajax.js"></script>
+		<script>
+			window.onload = function () {
+				showDirectory("{start_path}");
+			}
+
+			function showDirectory(path) {
+				if (isLoading) return;
+				showLoading();
+				ajax.getAndParseJson("./list", {"path": path}, getCallback(path));
+			}
+
+			function getCallback(path) {
+				return function (jsonResponse) {
+					if (jsonResponse.type == "error") {
+						showError();
+						return;
+					}
+
+					openDirectory(path, jsonResponse.items);
+					hideLoading();
+				};
+			}
+
+			function createDirectory() {
+				if (isLoading) return;
+				showLoading();
+
+				var data = {"answer_json": "true"};
+				var elements = document.getElementById("create_directory_form").elements;
+				for (var el in elements)
+					data[elements[el].name] = elements[el].value;
+
+				ajax.getAndParseJson("./create", data, getCreateDirectoryCallback(data["path"]));
+				show("create_directory");
+				return false; // invalidate form, so it won't submit
+			}
+
+			function getCreateDirectoryCallback(path) {
+				return function (jsonResponse) {
+					console.log(jsonResponse);
+
+					if (jsonResponse.type == "error") {
+						showError();
+						return;
+					}
+
+					hideLoading();
+					showDirectory(path);
+				};
+			}
+
+			var isLoading = false;
+
+			function showLoading() {
+				isLoading = true;
+				var e = document.getElementById("loading_message");
+				e.style.display = "block";
+				e = document.getElementById("error_message");
+				e.style.display = "none";
+			}
+
+			function showError() {
+				isLoading = false;
+				var e = document.getElementById("loading_message");
+				e.style.display = "none";
+				e = document.getElementById("error_message");
+				e.style.display = "block";
+				//TODO: pass the actual message there?
+			}
+
+			function hideLoading() {
+				isLoading = false;
+				var e = document.getElementById("loading_message");
+				e.style.display = "none";
+				e = document.getElementById("error_message");
+				e.style.display = "none";
+			}
+
+			function openDirectory(path, items) {
+				// update path
+				document.getElementById("create_directory_form").elements["path"].value = path;
+				document.getElementById("files_upload_form").action = "upload?path=" + path + "&ajax=true";
+
+				// update table contents
+				listDirectory(path, items);
+			}
+
+			function makeBreadcrumb(name, path) {
+				var a = createElementWithContents("a", name);
+				a.onclick = function () { showDirectory(path); };
+				a.href = "javascript:void(0);";
+				return a;
+			}
+
+			function makeBreadcrumbs(path) {
+				var b = document.createElement("b");
+				b.className = "directory_name";
+
+				b.appendChild(createElementWithContents("span", "{index_of}"));
+				var slashes = true;
+				var crumb = "";
+				var currentPath = "";
+				path += ' '; //so the last slash is added
+				for (var i=0; i<path.length; ++i) {
+					if (path[i] == '/' || path[i] == '\\') {
+						if (!slashes) {
+							currentPath += crumb;
+							b.appendChild(makeBreadcrumb(crumb, currentPath+'/'));
+							slashes = true;
+						}
+					} else {
+						if (slashes) {
+							currentPath += "/";
+							if (currentPath == "/") { //make special '/' crumb here
+								b.appendChild(makeBreadcrumb('/', '/'));
+							} else {
+								b.appendChild(createElementWithContents("span", "/"));
+							}
+							slashes = false;
+							crumb = "";
+						}
+						crumb += path[i];
+					}
+				}
+				return b;
+			}
+
+			function listDirectory(path, items) {
+				// cleanup the list
+				var files_list = document.getElementById("files_list");
+				while (files_list.hasChildNodes())
+					files_list.removeChild(files_list.firstChild);
+				var tbody = document.createElement("tbody");
+
+				// add header item
+				var tr = document.createElement("tr");
+				tr.appendChild(createElementWithContents("td", ""));
+				var td = document.createElement("td");
+				td.appendChild(makeBreadcrumbs(path));
+				tr.appendChild(td);
+				tr.appendChild(createElementWithContents("td", ""));
+				tbody.appendChild(tr);
+
+				// add items
+				for (var i in items)
+					addItem(tbody, items[i]);
+
+				files_list.appendChild(tbody);
+			}
+
+			function addItem(tbody, item) {
+				var tr = document.createElement("tr");
+				var td = document.createElement("td");
+				var img = document.createElement("img");
+				img.src = "./icons/" + item.icon;
+				td.appendChild(img);
+				tr.appendChild(td);
+
+				td = document.createElement("td");
+				var a = createElementWithContents("a", item.name);
+				if (item.isDirectory) {
+					a.onclick = function () { showDirectory(item.path); };
+					a.href = "javascript:void(0);";
+				} else
+					a.href = "./download?path=" + encodeURIComponent(item.path);
+				td.appendChild(a);
+				tr.appendChild(td);
+
+				tr.appendChild(createElementWithContents("td", ""));
+				tbody.appendChild(tr);
+			}
+
+			function createElementWithContents(type, innerHTML) {
+				var e = document.createElement(type);
+				e.innerHTML = innerHTML;
+				return e;
+			}
+		</script>
+	</body>
+</html>
\ No newline at end of file
diff --git a/dists/networking/wwwroot/.index.html b/dists/networking/wwwroot/.index.html
new file mode 100644
index 0000000..2a3d9d3
--- /dev/null
+++ b/dists/networking/wwwroot/.index.html
@@ -0,0 +1,18 @@
+<!doctype html>
+<html>
+	<head>
+		<title>ScummVM</title>
+		<meta charset="utf-8"/>
+		<link rel="stylesheet" type="text/css" href="style.css"/>
+	</head>
+	<body>
+		<div class="container">
+			<div class='header'>
+				<center><img src="logo.png"/></center>
+			</div>
+			<div class="content">
+				<p>{message}</p>
+			</div>
+		</div>
+	</body>
+</html>
\ No newline at end of file
diff --git a/dists/networking/wwwroot/ajax.js b/dists/networking/wwwroot/ajax.js
new file mode 100644
index 0000000..c01d7e9
--- /dev/null
+++ b/dists/networking/wwwroot/ajax.js
@@ -0,0 +1,48 @@
+// the following is snippet from http://stackoverflow.com/a/18078705
+// I changed a few things though
+
+var ajax = {};
+ajax.x = function () { return new XMLHttpRequest(); }; // "no one uses IE6"
+
+ajax.send = function (url, callback, errorCallback, method, data, async) {
+    if (async === undefined) async = true;
+
+    var x = ajax.x();
+    x.open(method, url, async);
+    x.onreadystatechange = function () {
+        if (x.readyState == XMLHttpRequest.DONE) {
+            if (x.status == 200)
+                callback(x.responseText);
+            else
+                errorCallback(x);
+        }
+    };
+    if (method == 'POST') {
+        x.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
+    }
+    x.send(data)
+};
+
+ajax.get = function (url, data, callback, errorCallback, async) {
+    var query = [];
+    for (var key in data) {
+        query.push(encodeURIComponent(key) + '=' + encodeURIComponent(data[key]));
+    }
+    ajax.send(url + (query.length ? '?' + query.join('&') : ''), callback, errorCallback, 'GET', null, async)
+};
+
+ajax.post = function (url, data, callback, errorCallback, async) {
+    var query = [];
+    for (var key in data) {
+        query.push(encodeURIComponent(key) + '=' + encodeURIComponent(data[key]));
+    }
+    ajax.send(url, callback, errorCallback, 'POST', query.join('&'), async)
+};
+
+ajax.getAndParseJson = function (url, data, callback) {
+    ajax.get(
+        url, data,
+        function (responseText) { callback(JSON.parse(responseText)); },
+        function (x) { console.log("error: " + x.status); }
+    );
+};
\ No newline at end of file
diff --git a/dists/networking/wwwroot/favicon.ico b/dists/networking/wwwroot/favicon.ico
new file mode 100644
index 0000000..0283e84
Binary files /dev/null and b/dists/networking/wwwroot/favicon.ico differ
diff --git a/dists/networking/wwwroot/icons/7z.png b/dists/networking/wwwroot/icons/7z.png
new file mode 100644
index 0000000..656e7e7
Binary files /dev/null and b/dists/networking/wwwroot/icons/7z.png differ
diff --git a/dists/networking/wwwroot/icons/dir.png b/dists/networking/wwwroot/icons/dir.png
new file mode 100644
index 0000000..bcdec04
Binary files /dev/null and b/dists/networking/wwwroot/icons/dir.png differ
diff --git a/dists/networking/wwwroot/icons/txt.png b/dists/networking/wwwroot/icons/txt.png
new file mode 100644
index 0000000..023d2ee
Binary files /dev/null and b/dists/networking/wwwroot/icons/txt.png differ
diff --git a/dists/networking/wwwroot/icons/unk.png b/dists/networking/wwwroot/icons/unk.png
new file mode 100644
index 0000000..346eebe
Binary files /dev/null and b/dists/networking/wwwroot/icons/unk.png differ
diff --git a/dists/networking/wwwroot/icons/up.png b/dists/networking/wwwroot/icons/up.png
new file mode 100644
index 0000000..2dc3df0
Binary files /dev/null and b/dists/networking/wwwroot/icons/up.png differ
diff --git a/dists/networking/wwwroot/icons/zip.png b/dists/networking/wwwroot/icons/zip.png
new file mode 100644
index 0000000..cdfc576
Binary files /dev/null and b/dists/networking/wwwroot/icons/zip.png differ
diff --git a/dists/networking/wwwroot/logo.png b/dists/networking/wwwroot/logo.png
new file mode 100644
index 0000000..9fdd2d0
Binary files /dev/null and b/dists/networking/wwwroot/logo.png differ
diff --git a/dists/networking/wwwroot/style.css b/dists/networking/wwwroot/style.css
new file mode 100644
index 0000000..ba31587
--- /dev/null
+++ b/dists/networking/wwwroot/style.css
@@ -0,0 +1,113 @@
+html {
+	background: rgb(212, 117, 11);
+	background: linear-gradient(to bottom, rgb(212, 117, 11) 0%, rgb(212, 117, 11) 36%, rgb(239, 196, 24) 100%);
+	min-height: 100vh;
+}
+
+.container {
+	width: 80%;
+	margin: 0 auto;
+}
+
+.header {
+	padding: 10pt;
+	margin-bottom: 0;
+}
+
+.content {
+	padding: 8pt;
+	background: rgb(251, 241, 206);
+	font-family: Tahoma;
+	font-size: 16pt;
+}
+
+.content p { margin: 0 0 6pt 0; }
+
+.controls {
+	padding: 8pt;
+	background: #FFF;
+	font-family: Tahoma;
+	font-size: 16pt;
+}
+
+.controls .buttons {
+	width: 100%;
+	max-width: 500pt;
+	margin: -8pt auto;
+	border: 0;
+	border-spacing: 0;
+}
+
+.controls .buttons td {
+	width: 50%;
+	text-align: center;
+	margin: 0;
+	padding: 0;
+}
+
+.controls .buttons a {
+	display: block;
+	height: 40pt;
+	line-height: 38pt;
+	vertical-align: middle;
+	color: #000;
+	text-decoration: none;
+}
+
+.controls .buttons a:hover {
+	background: #F3F3F3;
+}
+
+.modal {
+	margin-top: 10pt;
+	display: none;
+}
+
+.modal p { margin: 0 0 6pt 0; }
+
+#create_directory input[type="text"], #upload_file input[type="file"] {
+	width: calc(100% - 2 * 5pt);
+}
+
+.modal input {
+	border: 1px solid #EEE;
+	padding: 5pt;
+	font-size: 12pt;
+}
+
+.modal input[type="submit"] {
+	display: block;
+	margin: 6pt auto;
+	background: #DDD;
+	border: 0;
+}
+
+.modal input[type="submit"]:hover {
+	background: #F3F3F3;
+	cursor: pointer;
+}
+
+td img { vertical-align: middle; height: 20px; }
+
+.directory_name {
+	display: block;
+	padding-bottom: 6px;
+}
+
+.directory_name a { color: black; }
+.directory_name a:hover { color: blue; }
+
+#loading_message, #error_message {
+	margin: -8pt;
+	margin-bottom: 5pt;
+	padding: 4pt;
+	text-align: center;
+}
+
+#loading_message {
+	background: #99FF99;
+}
+
+#error_message {
+	background: #FF9999;
+}
diff --git a/dists/scummvm.rc b/dists/scummvm.rc
index d52d97d..023e7a0 100644
--- a/dists/scummvm.rc
+++ b/dists/scummvm.rc
@@ -20,7 +20,7 @@ scummmodern.zip        FILE    "gui/themes/scummmodern.zip"
 translations.dat       FILE    "gui/themes/translations.dat"
 #endif
 #ifdef USE_SDL_NET
-wwwroot.zip            FILE    "backends/networking/wwwroot.zip"
+wwwroot.zip            FILE    "dists/networking/wwwroot.zip"
 #endif
 
 #if ENABLE_ACCESS   == STATIC_PLUGIN
diff --git a/dists/scummvm.rc.in b/dists/scummvm.rc.in
index 60fa44b..3d7375b 100644
--- a/dists/scummvm.rc.in
+++ b/dists/scummvm.rc.in
@@ -20,7 +20,7 @@ scummmodern.zip        FILE    "gui/themes/scummmodern.zip"
 translations.dat       FILE    "gui/themes/translations.dat"
 #endif
 #ifdef USE_SDL_NET
-wwwroot.zip            FILE    "backends/networking/wwwroot.zip"
+wwwroot.zip            FILE    "dists/networking/wwwroot.zip"
 #endif
 
 #if ENABLE_ACCESS   == STATIC_PLUGIN





More information about the Scummvm-git-logs mailing list