diff --git a/README.md b/README.md index ac6fa9c..eca05f7 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Server side: # How to run -1. Download repository to local website folder. It should be placed into root of domen. It can work wrong from subdirectory. +1. Download repository to local website folder. It should be placed into root of domen. If you want to run graphonline from subdirectory read "Additional steps to run from subdirectory" below. 2. Change access rights of directory /tmp. PHP scripts need to create and modify files inside it. 3. Run file from browser: /script/merge.php. It merges all js files into one /script/example.js. 4. Run file from browser: /cgi-bin/getPluginsList.php?reset. It creates file with list of plug-ins. Just optimization. @@ -46,6 +46,24 @@ In files: 8. Some algorithms use binary CGI file (short-path, Eulerian cycle/path and so on). If you want to run them, you need to compile GraphOffline util: https://github.com/UnickSoft/GraphOffline. And place it with name /cgi-bin/GraphCGI.exe +# Additional steps to run from subdirectory: + +For example you place graphonline sources into http://localhost/graph/ directory. + +1. Edit .htaccess change RewriteRule to line: +``` +RewriteRule ^(.*)$ /graph/index.php?q=$1 [L,QSA] +``` +2. Write your directory name to script\main.j variable SiteDirs: +``` +var SiteDir = "graph/"; +``` +3. Write your directory to core config core\config\main.php in line SITE_IN_DIR: +``` +define('SITE_IN_DIR', 'graph'); +``` +4. Run merge.php to apply changes. Run http://localhost/graph/script/merge.php + # 3th-party 1. Micron (http://zmicron.itkd.ru/) is our engine. diff --git a/script/Algorithms.js b/script/Algorithms.js index db8ab35..c5df7fb 100644 --- a/script/Algorithms.js +++ b/script/Algorithms.js @@ -163,7 +163,7 @@ BaseAlgorithmEx.prototype.CalculateAlgorithm = function(queryString, resultCallb $.ajax({ type: "POST", - url: "/cgi-bin/GraphCGI.exe?" + queryString, + url: "/" + SiteDir + "cgi-bin/GraphCGI.exe?" + queryString, data: xml, dataType: "text", }) diff --git a/script/Appilcation.js b/script/Appilcation.js index 26a7cd3..964570c 100644 --- a/script/Appilcation.js +++ b/script/Appilcation.js @@ -497,7 +497,7 @@ Application.prototype.FindPath = function(graph1, graph2) $.ajax({ type: "POST", - url: "/cgi-bin/GraphCGI.exe?dsp=cgiInput&start=" + graph1.id + "&finish=" + graph2.id + "&report=xml", + url: "/" + SiteDir + "cgi-bin/GraphCGI.exe?dsp=cgiInput&start=" + graph1.id + "&finish=" + graph2.id + "&report=xml", data: creator.GetXMLString(), dataType: "text" }) @@ -778,7 +778,7 @@ Application.prototype.SetAdjacencyMatrix = function (matrix, separator) var c = {}; if (!this.TestAdjacencyMatrix(matrix, r, c, separator)) { - $.get( "/cgi-bin/addFailedMatrix.php?text=adjacency&matrix=" + encodeURIComponent(matrix), function( data ) {;}); + $.get( "/" + SiteDir + "cgi-bin/addFailedMatrix.php?text=adjacency&matrix=" + encodeURIComponent(matrix), function( data ) {;}); res = false; } @@ -806,7 +806,7 @@ Application.prototype.SetIncidenceMatrix = function (matrix) var c = {}; if (!this.TestIncidenceMatrix(matrix, r, c)) { - $.get( "/cgi-bin/addFailedMatrix.php?text=incidence&matrix=" + encodeURIComponent(matrix), function( data ) {;}); + $.get( "/" + SiteDir + "cgi-bin/addFailedMatrix.php?text=incidence&matrix=" + encodeURIComponent(matrix), function( data ) {;}); res = false; } @@ -880,7 +880,7 @@ Application.prototype.SaveGraphOnDisk = function () var app = this; $.ajax({ type: "POST", - url: "/cgi-bin/saveGraph.php?name=" + this.savedGraphName, + url: "/" + SiteDir + "cgi-bin/saveGraph.php?name=" + this.savedGraphName, data: graphAsString, dataType: "text" }) @@ -918,7 +918,7 @@ Application.prototype.SaveGraphImageOnDisk = function (showDialogCallback) $.ajax({ type: "POST", - url: "/cgi-bin/saveImage.php?name=" + imageName + rectParams, + url: "/" + SiteDir + "cgi-bin/saveImage.php?name=" + imageName + rectParams, data: { base64data : imageBase64Data }, @@ -947,7 +947,7 @@ Application.prototype.SaveFullGraphImageOnDisk = function (showDialogCallback, f $.ajax({ type: "POST", - url: "/cgi-bin/saveImage.php?name=" + imageName + rectParams, + url: "/" + SiteDir + "cgi-bin/saveImage.php?name=" + imageName + rectParams, data: { base64data : imageBase64Data }, @@ -977,7 +977,7 @@ Application.prototype.LoadGraphFromDisk = function (graphName) $.ajax({ type: "GET", - url: "/cgi-bin/loadGraph.php?name=" + graphName + url: "/" + SiteDir + "cgi-bin/loadGraph.php?name=" + graphName }) .done(function( msg ) { diff --git a/script/main.js b/script/main.js index e334110..8ca1541 100644 --- a/script/main.js +++ b/script/main.js @@ -1,3 +1,6 @@ + +var SiteDir = ""; + var application = new Application(document, window); var waitCounter = false; @@ -548,7 +551,7 @@ function postLoadPage() console.log("Vote" + this["voteIndex"]); $.ajax({ type: "GET", - url: "/cgi-bin/vote.php?index=" + this["voteIndex"], + url: "/" + SiteDir + "cgi-bin/vote.php?index=" + this["voteIndex"], dataType: "text" }); $("#voteDialog").dialog('close'); @@ -572,7 +575,7 @@ function postLoadPage() // Get algorithms list and load it. - $.get( "/cgi-bin/getPluginsList.php", + $.get( "/" + SiteDir + "cgi-bin/getPluginsList.php", function( data ) { var scriptList = JSON.parse(data); @@ -586,7 +589,7 @@ function postLoadPage() else { var script = document.createElement('script'); - script.src = scriptList[0]; + script.src = "/" + SiteDir + "script/" + scriptList[0]; scriptList.shift(); script.onload = loadOneScript; script.onerror = loadOneScript; diff --git a/script/plugins/disable/NeedAlgorithm.js b/script/plugins/disable/NeedAlgorithm.js index 8279b58..504e045 100644 --- a/script/plugins/disable/NeedAlgorithm.js +++ b/script/plugins/disable/NeedAlgorithm.js @@ -69,7 +69,7 @@ NeedAlgorithm.prototype.result = function(resultCallback) console.log("Vote" + this["voteIndex"]); $.ajax({ type: "GET", - url: "/cgi-bin/vote.php?index=" + this["voteIndex"], + url: "/" + SiteDir + "cgi-bin/vote.php?index=" + this["voteIndex"], dataType: "text" }); $("#voteDialog").dialog('close');