Skip to content

New module

Thomas T. Jarløv edited this page Aug 7, 2018 · 2 revisions

PR's and new modules are welcome!

The current structure is done by hand. In the future modules will be loaded with a macro.

Structure

A module can consist of 4 things:

  1. Database proc
  2. HTML (*.tmpl file)
  3. WWW routes
  4. Custom proc's

Database proc

If a module needs to create a table in the database:

File

Filename:

<module>_database.nim

Folder:

nimhapkg/resources/database/modules/

Naming

The proc shall be named <module>Database.

Import file

The file needs to be imported by nimha.nim. Insert the filepath at the top of file, where the other database imports are located.

Execute proc

The proc is runned on each start. Insert the proc at the bottom of the proc proc createDbTables() = located in nimha.nim.

HTML (*.tmpl)

If the plugin needs HTML, this shall be created in a *.tmpl file.

File

Filename:

<module>.tmpl

Folder:

nimhapkg/tmpl/

Naming

The main HTML generator shall be named gen<Module>.

Include file

The file needs to be include in nimha_webinterface.nim. Insert include "../tmpl/<module>.tmpl where the other tmpl-files are located.

WWW routes

If the plugin needs routes. These should be added at the bottom of nimha_webinterface.nim.

Custom proc's

If the plugin needs custom proc's, create a new folder and create a Nim file within.

Filename: There is no specific requirement, but if possible include the modules name. If there is a need for more information than the modules name in the filename, then append this information.

Folder:

nimhapkg/resources/<module>

Interaction with other modules

Modules might need integration with existing modules such as the alarm. No current procedure for this is available. Please add an issue with your suggestion.