Added possibility to correlate extensions

arbadacarba 2023-07-15 10:47:08 +02:00
parent 545de8a55d
commit 652a8677c0

@ -65,51 +65,15 @@ Anyone can create an extension by following the [example extension](https://gith
Start off by copying the [extensions example](https://github.com/lnbits/example) into your own repo or find an extension that is similar to your approach and you want to change. We will explain the process starting off from the example but rather want to encourage you to take an existing one. Before you start also check [this guide](http://docs.lnbits.org/guide/extension-install.html) in textform or [this video from Ben](https://www.youtube.com/watch?v=98VYC99s770&t=295s).
```
sh
cp -r lnbits/example lnbits/mysuperplugin # Let's not use dashes or anything; it doesn't like those.
cd lnbits/mysuperplugin
find . -type f -print0 | xargs -0 sed -i 's/example/mysuperplugin/g' # Change all occurrences of 'example' to your plugin name 'mysuperplugin'.
```
- make sure your docker image is up to date
- if you are on macOS and having difficulty with 'sed', consider `brew install gnu-sed` and use 'gsed':
`find . -type f -print0 | xargs -0 gsed -i 's/example/mysuperplugin/g'`
Going over the example extension's structure:
* `views_api.py`: This is where your public API would go. It will be exposed at "$DOMAIN/$PLUGIN/$ROUTE". For example: https://legend-lnbits.com/mysuperplugin/api/v1/tools.
* `views.py`: The `/` path will show up as your plugin's home page in lnbits' UI. Other pages you can define yourself. The `templates` folder should explain itself in relation to this.
* `migrations.py`: Create database tables for your plugin. They'll be created automatically when you start lnbits.
Within the manifest you can also define correlations of those extensions with the parameter "dependencies".
If you do not plan to push your extension to LNbits official repo you can just add a manifest.json inside your extensions and add this info to the extension manifests inside your lnbits.
```
{
"repos": [
{
"id": "nameofyourextension",
"organisation": "yourcompany",
"repository": "nameofyourextensionrepo"
}
]
}
```
If you want to get your extension vetted later on, clone it to lnbits/extensions and work on it there.
If the naming turns out to be not possible to save (name conflicts) clone the extension repo and create a link like this:
```
- ln -s /Users/my-user/git-repos/my-extension-repo/ /Users/my-user/git-repos/lnbits/lnbits/extensions/myextension
````
Each extension has a unique ID. It should be the same as the name of the extension dir and the name that you see in the URL when you are using the extension e.g. http://127.0.0.1:5000/lnurlp/?usr=a2f52f9b396249c7a561f8917a5b2dbd where the ID is a lnurlp.
It is recommended for the ID to be alphaumeric only (no -, _, . etc).
Each extension has a unique ID. It should be the same as the name of the extension dir and the name that you see in the URL when you are using the extension e.g. http://127.0.0.1:5000/lnurlp/?usr=a2f52f9b396249c7a561f8917a5b2dbd where the ID is "lnurlp". It is recommended for the ID to be alphaumeric only (no -, _, . etc).
The repo name is recommended to be the same as the extension ID for a better overview, but it is not mandatory.
You dont need a zip or filehash if you dont want to deploy it to official LNbits extentensions.json repo.
If you do want to add it to LNbits you will need to create a release and [hash it](https://emn178.github.io/online-tools/sha256_checksum.html)
If you do want to add it to LNbits you will need to create a release and [hash it](https://emn178.github.io/online-tools/sha256_checksum.html).
If its not ment to get released with LNbits you can just update the hash property in your own extension.json.
Please also include the api-request parameters at least in your readme, especially for those, that will not be included into the LNbits repo.