Skip to content

Commit ce09fdc

Browse files
committed
global: separate commands and output and [more]
- Separate commands to be entered (`bash` syntax to pop) and returned output (`console` syntax to be muted), so that commands can be copied via the clipboard icon directly. Closes #6 - Removed permission configuration advanced example temporarily given it wasn't working. - Documented more details of the workflow: * how checking for running containers incurs a 30s delay * how server must be stopped and started whenever invenio.cfg is changed - Moved some small sections around for clarity and focus. - Did a pass at all syntax highlighting in develop/ to make everything pop as much as possible (jsx doesn't work so broken js was used for jsx 🤷)
1 parent 4773f87 commit ce09fdc

File tree

11 files changed

+331
-239
lines changed

11 files changed

+331
-239
lines changed

docs/develop/cleanup.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
# Cleanup after you
22

3+
## Stop the instance
4+
5+
We have reached the end of this journey, we are going to stop the instance. This will **NOT** destroy images, containers or volumes i.e. your data will be preserved.
6+
7+
``` bash
8+
^C
9+
Stopping server and worker...
10+
Server and worker stopped...
11+
```
12+
313
## Destroy the instance
414

5-
Finally, we want to destroy it. This will take us to a clean state. Note that it destroys images, containers and volumes (the ones defined in the `february-release-2/docker-compose.full.yml`. ).
15+
If you want to get to a clean state with no images, containers or volumes, then destroy the instance. This **WILL** permanently erase your volume data (database and Elasticsearch indices).
16+
It destroys the images, containers and volumes defined in the `february-release-2/docker-compose.full.yml`.
617

7-
Stop the application:
18+
After stopping the application per above, destroy it:
819

9-
``` console
10-
$ invenio-cli destroy
20+
``` bash
21+
invenio-cli destroy
22+
```
23+
```console
1124
TODO: Revisit destroy command...
1225
```

docs/develop/config.md

Lines changed: 31 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ For the purpose of this example, we will only allow super users to create record
66

77
Open the `invenio.cfg` file with your favorite editor. We will use `vim` to avoid `emacs` and other wars ;).
88

9-
``` console
10-
$ vim invenio.cfg
9+
``` bash
10+
vim invenio.cfg
1111
```
1212

1313
Let's add the following to the file:
@@ -27,16 +27,30 @@ class MyRecordPermissionPolicy(RDMRecordPermissionPolicy):
2727
RECORDS_PERMISSIONS_RECORD_POLICY = MyRecordPermissionPolicy
2828
```
2929

30-
When we set `RECORDS_PERMISSIONS_RECORD_POLICY = MyRecordPermissionPolicy`, we are overriding `RECORDS_PERMISSIONS_RECORD_POLICY` provided by [invenio-records-permissions](https://github.com/inveniosoftware/invenio-app-rdm). You will note that `invenio.cfg` is really just a Python module. How convenient!
30+
And stop and start the server:
31+
32+
```bash
33+
^C
34+
Stopping server and worker...
35+
Server and worker stopped...
36+
```
37+
``` bash
38+
invenio-cli run
39+
```
40+
41+
!!! warning
42+
Changes to `invenio.cfg` **MUST** be accompanied by a restart to be picked up. This only restarts the server; it does not destroy any data.
43+
44+
When we set `RECORDS_PERMISSIONS_RECORD_POLICY = MyRecordPermissionPolicy`, we are overriding `RECORDS_PERMISSIONS_RECORD_POLICY` provided by [invenio-records-permissions](https://github.com/inveniosoftware/invenio-records-permissions). You will note that `invenio.cfg` is really just a Python module. How convenient!
3145

3246
**Pro tip** : You can type `can_create = []` to achieve the same effect; any empty permission list only allows super users.
3347

3448
That's it configuration-wise. If we try to create a record through the API, your instance will check if you are a super user before allowing you. The same approach to configuration holds for any other setting you would like to override.
3549

3650
Did the changes work? We are going to try to create a new record:
3751

38-
``` console
39-
$ curl -k -XPOST -H "Content-Type: application/json" https://localhost:5000/api/records/ -d '{
52+
``` bash
53+
curl -k -XPOST -H "Content-Type: application/json" https://localhost:5000/api/records/ -d '{
4054
"_access": {
4155
"metadata_restricted": false,
4256
"files_restricted": false
@@ -59,10 +73,10 @@ $ curl -k -XPOST -H "Content-Type: application/json" https://localhost:5000/api/
5973
],
6074
"creators": [
6175
{
62-
"name": "Julio Cesar",
76+
"name": "Marcus Junius Brutus",
6377
"type": "Personal",
64-
"given_name": "Julio",
65-
"family_name": "Cesar",
78+
"given_name": "Marcus",
79+
"family_name": "Brutus",
6680
"identifiers": [
6781
{
6882
"identifier": "9999-9999-9999-9999",
@@ -80,7 +94,7 @@ $ curl -k -XPOST -H "Content-Type: application/json" https://localhost:5000/api/
8094
],
8195
"titles": [
8296
{
83-
"title": "A Romans story",
97+
"title": "A permission story",
8498
"type": "Other",
8599
"lang": "eng"
86100
}
@@ -109,106 +123,14 @@ $ curl -k -XPOST -H "Content-Type: application/json" https://localhost:5000/api/
109123

110124
As you can see, the server could not know if we are authenticated/superuser and rejected us:
111125

112-
``` console
113-
{"message":"The server could not verify that you are authorized to access the URL requested. You either supplied the wrong credentials (e.g. a bad password), or your browser doesn't understand how to supply the credentials required.","status":401}
126+
``` json
127+
{
128+
"message": "The server could not verify that you are authorized to access the URL requested. You either supplied the wrong credentials (e.g. a bad password), or your browser doesn't understand how to supply the credentials required.",
129+
"status": 401
130+
}
114131
```
115132

