Skip to content
Merged
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
3 changes: 2 additions & 1 deletion .markdownlint.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"default": true,
"MD007": { "indent": 4 }
"MD007": { "indent": 4 },
"MD046": false
}
4 changes: 2 additions & 2 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
* @likp @runejo @michaelpande @JohannesFinsveen
/docs/ @likp @runejo @michaelpande @JohannesFinsveen @AsaArrhen @KristinGlomsas
* @likp @runejo @JohannesFinsveen
/docs/ @likp @runejo @JohannesFinsveen @AsaArrhen @KristinGlomsas @PxTools/devs-ssb @PxTools/devs-scb @PxTools/pxweb-triage
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

This repo contain the MarkDown for [www.pxtools.net](https://www.pxtools.net/)

We use [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) for this site
We use [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) for
this site

## Preview documentation locally while writing

Expand All @@ -11,7 +12,13 @@ We use [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) for t
### Docker

``` sh
docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material
docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material:9.6.20
```

Browse <http://localhost:8000/>

## Lint as you write in Visual Studio Code

Install [markdownlint](https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint)

> Markdown/CommonMark linting and style checking for Visual Studio Code
24 changes: 16 additions & 8 deletions docs/Other/changes-in-savedquery-usage.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
### Saved queries in PxWeb2 and PxWebApi2.
# Changes in savedquery usage

## Saved queries in PxWeb2 and PxWebApi2

A saved query has an output format, which was selected when it was created.

If the output format is "Screen" you should get the table with your selections in the gui.
If the output is "Download" (e.g. excel) the browser should download the data in the chosen format.
If the output format is "Screen" you should get the table with your selections
in the gui. If the output is "Download" (e.g. excel) the browser should download
the data in the chosen format.

In the old classic version, the url of the gui was used for both "screen" and "download", and the output format "screen" got
you pxweb "as it was" when the query was created. If the output format was excel, you would not see the gui, the browser would just start to download a file.
In the old classic version, the url of the gui was used for both "screen" and
"download", and the output format "screen" got you pxweb "as it was" when the
query was created. If the output format was excel, you would not see the gui,
the browser would just start to download a file.

In the new version, the responsibillity is sharded between the api and and gui:
The url to the gui is used to get pxweb "as it was", also for "download" output formats.
The url to the api is used to download the data of any savedquery. For the "sceen" output format will download jsonstat2 files.
The url to the gui is used to get pxweb "as it was", also for "download" output
formats. The url to the api is used to download the data of any savedquery.
For the "sceen" output format will download jsonstat2 files.

`http://mysite/api/pxwebapi/v2/savedqueries/N/data` will download the file.

`http://mysite/api/pxwebapi/v2/savedqueries/N` will get you the definition of the savedquery.
`http://mysite/api/pxwebapi/v2/savedqueries/N` will get you the definition of
the savedquery.
139 changes: 99 additions & 40 deletions docs/PxWeb2/documentation/customization.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Customization
# Customize PxWeb 2

PxWeb comes prebuilt with configuration for tables in English, a set of fonts
colors and icons. This guide help you customize PxWeb to your needs.
Expand All @@ -15,6 +15,7 @@ You can:
- Limit table sizes.
- Control how and where languages appear in URLs.
- Hide variables from the variable filter.
- Customize Definitions panel content.
- Customize start page text and footer links (examples included below).
- Define characters used for missing values.

Expand Down Expand Up @@ -164,31 +165,38 @@ maxDataCells: 500000

### Table title configuration

The default behaviour when creating the table title is to use content text at table level followed by an enumeration of selected variable names. Example:
The default behaviour when creating the table title is to use content text at
table level followed by an enumeration of selected variable names. Example:

```
```sh
Content at table level by variable1, variable2 and variable3
```

For CNMM databases it is possible to configure an alternative way of creating the table title with the following behaviour:
For CNMM databases it is possible to configure an alternative way of creating
the table title with the following behaviour:

#### One content value selected:
```
#### One content value selected

```sh
Alternative text for selected content by variable1, variable2 and variable3
```
#### Two or more content values selected:
```

#### Two or more content values selected

```sh
Content at table level by variable1, variable2 and variable3
```

If you want to use dynamic content texts in the table title, set `useDynamicContentInTitle` in `config/config.js` to `true`:
If you want to use dynamic content texts in the table title, set
`useDynamicContentInTitle` in `config/config.js` to `true`:

```js
useDynamicContentInTitle: true
```

!!! note "Only for CNMM databases"
This setting can only be used for CNMM databases. If your database is a PX-file database, this setting should be set to `false`.
This setting can only be used for CNMM databases. If your database is a
PX-file database, this setting should be set to `false`.

### Change the default characters for missing values

Expand Down Expand Up @@ -251,7 +259,8 @@ In `config/config.js`:
};
```

- `supportedLanguages`: The active languages (must match those available in the API).
- `supportedLanguages`: The active languages (must match those available in the
API).
- `defaultLanguage`: The primary language.
- `fallbackLanguage`: Used if a translation key is missing for the active language.
- `showDefaultLanguageInPath`: If `true`, URLs include the default language code.
Expand All @@ -272,15 +281,21 @@ Replace the font files in the `fonts` directory. Keep file names.
Make sure you have the proper license to self-host fonts.

### Change logo and favicon
The svg **must** include viewbox and width/height attributes for it to be rendered correctly.

To change the logo/favicon in PxWeb replace svgs in the image folder. The names must be the same.
The svg **must** include viewbox and width/height attributes for it to be
rendered correctly.

To change the logo/favicon in PxWeb replace svgs in the image folder. The names
must be the same.

For image replace `images/logo.svg` with your own logo.
Replace `images/favicon.ico` / `images/favicon-darkmode.svg` with your own favicon.

### Change logo URL
By default you will come to the PxWeb start page when clicking the logo. However, it is possible to configure this. You can configure a new logo URL per language by editing `homePage` in `config/config.js`:

By default you will come to the PxWeb start page when clicking the logo.
However, it is possible to configure this. You can configure a new logo URL per
language by editing `homePage` in `config/config.js`:

```js
homePage: {
Expand All @@ -290,6 +305,7 @@ By default you will come to the PxWeb start page when clicking the logo. However
```

### Show breadcrumb on start page

You can set if breadcrumbs should be shown on start page
Set `showBreadCrumbOnStartPage` in `config/config.js`. Example:

Expand Down Expand Up @@ -319,39 +335,50 @@ Keys reflect where in the UI a string is used. Only modify values.
### Change date format in translation file

Edit the relevant `locales/<lang>/translation.json` file.
We have two date formats defined under `date` in translation files - `simple_date` and `simple_date_with_time`.
We have two date formats defined under `date` in translation files -
`simple_date` and `simple_date_with_time`.

Change the format options as needed. **PxWeb2** uses `Intl.DateTimeFormat` for date formatting. See documentation for options here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat
Change the format options as needed. **PxWeb2** uses `Intl.DateTimeFormat` for
date formatting. See documentation for options here:
<https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat>

Here is an examples configuration used for english and norwegian:

??? tip "english date formats"

```json
"date": {
"simple_date": "{{value, datetime}}",
"simple_date_with_time": "{{value, datetime(year: 'numeric'; month: 'numeric'; day: 'numeric'; hour: 'numeric'; minute: 'numeric')}}"
"simple_date_with_time": "{{value, datetime(year: 'numeric';
month: 'numeric'; day: 'numeric'; hour: 'numeric'; minute: 'numeric')}}"
}
```

Example of how `simple_date_with_time` for english is displayed in PxWeb2 UI:
`2/21/2025, 8:00 AM`

??? tip "norwegian date formats"

```json
"date": {
"simple_date": "{{value, datetime(day: '2-digit'; month: '2-digit'; year: 'numeric')}}",
"simple_date_with_time": "{{value, datetime(year: 'numeric'; month: '2-digit'; day: '2-digit'; hour: 'numeric'; minute: 'numeric')}}"
"simple_date": "{{value, datetime(day: '2-digit'; month: '2-digit';
year: 'numeric')}}",
"simple_date_with_time": "{{value, datetime(year: 'numeric';
month: '2-digit'; day: '2-digit'; hour: 'numeric'; minute: 'numeric')}}"
}
```

Example of how `simple_date_with_time` for norwegian is displayed with two digit configuration in PxWeb2 UI:
`21.02.2025, 08:00`
Example of how `simple_date_with_time` for norwegian is displayed with two digit
configuration in PxWeb2 UI: `21.02.2025, 08:00`

### Override separators in number formatting per language

Edit the relevant `locales/<lang>/translation.json` file.
We have defined multiple number formatting rules under `number` in translation files. Here are some expamples of number formats that are used:
We have defined multiple number formatting rules under `number` in translation
files. Here are some expamples of number formats that are used:

??? tip "number formats"

```json
"number": {
"simple_number": "{{value, pxNumber}}",
Expand All @@ -366,22 +393,33 @@ We have defined multiple number formatting rules under `number` in translation f
- `simple_number_with_one_decimal`: Number formatting with one decimal place.
- `simple_number_with_two_decimals`: Number formatting with two decimal places.

The group and decimal separators are determined by the language locale. However, if you want to customize the number formatting further, you can add additional options to the `pxNumber` formatter.
The group and decimal separators are determined by the language locale. However,
if you want to customize the number formatting further, you can add additional
options to the `pxNumber` formatter.

To override decimal add `decimalSeparator` to the `number_format` object.
Likewise, to override group separator add `thousandSeparator` to the
`number_format` object.

To override decimal add `decimalSeparator` to the `number_format` object. Likewise, to override group separator add `thousandSeparator` to the `number_format` object.
If you need to add space as a group separator, you add the value `nbsp` for
non-breaking space or `nnbsp` for narrow non-breaking space, e.g.
`thousandSeparator: 'nbsp'`.

If you need to add space as a group separator, you add the value `nbsp` for non-breaking space or `nnbsp` for narrow non-breaking space, e.g. `thousandSeparator: 'nbsp'`.
Here is an example of how to override both decimal and group separators for
simple_number_with_two_decimals. Use `,` as decimal separator and non-breaking
space as group separator:

Here is an example of how to override both decimal and group separators for simple_number_with_two_decimals. Use `,` as decimal separator and non-breaking space as group separator:
```json
"number": {
"simple_number_with_two_decimals": "{{value, pxNumber(minimumFractionDigits: 2; maximumFractionDigits: 2; decimalSeparator: ','; thousandSeparator: 'nbsp';)}}",
"simple_number_with_two_decimals": "{{value, pxNumber(minimumFractionDigits: 2;
maximumFractionDigits: 2; decimalSeparator: ','; thousandSeparator: 'nbsp';)}}",
}
```

### Hide or show the default language in the URL

Toggle:

```js hl_lines="8"
globalThis.PxWeb2Config = {
language: {
Expand Down Expand Up @@ -495,12 +533,22 @@ Edit these CSS variables in `theme/variables.css`:
Do not alter `--px-border-radius-none` or `--px-border-radius-full` unless you
know the side effects (they are used for logical extremes).

### Customize Definitions panel content

The Definitions panel in the right sidebar on the table page, can be
customized by changing translation strings in the "presentation_page.main_content.about_table.definitions" section of the relevant `locales/<lang>/translation.json` file.

If the strings inside the "about_statistics" and "metadata" sections are empty, the Definitions panel will only show the primary links from the API. The keys inside the "about_statistics" will add a header and text description to the primary links section.

If the API also returns variable definitions, the keys inside the "metadata" section will add a header and text description to the variable definitions section.

### Change the text and related links on the startpage, table page and in the footer

The `content.json` file defines customizable text and links that appear in
**PxWeb’s user interface** This file allows you to configure localized UI
content: you can add a **detailsSection** after the ingress on the start page, update the **help section** on the table page, or update the
**footer** content for the application.
content: you can add a **detailsSection** after the ingress on the start page,
update the **help section** on the table page, or update the **footer** content
for the application.

```sh
root/content
Expand Down Expand Up @@ -531,7 +579,10 @@ root/content
{
"textBlock": {
"header": "When to use this section",
"text": "This is an optional section that can be used for content that may be useful for some users, but is not essential for everyone. Key information that all users need to see should always appear in the lead paragraph."
"text": "This is an optional section that can be used for content
that may be useful for some users, but is not essential for
everyone. Key information that all users need to see should always
appear in the lead paragraph."
}
},
{
Expand All @@ -556,7 +607,8 @@ root/content
"enabled": true,
"helpText": [
"Use *title:* to search only in the table name, for example *title:stockholm*.",
"You can add or remove items from this search help list to make it relevant for your specific database."
"You can add or remove items from this search help list to make it
relevant for your specific database."
]
}
},
Expand All @@ -577,7 +629,8 @@ root/content
},
"tableViewer": {
"helpSection": {
"description": "Help and guidance on how to use the PxWeb interface can be found on our help pages:",
"description": "Help and guidance on how to use the PxWeb interface can be
found on our help pages:",
"links": [
{
"text": "Example link 1",
Expand All @@ -590,7 +643,8 @@ root/content
],
"informationCard": {
"enabled": true,
"text": "For questions about the figures and table content, see the “Information” button."
"text": "For questions about the figures and table content, see the
“Information” button."
}
}
}
Expand All @@ -607,15 +661,20 @@ root/content
- **startPage.noResultSearchHelp** – Optional section displayed below
the “no results” message when no tables match the search or filters.
When `enabled` is `true`, each string in the `helpText` array is shown
as a separate list item under a help heading. The text will be rendered using a custom markdown renderer to allow *italic* formatting with asterisks.
as a separate list item under a help heading. The text will be rendered using
a custom markdown renderer to allow *italic* formatting with asterisks.

- **footer**
One or more footer columns with `header` and list of `links`. If links have `external` set to `true`, they automatically will have the icon for external links and will open in a new tab. See example above.
One or more footer columns with `header` and list of `links`. If links have
`external` set to `true`, they automatically will have the icon for external
links and will open in a new tab. See example above.

- **tableViewer.helpSection** – Optional help section on the table page.
Contains a `description` string, a list of `links` (with `text` and `url`), and
an optional `informationCard` (with `enabled` boolean and `text`). Links will always be opened in a new tab.
When at least on the above is defined, the application renders the **`HelpSection` component**.
an optional `informationCard` (with `enabled` boolean and `text`). Links will
always be opened in a new tab.
When at least on the above is defined, the application renders the
**`HelpSection` component**.

This setup allows administrators to adjust localized content (text and links)
for each language without modifying the application code.
Expand All @@ -629,9 +688,9 @@ Token categories:

1. Primitive (Base) Tokens: Raw color values (brand, accent, neutrals, semantic
palettes). Example: `--px-color-brand-400`.
2. Semantic (System) Tokens: Contextual meaning-based tokens mapping to
2. Semantic (System) Tokens: Contextual meaning-based tokens mapping to
primitives. Example: `--px-color-surface-default`, `--px-color-text-action`.
3. Component / Alias Tokens (if introduced later): Optional intermediary
3. Component / Alias Tokens (if introduced later): Optional intermediary
re-mappings for specific components.

Principles:
Expand Down Expand Up @@ -789,7 +848,7 @@ Below is the mapping of primitive tokens to semantic tokens that consume them:
## Troubleshooting

| Issue | Possible Cause | Fix |
|-------|----------------|-----|
| ----- | -------------- | --- |
| Language not switching | Missing folder or translation key | Verify `locales/<lang>/translation.json` exists and is valid JSON |
| Icons not showing | File name mismatch | Ensure mapping file matches actual SVG names |
| Colors look inconsistent | Edited semantic tokens directly | Revert semantic tokens; adjust primitives only |
Expand Down
2 changes: 1 addition & 1 deletion docs/PxWeb2/documentation/docker.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Docker
# Try PxWeb 2 with Docker

This document describes how you can use [Docker Compose](https://docs.docker.com/compose/)
to try out the new PxWeb 2.0 with your excisting database. The reason we need
Expand Down
Loading