Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions plugins/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
!projectnumber
!webhooks
!renderfindings
!rendersections
!excalidraw
!markdownexport
15 changes: 15 additions & 0 deletions plugins/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions plugins/rendersections/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
static
84 changes: 84 additions & 0 deletions plugins/rendersections/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Render Sections Plugins

This plugin allows you to create selectable sections to render to a PDF without rendering the whole report.
It is possible to render multiple sections in one PDF and to render each section to a separate PDF.

The plugin is closely related to the `renderfindings` plugin (it is based on the original code), but extends it to support choosing arbitrary parts of your report.


## Configuration

```
ENABLED_PLUGINS="rendersections"
```

You will need to update your design to support this plugin, as it relies on the `data-sysreptor-rendersections` attribute and an accompanying `id`.
This attribute takes one of the following values:

* `choosable`: The element can be chosen to be included or excluded from the PDF
* `related`: The element will only be included in the PDF, if one of the related sections is included. This is based on the attribute `data-sysreptor-rendersections-relatedids`, which takes a `,` separated list of section IDs.

Compared to the `renderfindings` plugin, this works also on non-top-level elements and only affects elements with the attribute `data-sysreptor-rendersections`.

How rendering works:

* Select one or multiple sections to render
* When getting the list of possible sections, the report HTML is fully rendered once and all items with the attribute `data-sysreptor-rendersections` and an `id` set are listed.
* The name for each section that is used in the list can be overriden by setting the attribute `data-sysreptor-rendersections-name`. By default it is the element's `id`.
* Since the report is fully rendered, you can also dynamically create elements with the attribute `data-sysreptor-rendersections` (e.g. on each of the findings, or on attachments).
* Render the selected findings and all sections to HTML using the project's design
* The entire report is rendered to HTML with all findings/sections (this is a difference to `renderfindings`, which only includes the selected findings and therefore might have issues with graphs and references that would not be included in the report).
* The variable `data.isPluginRenderFindings` is set to `true`. Use this variable to customize rendering. (This attribute name is kept for backwards compatibility)
* Remove non-selected sections from the HTML
* Get all elements containing `data-sysreptor-rendersections`.
* Remove all of these elements whose `id` is not in the list of selected sections and where there are no related findings included.
* Render post-processed HTML to PDF


## Limitations
* Different counter values than in the full report e.g. heading numbers, figures, tables, pages, etc.
* Table of Contents also contains sections that are not included in the report


## Examples

### Make Findings Choosable
```html
<section>
<h1>Finding List</h1>
<div v-for="finding in findings"
:id="finding.id"
data-sysreptor-rendersections="choosable"
:data-sysreptor-rendersections-name="finding.title"
>

<h2>{{ finding.title }}</h2>
...
</div>
</section>
```

### Related Sections
```html
<section>
<h1>Finding List</h1>
<div v-for="finding in findings"
:id="finding.id"
data-sysreptor-rendersections="choosable"
:data-sysreptor-rendersections-name="finding.title"
>

<h2>{{ finding.title }}</h2>
...
</div>
</section>

<!-- When using "related" then you don't need to set an id on the element itself, and since it's not shown as selectable in the list, a name is also not necessary -->
<section
data-sysreptor-rendersections="related"
:data-sysreptor-rendersections-relatedids="findings.map(x => x.id).join(',')"
>
<h1>Finding Related</h1>
...
</section>
```
Empty file.
12 changes: 12 additions & 0 deletions plugins/rendersections/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from sysreptor.plugins import PluginConfig


class RenderSectionsPluginConfig(PluginConfig):
"""
This plugin lets you choose sections of a PDF to render.
You might need to update your design to propertly support and customize this plugin.
For more information see the README.md file in the plugin's directory.
"""

plugin_id = 'ebfbb193-c108-4b80-bd6a-a97a86ba9c8f'
professional_only = True
24 changes: 24 additions & 0 deletions plugins/rendersections/frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Nuxt dev/build outputs
.output
.data
.nuxt
.nitro
.cache
dist

# Node dependencies
node_modules

# Logs
logs
*.log

# Misc
.DS_Store
.fleet
.idea

# Local env files
.env
.env.*
!.env.example
6 changes: 6 additions & 0 deletions plugins/rendersections/frontend/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// @ts-check
import withNuxt from './.nuxt/eslint.config.mjs'

export default withNuxt(
// Your custom configs here
)
16 changes: 16 additions & 0 deletions plugins/rendersections/frontend/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
extends: [
'@sysreptor/plugin-base-layer',
],

appConfig: {
pluginId: 'ebfbb193-c108-4b80-bd6a-a97a86ba9c8f',
},

nitro: {
output: {
publicDir: '../static/'
}
},
})
21 changes: 21 additions & 0 deletions plugins/rendersections/frontend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "@sysreptor/plugin-rendersections-frontend",
"private": true,
"type": "module",
"scripts": {
"dev": "nuxt dev",
"generate": "nuxt generate",
"postinstall": "nuxt prepare"
},
"dependencies": {
"@sysreptor/plugin-base-layer": "../../../packages/plugin-base-layer",
"@sysreptor/nuxt-base-layer": "../../../packages/nuxt-base-layer",

"nuxt": "*",
"vuetify": "*",
"pinia": "*"
},
"overrides": {
"vue": "latest"
}
}
Loading