5 Commits 815d2b10f3 ... 3e63a5965d

Author SHA1 Message Date
  sirjeff 3e63a5965d Release 1.0.4 4 weeks ago
  sirjeff 7f179779ef Renamed README.md to readme.md 4 weeks ago
  sirjeff 006109c747 Renamed README.md to readme.md 4 weeks ago
  sirjeff 14d84cad98 added instructions for the custom colour file 4 weeks ago
  sirjeff 3c54284109 added custom colours file to read custom colours from 4 weeks ago
7 changed files with 128 additions and 58 deletions
  1. 37 0
      Model/CustomColorModel.php
  2. 6 1
      Plugin.php
  3. 42 45
      Template/header.php
  4. 8 7
      Template/project_branding/show.php
  5. 23 3
      readme.md
  6. 11 1
      release.md
  7. 1 1
      ver

+ 37 - 0
Model/CustomColorModel.php

@@ -0,0 +1,37 @@
+<?php namespace Kanboard\Plugin\OMIProjectBranding\Model;
+
+use Kanboard\Model\ColorModel;
+
+class CustomColorModel extends ColorModel {
+  /**
+  * CustomColorModel Model
+  * Get all available colors.
+  *
+  * @access public
+  * @param bool $prepend
+  * @return array
+  * @author   Dwayne @ OMI NZ
+  */
+  public function getList($prepend = false) {
+    $colors = parent::getList($prepend);
+    $colorFile = DATA_DIR . DIRECTORY_SEPARATOR . "OMIProjectBrandingColours.txt";// Define the path to your color file
+    if (! file_exists($colorFile)) {// Check if the file exists, if not create it
+      $defaultContent = "Aqua=aqua\nBeige=beige\nBlack=black\nDark Blue=darkblue\nFuchsia=fuchsia\nGray=gray\nIndigo=indigo\nMaroon=maroon\nNavy=navy\nOlive=olive\nSlategrey=slategrey\nWhite=white\nWhitesmoke=whitesmoke";
+      file_put_contents($colorFile, $defaultContent);
+    }
+    $handle = fopen($colorFile, "r");// read from $colorFile
+    if ($handle) {
+      while (($line = fgets($handle)) !== false) {
+        $line = trim($line);
+        if (!empty($line)) {
+          list($name, $colorCode) = explode("=", $line, 2);// Split the line into name and color code
+          $colors[trim($colorCode)] = t(trim($name));// Add the color to the list
+        }
+      }
+      fclose($handle);
+    }
+    return $colors;
+  }
+}
+#-
+#plugins/OMIProjectBranding/Model/CustomColorModel.php

+ 6 - 1
Plugin.php

@@ -2,6 +2,7 @@
 
 use Kanboard\Core\Plugin\Base;
 use Kanboard\Core\Translator;
