Extensions as packaged file and project

Documentatie •
In dit artikel

This page gives a brief introduction of what CMake is and its implications with the Banana Plus software, beyond that it is explained how the project must be structured and how the files must be configured.

The chapters are:

  • Extension Package Definition file (qrc file).
  • Extension distribution package .sbaa.
  • The reference of: How to generate the package file.
  • The reference of:  Installing and running the extension.
  • Extension Project structure.
  • Multiple extensions in the same package.
  • The reference of: Unpack the package file.

Extension Package Definition file (qrc file)

The Definition file is a qrc file with a syntax of the Resource Collection Files (QRC) from the Qt Resource system
The qrc file is an xml that list the content of the packaged file.

The rcc compiler will then read the qrc and compress and package the content in a sbaa file. 

Example: ch.banana.script.report.jaml.qrc

<!DOCTYPE RCC><RCC version="1.0">
<qresource>
     <file>manifest.json</file>
     <file>ch.banana.script.report.jaml.js</file>
     <file>lib/jaml-all.js</file>
</qresource>
</RCC>

Minimum content of the qrc file

The Banana Extension Package should contains: 

  • A manifest file (see below).
    The manifest contains metadata relative to the package, like name, publisher. 
  • A valid javascript extension file

Other content of qrc file

  • Other javascript files (.js) used by the extension.
  • Other javascript extension file
    A single package can contains several extensions, also of different type.
    The package could contains one or more report extensions, import extensions and a general extensions.
  • stylesheets files (.css).
  • image files (.png, or .jpg).
  • qml files
  • any other files you need for your extensions.

Alias keyword

If you want to name the manifest file in another way you can use the alias keyword, so that the program will find a manifest.json file. 
The alias is necessary when you create multiple packages and the files are in the same folder, so you need to have different manifest.json.  

<!DOCTYPE RCC><RCC version="1.0">
<qresource>
    <file alias="manifest.json">ch.banana.script.report.vat-ch.manifest.json</file>
    <file>ch.banana.script.report.vat-ch.js</file>
</qresource>
</RCC>

 

Extension distribution package .sbaa

In order to distribute the extension you need to compile the qrc extension file to a .sbaa file.

  • To compile the qrc file the rcc utility is used.
  • The rcc compiler is a utility provided within by the QT framework.
    Banana Accounting include a copy of the rcc compiler.
  • The .sbaa file will contains all the files specified in the qrc, in a compressed form. 

Installing the extension package:

  • The .sbaa Extension needs to be installed through the Manage Extensions command.
  • Once the Extension is installed, it appears in the menu Extensions.
  • The Extension can be run from the menu Extensions.

How to generate the package file

When you generate a package .sbaa you can :

Installing and running the extension

Prior to run the extension you need to install it.

See: Installation & Execute Extensions

Manifest file

If you create a .sbaa file, also include a manifest file. The manifest.json file is a JSON-formatted file, which you can include in the .sbaa file through the .qrc file.
Using manifest.json, you specify basic metadata about your package such as the title, description and version.
The file name must end with the extension 'manifest.json'

Example: ch.banana.script.report.vat-ch.manifest.json

{
    "category": "import",
    "country":"switzerland",
    "countryCode":"ch",
    "description": "Postfinance Schweiz (Bewegungen importieren): ISO20022 und CSV Format",
    "description.en": "Swiss Postfinance (Import transactions): ISO20022 and CSV File Format",
    "language":"de",
    "publisher": "Banana.ch",
    "title": "Postfinance Schweiz (Bewegungen importieren)",
    "title.en": "Swiss Postfinance (Import transactions)",
    "version": "1.0"
}

Options for the files.

  • All tags are optional.
  • Categories
    • Valid categories are:
      export, import, invoice, invoice reminder, invoice statement, productivity. 
    • The category is used to displayed information on the Manage extension Dialog. 
      You need to choose a categorization type even if the package contains multiple extensions of different type. 
      In case of doubt use productivity. 
    • If you don't specify the category ("category": ""), the program will take the category from the first app included in the package. 
  • description
  • title
    Is used in the Menu Extensions to run the extensions.
    • If you have multiple extensions it becomes the title of the submenu that will contains all other extensions. 
    • The extensions will be listed in alphabetic order. 
      If you want a specific order precede the description of the extension with a number.
  • Country 
    • If you don't specify country or language, the app will be shown for any country or language;
  • Language
    You can specify more than one language.
  • Translations
    You can add translation by using the "description" followed by a dot and the language code. 

 

Extension Project structure

We advise to create a separate folder for each extension that you create. The folder will contains all the file needed by the project:

Folder structure

Create this folder structure, and add source files, images or folder as needed. 
We recommend to use as a file name the same as the extension's id. The extension's id is the unique identification of the script and is specified within the extension's attributes, and it is important that you avoid having duplicates.
Therefore replace <extension_id> with the desired extension's id. 

You can start by using a  Simple project template. 

Or you can create the folder structure manually.


  CMakeList.txt                              CMake project file
  <extension_id>.js                          Extension's code
  <extension_id>.manifest.json               Metadata such title, description and version
  <extension_id>.qrc                         List of files included in the package
  <extension_id>.sbaa                        Buided package
  changelog.md                               Change history
  /test                                      Test code
     /testcases                                 Test data (ac2 files, csv files, ...)
     /testexpcted                               Expected test results
     /testresults                               Results of last runned test
     <extension_id>.test.js                     Test code
  LICENCE                                    Extension licence 
  README.md                                  Repository main documentation page

 

LICENSE

A project's LICENSE file in CMake is a document that specifies the legal terms for using, modifying, and distributing the project's source code and binaries. The LICENSE file should contain the name of the license you choose, a brief description of its terms, and a full copy of the license text.

Readme.md

This file contain the explanation of the functionalities and the other detail about about your extension. Is the main file that contain the documentation of your extension.

Multiple extensions in the same package

The package file can contains multiple extensions. An extension is a Javascript file that has the extension attribute with the extension Id.

Depending on the extension @type and @visibility option the extension will be than available on the Extension's menu or in the specific dialog (for example import, invoice printing, etc.).

Unpack the package file

A project's that will unpack the package.

 

Help ons de documentatie te verbeteren

We horen graag uw feedback over hoe we deze pagina kunnen verbeteren.

Vertel ons welk thema een betere uitleg nodig heeft of hoe we een onderwerp kunnen verduidelijken.

Share this article: Twitter | Facebook | LinkedIn | Email