Skip to content

Commit

Permalink
Add template importer (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethWussmann authored Feb 26, 2024
1 parent 66f08c1 commit fccbb34
Show file tree
Hide file tree
Showing 25 changed files with 3,588 additions and 5,419 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- ✅ Collaborate on inventories with teams. [Explore collaboration](./docs/usage/teams.md)
- ✅ Secure access with Single Sign-On (SSO). [Set up SSO](./docs/hosting/configuration.md#authentication)
- ✅ Leverage advanced search capabilities through [MeiliSearch](https://www.meilisearch.com/)
- ✅ Share your Panthora structure using Templates or use AI 🤖 to generate your inventory structure. [Learn how](./docs/usage/templates.md)
- ✅ Fully responsive design, ensuring accessibility on any device, with support for light and dark modes for optimal viewing comfort.

<div align="center">
Expand Down
15 changes: 15 additions & 0 deletions docs/templates/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Templates

This directory contains templates that can be imported into Panthora to bootstrap asset types and tags easily.

## Examples

1.[Book Library](./book-library.json) - The book library described in the [example Use-Case](../usage/example-home-library.md)

## Writing Templates

Refer to the [Template Guide](../usage/templates.md) for more information.

## Contribute

Please open Pull Requests that add more examples to showcase what you do with Panthora!
117 changes: 117 additions & 0 deletions docs/templates/book-library.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
{
"$schema": "../../schemas/import-0.2.0.schema.json",
"name": "Book Library",
"version": "1.0",
"description": "Use Panthora as your book library.",
"author": "Panthora",
"tags": [
{
"id": "Genre",
"name": "Genre",
"children": [
{ "id": "Fiction", "name": "Fiction", "children": [] },
{ "id": "Non-Fiction", "name": "Non-Fiction", "children": [] },
{ "id": "Mystery", "name": "Mystery", "children": [] },
{
"id": "Science Fiction",
"name": "Science Fiction",
"children": [
{ "id": "Dystopian", "name": "Dystopian", "children": [] },
{ "id": "Space Opera", "name": "Space Opera", "children": [] }
]
}
]
},
{
"id": "Location",
"name": "Location",
"children": [
{ "id": "Living Room", "name": "Living Room", "children": [] },
{ "id": "Bedroom", "name": "Bedroom", "children": [] },
{ "id": "Study", "name": "Study", "children": [] }
]
},
{
"id": "Reading Status",
"name": "Reading Status",
"children": [
{ "id": "Read", "name": "Read", "children": [] },
{ "id": "Unread", "name": "Unread", "children": [] },
{ "id": "Reading", "name": "Reading", "children": [] }
]
},
{
"id": "Loan Status",
"name": "Loan Status",
"children": [
{ "id": "Available", "name": "Available", "children": [] },
{ "id": "Borrowed", "name": "Borrowed", "children": [] }
]
}
],
"assetTypes": [
{
"name": "Book",
"fields": [
{
"type": "STRING",
"name": "Title",
"inputRequired": true,
"showInTable": true
},
{
"type": "STRING",
"name": "Author",
"inputRequired": true,
"showInTable": true
},
{
"type": "STRING",
"name": "ISBN",
"inputRequired": false,
"showInTable": false
},
{
"type": "TAG",
"name": "Genre",
"parentTagId": "Genre",
"inputMin": 1,
"inputRequired": true,
"showInTable": true
},
{
"type": "TAG",
"name": "Location",
"parentTagId": "Location",
"inputMax": 1,
"inputRequired": false,
"showInTable": false
},
{
"type": "TAG",
"name": "Reading Status",
"parentTagId": "Reading Status",
"inputMax": 1,
"inputMin": 1,
"inputRequired": true,
"showInTable": true
},
{
"type": "TAG",
"name": "Loan Status",
"parentTagId": "Loan Status",
"inputMax": 1,
"inputMin": 1,
"inputRequired": true,
"showInTable": false
},
{
"type": "STRING",
"name": "Borrower",
"inputRequired": false,
"showInTable": false
}
]
}
]
}
6 changes: 6 additions & 0 deletions docs/usage/example-home-library.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,9 @@ This home library use case illustrates Panthora's ability to:
- **Adapt and Scale:** Whether you’re cataloging a few dozen books or a vast collection spanning thousands, Panthora adjusts to your needs.

By applying Panthora to manage your home library, you transform a simple book collection into a dynamic, accessible, and shared resource for your household, enhancing the reading experience for everyone.

## Use this Template

You can directly import this Home Library into your Panthora using [Templates](./templates.md). The template for this use-case can be found here: [Book Library](../templates/book-library.json).

See the [Template Guide](./templates.md) to learn how to use it.
42 changes: 42 additions & 0 deletions docs/usage/templates.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Templates

Templates are specialized JSON formats that define the structure of asset types and tags. These templates enable the sharing of Panthora use-case structures in a standardized manner, facilitating collaboration and reuse.

## Writing a Template

Templates are crafted in JSON format. To begin, create a new JSON file, such as `book-library.json`, with the following structure:

```JSON
{
"$schema": "../../schemas/import-0.2.0.schema.json",
"name": "Book Library",
"version": "1.0",
"description": "A concise description of the template's purpose.",
"author": "Your Name",
"tags": [],
"assetTypes": []
}
```

Utilizing an editor like [VSCode](https://code.visualstudio.com/) enhances the experience by offering code completion guided by the `$schema`, aiding in the accurate development of the template.

To populate the template, add tags and asset types as needed. Refer to the [example templates for inspiration](../templates/) and guidance on potential configurations.

## Leveraging AI for Panthora Structure Generation

For those seeking a more streamlined approach, the AI-powered generator simplifies the template creation process. By providing a brief description of the intended Panthora use-case, the AI generates a bespoke template that can be directly imported into Panthora, eliminating the need for manual JSON composition.

Access the AI generator here: [Panthora AI](https://chat.openai.com/g/g-3bQ9bDq9a-panthora)

## Importing Template

To integrate a template into Panthora, follow these steps:

1. Open Panthora.
2. Press <kbd>Command</kbd> + <kbd>K</kbd> (or <kbd>Ctrl</kbd> + <kbd>K</kbd> on Windows) to open the command palette.
3. Type `import` and select `Import Template`.
4. Insert the JSON of your template and select `Import` to complete the process.

## Contribute

Please open Pull Requests that add more examples to showcase what you do with Panthora!
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"lint": "next lint",
"start": "next start",
"test": "vitest --passWithNoTests",
"dependency-update": "npm-check-updates -u --filterVersion \"/^[~^<>]| - |\\.x$/\" --deep && pnpm install"
"dependency-update": "npm-check-updates -u --filterVersion \"/^[~^<>]| - |\\.x$/\" --deep && pnpm install",
"generate-schema": "tsx scripts/generate-import-schema.ts"
},
"engines": {
"node": "20",
Expand Down Expand Up @@ -81,7 +82,8 @@
"tsx": "^4.7.1",
"typescript": "^5.3.3",
"vitest": "^1.3.1",
"vitest-mock-extended": "^1.3.1"
"vitest-mock-extended": "^1.3.1",
"zod-to-json-schema": "^3.22.4"
},
"ct3aMetadata": {
"initVersion": "7.22.0"
Expand Down
Loading

0 comments on commit fccbb34

Please sign in to comment.