Basic extension template for Platform.Bible
This is a webpack project template pre-configured to build a Platform.Bible extension. It contains the bare minimum of what an extension needs. Note that the *.web-view.*
files and the public/assets
folder mentioned in Summary are not present in this template. For inspiration on what these could look like, refer to any extension that is built using this template. An example would be the Text Collection extension.
There is also a template pre-configured to build an arbitrary number of Platform.Bible extensions in one repo.
Follow these instructions to customize the template to be your own Platform.Bible extension. This section is a more compact version of the Your first extension
guide.
Note: please skip this section and continue with Replace placeholders if you are following these instructions as part of creating an extension within paranext-multi-extension-template
.
To make the process of customizing from the template as smooth as possible, we recommend you do the following before anything else:
-
At the top of this
README.md
:- Replace the first line
# paranext-extension-template
with# your-extension-name
- Below the first line, replace the extension description with your own description
- In the Summary section, replace
src/types/paranext-extension-template.d.ts
withsrc/types/<your_extension_name>.d.ts
- Replace the first line
-
In
manifest.json
:- Replace
paranext-extension-template
withyour-extension-name
(2 occurrences) - Replace the description with your own description
- Update ownership information and other relevant fields as desired
- Replace
-
In
package.json
:- Replace
paranext-extension-template
withyour-extension-name
(2 occurrences) - Replace the description with your own description
- Update ownership information and other relevant fields as desired
- Replace
-
In
LICENSE
:- Adjust as desired (feel free to choose a different license)
- If you choose to stay with the current license, update the copyright statement
-
Rename
src/types/paranext-extension-template.d.ts
tosrc/types/<your_extension_name>.d.ts
- In this renamed file, replace
paranext-extension-template
withyour-extension-name
- In this renamed file, replace
-
In
src/main.ts
, replaceExtension template
withYour Extension Name
(2 occurrences)
The manifest.json
and package.json
files contain information specific to your extension. Add your extension's details in these two files as needed. See more information on the manifest.json
and package.json
files in Extension Anatomy.
Once finished customizing this template to be your own, you can remove the Template Info section and sub-sections of this readme.
The general file structure is as follows:
package.json
contains information about this extension's npm package. It is required for Platform.Bible to use the extension properly. It is copied into the build foldermanifest.json
is the manifest file that defines the extension and important properties for Platform.Bible. It is copied into the build foldersrc/
contains the source code for the extensionsrc/main.ts
is the main entry file for the extensionsrc/types/paranext-extension-template.d.ts
is this extension's types file that defines how other extensions can use this extension through thepapi
. It is copied into the build folder*.web-view.tsx
files will be treated as React WebViews*.web-view.html
files are a conventional way to provide HTML WebViews (no special functionality)
assets/
contains asset files the extension and its WebViews can retrieve using thepapi-extension:
protocol. It is copied into the build foldercontributions/
contains JSON files the platform uses to extend data structures for things like menus and settings. The JSON files are referenced from the manifestpublic/
contains other static files that are copied into the build folderdist/
is a generated folder containing the built extension filesrelease/
is a generated folder containing a zip of the built extension files
- Follow the instructions to install
paranext-core
. - In this repo, run
npm install
to install local and published dependencies
In order to interact with paranext-core
, you must point package.json
to your installed paranext-core
repository:
- Follow the instructions to install
paranext-core
. We recommend you cloneparanext-core
in the same parent directory in which you cloned this repository so you do not have to reconfigure paths toparanext-core
. - If you cloned
paranext-core
anywhere other than in the same parent directory in which you cloned this repository, update the paths toparanext-core
in this repository'spackage.json
to point to the correctparanext-core
directory.
To run Platform.Bible with this extension:
npm start
Note: The built extension will be in the dist
folder. In order for Platform.Bible to run this extension, you must provide the directory to this built extension to Platform.Bible via a command-line argument. This command-line argument is already provided in this package.json
's start
script. If you want to start Platform.Bible and use this extension any other way, you must provide this command-line argument or put the dist
folder into Platform.Bible's extensions
folder.
To watch extension files (in src
) for changes:
npm run watch
To build the extension once:
npm run build
To package this extension into a zip file for distribution:
npm run package
This extension project is forked from paranext-extension-template
, which is updated periodically and will sometimes receive updates that help with breaking changes on paranext-core
. We recommend you periodically update your extension by merging the latest template updates into your extension.
To set up this extension to be updated from the template, run the following command once after cloning this repo:
git remote add template https://github.com/paranext/paranext-extension-template
To update this extension from the template, make sure your repo has no working changes. Then run the following commands:
git fetch template
git merge template/main --allow-unrelated-histories
For more information, read the instructions on the wiki.
Note: The merge/squash commits created when updating this repo from the template are important; Git uses them to compare the files for future updates. If you edit this repo's Git history, please preserve these commits (do not squash them, for example) to avoid duplicated merge conflicts in the future.
This project has special features and specific configuration to make building an extension for Platform.Bible easier. See Special features of paranext-multi-extension-template
for information on these special features.