Skip to content

Commit

Permalink
feat: "default" and "description" columns added to extension configur…
Browse files Browse the repository at this point in the history
…ation properties (#265)

Refs: #256
  • Loading branch information
grigoriev authored Oct 22, 2024
1 parent 1dbf304 commit 1b8468d
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 14 deletions.
29 changes: 20 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,7 @@ First of all you need to inject appropriate JavaScript code into Polarion:
5. Save changes by clicking 💾 Save

Then open a project, its Live Report you wish to export, and click "Expand Tools" on top of the page.
As a result report's toolbar will appear. Click "Edit" button in a toolbar, as a result the report will be switched into an edit mode. Add an empty region on top
of the report, place cursor there, choose "Generic" tag on "Widgets" sidebar on right hand side of the page, find "Export to PDF Button" widget there and click it
to add to the report. Then save a report clicking 💾 in a toolbar and then return to a view mode clicking "Back" button. When you click "Export to PDF" button just added
to the report, PDF Exporter view will be opened in a popup and you will be able to proceed with exporting the report to PDF. Be aware that in report's context limited
set of properties are available for configuration in PDF popup, the rest of them are relevant only in Live Document context.
As a result report's toolbar will appear. Click "Edit" button in a toolbar, as a result the report will be switched into an edit mode. Add an empty region on top of the report, place cursor there, choose "Generic" tag on "Widgets" sidebar on right hand side of the page, find "Export to PDF Button" widget there and click it to add to the report. Then save a report clicking 💾 in a toolbar and then return to a view mode clicking "Back" button. When you click "Export to PDF" button just added to the report, PDF Exporter view will be opened in a popup and you will be able to proceed with exporting the report to PDF. Be aware that in report's context limited set of properties are available for configuration in PDF popup, the rest of them are relevant only in Live Document context.

### Configuring logs

Expand Down Expand Up @@ -160,14 +156,29 @@ If HTML logging is switched on, then in standard polarion log file there will be

Here you can find out in which files HTML was stored.

### Enabling internalization of CSS links
### PDF Variants configuration

The converting HTML can contain some external CSS links referencing Polarion Server, like:
This configuration property allows selecting a PDF variant to be used for PDF generation. The following variants are supported:

```html
<link rel="stylesheet" href="/polarion/diff-tool-app/ui/app/_next/static/css/3c374f9daffd361a.css" data-precedence="next">
| Variant | Description |
|--------------|------------------------------------------------------------------|
| **pdf/a-1b** | Basic visual preservation (older PDF standard) |
| **pdf/a-2b** | Basic visual preservation with modern features like transparency |
| **pdf/a-3b** | Visual preservation with file attachments |
| **pdf/a-4b** | Visual preservation using PDF 2.0 standard |
| **pdf/a-2u** | Visual preservation + searchable text (Unicode) |
| **pdf/a-3u** | Visual preservation + searchable text with file attachments |
| **pdf/a-4u** | Searchable text + PDF 2.0 features |
| **pdf/ua-1** | Accessible PDF for assistive technologies |

To configure the PDF variant, adjust the following property in the `polarion.properties` file:

```properties
ch.sbb.polarion.extension.pdf-exporter.weasyprint.pdf.variant=pdf/a-2b
```

The default value is `pdf/a-2b`.

## Extension configuration

1. On the top of the project's navigation pane click ⚙ (Actions) ➙ 🔧 Administration. Project's administration page will be opened.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,66 @@
@Discoverable
public class PdfExporterExtensionConfiguration extends ExtensionConfiguration {

public static final String DEBUG_DESCRIPTION = "Enable <a href='#debug-option'>debug mode</a>";

public static final String WEASYPRINT_SERVICE = "weasyprint.service";
public static final String WEASYPRINT_SERVICE_DEFAULT = "http://localhost:9080";
public static final String WEASYPRINT_SERVICE_DESCRIPTION = "The URL of the <a href='#weasyprint-configuration'>WeasyPrint service</a>";
public static final String WEASYPRINT_SERVICE_DEFAULT_VALUE = "http://localhost:9080";

public static final String WEASYPRINT_PDF_VARIANT = "weasyprint.pdf.variant";
public static final String WEASYPRINT_PDF_VARIANT_DEFAULT = "pdf/a-2b";
public static final String WEASYPRINT_PDF_VARIANT_DESCRIPTION = "The <a href='#pdf-variants-configuration'>PDF variant</a> of generated PDF files";
public static final String WEASYPRINT_PDF_VARIANT_DEFAULT_VALUE = "pdf/a-2b";

public static final String WEBHOOKS_ENABLED = "webhooks.enabled";
public static final String WEBHOOKS_ENABLED_DESCRIPTION = "Enable <a href='#enabling-webhooks'>webhooks</a>";
public static final Boolean WEBHOOKS_ENABLED_DEFAULT_VALUE = false;

@Override
public String getDebugDescription() {
return DEBUG_DESCRIPTION;
}

public String getWeasyprintService() {
return SystemValueReader.getInstance().readString(getPropertyPrefix() + WEASYPRINT_SERVICE, WEASYPRINT_SERVICE_DEFAULT);
return SystemValueReader.getInstance().readString(getPropertyPrefix() + WEASYPRINT_SERVICE, WEASYPRINT_SERVICE_DEFAULT_VALUE);
}

@SuppressWarnings("unused")
public String getWeasyprintServiceDescription() {
return WEASYPRINT_SERVICE_DESCRIPTION;
}

@SuppressWarnings("unused")
public String getWeasyprintServiceDefaultValue() {
return WEASYPRINT_SERVICE_DEFAULT_VALUE;
}

public String getWeasyprintPdfVariant() {
return SystemValueReader.getInstance().readString(getPropertyPrefix() + WEASYPRINT_PDF_VARIANT, WEASYPRINT_PDF_VARIANT_DEFAULT);
return SystemValueReader.getInstance().readString(getPropertyPrefix() + WEASYPRINT_PDF_VARIANT, WEASYPRINT_PDF_VARIANT_DEFAULT_VALUE);
}

@SuppressWarnings("unused")
public String getWeasyprintPdfVariantDescription() {
return WEASYPRINT_PDF_VARIANT_DESCRIPTION;
}

@SuppressWarnings("unused")
public String getWeasyprintPdfVariantDefaultValue() {
return WEASYPRINT_PDF_VARIANT_DEFAULT_VALUE;
}

@NotNull
public Boolean getWebhooksEnabled() {
return SystemValueReader.getInstance().readBoolean(getPropertyPrefix() + WEBHOOKS_ENABLED, false);
return SystemValueReader.getInstance().readBoolean(getPropertyPrefix() + WEBHOOKS_ENABLED, WEBHOOKS_ENABLED_DEFAULT_VALUE);
}

@SuppressWarnings("unused")
public String getWebhooksEnabledDescription() {
return WEBHOOKS_ENABLED_DESCRIPTION;
}

@SuppressWarnings("unused")
public String getWebhooksEnabledDefaultValue() {
return String.valueOf(WEBHOOKS_ENABLED_DEFAULT_VALUE);
}

@Override
Expand Down

0 comments on commit 1b8468d

Please sign in to comment.