Skip to content

Commit

Permalink
Merge pull request #3 from tyclipso/rendering-api
Browse files Browse the repository at this point in the history
Add data_source and resource for rendering api of wikijs
  • Loading branch information
MarauderXtreme authored Oct 25, 2024
2 parents cd906a9 + 664b46a commit 75d7232
Show file tree
Hide file tree
Showing 15 changed files with 1,294 additions and 20 deletions.
56 changes: 56 additions & 0 deletions docs/data-sources/renderers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "wikijs_renderers Data Source - terraform-provider-wikijs"
subcategory: ""
description: |-
The wikijs_renderers Data Source implements the WikiJS API query rendering{renderers{…}}.
You can use this data source to manipulate only certain fields with the renderers resource.
---

# wikijs_renderers (Data Source)

The `wikijs_renderers` Data Source implements the WikiJS API query `rendering{renderers{…}}`.
You can use this data source to manipulate only certain fields with the `renderers` resource.

## Example Usage

```terraform
# Use this data source to query the current setup and make changes in
# certain renderers. Note that this data source only takes an empty
# renderers list.
data "wikijs_theme_renderers" "renderers" {
renderers = []
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `renderers` (Attributes List) List of renderers in the system. (see [below for nested schema](#nestedatt--renderers))

<a id="nestedatt--renderers"></a>
### Nested Schema for `renderers`

Read-Only:

- `config` (Map of String) A list of Key/Value pairs of config for each renderer.
Some take none, others have a long list.
You can use this field in the `renderers` ressource.
- `depends_on` (String) The `key` of the renderer, this renderer depends on.
This could be `markdownCore` for a markdown renderer.
The `renderers` ressource currently does not check against this, so make sure to activate them.
- `description` (String) The description of the renderer shown in the backend.
- `icon` (String) The icon of the renderer shown in the backend.
- `input` (String) What kind of input format this renderer takes.
This could be for example `markdown`, `asciidoc`, `openapi`, `html` or `null`.
- `is_enabled` (Boolean) Either if the renderer is active or not.
You can use this field in the `renderers` ressource.
- `key` (String) The unique identifier of each renderer.
This is set in code and you can use this field in the `renderers` ressource.
- `output` (String) What kind of output format this renderer produces.
This could be for example `html` or `null`.
- `title` (String) The title of the renderer shown in the backend.


9 changes: 4 additions & 5 deletions docs/data-sources/themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ In wikijs [v2][api-themes] this contains only the default theme.
## Example Usage

```terraform
# This data source currently only returns a list with one item
# The themes query is hardcoded to only respond with the default
# theme in v2
# This data source currently only returns a list with one item. The
# themes query is hardcoded to only respond with the default theme in v2
data "wikijs_themes" "themes_list" {
themes = []
}
# You could use it to reset the theme but it seems easier to just
# write "default"
# You could use it to reset the theme but it seems easier to just write
# "default"
resource "wikijs_theme_config" "theme_config" {
theme = data.wikijs_themes.themes_list[0].key
iconset = "mdi"
Expand Down
3 changes: 1 addition & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ provider "wikijs" {
## Configure a login for elevated rights
```terraform
# If you want to edit content or administer the wiki
# you need to login
# If you want to edit content or administer the wiki you need to login

terraform {
required_providers {
Expand Down
277 changes: 277 additions & 0 deletions docs/resources/renderers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,277 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "wikijs_renderers Resource - terraform-provider-wikijs"
subcategory: ""
description: |-
The wikijs_renderers Resource implements the WikiJS API mutatation rendering{updateRenderers{renderers{…}}}.
Be aware.
This Resource supports only one instance as the implementation needs the complete configuration of renderers.
You cannot specify one renderer with its config as this will erase the complete list.
If you are unsure about the key and config fields, you can query the API after activating it manually or with the wikijs_api resource.
The query with the minimal information you need is as follows:
graphql
query{
rendering{
renderers{
title,
key,
isEnabled,
config{
key,
value
}
}
}
}
The title field is not needed in the wikijs_renderers Resource but is necessary for the graphql query.
You get back a JSON in the config.value field where you have to look for another value field.
---

# wikijs_renderers (Resource)

The `wikijs_renderers` Resource implements the WikiJS API mutatation `rendering{updateRenderers{renderers{…}}}`.

**Be aware**.
This Resource supports only one instance as the implementation needs the complete configuration of renderers.
You cannot specify one renderer with its config as this will erase the complete list.
If you are unsure about the `key` and `config` fields, you can query the API after activating it manually or with the `wikijs_api` resource.
The query with the minimal information you need is as follows:

```graphql
query{
rendering{
renderers{
title,
key,
isEnabled,
config{
key,
value
}
}
}
}
```

The `title` field is not needed in the `wikijs_renderers` Resource but is necessary for the graphql query.
You get back a JSON in the `config.value` field where you have to look for another `value` field.

## Example Usage

```terraform
# This is a _currently_ complete configuration for the renderers. If you
# add your own renderer, place the object in this list.
# The order of this example is as it can be found in the backend for
# easier working.
resource "wikijs_renderers" "wikijs_renderers" {
renderers = [
{
key = "openapiCore"
is_enabled = true
config = {}
},
{
key = "markdownCore"
is_enabled = true
config = {
"allowHTML" = true
"linkify" = true
"linebreaks" = true
"underline" = false
"typographer" = false
# This field is an enum and has the following available values:
# "Chinese", "English", "French", "German", "Greek", "Japanese",
# "Hungarian", "Polish", "Portuguese", "Russian", "Spanish",
# "Swedish"
"quotes" = "English"
}
},
{
key = "markdownAbbr"
is_enabled = true
config = {}
},
{
key = "markdownEmoji"
is_enabled = true
config = {}
},
{
key = "markdownExpandtabs"
is_enabled = true
config = {
"tabWidth" = 4
}
},
{
key = "markdownFootnotes"
is_enabled = true
config = {}
},
{
key = "markdownImsize"
is_enabled = true
config = {}
},
{
key = "markdownKatex"
is_enabled = true
config = {
"useInline" : true
"useBlocks" : true
}
},
{
key = "markdownKroki"
is_enabled = false
config = {
"server" = "https://kroki.io"
"openMarker" = "```kroki"
"closeMarker" = "```"
}
},
{
key = "markdownMathjax"
is_enabled = false
config = {
"useInline" = true
"useBlocks" = true
}
},
{
key = "markdownMultiTable"
is_enabled = false
config = {
"headerlessEnabled" = true
"multilineEnabled" = true
"rowspanEnabled" = true
}
},
{
key = "markdownPivotTable"
is_enabled = false
config = {}
},
{
key = "markdownPlantuml"
is_enabled = true
config = {
"server" = "https://plantuml.requarks.io"
"openMarker" = "```plantuml"
"closeMarker" = "```"
"imageFormat" = "svg"
}
},
{
key = "markdownSupsub"
is_enabled = true
config = {
"subEnabled" = true
"supEnabled" = true
}
},
{
key = "markdownTasklists"
is_enabled = true
config = {}
},
{
key = "asciidocCore"
is_enabled = true
config = {
# This field is an enum and has the following available values:
# "unsafe", "safe", "server", "secure"
"safeMode" = "server"
}
},
{
key = "htmlCore"
is_enabled = true
config = {
"absoluteLinks" = false
"openExternalLinkNewTab" = false
# This field is an enum and has the following available values:
# "noreferrer", "noopener"
"relAttributeExternalLink" = "noreferrer"
}
},
{
key = "htmlAsciinema"
is_enabled = false
config = {}
},
{
key = "htmlBlockquotes"
is_enabled = true
config = {}
},
{
key = "htmlCodehighlighter"
is_enabled = true
config = {}
},
{
key = "htmlDiagram"
is_enabled = true
config = {}
},
{
key = "htmlImagePrefetch"
is_enabled = false
config = {}
},
{
key = "htmlMediaplayers"
is_enabled = true
config = {}
},
{
key = "htmlMermaid"
is_enabled = true
config = {}
},
{
key = "htmlSecurity"
is_enabled = true
config = {
"safeHTML" = true
"allowDrawIoUnsafe" = true
"allowIFrames" = false
}
},
{
key = "htmlTabset"
is_enabled = true
config = {}
},
{
key = "htmlTwemoji"
is_enabled = true
config = {}
}
]
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `renderers` (Attributes List) (see [below for nested schema](#nestedatt--renderers))

<a id="nestedatt--renderers"></a>
### Nested Schema for `renderers`

Required:

- `is_enabled` (Boolean) Is the renderer enabled or not.
- `key` (String) The registered/machine name of the renderer used to identify it in the system.

Optional:

- `config` (Map of String) Map with config options for this specific renderer.


6 changes: 3 additions & 3 deletions docs/resources/theme_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ The Schema descriptions are mostly lifted from the descriptions of the input fie
## Example Usage

```terraform
# The following example shows how to configure the wikijs theme
# Since v2 of Wiki.js does not allow for dynamic addition of
# custom themes you need to provide your own string there
# The following example shows how to configure the wikijs theme. Since
# v2 of Wiki.js does not allow for dynamic addition of custom themes you
# need to provide your own string there
resource "wikijs_theme_config" "config" {
theme = "custom_name"
Expand Down
6 changes: 6 additions & 0 deletions examples/data-sources/wikijs_renderers/data-source.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Use this data source to query the current setup and make changes in
# certain renderers. Note that this data source only takes an empty
# renderers list.
data "wikijs_theme_renderers" "renderers" {
renderers = []
}
Loading

0 comments on commit 75d7232

Please sign in to comment.