116-
**Advanced example**:
117-
118-
1- Create a user, for example using the web UI (*sign up* button). Alternatively, you can do so with the CLI, executing the following command (Wait until you read point number *2* before executing):
119-
120-
``` console
121-
pipenv run invenio users create [email protected] --password=123456
122-
```
123-
124-
Note that the user will have ID 1 if it was the first one created.
125-
126-
2- Grant admin access to it. In order to do so, we only have to add the `-a` flag to the previous command:
127-
128-
``` console
129-
pipenv run invenio users create [email protected] -a --password=123456
130-
```
131-
132-
Note that this user will have ID 2.
133-
134-
3- Get a token and try to create the record again. You can do so on the UI by going to `settings->applications-->new token`. Alternatively you can do it in the terminal by executing the following command:
135-
136-
``` console
137-
# TODO Wait until invenio-oauthclient REST only is integrated
138-
```
139-
140-
Afterwards we can test if the new permissions are working correctly.
141-
142-
``` console
143-
$ curl -k -XPOST -H "Authorization:Bearer sHHq1K9y7a2v5doKDRSFmSFOxa1tZDHFcbs31npaxm1sFEt27yomLMt0ynkl" -H "Content-Type: application/json" https://localhost:5000/api/records/ -d '{
144-
"_access": {
145-
"metadata_restricted": false,
146-
"files_restricted": false
147-
},
148-
"_owners": [1],
149-
"_created_by": 1,
150-
"access_right": "open",
151-
"resource_type": {
152-
"type": "image",
153-
"subtype": "photo"
154-
},
155-
"identifiers": [
156-
{
157-
"identifier": "10.9999/rdm.9999999",
158-
"scheme": "DOI"
159-
}, {
160-
"identifier": "9999.99999",
161-
"scheme": "arXiv"
162-
}
163-
],
164-
"creators": [
165-
{
166-
"name": "Julio Cesar",
167-
"type": "Personal",
168-
"given_name": "Julio",
169-
"family_name": "Cesar",
170-
"identifiers": [
171-
{
172-
"identifier": "9999-9999-9999-9999",
173-
"scheme": "Orcid"
174-
}
175-
],
176-
"affiliations": [
177-
{
178-
"name": "Entity One",
179-
"identifier": "entity-one",
180-
"scheme": "entity-id-scheme"
181-
}
182-
]
183-
}
184-
],
185-
"titles": [
186-
{
187-
"title": "A Romans story",
188-
"type": "Other",
189-
"lang": "eng"
190-
}
191-
],
192-
"descriptions": [
193-
{
194-
"description": "A story on how Julio Cesar relates to Gladiator.",
195-
"type": "Abstract",
196-
"lang": "eng"
197-
}
198-
],
199-
"community": {
200-
"primary": "Maincom",
201-
"secondary": ["Subcom One", "Subcom Two"]
202-
},
203-
"licenses": [
204-
{
205-
"license": "Berkeley Software Distribution 3",
206-
"uri": "https://opensource.org/licenses/BSD-3-Clause",
207-
"identifier": "BSD-3",
208-
"scheme": "BSD-3"
209-
}
210-
]
211-
}'
212-
```
133+
!!!todo
134+
Document how to generate an API token when permissions via token work.
213135

214-
It works!
136+
Revert the changes in `invenio.cfg` and restart the server to get back to where we were.

docs/develop/customize.md

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,26 @@ As we just saw, overriding configured values is an easy and common way of custom
44

55
## Update the logo
66

