From 0762dae47cfc0c781069a346c3af55292fc97779 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 16 Apr 2011 13:03:28 -0400 Subject: [PATCH] Add logic to handle remote service requests by serving a separate HTML front-end file --- build.py | 1 + src/server.go | 8 ++++++-- web_frontend/index.html | 1 + web_frontend/main.js | 19 +++++++++++++++++-- web_frontend/service_request.html | 10 ++++++++++ 5 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 web_frontend/service_request.html diff --git a/build.py b/build.py index 18b0346..7c99ec9 100755 --- a/build.py +++ b/build.py @@ -45,6 +45,7 @@ SOURCES_FE = [ ] RESOURCES_FE = [ 'index.html', + 'service_request.html', 'screen.css', 'reset.css' ] diff --git a/src/server.go b/src/server.go index 07674a0..9cefd5f 100644 --- a/src/server.go +++ b/src/server.go @@ -1,6 +1,6 @@ // // Armadillo File Manager -// Copyright (c) 2010, Robert Sesek +// Copyright (c) 2010-2011, Robert Sesek // // This program is free software: you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free Software @@ -27,7 +27,11 @@ var kFrontEndFiles string = path.Join(dir, "fe") var gConfig *config.Configuration = nil func indexHandler(response http.ResponseWriter, request *http.Request) { - fd, err := os.Open(path.Join(kFrontEndFiles, "index.html"), os.O_RDONLY, 0) + var fileName string = "index.html" + if strings.HasPrefix(request.URL.Path, "/_@/") { + fileName = "service_request.html" + } + fd, err := os.Open(path.Join(kFrontEndFiles, fileName), os.O_RDONLY, 0) if err != nil { fmt.Print("Error opening file ", err.String(), "\n") return diff --git a/web_frontend/index.html b/web_frontend/index.html index e733bd0..9253b46 100644 --- a/web_frontend/index.html +++ b/web_frontend/index.html @@ -20,6 +20,7 @@ \ No newline at end of file diff --git a/web_frontend/main.js b/web_frontend/main.js index 1855a1b..de6638d 100644 --- a/web_frontend/main.js +++ b/web_frontend/main.js @@ -1,6 +1,6 @@ // // Armadillo File Manager -// Copyright (c) 2010, Robert Sesek +// Copyright (c) 2010-2011, Robert Sesek // // This program is free software: you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free Software @@ -21,6 +21,12 @@ goog.require('goog.string.format'); goog.require('goog.Uri.QueryData'); armadillo.App = function() { +} + +/** + * Runs the main front end. + */ +armadillo.App.prototype.frontEndMain = function() { var start_path = '/'; if (window.location.hash) { start_path = window.location.hash.substr(1); @@ -35,7 +41,16 @@ armadillo.App = function() { armadillo.Version.MAJOR, armadillo.Version.MINOR, armadillo.Version.BUILD); goog.dom.setTextContent(goog.dom.getElement('footer'), version) -} +}; + +/** + * Performs a remote service request, which is essentially an API call that uses + * the JavaScript frontend rather than the backend. + */ +armadillo.App.prototype.serviceRequestMain = function() { + document.write(window.location); + console.log(window.location); +}; /** * Starts a new XHR service request from the backend. diff --git a/web_frontend/service_request.html b/web_frontend/service_request.html new file mode 100644 index 0000000..6475a4e --- /dev/null +++ b/web_frontend/service_request.html @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file -- 2.43.5