commit 8316669b716aa4305ea8f1a3bd7926497ee018fb Author: PMKuipers Date: Fri Mar 22 22:10:56 2024 +0100 Initial Commit diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..91924d9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/.vs +/node_modules +/amd/build +/build diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..6760ffa --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,101 @@ +// This file is part of Moodle - http://moodle.org/ +// +// Moodle 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 Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Moodle is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Moodle. If not, see . +/* jshint node: true, browser: false */ +/* eslint-env node */ + +/** + * Grunt configuration for local_treestudyplan + * + * @copyright 2023 P.M. Kuipers + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + + +/** + * Grunt configuration. + * + * @param {Grunt} grunt + */ +module.exports = function(grunt) { + const path = require('path'); + const process = require('process'); + const sass = require('sass'); + + // Import grunt configuration for moodle base + process.chdir("../../.."); // change dir to moodle base + require(path.resolve(`./Gruntfile.js`))(grunt); // Run Gruntfile module from moodle base + + grunt.registerTask('scssplugin','Compile scss/styles.sccs into styles.css and css/devstyles.css', () => { + + const devoutput = 'css/devstyles.css'; + const prodoutput = 'styles.css'; + + // Get full path of compenent and scss folder + const componentPath = path.join(grunt.moodleEnv.gruntFilePath,grunt.moodleEnv.componentDirectory); + const scssPath = path.join(componentPath, 'scss','styles.scss'); + console.log(`Compiling ${scssPath} including any imported files therein`); + + process.chdir(path.join(componentPath, 'scss')); + const result = sass.compile(scssPath); + if ( result ) { + console.info("got result"); + + // Some regex processing to match moodle stylelint styles + + // change tab indent to 4 instead of 2 + let css = result.css.replace(/^ ([^ ])/gm ," $1"); + + // insert a newline after every comma in a css selector + // (only combined selectors will get that long) + css = css.replace(/^[^ ].*[\{,]$/gm , (m) => { // Find CSS selector lines + return m.replace(/, /g,",\n"); // replace comma followed by space with comma newline + }); + + // replace hex color codes with lowercase (convenience function since I don't really care for the hex codes lowercase only rule) + const hexCodeToLower = (match, m1, m2) => { + return '#'+m1.toLowerCase()+m2; + } + css = css.replace(/#([A-F0-9a-f]{3})([^A-F0-9a-f]?)/gm , hexCodeToLower); // 3 digit color codes + css = css.replace(/#([A-F0-9a-f]{6})([^A-F0-9a-f]?)/gm , hexCodeToLower); // 6 digit color codes + css = css.replace(/#([A-F0-9a-f]{8})([^A-F0-9a-f]?)/gm , hexCodeToLower); // 8 digit color codes (with alpha) + + // All other errors should really be fixed in the scss files :) + + [devoutput,prodoutput].forEach((output) => { + console.info(`Storing ${output}`); + grunt.file.write(path.join(componentPath, output),css); + }); + } + + }); + + // Rebuild on changes in the scss files when using 'grunt watch' + grunt.config.merge({ + watch: { + scssplugin: { + files: ['scss/*.scss'], + tasks: ['scssplugin'] + }, + }, + }); + + // Remove gherkinlint from the startup list, since it exits with an error because of errors in moodle's own code + grunt.moodleEnv.startupTasks.splice(grunt.moodleEnv.startupTasks.indexOf("gherkinlint"),1); + + // Add the 'scssplugin' task as a startup task. + grunt.moodleEnv.startupTasks.push('scssplugin'); + + +}; diff --git a/LICENSE b/LICENSE new file mode 100755 index 0000000..4b1c5a4 --- /dev/null +++ b/LICENSE @@ -0,0 +1,4 @@ +Copyright (C) 2024 Peter-Martijn Kuipers +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 Foundation; either version 2 of the License, or (at your option) any later version. +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 , USA. Also add information on how to contact you by electronic and paper mail. diff --git a/README.md b/README.md new file mode 100755 index 0000000..e69de29 diff --git a/amd/src/tool_sptoolboxmanager.js b/amd/src/tool_sptoolboxmanager.js new file mode 100644 index 0000000..b2358d1 --- /dev/null +++ b/amd/src/tool_sptoolboxmanager.js @@ -0,0 +1,29 @@ +/*eslint no-var: "error" */ +/*eslint no-unused-vars: "off" */ +/*eslint linebreak-style: "off" */ +/*eslint no-trailing-spaces: "off" */ +/*eslint-env es6*/ +// Put this file in path/to/plugin/amd/src +// You can call it anything you like + + +import {call} from 'core/ajax'; +import notification from 'core/notification'; +import {load_strings} from 'local_treestudyplan/util/string-helper'; +import Debugger from 'local_treestudyplan/util/debugger'; + +let debug = new Debugger("mytreestudyplan"); +debug.enable(); + +let strings = load_strings({ + studyplan: { + + }, +},"tool_sptoolboxmgr"); + +/** + * Initialize the Page + */ + export function init() { + +} diff --git a/build.php b/build.php new file mode 100644 index 0000000..4d033ac --- /dev/null +++ b/build.php @@ -0,0 +1,76 @@ +. +/** + * Build script to properly create a distribution zip + * @package block_mytreestudyplan + * @copyright 2023 P.M. Kuipers + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +define('CLI_SCRIPT', true); +require_once("../../config.php"); +$plugin = new stdClass; +require_once('version.php'); + +$a = explode("_", $plugin->component, 2); +$plugin->type = $a[0]; +$plugin->name = $a[1]; + +$excludepaths = [ + "build", // Dir for build zip files. + "build/*", + "build.*", + "vuemode.sh", + "amd/src", + "amd/src/*", + ".git", + ".git/*", + ".gitignore", + "*.zip", +]; + +// Determine some paths. +$wd = realpath(dirname(__FILE__)); +$parent = dirname($wd); +$plugindirname = basename($wd); +$builddir = $wd."/"."build"; +$zipname = $builddir."/"."{$plugin->name}-{$plugin->version}.zip"; + +// Create the exclude line. +$exclude = "-x "; +foreach ($excludepaths as $x) { + $exclude .= "'{$plugindirname}/{$x}' "; +} + +if (!is_dir($builddir)) { + mkdir($builddir); + if (!is_dir($builddir)) { + print("Cannot access dir '{$builddir}' to store zip files\n"); + exit(1); + } +} + +if (file_exists($zipfile)) { + print("Zip file '{$zipfile}' already exists. Exiting...\n"); + exit(1); +} + +$cwd = getcwd(); +chdir($parent); + +$cmd = "zip -r '{$zipname}' '{$plugindirname}' {$exclude}"; +system($cmd); + +chdir($cwd); diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..7528487 --- /dev/null +++ b/build.sh @@ -0,0 +1,14 @@ +#!/bin/bash +SCRIPTDIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +WD=`pwd` + +# run the grunt script in the scripts working directory +cd $SCRIPTDIR +grunt amd + +# run the build php script +php ${SCRIPTDIR}/build.php $@ + + +# return to the working directory +cd $WD \ No newline at end of file diff --git a/css/devstyles.css b/css/devstyles.css new file mode 100644 index 0000000..462260c --- /dev/null +++ b/css/devstyles.css @@ -0,0 +1,4 @@ +/* stylelint-disable length-zero-no-unit, color-hex-case, color-hex-length*/ +.path-admin-tool-sptoolboxmgr [v-cloak] { + visibility: hidden; +} \ No newline at end of file diff --git a/db/access.php b/db/access.php new file mode 100755 index 0000000..0071360 --- /dev/null +++ b/db/access.php @@ -0,0 +1,26 @@ +. +/** + * Permission descriptions + * @package block_mytreestudyplan + * @copyright 2023 P.M. Kuipers + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +defined('MOODLE_INTERNAL') || die(); + +$capabilities = [ + +]; diff --git a/lang/en/tool_sptoolboxmgr.php b/lang/en/tool_sptoolboxmgr.php new file mode 100755 index 0000000..d86a216 --- /dev/null +++ b/lang/en/tool_sptoolboxmgr.php @@ -0,0 +1,25 @@ +. +/** + * English language file + * @package tool_sptoolboxmgr + * @copyright 2024 P.M. Kuipers + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['pluginname'] = 'ToolboxManager (Studyplan)'; +$string['toolboxmanager'] = 'ToolboxManager'; + diff --git a/lang/nl/tool_sptoolboxmgr.php b/lang/nl/tool_sptoolboxmgr.php new file mode 100755 index 0000000..aea5cba --- /dev/null +++ b/lang/nl/tool_sptoolboxmgr.php @@ -0,0 +1,25 @@ +. +/** + * Dutch language file + * @package tool_sptoolboxmgr + * @copyright 2024 P.M. Kuipers + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['pluginname'] = 'ToolboxBeheer (Studieplan)'; +$string['toolboxmanager'] = 'ToolboxBeheer'; + diff --git a/lib.php b/lib.php new file mode 100755 index 0000000..02385dd --- /dev/null +++ b/lib.php @@ -0,0 +1,21 @@ +. +/** + * Library page + * @package tool_sptoolboxmgr + * @copyright 2023 P.M. Kuipers + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ diff --git a/scss/styles.scss b/scss/styles.scss new file mode 100644 index 0000000..abf9982 --- /dev/null +++ b/scss/styles.scss @@ -0,0 +1,7 @@ +/* stylelint-disable length-zero-no-unit, color-hex-case, color-hex-length*/ + +.path-admin-tool-sptoolboxmgr{ + [v-cloak] { + visibility: hidden; + } +} \ No newline at end of file diff --git a/settings.php b/settings.php new file mode 100755 index 0000000..ebfb77b --- /dev/null +++ b/settings.php @@ -0,0 +1,21 @@ +. +/** + * Settings page + * @package tool_sptoolboxmgr + * @copyright 2024 P.M. Kuipers + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ diff --git a/styles.css b/styles.css new file mode 100755 index 0000000..462260c --- /dev/null +++ b/styles.css @@ -0,0 +1,4 @@ +/* stylelint-disable length-zero-no-unit, color-hex-case, color-hex-length*/ +.path-admin-tool-sptoolboxmgr [v-cloak] { + visibility: hidden; +} \ No newline at end of file diff --git a/templates/block.mustache b/templates/block.mustache new file mode 100644 index 0000000..712833a --- /dev/null +++ b/templates/block.mustache @@ -0,0 +1,51 @@ +{{! + This file is part of Moodle - https://moodle.org/ + + Moodle 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 Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template block_mytreestudyplan/block + + Render my treestudyplan block + + Classes required for JS: + * none + + Data attributes required for JS: + * none + + Context variables required for this template: + * none + + Example context (json): + { + } +}} + +
+
+
+ Loading... +
+
+
+ {{^teachermode}} + + {{/teachermode}} + {{#teachermode}} + + {{/teachermode}} + +
+
\ No newline at end of file diff --git a/version.php b/version.php new file mode 100644 index 0000000..6d65e60 --- /dev/null +++ b/version.php @@ -0,0 +1,35 @@ +. +/** + * Version description + * @package tool_sptoolboxmgr + * @copyright 2024 P.M. Kuipers + * @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +defined('MOODLE_INTERNAL') || die(); + +$plugin->component = 'tool_sptoolboxmgr'; // Recommended since 2.0.2 (MDL-26035). Required since 3.0 (MDL-48494). +$plugin->version = 2024032200; // YYYYMMDDHH (year, month, day, iteration). +$plugin->requires = 2021051700; // YYYYMMDDHH (This is the release version for Moodle 3.11). + +$plugin->release = "1.0.0"; +$plugin->maturity = MATURITY_RC; +// Supported from Moodle 3.11 to 4.2 (4.3 not yet tested). +$plugin->supported = [ 311, 402 ]; + +$plugin->dependencies = [ + 'local_treestudyplan' => 2024031300, +];