Skip to content

Commit

Permalink
Static pages / update documentation page
Browse files Browse the repository at this point in the history
  • Loading branch information
josegar74 committed Jan 15, 2025
1 parent 920d491 commit 3a31be8
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 72 deletions.
109 changes: 37 additions & 72 deletions docs/manual/docs/customizing-application/adding-static-pages.md
Original file line number Diff line number Diff line change
@@ -1,95 +1,55 @@
# Adding static pages

This feature allows to store the HTML content for static pages and show the links to these pages in specific sections of the user interface:
This function allows storing the HTML content of static pages and displaying links to these pages in specific sections of the user interface.

- The HTML content is stored in a new table of the GN's database.
To add new static pages go to **Admin Console** --> **Settings** --> **Static Pages** and select the **+ New Static Page** option, providing the following information:

- The link to pages can be showed in different points of the GN's GUI according to a list of "sections" associated to each page. In this PR is introduced the support to show the links for the top toolbar and the footer.
- **Language**: User interface language in which the static page will be displayed.
- **Page identifier**: A unique text identifier for the page.
- **Page label**: Label to display on the link.
- **Page icon**: (Optional) Icon to display next to the link label.
- **Format**: Format of the static page:

- Each page can be in 3 states:
- **Web link**: Link to a web page.
- **HTML content displayed embedded in the app**
- **HTML content displayed in a new browser tab**
- **Plain text content**
- **Email link**: Email address. Opens the system's mail client to send mail to the configured address.

- `HIDDEN`: visible to administrator.
- `PRIVATE`: visible to logged users.
- `PUBLIC`: visible to everyone.
- **Link**: Available for **Web link** / **Email link** formats.

- Pages can be added to different page sections. Currently the sections implemented are `TOP` (top menu of the main page) and `FOOTER` (footer of the main page).
- For **Web link** the link to a web page.
- For **Email link**, the email address to which the email will be sent.

- Only the administrator can edit the pages and see the pages in `HIDDEN` status.
- **Page content file**: For formats other than **Web link** or **Email link**, allows uploading a file with the HTML content / text to be displayed.

- The creation and the management of the content is done via the API.
- **Page content**: For formats other than **Web link** or **Email link**, allows editing the HTML / text content to display.

![](img/pages-api.png)
- **Page section**: Section of the page to display the link. Currently implemented sections are `TOP` (top menu of the main page) and `FOOTER` (footer of the main page).

Some restrictions:

- It is not possible to apply custom CSS to the page.
- Any external image must be loaded externally.

## Examples of API usage

Before executing the following examples, see [Example of CSRF call using curl](misc.md#example-csrf-curl) for details on the usage of the CSRF token (instead of the value `"X-XSRF-TOKEN: e934f557-17a3-47f2-8e6b-bdf1a3c90a97"` used in the examples) and cookies in the requests.

### Load a page in the top menu bar

In this example we're going to upload a file ``contactus.html`` and link it in the top menu:

1. Load the content by using the method POST `/api/pages/`, the mandatory fields are:

- language (3 letters like 'eng', 'ita', 'fra' \...)
- pageId (the identifier/link description of the page)
- format (must be LINK if a link is associated to the page)
- the content: data (a file with the page content) or a link (URL to another page). Define both is not possible.

``` bash
$ curl -X POST "http://localhost:8080/geonetwork/srv/api/pages/?language=eng&pageId=contactus&format=HTML" -H "accept: */*" -H "Content-Type: multipart/form-data" -H "X-XSRF-TOKEN: e934f557-17a3-47f2-8e6b-bdf1a3c90a97" -d contactus.html
```

At this point the page is created but not visible because is in status HIDDEN and is not loaded explicitly in any section of the page, except DRAFT that is not visible (in the future could be added to a page with an editor interface). Similar requests should be done for each UI language supported.

2. To associate the link to the top bar is necessary to use the method POST `/api/pages/{language}/{pageId}/{section}` with the `TOP` value for the section.
- **Status**: Defines which users can see the link.

``` bash
$ curl -X POST "http://localhost:8080/geonetwork/srv/api/pages/eng/contactus/TOP" -H "accept: */*" -H "X-XSRF-TOKEN: 7cfa1a0d-3335-4846-8061-a5bf176687b5" --user admin:admin -b /tmp/cookie
```
- **Visible only to the administrator**
- **Visible to logged users**
- **Visible to users belonging to groups**
- **Visible to every one**

### Load a link in the footer bar
![](img/add-static-page.png)

In this example we're going to add a link to an external resource <http://myorganisation/contactus.html> and link it in the footer:

1. Add the link by using the method POST `/api/pages/` with the `link` parameter in the request:
![](img/static-page-footer.png)

``` bash
$ curl -X POST "http://localhost:8080/geonetwork/srv/api/pages/?language=eng&pageId=contactus&format=LINK&link=http://myorganisation/contactus.html" -H "accept: */*" -H "X-XSRF-TOKEN: e934f557-17a3-47f2-8e6b-bdf1a3c90a97"
```

2. To associate the link to the footer is necessary to use the method POST `/api/pages/{language}/{pageId}/{section}` with the `FOOTER` value for the section.
``` bash
$ curl -X POST "http://localhost:8080/geonetwork/srv/api/pages/eng/contactus/FOOTER" -H "accept: */*" -H "X-XSRF-TOKEN: 7cfa1a0d-3335-4846-8061-a5bf176687b5" --user admin:admin -b /tmp/cookie
```
### Remove a page from a section
To remove a page from a section DELETE `/api/pages/{language}/{pageId}/{section}`
``` bash
curl -X DELETE "http://localhost:8080/geonetwork/srv/api/pages/eng/contactus?format=LINK" -H "accept: */*" -H "X-XSRF-TOKEN: 7cfa1a0d-3335-4846-8061-a5bf176687b5" --user admin:admin -b /tmp/cookie
```
### Change the page status
The status of the page can be changed with the method PUT `/api/pages/{language}/{pageId}/{status}` where status could assume these values:
Some restrictions:

- `PUBLIC` - Visible to every user
- `PUBLIC_ONLY` - Visible to not logged users
- `PRIVATE` - Visible to logged users
- `HIDDEN` - Hidden to anyone
- It is not possible to apply custom CSS to the page.
- Any external image must be loaded externally.

Other methods in the API are to change/delete a page and to GET the list of the pages or the info of a specific one.
## Change the menu order in the top toolbar

### Change the menu order in the top toolbar
In the top bar, pages can be inserted between the default menu of the catalogue. This can be configured in **Admin Console** --> **Settings** --> **User interface**, in the **Header custom menu items** section.

Pages can be inserted in between catalogue default menu which are:
By default, the order of the items in the top bar is as follows:

``` json
["gn-site-name-menu",
Expand All @@ -100,7 +60,7 @@ Pages can be inserted in between catalogue default menu which are:
"gn-admin-menu"]
```

Insert a page as a simple menu using its id or as a submenu using an object:
Insert a page as a simple menu using the page identifier or as a submenu using an object:

``` json
["gn-site-name-menu",
Expand All @@ -115,3 +75,8 @@ Insert a page as a simple menu using its id or as a submenu using an object:
"gn-admin-menu",
"documentation"]
```

## Change the static pages order in the footer

The order of the footer pages can be configured in **Admin Console** --> **Settings** --> **User interface**, in the **Footer custom menu items** section.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3a31be8

Please sign in to comment.