eXaminator / kanka-foundry

FoundryVTT module to import information from kanka.io
MIT License
22 stars 9 forks source link

Logo of Kanka-Foundry

Supported Foundry Version Downloads Forge Installs Foundry Hub Endorsements ko-fi

Translation status

Kanka-Foundry

This is a module which integrates Kanka.io, a free worldbuilding and tabletop RPG campaign management tool, with Foundry Virtual Tabletop, allowing you to import entities written in Kanka as journal entries into Foundry VTT. This module imports full Kanka entities, including their main entry text, image, relations and other data. This is not an official module, but a fan creation by someone who uses both Kanka and Foundry VTT.

Screenshot of a journal entry after importing it from Kanka.Screenshot of the relation tab of a character after importing it.

Installation

This module can be installed from the Foundry Virtual Tabletop module browser, or by using the following module manifest url: https://github.com/eXaminator/kanka-foundry/releases/latest/download/module.json.

Features

Configuration

This module provides many configuration options to handle authentication to Kanka as well as details on how do display imported data.

Screenshot of the settings view.

Usage

After installing and configuring the module, you will find a button with the Kanka icon at the bottom of the Journal sidebar.

Screenshot of the kanka button in the Foundry VTT user interface.

Clicking this button will open an overview of all your Kanka entities based on their category. You can view the entities either as a list or in a grid view. Each entity has a button to link the entity. This will create a journal folder and import that entity into that folder. After linking an entity you will now see a button to open the linked journal entry, as well as a button to update this entity from Kanka. If the entity was changed in Kanka since the last update the entry will have a red background and an appropriate icon over its image. Automatically created folders can be renamed once they were created. The module will keep importing new entities into the same folder without problems.

Next to each category you will also find buttons to link all entities in that category that have not been linked before or to refresh all entities that are outdated. Please beware API request limits, see below.

Screenshot of the kanka browser from which entries can be imported.

API limitations

The Kanka API enforces certain rate limits. For most users this means that you cannot make more than 30 requests per minute. Kanka subscribers have a higher limit of 90 requests per minute. I have tried to limit the number of requests as best as possible, but there is always room for improvement, and some entries simply require more requests than others. This module monitors the amount of requests it is making against the Kanka API and will simply wait if the limit was reached. This can sometimes create wait times, especially when linking or updating many entities at once.

Outdated references

Many entities can reference other entities, like members of an organisation, inventories or just general relations. Each linked entity also keeps a list of those references so that it can display things like the name or image of those references. This can lead to situations, where these references are outdated, because the referenced entity was changed in Kanka. There are 2 ways to handle this:

  1. You can update the entity that has these references, in which case the references will also update.
  2. You can link (or update) the referenced entity itself. If Kanka-Foundry finds a Journal Entry for a referenced entity it will always take the information from that instead of its own snapshot for that reference.

Software License and Contribution Policy

This software is licensed under the MIT License. See the LICENSE file in this repository for details.

Contribution

All issues and merge requests are welcomed. But please understand if I cannot always immediately comment or review your contribution. Merge requests will always receive a code review by me and must adhere to my general standards and style (which are not really documented at this point). I at least expect eslint and typescript to not throw any errors when running npm run check.

Translations

I'm also happy to accept translations via weblate. You can go here to get more information on how to help: https://weblate.foundryvtt-hub.com/engage/kanka-foundry/

Running and Building the module

This module uses vite to build the code and allows using its dev-server. You need the following software installed on your computer:

Setup

Before you do anything else you should install all dependencies by running npm ci in the root folder of the module.

Next you might want to copy secrets.json.dist to a new file called secrets.json and fill out the information in that as appropriate for you. This file is used by Docker to download and runn foundry in later steps. If you try to avoid Docker you don't need this step.

If you want to get rid of typescript errors you need a folder named foundry-code in the root folder of this module. The simplest way to get that is to run ./sync-foundry-code.sh (which might not work in Windows, you should use wsl or something similar, but support for that is outside the scope of this module!). This script requires Docker to be installed on your system.

Building

You can run npm run build to build the module. The module code will be generated inside the dist folder.

You could now copy this folder into your Foundry modules folder, but you might need to restart foundry for it to get any changes. This is not necessary if you use the provided docker-compose.yml configuration to run Foundry in Docker. Read the next part for more info on this.

Dev-Server

The easiest way to test changes for this module is to run Foundry via the docker compose and then run the Vite Dev-Server. This will give you automatic browser reloads on changes (and even HMR for certain parts).

  1. Make sure you have done everything under "Setup" above.
  2. Create an initial build via npm run build
  3. Run Foundry via docker compose up.
  4. Run dev-server via npm start

You can now go to http://localhost:3000 and should see Foundry. Install other modules and rule systems as you see fit and create a world for your tests. Changes in the code should be reflected immediately or after a browser refresh (which should be made automatically).