+use Kanboard\Plugin\OMIProjectBranding\Listener\ColorListExtender;
 
 /**
  * Plugin Initialisation
@@ -15,6 +16,9 @@ class Plugin extends Base {
     $this->hook->on("template:project:sidebar", ["template" => "OMIProjectBranding:project/sidebar"]);
     $this->route->addRoute("project/:project_id/branding", "ProjectBrandingController", "show", "OMIProjectBranding");
     $this->template->setTemplateOverride("header", "OMIProjectBranding:header");
+    $this->container["colorModel"] = $this->container->factory(function ($c) {
+      return new \Kanboard\Plugin\OMIProjectBranding\Model\CustomColorModel($c);
+    });
   }
   
   public function getClasses() {
@@ -24,6 +28,7 @@ class Plugin extends Base {
       ],
       "Plugin\OMIProjectBranding\Model" => [
         "ProjectBrandingModel",
+        "CustomColorModel",
       ],
       "Plugin\OMIProjectBranding\Helper" => [
         "ProjectBrandingHelper",
@@ -44,7 +49,7 @@ class Plugin extends Base {
   }
   
   public function getPluginVersion() {
-    return "1.0.3";
+    return "1.0.4";
   }
   
   public function getPluginHomepage() {

+ 42 - 45
Template/header.php

@@ -21,59 +21,56 @@ if (isset($project) && isset($project["id"])) {
 
 <?php if (isset($branding["enabled"]) && $branding["enabled"] == 1 && !empty($branding["logo_url"])): ?>
 <style>
-header{
-background-color:<?= $branding['background_color'] ?>;
-}
-.project-header{
- background-color:<?= $branding['second_background_color'] ?>;
-}
-h1 {
- color:<?= $branding['foreground_color'] ?>;
- background-color:<?= $branding['background_color'] ?>;
-}
-span.logo a{
-vertical-align: middle;
-margin-right:5px;
-opacity:1;
-}
+  .page {
+    margin:0 auto;
+  }
+  header{
+    background-color:<?= !empty($branding["background_color"]) ? $branding["background_color"] : "transparent" ?> !important;
+    margin-bottom:0;
+  }
+  .project-header{
+    background-color:<?= !empty($branding["second_background_color"]) ? $branding["second_background_color"] : "transparent" ?>;
+    padding:.5em;
+    height: 1.5em;
+  }
+  h1 {
+    color:<?= !empty($branding["foreground_color"]) ? $branding["foreground_color"] : "initial" ?>;
+    background-color:<?= !empty($branding["background_color"]) ? $branding["background_color"] : "transparent" ?>;
+  }
+  span.logo a{
+    vertical-align: middle;
+    margin-right:5px;
+    opacity:1;
+  }
 </style>
 <?php endif ?>
 
-
 <header>
   <div class="title-container">
-
-  
-  
-<h1>
-    <span class="logo">
-    <?php if (isset($branding["enabled"]) && $branding["enabled"] == 1 && !empty($branding["logo_url"])): ?>
-
+    <h1>
+      <span class="logo">
+      <?php if (isset($branding["enabled"]) && $branding["enabled"] == 1 && !empty($branding["logo_url"])): ?>
       <a href="<?= $this->url->to('DashboardController', 'show') ?>">
         <img src="<?= $branding['logo_url'] ?>" alt="<?= t('Logo') ?>" height="32">
-      </a>
-          
-    <?php else: ?>
-      <?= $this->url->link('K<span>B</span>', 'DashboardController', 'show', array(), false, '', t('Dashboard')) ?>
-    <?php endif ?>
-    </span>
-    <span class="title">
-        <?php if (! empty($project) && ! empty($task)): ?>
-            <?= $this->url->link($this->text->e($project['name']), 'BoardViewController', 'show', array('project_id' => $project['id'])) ?>
-        <?php else: ?>
-            <?= $this->text->e($title) ?>
-            <?php if (! empty($project) && $project['task_limit'] && array_key_exists('nb_active_tasks', $project)): ?>
-              (<span><?= intval($project['nb_active_tasks']) ?></span> / <span title="<?= t('Task limit') ?>"><span class="ui-helper-hidden-accessible"><?= t('Task limit') ?> </span><?= $this->text->e($project['task_limit']) ?></span>)
-            <?php endif ?>
-        <?php endif ?>
-    </span>
-    <?php if (! empty($description)): ?>
+      </a>          
+      <?php else: ?>
+        <?= $this->url->link("K<span>B</span>", "DashboardController", "show", [], false, "", t("Dashboard")) ?>
+      <?php endif ?>
+      </span>
+      <span class="title">
+      <?php if (! empty($project) && ! empty($task)): ?>
+          <?= $this->url->link($this->text->e($project["name"]), "BoardViewController", "show", ["project_id" => $project["id"]]) ?>
+      <?php else: ?>
+          <?= $this->text->e($title) ?>
+          <?php if (! empty($project) && $project["task_limit"] && array_key_exists("nb_active_tasks", $project)): ?>
+            (<span><?= intval($project["nb_active_tasks"]) ?></span> / <span title="<?= t('Task limit') ?>"><span class="ui-helper-hidden-accessible"><?= t("Task limit") ?> </span><?= $this->text->e($project["task_limit"]) ?></span>)
+          <?php endif ?>
+      <?php endif ?>
+      </span>
+      <?php if (! empty($description)): ?>
         <?= $this->app->tooltipHTML($description) ?>
-    <?php endif ?>
-</h1>
-
-
-
+      <?php endif ?>
+    </h1>
   </div>
   <div class="board-selector-container">
     <?php if (! empty($board_selector)): ?>

+ 8 - 7
Template/project_branding/show.php

@@ -5,9 +5,9 @@
 <form method="post" action="<?= $this->url->to('ProjectBrandingController', 'show', ['project_id' => $project['id'], 'plugin' => 'OMIProjectBranding']) ?>" autocomplete="off">
   <?= $this->form->csrf() ?>
   
-  <div class="form-help">
-    <?= t("Configure the logo and primary color for this project.") ?>
-  </div>
+  <p>
+    <?= t("Configure the header logo and colours for this project.") ?>
+  </p>
   
   <?= $this->form->label(t("Enable custom branding"), "enabled") ?>
   <?= $this->form->checkbox("enabled", "", 1, $branding["enabled"] ?? 0) ?>
@@ -16,13 +16,14 @@
   <?= $this->form->text("logo_url", $branding, [], ['placeholder="https://example.com/logo.png"']) ?>
   
   <?= $this->form->label(t("Foreground Color"), "foreground_color") ?>
-  <?= $this->form->text("foreground_color", $branding, [], ['type="color"']) ?>
+  <?= $this->form->colorSelect("foreground_color", $branding) ?>
 
+    
   <?= $this->form->label(t("Background Color"), "background_color") ?>
-  <?= $this->form->text("background_color", $branding, [], ['type="color"']) ?>
-  
+  <?= $this->form->colorSelect("background_color", $branding) ?>
+
   <?= $this->form->label(t("Secondary Background Color"), "second_background_color") ?>
-  <?= $this->form->text("second_background_color", $branding, [], ['type="color"']) ?>
+  <?= $this->form->colorSelect("second_background_color", $branding) ?>
   
   <div class="form-actions">
     <button type="submit" class="btn btn-blue"><?= t("Save") ?></button>

+ 23 - 3
README.md → readme.md

@@ -67,12 +67,32 @@ This message will change when the code is finalised :)
 
 Use the "Branding" link in the left hand menu when you're in a project.  
 You can modify the logo per project by entering an image URL ( no upload possible here ) into the 'Logo URL' field.  
-The 'Accent Color' colour currently underlines the logo and that's all. It was just part of a PoC.  
-Still WiP so check back later :)  
+The header colours, background and foreground can also be modified, via a dropdown list of built in colours and custom colours that you can add yourself [See the 'Custom Colours File' below](#custom-colours-file).  
+
+## Custom Colours File
+
+The dropdown colour picker uses a built in list, which has a limited number of colours.  
+This plugin adds a set of custom colours to this list, and also allows you to modify the list so you can add your own colours.  
+The list is a simple Name=Value style text file called `OMIProjectBrandingColours.txt` living in your data folder.  
+It goes, **friendly colour name**=**css colour**   
+e.g.  
+```css
+Light-as Yellow=#ff9
+White=#fff
+This is also white=#ffffff
+HoT PinK=hotpink
+Faded Red=rgba(255,0,0,0.5)
+```  
+Don't forget to back this file up if you upgrade your Kanboard.  
 
 ## Compatibility 
 Compatibility with other Plugins.  
-So far I know it works with Customizer, but it will override the global logo ( which is the point of this plugin ).  
+So far I've used it successfully with Customizer, and WeKanboard.  
+It will override the global logo ( which is the point of this plugin ) in the header when you're in a project.  
+
+Please let me know if there are any issues with the header styles, when using other plugins.  
+[You can add issues here.](https://vcs.nz/ominz/OMIProjectBranding/issues/)  
+
 
 ## Maintainers
 

+ 11 - 1
release.md

@@ -1,4 +1,14 @@
-# Release Notes 
+# Release Notes  
+
+## v1.0.4 2025-08-14 *[more_styles]*  
+Why the version jump? This was so I could test the database `drop table` which only kicks in via a version _after_ the initial one.  
+I think it took 2 tries to get it going :/  
+
+- Added 3 fields to the db `foreground_color`, `background_color` & `second_background`  
+- Added the drop table statement to the `Sqlite.php` schema file.  
+- Added custom routine that builds the "data/OMIProjectBrandingColours.txt" file.  
+  Used for adding custom colours.  
+- Removed Herobrine . 
 
 ## v1.0.1 2025-08-12 *[main]*
 

+ 1 - 1
ver

@@ -1 +1 @@
-1.0.3
+1.0.4