7-
We are going to change the logo, take an *svg* file and update your **local** static files (You can use the [invenio color logo](https://github.com/inveniosoftware/invenio-theme/blob/master/invenio_theme/static/images/invenio-color.svg)):
7+
We are going to change the logo. Take an *svg* file and copy it to your **local** static files. You can use the [invenio color logo](https://github.com/inveniosoftware/invenio-theme/raw/master/invenio_theme/static/images/invenio-color.svg):
88

9-
``` console
10-
$ cp ./path/to/new/color/logo.svg static/images/logo.svg
9+
``` bash
10+
cp ./path/to/new/color/logo.svg static/images/logo.svg
1111
```
1212

1313
Then, use the `update` command:
1414

15+
``` bash
16+
invenio-cli update --no-install-js
17+
```
1518
``` console
16-
$ invenio-cli update --no-install-js
19+
# Summarized output
1720
Collecting statics and assets...
21+
Collect static from blueprints.
22+
Created webpack project.
1823
Copying project statics and assets...
24+
Symlinking assets/...
1925
Building assets...
26+
Built webpack project.
2027
```
2128

2229
Passing the `--no-install-js` option, skips re-installation of JS dependencies.
@@ -26,28 +33,26 @@ Go to the browser [*https://localhost:5000/*](https://localhost:5000) or refresh
2633
!!! warning "That evil cache"
2734
If you do not see it changing, check in an incognito window; the browser might have cached the logo.
2835

29-
Need further customizations? Have you thought of creating your own extensions? How to add them to your InvenioRDM instance is explained in the next section - [here](../extensions/custom.md).
30-
3136
## Change colors
3237

3338
You might also be wondering: *How do I change the colors so I can make my instance look like my institution's theme?*
3439

3540
We are going to change the top header section in the frontpage to apply our custom background color. Open the `assets/scss/<your instance shortname>/variables.scss` file and edit it as below:
3641

37-
``` console
42+
``` scss
3843
$navbar_background_image: unset;
3944
$navbar_background_color: #000000; // Note this hex value is an example. Choose yours.
4045
```
4146

42-
Then, run the `invenio-cli update` command as above and refresh the page! You should be able to see your top header's color changed! You can find all the available variables that you can change [here](https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/theme/assets/scss/invenio_app_rdm/variables.scss).
47+
Then, run the `invenio-cli update` command as above and refresh the page! You should be able to see your top header's color changed! You can find all the available styling variables that you can change [here](https://github.com/inveniosoftware/invenio-app-rdm/blob/master/invenio_app_rdm/theme/assets/scss/invenio_app_rdm/variables.scss).
4348

4449
## Change search results
4550

4651
Changing how your results are presented in the search page is also something quite common.
4752

4853
We are going to update the search result template so we can show more text in the result's description. Create a file called `ResultsItemTemplate.jsx` inside `assets/templates/search` folder and then edit it as below:
4954

50-
```console
55+
```js
5156
import React from 'react';
5257
import {Item} from 'semantic-ui-react';
5358
import _truncate from 'lodash/truncate';
@@ -74,14 +79,14 @@ When you click on a search result, you navigate in the details page of a specifi
7479

7580
We are going to configure our instance to use our template for displaying the information in the record's landing page. Open the `invenio.cfg` file and add the below:
7681

77-
```console
82+
```python
7883
from invenio_rdm_records.config import RECORDS_UI_ENDPOINTS
7984
RECORDS_UI_ENDPOINTS['recid'].update(template='my_record_landing_page.html')
8085
```
8186

8287
Then, we create a file `my_record_landing_page.html` inside the `templates` folder and edit it as below:
8388

84-
```console
89+
```jinja
8590
{%- extends 'invenio_rdm_records/record_landing_page.html' %}
8691
8792
{%- block page_body %}
@@ -90,3 +95,20 @@ Then, we create a file `my_record_landing_page.html` inside the `templates` fold
9095
```
9196

9297
Inside the `page_body` block you can restructure the page as you want! You can check the default record landing page template [here](https://github.com/inveniosoftware/invenio-rdm-records/blob/master/invenio_rdm_records/theme/templates/invenio_rdm_records/record_landing_page.html).
98+
99+
Since we modified `invenio.cfg`, we need to re-start the server to see our changes take effect:
100+
101+
```bash
102+
^C
103+
Stopping server and worker...
104+
Server and worker stopped...
105+
```
106+
```bash
107+
invenio-cli run
108+
```
109+
110+
## Change functionality
111+
112+
Need further customizations? Have you thought of creating your own extensions?
113+
114+
How to make an extension and add it to your InvenioRDM instance is explained in the [Extensions section](../extensions/custom.md).

docs/develop/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ We start by creating a new project in a different folder. We will just follow wh
1414
did in the [Preview section](../preview/index.md). Feel free to use your own
1515
project name.
1616

17+
``` bash
18+
invenio-cli init --flavour=RDM
19+
```
1720
``` console
18-
$ invenio-cli init --flavour=RDM
1921
Initializing RDM application...
2022
project_name [My Site]: February Release 2
2123
project_shortname [february-release-2]:

0 commit comments

Comments
 (0)