Compare commits

...

3 Commits

Author SHA1 Message Date
Oleg Sh
e81ca36385 Updated README.md 2023-11-11 16:22:16 +02:00
Oleg Sh
7d6de6d6be Removed unnecessary files. 2023-11-11 16:04:46 +02:00
Oleg Sh
af68690055 Added admin page to update script caches. 2023-11-11 16:01:55 +02:00
18 changed files with 152 additions and 149 deletions

View File

@ -19,13 +19,11 @@ Server side:
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 (it is actually for Non-Windows system, you should set rwx). PHP scripts should be able to create and to 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.
5. Change default root password in file: /core/config/admin_sector.php
3. Change default root password in file: /core/config/admin_sector.php
```
$g_config['admin_sector']['def_pwd'] = 'rootPass';
```
6. Change password to wiki. Change lines:
4. Change password to wiki. Change lines:
```
$DefaultPasswords['admin'] = pmcrypt('pas');
$DefaultPasswords['edit'] = pmcrypt('pas');
@ -34,7 +32,7 @@ In files:
/wiki/local/config.php
/en/wiki/local/config.php
7. Maybe you need to disable autoredirect to https. Comments or remove lines:
5. Maybe you need to disable autoredirect to https. Comments or remove lines:
```
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
@ -44,7 +42,7 @@ In files:
/wiki/.htaccess
/en/wiki/.htaccess
8. Some algorithms (short-path, Eulerian cycle/path and so on) use external modul for algorithm. Currently for desktops it is JS file: script\Graphoffline.Emscripten.js. For mobile phones and tablets we continue using binary CGI file. Binary CGI or Graphoffline.Emscripten.js are built from GraphOffline: https://github.com/UnickSoft/GraphOffline. Binary cgi should be placed to /cgi-bin/GraphCGI.exe or you can take precompiled file(Windows and Mac) from /cgi-bin/GraphOffline/
6. Some algorithms (short-path, Eulerian cycle/path and so on) use external modul for algorithm. Currently for desktops it is JS file: script\Graphoffline.Emscripten.js. For mobile phones and tablets we continue using binary CGI file. Binary CGI or Graphoffline.Emscripten.js are built from GraphOffline: https://github.com/UnickSoft/GraphOffline. Binary cgi should be placed to /cgi-bin/GraphCGI.exe or you can take precompiled file(Windows and Mac) from /cgi-bin/GraphOffline/
# Additional steps to run from subdirectory:
@ -69,6 +67,11 @@ define('SITE_IN_DIR', 'graph');
@fa-font-path: "/graph/i/fonts/dev/fontawesome";
```
# Additional steps if you want to change js scripts from script directory:
1. We use our own js cache. It is files *.js.cache located in in script/pages. If you remove these cache files the browser will load scripts from source files. You may need to disable browser cache. Or change setting: $g_config['use_js_cache']
2. If you want to update cache use this admin page: /admin/page_update_script_cache. Just click to all links and wait until the cache will be updated.
3. If you change cache files and you want browsers to redownload script cache incripent number in setting $g_config['engine_version'].
# Fix problems
1. If you see page but css is not loaded. Maybe your web server does not support gzip encoding. You can try change FORCE_DISABLE_GZIP field from **false** to **true**. (It is placed in file /lib/ExtraPacker/ExtraPacker.php).

View File

@ -93,5 +93,5 @@
$g_config['vote'] = "./tmp/vote/vote.txt";
$g_config['voteTopics'] = "./tmp/vote/voteTopics.txt_";
$g_config['use_js_cache'] = true;
$g_config['engine_version'] = 1;
$g_config['engine_version'] = 76;
?>

View File

@ -46,7 +46,8 @@
array('link' => SiteRoot('admin/page_saved_graph'), 'name' => 'Статистика', 'label' => 'Статистика сохранений'),
array('link' => SiteRoot('admin/page_example_graph'), 'name' => 'Примеры', 'label' => 'Примеры графов'),
array('link' => SiteRoot('admin/page_vote'), 'name' => 'Голосование', 'label' => 'Результаты голосования'),
array('link' => SiteRoot('admin/page_test_graphcgi'), 'name' => 'Тестирование CGI', 'label' => 'Тестирования GraphCGI')
array('link' => SiteRoot('admin/page_test_graphcgi'), 'name' => 'Тестирование CGI', 'label' => 'Тестирования GraphCGI'),
array('link' => SiteRoot('admin/page_update_script_cache'), 'name' => 'Обновить кэш скрипта', 'label' => 'Обновить кэш скрипта')
)
);

View File

@ -1,18 +1 @@
<h1>Update cache</h1>
<?php
$cacheList = array(
"/script/pages/editor/api/index.js",
"/script/pages/create_graph_by_edge_list/api/index.js",
"/script/pages/create_graph_by_incidence_matrix/api/index.js",
"/script/pages/create_graph_by_matrix/api/index.js"
);
echo ("<ul>");
foreach ($cacheList as &$page) {
$date = date('d.m.Y H:i:s', filemtime("../$page.cache"));
echo ("<li><a href='pack.php?target=$page' target='_blank'>$page</a> $date</li>");
}
echo ("</ul>");
?>
<h1>Use /admin/page_update_script_cache page to update caches</h1>

View File

@ -1,104 +0,0 @@
<?php if (!isset($_GET["cacheFiles"]) && isset($_GET["target"])): ?>
<head>
<script src="/script/shared/config.js" ></script>
<script src="/script/shared/loader.js" ></script>
<script src="<?= $_GET["target"] ?>" ></script>
<script>
setTimeout(
() => {
document.getElementById("state").innerHTML = "Saving files";
const xhr = new XMLHttpRequest();
xhr.open("GET", "<?= $_SERVER['PHP_SELF'] ?>?cacheFiles=" + moduleLoader.syncLoaded.toString() + "&target=" + "<?= $_GET["target"] ?>");
xhr.send();
xhr.onload = () => {
if (xhr.readyState == 4 && xhr.status == 200) {
document.getElementById("state").innerHTML = "Finished <br>" + xhr.response;
} else {
document.getElementById("state").innerHTML = "Error happends";
}
};
}, 3000);
</script>
</head>
<body>
<div>
<p>State:</p>
<p id="state">Loading</p>
</div>
</doby>
<?php endif; ?>
<?php
if (!isset($_GET["target"])) {
echo ("Error target is not set");
return;
}
?>
<!-- Create cache file -->
<?php
/**
* Return relative path between two sources
* @param $from
* @param $to
* @param string $separator
* @return string
*/
function relativePath($from, $to, $separator = DIRECTORY_SEPARATOR)
{
$from = str_replace(array('/', '\\'), $separator, $from);
$to = str_replace(array('/', '\\'), $separator, $to);
$arFrom = explode($separator, rtrim($from, $separator));
$arTo = explode($separator, rtrim($to, $separator));
while(count($arFrom) && count($arTo) && ($arFrom[0] == $arTo[0]))
{
array_shift($arFrom);
array_shift($arTo);
}
return str_pad("", count($arFrom) * 3, '..'.$separator).implode($separator, $arTo);
}
include (relativePath(dirname($_SERVER['PHP_SELF']), "/") . "lib/ExtraPacker/Lib/JSMin.php");
if (isset($_GET["cacheFiles"])) {
$cacheFilenameList = $_GET["cacheFiles"];
$files = explode(",", $cacheFilenameList);
//print_r($files);
$indexFilename = "../" . $_GET["target"];
$outputFilename = $indexFilename . '.cache';
unlink($outputFilename);
// Put files already loaded.
$cacheContent = "";
$cacheContent = $cacheContent . "\nmoduleLoader.beginCacheLoading([";
foreach ($files as &$file) {
$cacheContent = $cacheContent . "\"" . $file . "\"" . ",";
}
$cacheContent = $cacheContent . "]);\n";
// Put index file.
$processedFilesCount = 1;
$cacheContent = $cacheContent . file_get_contents($indexFilename);
// Put files
foreach ($files as &$file) {
$relativePath = strtok($file, '?');
$relativePath = relativePath(dirname($_SERVER['PHP_SELF']), $relativePath);
$cacheContent = $cacheContent . file_get_contents($relativePath);
$processedFilesCount ++;
}
// Put event about cache loaded.
$cacheContent = $cacheContent . "\nmoduleLoader.endCacheLoading();";
$minifiedCacheContent = JSMin::minify($cacheContent);
file_put_contents($outputFilename, $minifiedCacheContent, FILE_APPEND);
echo("Prcoessed files: " . $processedFilesCount);
}
?>

View File

@ -1,6 +1,3 @@
// Global version needs to force reload scripts from server.
globalVersion = 75;
{
let modulDir = "pages/create_graph_by_edge_list/";

View File

@ -1,4 +1,4 @@
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=75","/script/shared/point.js?v=75","/script/entities/edge/api/index.js?v=75","/script/entities/edge/model/BaseEdge.js?v=75","/script/entities/edge/model/EdgeModel.js?v=75","/script/entities/vertex/api/index.js?v=75","/script/entities/vertex/model/BaseVertex.js?v=75","/script/entities/vertex/model/VertexModel.js?v=75","/script/entities/graph/model/Graph.js?v=75",]);globalVersion=75;{let modulDir="pages/create_graph_by_edge_list/";doInclude([include("entities/graph/api/index.js")]);}
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=75","/script/shared/point.js?v=75","/script/entities/edge/api/index.js?v=75","/script/entities/edge/model/BaseEdge.js?v=75","/script/entities/edge/model/EdgeModel.js?v=75","/script/entities/vertex/api/index.js?v=75","/script/entities/vertex/model/BaseVertex.js?v=75","/script/entities/vertex/model/VertexModel.js?v=75","/script/entities/graph/model/Graph.js?v=75",]);{let modulDir="pages/create_graph_by_edge_list/";doInclude([include("entities/graph/api/index.js")]);}
{let modulDir="entities/graph/";doInclude([include("shared/point.js"),include("entities/edge/api/index.js"),include("entities/vertex/api/index.js"),include("model/Graph.js",modulDir)])}function Point(x,y){this.x=x||0;this.y=y||0;};Point.prototype.x=null;Point.prototype.y=null;Point.prototype.add=function(v){return new Point(this.x+v.x,this.y+v.y);};Point.prototype.addValue=function(v){return new Point(this.x+v,this.y+v);};Point.prototype.clone=function(){return new Point(this.x,this.y);};Point.prototype.degreesTo=function(v){var dx=this.x-v.x;var dy=this.y-v.y;var angle=Math.atan2(dy,dx);return angle*(180/Math.PI);};Point.prototype.distance=function(v){return Math.sqrt(this.distanceSqr(v));};Point.prototype.distanceSqr=function(v){var x=this.x-v.x;var y=this.y-v.y;return x*x+y*y;};Point.prototype.equals=function(toCompare){return this.x==toCompare.x&&this.y==toCompare.y;};Point.prototype.interpolate=function(v,f){return new Point((this.x+v.x)*f,(this.y+v.y)*f);};Point.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y);};Point.prototype.normalize=function(thickness){var l=this.length();this.x=this.x/l*thickness;this.y=this.y/l*thickness;return new Point(this.x,this.y);};Point.prototype.normalizeCopy=function(thickness){var l=this.length();return new Point(this.x/l*thickness,this.y/l*thickness);};Point.prototype.orbit=function(origin,arcWidth,arcHeight,degrees){var radians=degrees*(Math.PI/180);this.x=origin.x+arcWidth*Math.cos(radians);this.y=origin.y+arcHeight*Math.sin(radians);};Point.prototype.rotate=function(center,degrees){var radians=degrees*(Math.PI/180);offset=this.subtract(center);this.x=offset.x*Math.cos(radians)-offset.y*Math.sin(radians);this.y=offset.x*Math.sin(radians)+offset.y*Math.cos(radians);this.x=this.x+center.x;this.y=this.y+center.y;return this;};Point.prototype.offset=function(dx,dy){this.x+=dx;this.y+=dy;};Point.prototype.subtract=function(v){return new Point(this.x-v.x,this.y-v.y);};Point.prototype.subtractValue=function(value){return new Point(this.x-value,this.y-value);};Point.prototype.multiply=function(value){return new Point(this.x*value,this.y*value);};Point.prototype.toString=function(){return"(x="+this.x+", y="+this.y+")";};Point.prototype.normal=function(){return new Point(-this.y,this.x);};Point.prototype.min=function(point)
{return new Point(Math.min(this.x,point.x),Math.min(this.y,point.y));};Point.prototype.max=function(point)
{return new Point(Math.max(this.x,point.x),Math.max(this.y,point.y));};Point.prototype.inverse=function()

View File

@ -1,7 +1,3 @@
// Global version needs to force reload scripts from server.
globalVersion = 75;
{
let modulDir = "pages/create_graph_by_matrix/";

View File

@ -1,4 +1,4 @@
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=75","/script/shared/point.js?v=75","/script/entities/edge/api/index.js?v=75","/script/entities/edge/model/BaseEdge.js?v=75","/script/entities/edge/model/EdgeModel.js?v=75","/script/entities/vertex/api/index.js?v=75","/script/entities/vertex/model/BaseVertex.js?v=75","/script/entities/vertex/model/VertexModel.js?v=75","/script/entities/graph/model/Graph.js?v=75",]);globalVersion=75;{let modulDir="pages/create_graph_by_matrix/";doInclude([include("entities/graph/api/index.js")]);}
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=75","/script/shared/point.js?v=75","/script/entities/edge/api/index.js?v=75","/script/entities/edge/model/BaseEdge.js?v=75","/script/entities/edge/model/EdgeModel.js?v=75","/script/entities/vertex/api/index.js?v=75","/script/entities/vertex/model/BaseVertex.js?v=75","/script/entities/vertex/model/VertexModel.js?v=75","/script/entities/graph/model/Graph.js?v=75",]);{let modulDir="pages/create_graph_by_matrix/";doInclude([include("entities/graph/api/index.js")]);}
{let modulDir="entities/graph/";doInclude([include("shared/point.js"),include("entities/edge/api/index.js"),include("entities/vertex/api/index.js"),include("model/Graph.js",modulDir)])}function Point(x,y){this.x=x||0;this.y=y||0;};Point.prototype.x=null;Point.prototype.y=null;Point.prototype.add=function(v){return new Point(this.x+v.x,this.y+v.y);};Point.prototype.addValue=function(v){return new Point(this.x+v,this.y+v);};Point.prototype.clone=function(){return new Point(this.x,this.y);};Point.prototype.degreesTo=function(v){var dx=this.x-v.x;var dy=this.y-v.y;var angle=Math.atan2(dy,dx);return angle*(180/Math.PI);};Point.prototype.distance=function(v){return Math.sqrt(this.distanceSqr(v));};Point.prototype.distanceSqr=function(v){var x=this.x-v.x;var y=this.y-v.y;return x*x+y*y;};Point.prototype.equals=function(toCompare){return this.x==toCompare.x&&this.y==toCompare.y;};Point.prototype.interpolate=function(v,f){return new Point((this.x+v.x)*f,(this.y+v.y)*f);};Point.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y);};Point.prototype.normalize=function(thickness){var l=this.length();this.x=this.x/l*thickness;this.y=this.y/l*thickness;return new Point(this.x,this.y);};Point.prototype.normalizeCopy=function(thickness){var l=this.length();return new Point(this.x/l*thickness,this.y/l*thickness);};Point.prototype.orbit=function(origin,arcWidth,arcHeight,degrees){var radians=degrees*(Math.PI/180);this.x=origin.x+arcWidth*Math.cos(radians);this.y=origin.y+arcHeight*Math.sin(radians);};Point.prototype.rotate=function(center,degrees){var radians=degrees*(Math.PI/180);offset=this.subtract(center);this.x=offset.x*Math.cos(radians)-offset.y*Math.sin(radians);this.y=offset.x*Math.sin(radians)+offset.y*Math.cos(radians);this.x=this.x+center.x;this.y=this.y+center.y;return this;};Point.prototype.offset=function(dx,dy){this.x+=dx;this.y+=dy;};Point.prototype.subtract=function(v){return new Point(this.x-v.x,this.y-v.y);};Point.prototype.subtractValue=function(value){return new Point(this.x-value,this.y-value);};Point.prototype.multiply=function(value){return new Point(this.x*value,this.y*value);};Point.prototype.toString=function(){return"(x="+this.x+", y="+this.y+")";};Point.prototype.normal=function(){return new Point(-this.y,this.x);};Point.prototype.min=function(point)
{return new Point(Math.min(this.x,point.x),Math.min(this.y,point.y));};Point.prototype.max=function(point)
{return new Point(Math.max(this.x,point.x),Math.max(this.y,point.y));};Point.prototype.inverse=function()

View File

@ -1,7 +1,3 @@
// Global version needs to force reload scripts from server.
globalVersion = 75;
{
let modulDir = "pages/create_graph_by_matrix/";

View File

@ -1,4 +1,4 @@
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=75","/script/shared/point.js?v=75","/script/entities/edge/api/index.js?v=75","/script/entities/edge/model/BaseEdge.js?v=75","/script/entities/edge/model/EdgeModel.js?v=75","/script/entities/vertex/api/index.js?v=75","/script/entities/vertex/model/BaseVertex.js?v=75","/script/entities/vertex/model/VertexModel.js?v=75","/script/entities/graph/model/Graph.js?v=75","/script/pages/create_graph_by_matrix/model/createByMatrixMain.js?v=75","/script/pages/create_graph_by_matrix/model/main.js?v=75",]);globalVersion=75;{let modulDir="pages/create_graph_by_matrix/";doInclude([include("entities/graph/api/index.js"),include("model/createByMatrixMain.js",modulDir),include("model/main.js",modulDir)]);}
moduleLoader.beginCacheLoading(["/script/entities/graph/api/index.js?v=75","/script/shared/point.js?v=75","/script/entities/edge/api/index.js?v=75","/script/entities/edge/model/BaseEdge.js?v=75","/script/entities/edge/model/EdgeModel.js?v=75","/script/entities/vertex/api/index.js?v=75","/script/entities/vertex/model/BaseVertex.js?v=75","/script/entities/vertex/model/VertexModel.js?v=75","/script/entities/graph/model/Graph.js?v=75","/script/pages/create_graph_by_matrix/model/createByMatrixMain.js?v=75","/script/pages/create_graph_by_matrix/model/main.js?v=75",]);{let modulDir="pages/create_graph_by_matrix/";doInclude([include("entities/graph/api/index.js"),include("model/createByMatrixMain.js",modulDir),include("model/main.js",modulDir)]);}
{let modulDir="entities/graph/";doInclude([include("shared/point.js"),include("entities/edge/api/index.js"),include("entities/vertex/api/index.js"),include("model/Graph.js",modulDir)])}function Point(x,y){this.x=x||0;this.y=y||0;};Point.prototype.x=null;Point.prototype.y=null;Point.prototype.add=function(v){return new Point(this.x+v.x,this.y+v.y);};Point.prototype.addValue=function(v){return new Point(this.x+v,this.y+v);};Point.prototype.clone=function(){return new Point(this.x,this.y);};Point.prototype.degreesTo=function(v){var dx=this.x-v.x;var dy=this.y-v.y;var angle=Math.atan2(dy,dx);return angle*(180/Math.PI);};Point.prototype.distance=function(v){return Math.sqrt(this.distanceSqr(v));};Point.prototype.distanceSqr=function(v){var x=this.x-v.x;var y=this.y-v.y;return x*x+y*y;};Point.prototype.equals=function(toCompare){return this.x==toCompare.x&&this.y==toCompare.y;};Point.prototype.interpolate=function(v,f){return new Point((this.x+v.x)*f,(this.y+v.y)*f);};Point.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y);};Point.prototype.normalize=function(thickness){var l=this.length();this.x=this.x/l*thickness;this.y=this.y/l*thickness;return new Point(this.x,this.y);};Point.prototype.normalizeCopy=function(thickness){var l=this.length();return new Point(this.x/l*thickness,this.y/l*thickness);};Point.prototype.orbit=function(origin,arcWidth,arcHeight,degrees){var radians=degrees*(Math.PI/180);this.x=origin.x+arcWidth*Math.cos(radians);this.y=origin.y+arcHeight*Math.sin(radians);};Point.prototype.rotate=function(center,degrees){var radians=degrees*(Math.PI/180);offset=this.subtract(center);this.x=offset.x*Math.cos(radians)-offset.y*Math.sin(radians);this.y=offset.x*Math.sin(radians)+offset.y*Math.cos(radians);this.x=this.x+center.x;this.y=this.y+center.y;return this;};Point.prototype.offset=function(dx,dy){this.x+=dx;this.y+=dy;};Point.prototype.subtract=function(v){return new Point(this.x-v.x,this.y-v.y);};Point.prototype.subtractValue=function(value){return new Point(this.x-value,this.y-value);};Point.prototype.multiply=function(value){return new Point(this.x*value,this.y*value);};Point.prototype.toString=function(){return"(x="+this.x+", y="+this.y+")";};Point.prototype.normal=function(){return new Point(-this.y,this.x);};Point.prototype.min=function(point)
{return new Point(Math.min(this.x,point.x),Math.min(this.y,point.y));};Point.prototype.max=function(point)
{return new Point(Math.max(this.x,point.x),Math.max(this.y,point.y));};Point.prototype.inverse=function()

View File

@ -1,7 +1,3 @@
// Global version needs to force reload scripts from server.
globalVersion = 75;
{
function onloadEditor() {
console.log("onload() call");

View File

@ -1,4 +1,4 @@
moduleLoader.beginCacheLoading(["/script/shared/utils.js?v=75","/script/entities/graph/api/index.js?v=75","/script/shared/point.js?v=75","/script/entities/edge/api/index.js?v=75","/script/entities/edge/model/BaseEdge.js?v=75","/script/entities/edge/model/EdgeModel.js?v=75","/script/entities/vertex/api/index.js?v=75","/script/entities/vertex/model/BaseVertex.js?v=75","/script/entities/vertex/model/VertexModel.js?v=75","/script/entities/graph/model/Graph.js?v=75","/script/features/draw_graph/api/index.js?v=75","/script/features/draw_graph/model/BaseBackgroundDrawer.js?v=75","/script/features/draw_graph/model/BaseEdgeDrawer.js?v=75","/script/features/draw_graph/model/BaseVertexDrawer.js?v=75","/script/features/algorithms/api/index.js?v=75","/script/features/algorithms/model/Algorithms.js?v=75","/script/features/algorithms/model/BaseTraversal.js?v=75","/script/features/base_handler/index.js?v=75","/script/features/default_handler/index.js?v=75","/script/features/add_vertices_handler/index.js?v=75","/script/features/connect_vertices_handler/index.js?v=75","/script/features/delete_objects_handler/index.js?v=75","/script/features/algorithm_handler/index.js?v=75","/script/features/serialization/api/index.js?v=75","/script/features/serialization/model/GraphMLCreator.js?v=75","/script/features/enum_vertices/EnumVertices.js?v=75","/script/pages/editor/model/texts.js?v=75","/script/pages/editor/model/Application.js?v=75","/script/pages/editor/ui/main.js?v=75",]);globalVersion=75;{function onloadEditor(){console.log("onload() call");doIncludeAsync([include("shared/canvas2svg.js"),include("features/group_rename_handler/index.js"),include("features/saved_graph_handler/index.js"),include("features/saved_graph_image_handler/index.js"),include("features/show_adjacency_matrix/index.js"),include("features/show_distance_matrix/index.js"),include("features/show_incidence_matrix/index.js"),include("features/setup_background_style/index.js"),include("features/setup_edge_style/index.js"),include("features/setup_vertex_style/index.js"),]);preLoadPage();postLoadPage();}
moduleLoader.beginCacheLoading(["/script/shared/utils.js?v=75","/script/entities/graph/api/index.js?v=75","/script/shared/point.js?v=75","/script/entities/edge/api/index.js?v=75","/script/entities/edge/model/BaseEdge.js?v=75","/script/entities/edge/model/EdgeModel.js?v=75","/script/entities/vertex/api/index.js?v=75","/script/entities/vertex/model/BaseVertex.js?v=75","/script/entities/vertex/model/VertexModel.js?v=75","/script/entities/graph/model/Graph.js?v=75","/script/features/draw_graph/api/index.js?v=75","/script/features/draw_graph/model/BaseBackgroundDrawer.js?v=75","/script/features/draw_graph/model/BaseEdgeDrawer.js?v=75","/script/features/draw_graph/model/BaseVertexDrawer.js?v=75","/script/features/algorithms/api/index.js?v=75","/script/features/algorithms/model/Algorithms.js?v=75","/script/features/algorithms/model/BaseTraversal.js?v=75","/script/features/base_handler/index.js?v=75","/script/features/default_handler/index.js?v=75","/script/features/add_vertices_handler/index.js?v=75","/script/features/connect_vertices_handler/index.js?v=75","/script/features/delete_objects_handler/index.js?v=75","/script/features/algorithm_handler/index.js?v=75","/script/features/serialization/api/index.js?v=75","/script/features/serialization/model/GraphMLCreator.js?v=75","/script/features/enum_vertices/EnumVertices.js?v=75","/script/pages/editor/model/texts.js?v=75","/script/pages/editor/model/Application.js?v=75","/script/pages/editor/ui/main.js?v=75",]);{function onloadEditor(){console.log("onload() call");doIncludeAsync([include("shared/canvas2svg.js"),include("features/group_rename_handler/index.js"),include("features/saved_graph_handler/index.js"),include("features/saved_graph_image_handler/index.js"),include("features/show_adjacency_matrix/index.js"),include("features/show_distance_matrix/index.js"),include("features/show_incidence_matrix/index.js"),include("features/setup_background_style/index.js"),include("features/setup_edge_style/index.js"),include("features/setup_vertex_style/index.js"),]);preLoadPage();postLoadPage();}
let modulDir="pages/editor/";doInclude([include("shared/utils.js"),include("entities/graph/api/index.js"),include("features/draw_graph/api/index.js"),include("features/algorithms/api/index.js"),include("features/base_handler/index.js"),include("features/default_handler/index.js"),include("features/add_vertices_handler/index.js"),include("features/connect_vertices_handler/index.js"),include("features/delete_objects_handler/index.js"),include("features/algorithm_handler/index.js"),include("features/serialization/api/index.js"),include("features/enum_vertices/EnumVertices.js"),include("model/texts.js",modulDir),include("model/Application.js",modulDir),include("ui/main.js",modulDir)],onloadEditor);}
function gEncodeToHTML(str)
{if(typeof str!=='string')

View File

@ -1,3 +1,6 @@
// Global version needs to force reload scripts from server.
let globalVersion = 75;
var include = function(filename, localDir) {
return {filename: filename, localDir: localDir};
};

68
src/admin/pack.php Normal file
View File

@ -0,0 +1,68 @@
<?php
/**
* Return relative path between two sources
* @param $from
* @param $to
* @param string $separator
* @return string
*/
function relativePath($from, $to, $separator = DIRECTORY_SEPARATOR)
{
$from = str_replace(array('/', '\\'), $separator, $from);
$to = str_replace(array('/', '\\'), $separator, $to);
$arFrom = explode($separator, rtrim($from, $separator));
$arTo = explode($separator, rtrim($to, $separator));
while(count($arFrom) && count($arTo) && ($arFrom[0] == $arTo[0]))
{
array_shift($arFrom);
array_shift($arTo);
}
return str_pad("", count($arFrom) * 3, '..'.$separator).implode($separator, $arTo);
}
include (relativePath(dirname($_SERVER['PHP_SELF']), "/") . "lib/ExtraPacker/Lib/JSMin.php");
if (isset($_GET["cacheFiles"])) {
$cacheFilenameList = $_GET["cacheFiles"];
$files = explode(",", $cacheFilenameList);
//print_r($files);
$indexFilename = "./" . $_GET["target"];
$outputFilename = $indexFilename . '.cache';
unlink($outputFilename);
// Put files already loaded.
$cacheContent = "";
$cacheContent = $cacheContent . "\nmoduleLoader.beginCacheLoading([";
foreach ($files as &$file) {
$cacheContent = $cacheContent . "\"" . $file . "\"" . ",";
}
$cacheContent = $cacheContent . "]);\n";
// Put index file.
$processedFilesCount = 1;
$cacheContent = $cacheContent . file_get_contents($indexFilename);
// Put files
foreach ($files as &$file) {
$relativePath = strtok($file, '?');
$relativePath = relativePath(dirname($_SERVER['PHP_SELF']), $relativePath);
$cacheContent = $cacheContent . file_get_contents($relativePath);
$processedFilesCount ++;
}
// Put event about cache loaded.
$cacheContent = $cacheContent . "\nmoduleLoader.endCacheLoading();";
$minifiedCacheContent = JSMin::minify($cacheContent);
file_put_contents($outputFilename, $minifiedCacheContent, FILE_APPEND);
echo("<p>Processed files: " . $processedFilesCount . "</p>");
echo("<p>File updated: " . $outputFilename . "</p>");
echo("<p>You may close this page</p>");
}
?>

View File

@ -0,0 +1,10 @@
<?php
$cacheList = array(
"/script/pages/editor/api/index.js",
"/script/pages/create_graph_by_edge_list/api/index.js",
"/script/pages/create_graph_by_incidence_matrix/api/index.js",
"/script/pages/create_graph_by_matrix/api/index.js"
);
?>

41
tpl/admin/pack.php Normal file
View File

@ -0,0 +1,41 @@
<?php if (!isset($_GET["cacheFiles"]) && isset($_GET["target"])): ?>
<head>
<script src="/script/shared/config.js" ></script>
<script src="/script/shared/loader.js" ></script>
<script src="<?= $_GET["target"] ?>" ></script>
<script>
setTimeout(
() => {
document.getElementById("state").innerHTML = "Saving files";
const xhr = new XMLHttpRequest();
xhr.open("GET", "pack?cacheFiles=" + moduleLoader.syncLoaded.toString() + "&target=" + "<?= $_GET["target"] ?>");
xhr.send();
xhr.onload = () => {
if (xhr.readyState == 4 && xhr.status == 200) {
document.getElementById("state").innerHTML = "Finished <br>";
document.getElementById("other_page").innerHTML = xhr.response;
} else {
document.getElementById("state").innerHTML = "Error happends";
}
};
}, 3000);
</script>
</head>
<body>
<div>
<h1>Update script cache</h1>
<h2>State: <span id="state">Loading</span></h2>
<p id="other_page"></p>
</div>
</doby>
<?php endif; ?>
<?php
if (!isset($_GET["target"])) {
echo ("Error target is not set");
return;
}
?>

View File

@ -0,0 +1,13 @@
<?php IncludeCom('dev/bootstrap3')?>
<h1>Update script cache</h1>
<p>Click to each link to update cache. Don't forget change $g_config['engine_version'] version in file /core/config/main.php</p>
<ul>
<?php
foreach ($cacheList as &$page) {
$date = date('d.m.Y H:i:s', filemtime("./$page.cache"));
echo ("<li><a href='pack?target=$page' target='_blank'>$page</a> $date</li>");
}
?>
</ul>