Compare commits
3 Commits
2d5c6a1377
...
v0.2
| Author | SHA1 | Date | |
|---|---|---|---|
| b25316e58f | |||
| 736bf1eac5 | |||
| 01af36d8c1 |
6
Asset/css/finance.css
Normal file
6
Asset/css/finance.css
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
/*
|
||||||
|
* FinanceBuddy styles.
|
||||||
|
*
|
||||||
|
* Empty for now. The money badge (.fb-badge / .fb-installments) and the per-column total
|
||||||
|
* (.fb-column-total) styling are added as those features land in later versions.
|
||||||
|
*/
|
||||||
1
Asset/css/skeleton.css
vendored
1
Asset/css/skeleton.css
vendored
@@ -1 +0,0 @@
|
|||||||
/* Skeleton plugin styles -- add CSS here. Loaded via template:layout:css. */
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
// Skeleton plugin script -- add JS here. Loaded via template:layout:js.
|
|
||||||
28
Helper/FinanceHelper.php
Normal file
28
Helper/FinanceHelper.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Kanboard\Plugin\FinanceBuddy\Helper;
|
||||||
|
|
||||||
|
use Kanboard\Core\Base;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Template/controller helper for FinanceBuddy.
|
||||||
|
*
|
||||||
|
* FinanceBuddy is opt-in per board: every render and save point is gated on isEnabled(), so an
|
||||||
|
* un-enabled board is untouched. The flag lives in project metadata (key financebuddy_enabled),
|
||||||
|
* written by the checkbox on the project's Integrations page.
|
||||||
|
*/
|
||||||
|
class FinanceHelper extends Base
|
||||||
|
{
|
||||||
|
const ENABLED_KEY = 'financebuddy_enabled';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is FinanceBuddy enabled for this board?
|
||||||
|
*
|
||||||
|
* @param integer $project_id
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isEnabled($project_id)
|
||||||
|
{
|
||||||
|
return (int) $this->projectMetadataModel->get($project_id, self::ENABLED_KEY, 0) === 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
32
Plugin.php
32
Plugin.php
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Kanboard\Plugin\Skeleton;
|
namespace Kanboard\Plugin\FinanceBuddy;
|
||||||
|
|
||||||
use Kanboard\Core\Plugin\Base;
|
use Kanboard\Core\Plugin\Base;
|
||||||
|
|
||||||
@@ -8,28 +8,32 @@ class Plugin extends Base
|
|||||||
{
|
{
|
||||||
public function initialize()
|
public function initialize()
|
||||||
{
|
{
|
||||||
// 1. Render a visible word at the top of every page (the demo output).
|
// Plugin stylesheet. Empty for now; the money badge and per-column total styling
|
||||||
$this->template->hook->attach('template:layout:top', 'skeleton:layout/header');
|
// are added as those features land in later versions.
|
||||||
|
|
||||||
// 2. Load the plugin stylesheet (currently empty -- proves the CSS hook fires).
|
|
||||||
$this->hook->on('template:layout:css', array(
|
$this->hook->on('template:layout:css', array(
|
||||||
'template' => 'plugins/Skeleton/Asset/css/skeleton.css',
|
'template' => 'plugins/FinanceBuddy/Asset/css/finance.css',
|
||||||
));
|
));
|
||||||
|
|
||||||
// 3. Load the plugin script (currently empty -- proves the JS hook fires).
|
// Per-board opt-in: a checkbox on the project's Settings -> Integrations page. Nothing
|
||||||
$this->hook->on('template:layout:js', array(
|
// else in the plugin renders or saves until a project manager enables it for that board.
|
||||||
'template' => 'plugins/Skeleton/Asset/js/skeleton.js',
|
$this->template->hook->attach('template:project:integrations', 'financeBuddy:project/integration');
|
||||||
));
|
}
|
||||||
|
|
||||||
|
public function getHelpers()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'Plugin\FinanceBuddy\Helper' => array('FinanceHelper'),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPluginName()
|
public function getPluginName()
|
||||||
{
|
{
|
||||||
return 'Skeleton';
|
return 'FinanceBuddy';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPluginDescription()
|
public function getPluginDescription()
|
||||||
{
|
{
|
||||||
return t('Reusable skeleton/template for building Kanboard plugins.');
|
return t('Attach a money value (debit/credit and installments) to board cards, shown on the card and totalled per column. Opt-in per board.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPluginAuthor()
|
public function getPluginAuthor()
|
||||||
@@ -39,12 +43,12 @@ class Plugin extends Base
|
|||||||
|
|
||||||
public function getPluginVersion()
|
public function getPluginVersion()
|
||||||
{
|
{
|
||||||
return '0.1.0';
|
return '0.2.0';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPluginHomepage()
|
public function getPluginHomepage()
|
||||||
{
|
{
|
||||||
return 'https://code.beco.cc/beco/kanboard-plugin-skeleton';
|
return 'https://code.beco.cc/beco/FinanceBuddy';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCompatibleVersion()
|
public function getCompatibleVersion()
|
||||||
|
|||||||
88
README.md
88
README.md
@@ -1,19 +1,39 @@
|
|||||||
# Skeleton -- a Kanboard plugin template
|
# FinanceBuddy -- money on your Kanboard cards
|
||||||
|
|
||||||
A minimal, working Kanboard plugin that you copy and rename as the starting point for a
|
Attach a money value to a board card, see it on the card, and total it per column -- so a
|
||||||
real plugin. By itself it does only one trivial thing: it renders the word "Skeleton" at
|
Kanboard project can double as a simple, visual finance board (bills, installments, income
|
||||||
the top of every page. It changes no data and runs no database migration.
|
vs expenses).
|
||||||
|
|
||||||
## What it demonstrates
|
FinanceBuddy is **opt-in per board**: installing it changes nothing until a project manager
|
||||||
|
enables it for a specific board under Settings -> Integrations. Boards that are not enabled
|
||||||
|
look exactly as before.
|
||||||
|
|
||||||
- A complete `Plugin.php` registration class with all the metadata Kanboard shows in
|
## The idea: a bill-lifecycle board
|
||||||
Settings -> Plugins (name, description, author, version, homepage, compatible version).
|
|
||||||
- A template hook (`template:layout:top`) that injects a template into the page.
|
Kanboard imposes no structure, so FinanceBuddy is built to fit one rather than dictate it. The
|
||||||
- Asset hooks (`template:layout:css` and `template:layout:js`) that load a stylesheet and
|
suggested organization:
|
||||||
a script. They are empty for now but prove the injection path works -- handy when a real
|
|
||||||
plugin needs custom CSS or JS.
|
- **Columns = a bill's status:** `Templates -> Due this month -> Paid`. Cards flow left to
|
||||||
- The standard plugin directory layout, with stub folders (`Controller/`, `Model/`,
|
right as they are paid.
|
||||||
`Schema/`, `Locale/`, `Test/`) ready to grow into.
|
- **Tags = category:** housing, utilities, comms, food...
|
||||||
|
- **Due date = the bill's due date;** color/priority = urgency.
|
||||||
|
- Each card carries a **money value** (debit or credit) and, optionally, an **installment**
|
||||||
|
count (`p2/10` = 2nd of 10 payments; leave the total blank for an open-ended recurring bill).
|
||||||
|
|
||||||
|
Recurring monthly bills can live as template cards spawned each month by the companion RecoReco
|
||||||
|
plugin; FinanceBuddy only owns the money.
|
||||||
|
|
||||||
|
## Money format
|
||||||
|
|
||||||
|
Amounts are shown in R$ with a comma decimal and no thousand separator (for example
|
||||||
|
`R$1234,56`). Input accepts either a dot or a comma as the decimal separator, so `1234.56` and
|
||||||
|
`1234,56` are the same value.
|
||||||
|
|
||||||
|
## Status
|
||||||
|
|
||||||
|
Early development. This version registers the plugin and loads its stylesheet; the per-board
|
||||||
|
toggle, the in-form editing, the card badge, and the per-column totals arrive in the following
|
||||||
|
versions.
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
@@ -21,45 +41,9 @@ the top of every page. It changes no data and runs no database migration.
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
No build step and no dependencies.
|
Copy this folder into your Kanboard installation as `plugins/FinanceBuddy/`. The directory name
|
||||||
|
must be exactly `FinanceBuddy` (Kanboard derives the plugin namespace from the folder name). No
|
||||||
1. Copy this folder into your Kanboard installation as `plugins/Skeleton/`.
|
build step and no database migration.
|
||||||
2. Reload any page. The word "Skeleton" appears at the top.
|
|
||||||
3. Confirm it under Settings -> Plugins.
|
|
||||||
|
|
||||||
To uninstall, delete `plugins/Skeleton/`. Nothing else is left behind.
|
|
||||||
|
|
||||||
## Directory layout
|
|
||||||
|
|
||||||
```
|
|
||||||
Skeleton/
|
|
||||||
Plugin.php Registration and hook wiring (the only required file).
|
|
||||||
README.md
|
|
||||||
LICENSE AGPL-3.0.
|
|
||||||
Template/
|
|
||||||
layout/header.php The visible "Skeleton" word.
|
|
||||||
Asset/
|
|
||||||
css/skeleton.css Loaded via template:layout:css.
|
|
||||||
js/skeleton.js Loaded via template:layout:js.
|
|
||||||
Controller/ Stub for future request handlers.
|
|
||||||
Model/ Stub for future business logic / DB access.
|
|
||||||
Schema/ Stub for future database migrations.
|
|
||||||
Locale/ Stub for future translations (e.g. pt_BR/, fr_FR/).
|
|
||||||
Test/ Stub for future unit tests.
|
|
||||||
```
|
|
||||||
|
|
||||||
## How to fork this into a new plugin
|
|
||||||
|
|
||||||
1. Copy the folder and rename it, e.g. `plugins/MyPlugin/`. The folder name must match the
|
|
||||||
namespace and start with a capital letter.
|
|
||||||
2. In `Plugin.php`, change the namespace from `Kanboard\Plugin\Skeleton` to
|
|
||||||
`Kanboard\Plugin\MyPlugin`.
|
|
||||||
3. Update the metadata methods (`getPluginName`, `getPluginDescription`, `getPluginAuthor`,
|
|
||||||
`getPluginVersion`, `getPluginHomepage`, `getCompatibleVersion`).
|
|
||||||
4. Update the hook target paths: the lowercase prefix in `'skeleton:layout/header'` and the
|
|
||||||
`plugins/Skeleton/Asset/...` asset paths must match the new plugin name.
|
|
||||||
5. Replace `Template/layout/header.php` with your real template, or attach to a different
|
|
||||||
hook. See the Kanboard plugin hooks documentation for the full list of hook points.
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
<div class="skeleton-plugin-marker">Skeleton</div>
|
|
||||||
20
Template/project/integration.php
Normal file
20
Template/project/integration.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<h3><i class="fa fa-money fa-fw" aria-hidden="true"></i> <?= t('FinanceBuddy') ?></h3>
|
||||||
|
<div class="listing">
|
||||||
|
<?php /* Hidden 0 before the checkbox so unchecking posts a value (a bare unchecked box posts
|
||||||
|
nothing, which would leave a stale 1). The checkbox's 1 wins when checked. The shared
|
||||||
|
Integrations form saves this straight into project metadata. */ ?>
|
||||||
|
<input type="hidden" name="<?= \Kanboard\Plugin\FinanceBuddy\Helper\FinanceHelper::ENABLED_KEY ?>" value="0">
|
||||||
|
<?= $this->form->checkbox(
|
||||||
|
\Kanboard\Plugin\FinanceBuddy\Helper\FinanceHelper::ENABLED_KEY,
|
||||||
|
t('Enable FinanceBuddy on this board'),
|
||||||
|
1,
|
||||||
|
isset($values['financebuddy_enabled']) && $values['financebuddy_enabled'] == 1
|
||||||
|
) ?>
|
||||||
|
<p class="form-help">
|
||||||
|
<?= t('When enabled, cards on this board can carry a money value (debit or credit, with optional installments), shown on the card and totalled per column. Boards left disabled are unaffected.') ?>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-actions">
|
||||||
|
<button type="submit" class="btn btn-blue"><?= t('Save') ?></button>
|
||||||
|
</div>
|
||||||
Reference in New Issue
Block a user