From 7dad24cb3d807d2aef23583aac2d48b70edb1903 Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Wed, 8 Oct 2025 02:10:24 -0700 Subject: initial version of the Mantis Smalltech plugin this plugin will hold whatever style and navigation changes we wind up making to Mantis over time. the plan is to eventually publish it as part of Smalltech. as of this initial version, it makes the b/37 syntax work for links to Mantis bugs (per the feature request tracked in that same bug) Force-Push: initial development in a new repo Change-Id: Ie98e8abc9658fdf673b2feb23fb1323fa9b1b1c4 --- .envrc | 2 ++ .gitignore | 5 +++++ MantisSmalltech.php | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ composer.json | 13 ++++++++++++ composer.lock | 18 +++++++++++++++++ flake.lock | 27 +++++++++++++++++++++++++ flake.nix | 43 +++++++++++++++++++++++++++++++++++++++ lang/strings_english.txt | 4 ++++ 8 files changed, 164 insertions(+) create mode 100644 .envrc create mode 100644 .gitignore create mode 100644 MantisSmalltech.php create mode 100644 composer.json create mode 100644 composer.lock create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 lang/strings_english.txt diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..e3fecb3 --- /dev/null +++ b/.envrc @@ -0,0 +1,2 @@ +use flake + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..39eac8c --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +result +*.swp +.direnv +vendor + diff --git a/MantisSmalltech.php b/MantisSmalltech.php new file mode 100644 index 0000000..fcdb162 --- /dev/null +++ b/MantisSmalltech.php @@ -0,0 +1,52 @@ +name = plugin_lang_get( 'title' ); + $this->description = plugin_lang_get( 'description' ); + $this->page = ''; + + $this->version = '0.1'; + $this->requires = array( + 'MantisCore' => '2.3.0-dev', + ); + + $this->author = 'Irene Knapp'; + $this->contact = 'ireneista@internetsafetylabs.org'; + $this->url = 'https://irenes.space'; + + /* The MantisCoreFormatting plugin already does bug links. We could + * reimplement its logic, but it's simpler to just override its + * configuration. We set it in memory, not in the database, so that + * uninstalling MantisSmalltech will change it back. + * + * MantisCoreFormatting also has an "issue note" syntax, for links within + * a single issue thread. We leave that one at its default. + */ + config_set_global( 'bug_link_tag', 'b/', true ); + } + + /** + * plugin hooks + * @return array + */ + function hooks() { + $t_hooks = array( + 'EVENT_DISPLAY_BUG_ID' => 'display_bug_id', + ); + + return $t_hooks; + } + + function display_bug_id( $p_event_name, $p_string, $p_number ) { + return sprintf( 'b/%u', $p_number ); + } +} diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..58adc16 --- /dev/null +++ b/composer.json @@ -0,0 +1,13 @@ +{ + "name": "isl/mantis-smalltech", + "description": "The Smalltech extensions to the Mantis bug tracker", + "type": "mantis-plugin", + "license": "proprietary", + "authors": [ + { + "name": "Irene Knapp", + "email": "ireneista@internetsafetylabs.org" + } + ], + "require": {} +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..10559de --- /dev/null +++ b/composer.lock @@ -0,0 +1,18 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "7f17cf3dbd4616ae142a837cf7d3a169", + "packages": [], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": {}, + "prefer-stable": false, + "prefer-lowest": false, + "platform": {}, + "platform-dev": {}, + "plugin-api-version": "2.6.0" +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..c365793 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1759735786, + "narHash": "sha256-a0+h02lyP2KwSNrZz4wLJTu9ikujNsTWIC874Bv7IJ0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "20c4598c84a671783f741e02bf05cbfaf4907cff", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-25.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..75e49aa --- /dev/null +++ b/flake.nix @@ -0,0 +1,43 @@ +{ + inputs = { + nixpkgs = { + type = "github"; + owner = "NixOS"; + repo = "nixpkgs"; + ref = "nixos-25.05"; + }; + }; + + outputs = { nixpkgs, ... }: + let supportedSystems = [ "aarch64-linux" "x86_64-linux" ]; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; }); + in { + packages = forAllSystems (system: let pkgs = nixpkgsFor.${system}; in { + default = pkgs.php.buildComposerProject2 rec { + pname = "mantis-smalltech"; + version = "1.0"; + + src = ./.; + vendorHash = "sha256-xSUFx75c7z6IVBqnwV/CqnzhHZfSXTxFyOLyemhPb8Y="; + + dontBuild = true; + + postInstall = '' + mv $out/share/php/mantis-smalltech $out/MantisSmalltech + rmdir $out/share/php + rmdir $out/share + ''; + }; + }); + + devShells = forAllSystems (system: let pkgs = nixpkgsFor.${system}; in { + default = pkgs.mkShell { + buildInputs = with pkgs; [ + php + phpPackages.composer + ]; + }; + }); + }; +} diff --git a/lang/strings_english.txt b/lang/strings_english.txt new file mode 100644 index 0000000..ec164f6 --- /dev/null +++ b/lang/strings_english.txt @@ -0,0 +1,4 @@ +