summary refs log tree commit diff
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@internetsafetylabs.org>2025-10-08 02:10:24 -0700
committerIrene Knapp <ireneista@internetsafetylabs.org>2025-10-08 02:10:24 -0700
commit7dad24cb3d807d2aef23583aac2d48b70edb1903 (patch)
tree9b5e2c0dbfc1a08279e98c613c8dcd454ce78827
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
-rw-r--r--.envrc2
-rw-r--r--.gitignore5
-rw-r--r--MantisSmalltech.php52
-rw-r--r--composer.json13
-rw-r--r--composer.lock18
-rw-r--r--flake.lock27
-rw-r--r--flake.nix43
-rw-r--r--lang/strings_english.txt4
8 files changed, 164 insertions, 0 deletions
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 @@
+<?php
+
+/**
+ * Mantis plugin to make stylistic and navigation changes, as part of the
+ * Smalltech project.
+ */
+class MantisSmalltechPlugin extends MantisPlugin  {
+  /**
+   * A method that populates the plugin information and minimum requirements.
+   * @return void
+   */
+  function register() {
+    $this->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 @@
+<?php
+
+$s_plugin_MantisSmalltech_title = 'MantisSmalltech';
+$s_plugin_MantisSmalltech_description = 'The Smalltech extensions to the Mantis bug tracker';