-
Notifications
You must be signed in to change notification settings - Fork 237
Add rendersections plugin #511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Neverbolt
wants to merge
2
commits into
Syslifters:main
Choose a base branch
from
Neverbolt:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,5 +14,6 @@ | |
| !projectnumber | ||
| !webhooks | ||
| !renderfindings | ||
| !rendersections | ||
| !excalidraw | ||
| !markdownexport | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| static |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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/' | ||
| } | ||
| }, | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.