Skip to content

Commit e06f8b6

Browse files
committed
chore: add documentation of new themes endpoint
1 parent 5652b51 commit e06f8b6

File tree

12 files changed

+176
-0
lines changed

12 files changed

+176
-0
lines changed

docs/source/endpoints/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ searching
4949
sharing
5050
site
5151
system
52+
themes
5253
transactions
5354
translations
5455
tusupload

docs/source/endpoints/themes.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
---
2+
myst:
3+
html_meta:
4+
"description": "Diazo themes can be managed programmatically through the @themes endpoint in a Plone site."
5+
"property=og:description": "Diazo themes can be managed programmatically through the @themes endpoint in a Plone site."
6+
"property=og:title": "Themes"
7+
"keywords": "Plone, plone.restapi, REST, API, Themes, Diazo"
8+
---
9+
10+
# Themes
11+
12+
Diazo themes can be managed programmatically through the `@themes` endpoint in a Plone site.
13+
This endpoint requires `plone.app.theming` to be installed and the `cmf.ManagePortal` permission.
14+
15+
It is particularly useful in containerized deployments (such as Kubernetes) where access to the Plone UI may not be available.
16+
17+
## Listing themes
18+
19+
A list of all available themes can be retrieved by sending a `GET` request to the `@themes` endpoint:
20+
21+
```{eval-rst}
22+
.. http:example:: curl httpie python-requests
23+
:request: ../../../src/plone/restapi/tests/http-examples/themes_get_list.req
24+
```
25+
26+
Response:
27+
28+
```{literalinclude} ../../../src/plone/restapi/tests/http-examples/themes_get_list.resp
29+
:language: http
30+
```
31+
32+
The following fields are returned for each theme:
33+
34+
- `@id`: hypermedia link to the theme resource
35+
- `id`: the theme identifier
36+
- `title`: the friendly name of the theme
37+
- `description`: description of the theme
38+
- `active`: whether this theme is currently active
39+
- `preview`: path to the theme preview image (or `null`)
40+
- `rules`: path to the theme rules file
41+
42+
## Reading a theme
43+
44+
A single theme can be retrieved by sending a `GET` request with the theme ID as a path parameter:
45+
46+
```{eval-rst}
47+
.. http:example:: curl httpie python-requests
48+
:request: ../../../src/plone/restapi/tests/http-examples/themes_get.req
49+
```
50+
51+
Response:
52+
53+
```{literalinclude} ../../../src/plone/restapi/tests/http-examples/themes_get.resp
54+
:language: http
55+
```
56+
57+
## Uploading a theme
58+
59+
A new theme can be uploaded by sending a `POST` request with a ZIP archive as `multipart/form-data`:
60+
61+
```{eval-rst}
62+
.. http:example:: curl httpie python-requests
63+
:request: ../../../src/plone/restapi/tests/http-examples/themes_post.req
64+
```
65+
66+
Response:
67+
68+
```{literalinclude} ../../../src/plone/restapi/tests/http-examples/themes_post.resp
69+
:language: http
70+
```
71+
72+
The following form fields are accepted:
73+
74+
- `themeArchive` (required): the ZIP file containing the theme
75+
- `enable` (optional): set to `true` to activate the theme immediately after upload
76+
- `replace` (optional): set to `true` to overwrite an existing theme with the same ID
77+
78+
## Activating a theme
79+
80+
A theme can be activated by sending a `PATCH` request with `{"active": true}`:
81+
82+
```{eval-rst}
83+
.. http:example:: curl httpie python-requests
84+
:request: ../../../src/plone/restapi/tests/http-examples/themes_patch_activate.req
85+
```
86+
87+
Response:
88+
89+
```{literalinclude} ../../../src/plone/restapi/tests/http-examples/themes_patch_activate.resp
90+
:language: http
91+
```
92+
93+
## Deactivating a theme
94+
95+
A theme can be deactivated by sending a `PATCH` request with `{"active": false}`:
96+
97+
```{eval-rst}
98+
.. http:example:: curl httpie python-requests
99+
:request: ../../../src/plone/restapi/tests/http-examples/themes_patch_deactivate.req
100+
```
101+
102+
Response:
103+
104+
```{literalinclude} ../../../src/plone/restapi/tests/http-examples/themes_patch_deactivate.resp
105+
:language: http
106+
```
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
GET /plone/@themes/plonetheme.barceloneta HTTP/1.1
2+
Accept: application/json
3+
Authorization: Basic YWRtaW46c2VjcmV0
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
HTTP/1.1 200 OK
2+
Content-Type: application/json
3+
4+
{
5+
"@id": "http://localhost:55001/plone/@themes/plonetheme.barceloneta",
6+
"id": "plonetheme.barceloneta",
7+
"title": "Barceloneta Theme",
8+
"description": "The default Plone 5 theme",
9+
"active": true,
10+
"preview": "++theme++plonetheme.barceloneta/preview.png",
11+
"rules": "++theme++plonetheme.barceloneta/rules.xml"
12+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
GET /plone/@themes HTTP/1.1
2+
Accept: application/json
3+
Authorization: Basic YWRtaW46c2VjcmV0
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
HTTP/1.1 200 OK
2+
Content-Type: application/json
3+
4+
[
5+
{
6+
"@id": "http://localhost:55001/plone/@themes/plonetheme.barceloneta",
7+
"id": "plonetheme.barceloneta",
8+
"title": "Barceloneta Theme",
9+
"description": "The default Plone 5 theme",
10+
"active": true,
11+
"preview": "++theme++plonetheme.barceloneta/preview.png",
12+
"rules": "++theme++plonetheme.barceloneta/rules.xml"
13+
}
14+
]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
PATCH /plone/@themes/plonetheme.barceloneta HTTP/1.1
2+
Accept: application/json
3+
Authorization: Basic YWRtaW46c2VjcmV0
4+
Content-Type: application/json
5+
6+
{"active": true}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
HTTP/1.1 204 No Content
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
PATCH /plone/@themes/plonetheme.barceloneta HTTP/1.1
2+
Accept: application/json
3+
Authorization: Basic YWRtaW46c2VjcmV0
4+
Content-Type: application/json
5+
6+
{"active": false}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
HTTP/1.1 204 No Content

0 commit comments

Comments
 (0)