From 85f7760740eed985be30986030247e67d04da7be Mon Sep 17 00:00:00 2001 From: Matthias Konitzny <konitzny@ibr.cs.tu-bs.de> Date: Fri, 25 Mar 2022 11:48:19 +0100 Subject: [PATCH] Fixed PHP paths. Moved all the remaining code to /src. --- gulpfile.js | 8 +---- knowledge-space.php | 29 +++++++++++-------- {datasets => src}/datasets.js | 0 {datasets => src}/datasets.php | 0 src/editor/js/editor.js | 2 +- .../knowledge-space-database.php | 2 +- {datasets => src}/ks-datasets-database.php | 2 +- 7 files changed, 21 insertions(+), 22 deletions(-) rename {datasets => src}/datasets.js (100%) rename {datasets => src}/datasets.php (100%) rename knowledge-space-database.php => src/knowledge-space-database.php (93%) rename {datasets => src}/ks-datasets-database.php (96%) diff --git a/gulpfile.js b/gulpfile.js index d8d3af7..541a078 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -6,7 +6,6 @@ const replace = require("gulp-replace"); const zip = require("gulp-zip"); const del = require("del"); const fs = require("fs"); -const path = require("path"); const dir = { src: ".", @@ -44,12 +43,7 @@ function copyPHP() { ) ) .pipe(replace("Version: 1.0", `Version: ${version}`)) - .pipe( - gulp.dest(function (file) { - file.path = path.basename(file.path); - return php.build; - }) - ); + .pipe(gulp.dest(php.build)); } function copyWebpackContent() { diff --git a/knowledge-space.php b/knowledge-space.php index 8cb8c7a..b5deec8 100644 --- a/knowledge-space.php +++ b/knowledge-space.php @@ -14,14 +14,19 @@ function ks_add_graph($atts = []): string { $div = '<div id="3d-graph"></div>'; // The id "3d-graph" indicates, that the javascript associated with this should automatically be executed - $script_path = 'build' . DIRECTORY_SEPARATOR . $GLOBALS['build'] . DIRECTORY_SEPARATOR . 'frontend.js'; - ks_load_styles(); - wp_enqueue_script("ks-display-js", plugins_url($script_path, __FILE__), array('jquery'), false); + ks_load_styles("frontend.css"); + wp_enqueue_script("ks-runtime-js", plugins_url(get_script_path("runtime.js"), __FILE__), array('jquery'), false); + wp_enqueue_script("ks-vendors-js", plugins_url(get_script_path("vendors.js"), __FILE__), array('jquery'), false); + wp_enqueue_script("ks-display-js", plugins_url(get_script_path("frontend.js"), __FILE__), array('jquery'), false); ks_localize("ks-display-js", $atts); return $div; } +function get_script_path($script_name) { + return 'build' . DIRECTORY_SEPARATOR . $GLOBALS['build'] . DIRECTORY_SEPARATOR . $script_name; +} + function parse_atts($atts) { return shortcode_atts(array( @@ -63,20 +68,20 @@ function ks_add_editor($atts = []) { ks_add_editor_dependencies(); ks_localize("ks-editor-js", $atts); - ks_load_styles(); + ks_load_styles("backend.css"); - require_once(__DIR__ . '/editor/editor.php'); + require_once(__DIR__ . '/src/editor/editor.php'); } function ks_add_editor_dependencies() { - $script_path = 'build' . DIRECTORY_SEPARATOR . $GLOBALS['build'] . DIRECTORY_SEPARATOR . 'backend.js'; - wp_enqueue_script("ks-editor-js", plugins_url($script_path, __FILE__), array('jquery'), false); - + wp_enqueue_script("ks-runtime-js", plugins_url(get_script_path("runtime.js"), __FILE__), array('jquery'), false); + wp_enqueue_script("ks-vendors-js", plugins_url(get_script_path("vendors.js"), __FILE__), array('jquery'), false); + wp_enqueue_script("ks-editor-js", plugins_url(get_script_path("backend.js"), __FILE__), array('jquery'), false); } -function ks_load_styles() { - $styles_path = 'build' . DIRECTORY_SEPARATOR . $GLOBALS['build'] . DIRECTORY_SEPARATOR . 'graph.css'; +function ks_load_styles($styles_name) { + $styles_path = 'build' . DIRECTORY_SEPARATOR . $GLOBALS['build'] . DIRECTORY_SEPARATOR . $styles_name; wp_enqueue_style('ks-style', plugins_url($styles_path, __FILE__)); } @@ -124,8 +129,8 @@ function kg_editor_admin_add_page() } -require_once(__DIR__ . "/knowledge-space-database.php"); -require_once(__DIR__ . '/datasets/datasets.php'); +require_once(__DIR__ . "/src/knowledge-space-database.php"); +require_once(__DIR__ . '/src/datasets.php'); //add_action('wp_enqueue_scripts', 'kg_load_css'); add_shortcode('knowledge-space', 'ks_add_graph'); diff --git a/datasets/datasets.js b/src/datasets.js similarity index 100% rename from datasets/datasets.js rename to src/datasets.js diff --git a/datasets/datasets.php b/src/datasets.php similarity index 100% rename from datasets/datasets.php rename to src/datasets.php diff --git a/src/editor/js/editor.js b/src/editor/js/editor.js index ab42cae..c45f59c 100644 --- a/src/editor/js/editor.js +++ b/src/editor/js/editor.js @@ -1,6 +1,6 @@ import { State } from "./state"; import * as Graph from "./graph"; -import { loadGraphJson } from "../../../datasets/datasets"; +import { loadGraphJson } from "../../datasets"; import ForceGraph from "force-graph"; import * as Interactions from "./interactions"; import { setSpace, SPACE } from "../../config"; diff --git a/knowledge-space-database.php b/src/knowledge-space-database.php similarity index 93% rename from knowledge-space-database.php rename to src/knowledge-space-database.php index ee25088..cb8db3b 100644 --- a/knowledge-space-database.php +++ b/src/knowledge-space-database.php @@ -25,7 +25,7 @@ function ks_install() } $charset_collate = $wpdb->get_charset_collate(); - require_once(__DIR__ . '/../../../wp-admin/includes/upgrade.php'); + require_once(__DIR__ . '/../../../../wp-admin/includes/upgrade.php'); global $SPACES_TABLE; $sql = "CREATE TABLE $SPACES_TABLE ( diff --git a/datasets/ks-datasets-database.php b/src/ks-datasets-database.php similarity index 96% rename from datasets/ks-datasets-database.php rename to src/ks-datasets-database.php index 0a526be..39d9e69 100644 --- a/datasets/ks-datasets-database.php +++ b/src/ks-datasets-database.php @@ -1,5 +1,5 @@ <?php -require_once(__DIR__ . "/../knowledge-space-database.php"); +require_once(__DIR__ . "/knowledge-space-database.php"); function ks_insert_or_update_graph($name, $graph) { -- GitLab