From 4fe2e60c8aaf85eaf9ecd55d71383a055854a63b Mon Sep 17 00:00:00 2001 From: Pratik Borsadiya Date: Thu, 8 Jun 2017 22:13:51 +0530 Subject: [PATCH 1/2] Add support to use Node as webserver --- README.md | 5 ++++- node-server.js | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 node-server.js diff --git a/README.md b/README.md index b432aea..9942055 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,10 @@ aria2c --enable-rpc --rpc-listen-all If aria2 is not installed in your local machine then head on to https://aria2.github.io/ and follow the instructions there. -Then download the webui, you can either do that by downloading this repository and running index.html in the browser. Or you could just head on to https://ziahamza.github.io/webui-aria2/ and just start downloading files! After that you can also save it for offline use by saving from the browser save page as option. +Then download the webui, you can either do that by downloading this repository and running index.html in the browser. Or you could just head on to https://ziahamza.github.io/webui-aria2/ and just start downloading files! After that you can also save it for offline use by saving from the browser save page as option. You can also use node js to create simple server by using the following command from the download folder. +````bash +node node-server.js +```` Tips ==== diff --git a/node-server.js b/node-server.js new file mode 100644 index 0000000..fa8724c --- /dev/null +++ b/node-server.js @@ -0,0 +1,36 @@ +var http = require("http"), + url = require("url"), + path = require("path"), + fs = require("fs") + port = process.argv[2] || 8888; + +http.createServer(function(request, response) { + var uri = url.parse(request.url).pathname, + filename = path.join(process.cwd(), uri); + + fs.exists(filename, function(exists) { + if(!exists) { + response.writeHead(404, {"Content-Type": "text/plain"}); + response.write("404 Not Found\n"); + response.end(); + return; + } + + if (fs.statSync(filename).isDirectory()) filename += '/index.html'; + + fs.readFile(filename, "binary", function(err, file) { + if(err) { + response.writeHead(500, {"Content-Type": "text/plain"}); + response.write(err + "\n"); + response.end(); + return; + } + response.writeHead(200); + response.write(file, "binary"); + response.end(); + }); + + }); +}).listen(parseInt(port, 10)); + +console.log("WebUI Aria2 Server is running on http://localhost:" + port ); From 12ea6710adc39186a60eda8abd2b472a8844c12a Mon Sep 17 00:00:00 2001 From: no1xsyzy Date: Thu, 27 Jul 2017 10:26:13 +0800 Subject: [PATCH 2/2] Fixes #302 --- js/ctrls/modal.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/js/ctrls/modal.js b/js/ctrls/modal.js index 3177c3d..0387038 100644 --- a/js/ctrls/modal.js +++ b/js/ctrls/modal.js @@ -79,7 +79,17 @@ angular parse: function() { return _ .chain(this.uris.trim().split(/\r?\n/g)) - .map(function(d) { return d.trim().split(/\s+/g) }) + .map(function(d) { + return _(d) + .replace(/("[^"]*")/g, function(c) { + return c.replace('%','%25').replace(' ','%20'); + }) + .trim() + .split(/\s+/g) + .map(function(c) { + return c.replace('%20',' ').replace('%25','%').replace(/"/g,''); + }); + }) .filter(function(d) { return d.length }) .value(); }