@eeacms/volto-citation 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ [ -n "$CI" ] && exit 0
2
+ yarn lint-staged
package/CHANGELOG.md CHANGED
@@ -4,6 +4,56 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
+ ### [0.1.4](https://github.com/eea/volto-citation/compare/0.1.3...0.1.4) - 29 September 2023
8
+
9
+ #### :house: Internal changes
10
+
11
+ - style: lint-staged reorder in package.json [Alin Voinea - [`b05d983`](https://github.com/eea/volto-citation/commit/b05d983e283811a20679c44254c55e549462028a)]
12
+
13
+ #### :house: Documentation changes
14
+
15
+ - docs: Update README and DEVELOP [Alin Voinea - [`7cdf143`](https://github.com/eea/volto-citation/commit/7cdf14349b4f08f09acb5b57525c79d307d1b254)]
16
+ - docs: Update README and DEVELOP [Alin Voinea - [`a124382`](https://github.com/eea/volto-citation/commit/a1243827ef8a4ad7d4f804af8a8d05f96f59c477)]
17
+
18
+ #### :hammer_and_wrench: Others
19
+
20
+ - test: EN locales, pre-commit fix, feature PRs checks Refs #257193 [valentinab25 - [`adbc1b5`](https://github.com/eea/volto-citation/commit/adbc1b5359b70e16510b764eb42c1c52778536ab)]
21
+ - test: Fix eslint and yarn i18n [Alin Voinea - [`d8f5cd1`](https://github.com/eea/volto-citation/commit/d8f5cd1fab04c42e354af4ecd640e2f9d1202e38)]
22
+ - i18n: Add en [Alin Voinea - [`9100e04`](https://github.com/eea/volto-citation/commit/9100e04e4de63f607a3867eaf45161b90d0985be)]
23
+ - test: Update Makefile and docker-compose to align it with Jenkinsfile [valentinab25 - [`766a456`](https://github.com/eea/volto-citation/commit/766a456f3ab988aa916feaae5fab9f2f894390fe)]
24
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`44b2af5`](https://github.com/eea/volto-citation/commit/44b2af58fe025442100ef0c52c45154b2d74e267)]
25
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`8f0a7e2`](https://github.com/eea/volto-citation/commit/8f0a7e2713a1a2a7ecf34bd3f7dc23e61b815283)]
26
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`c2597b9`](https://github.com/eea/volto-citation/commit/c2597b9778a2515e0b015b39a983add268f5c29a)]
27
+ ### [0.1.3](https://github.com/eea/volto-citation/compare/0.1.2...0.1.3) - 3 August 2023
28
+
29
+ #### :house: Documentation changes
30
+
31
+ - docs: Cleanup Makefile, update DEVELOP documentation, i18n - refs #254894 [valentinab25 - [`987cef0`](https://github.com/eea/volto-citation/commit/987cef0334372e3f119a6d35bd2a2fdb0c403b79)]
32
+
33
+ #### :hammer_and_wrench: Others
34
+
35
+ - citation [Dobricean Ioan Dorian - [`a9d15f9`](https://github.com/eea/volto-citation/commit/a9d15f9cc44c4857d42c3ad1c246e48d25113d79)]
36
+ - tab test [Dobricean Ioan Dorian - [`85ebc22`](https://github.com/eea/volto-citation/commit/85ebc22c31481f2cc80ef9248f3880c58d8c5796)]
37
+ - increase covreage [Dobricean Ioan Dorian - [`c6b2d7b`](https://github.com/eea/volto-citation/commit/c6b2d7b512cbc047e6fa5c5bb5045dcce56672c6)]
38
+ - increase [Dobricean Ioan Dorian - [`978a6ea`](https://github.com/eea/volto-citation/commit/978a6ea3ef35a19fd891167a23c6ff7d575c4ead)]
39
+ - increase code covreage [Dobricean Ioan Dorian - [`9644480`](https://github.com/eea/volto-citation/commit/964448028b2e32b82a8313a003567365ac9455cf)]
40
+ - increase code covreage [Dobricean Ioan Dorian - [`0123f35`](https://github.com/eea/volto-citation/commit/0123f35ce0fd39422e0bbdc38c36ee8e38486908)]
41
+ - accesibility [Dobricean Ioan Dorian - [`104b624`](https://github.com/eea/volto-citation/commit/104b624c77682f4599b48cc93aefc29d56adef92)]
42
+ - refecator [Dobricean Ioan Dorian - [`c7f8eeb`](https://github.com/eea/volto-citation/commit/c7f8eeb574ec9230e4a1bf2736b6a27375b186c1)]
43
+ - remove console [Dobricean Ioan Dorian - [`a50f9cc`](https://github.com/eea/volto-citation/commit/a50f9cca891fa11417936bd0ea615ca1ad557a32)]
44
+ - merge [Dobricean Ioan Dorian - [`a8bf3aa`](https://github.com/eea/volto-citation/commit/a8bf3aa3f8765669db598ca62fe76bd35efeea43)]
45
+ - remove empty line [Dobricean Ioan Dorian - [`066914e`](https://github.com/eea/volto-citation/commit/066914ef76010cce4f5a1f2cb97ada7afd7d9353)]
46
+ - use static [Dobricean Ioan Dorian - [`a3065e3`](https://github.com/eea/volto-citation/commit/a3065e38bd528bfd0f008a6aa76101597d7376e3)]
47
+ - new styles [Dobricean Ioan Dorian - [`465933f`](https://github.com/eea/volto-citation/commit/465933fe4b7f89b2054373572b521799f213371a)]
48
+ - Don't crash [Tiberiu Ichim - [`c607fd1`](https://github.com/eea/volto-citation/commit/c607fd1708f1abc20500d7985a5a44272cecd226)]
49
+ - Code cleanup [Tiberiu Ichim - [`394bc85`](https://github.com/eea/volto-citation/commit/394bc853429626fe863c069500bf22e7e60b86c4)]
50
+ - test [Dobricean Ioan Dorian - [`6f9ab9a`](https://github.com/eea/volto-citation/commit/6f9ab9abf379cd91a613f93cf9a7797cb0afbe10)]
51
+ - fix font [Dobricean Ioan Dorian - [`57a5182`](https://github.com/eea/volto-citation/commit/57a51828a38bd3f628f201f0db855280a6a08794)]
52
+ - change style [Dobricean Ioan Dorian - [`839187e`](https://github.com/eea/volto-citation/commit/839187e9beaf0e5fcaa7ae79f8d67cea240436ff)]
53
+ - fix cypress [Dobricean Ioan Dorian - [`b4ad8e2`](https://github.com/eea/volto-citation/commit/b4ad8e25e048426155fac5007d05df11dc23a601)]
54
+ - icon [Dobricean Ioan Dorian - [`191585f`](https://github.com/eea/volto-citation/commit/191585f49cb007537e288b0280aff143949da767)]
55
+ - use icons [Dobricean Ioan Dorian - [`4d1aadc`](https://github.com/eea/volto-citation/commit/4d1aadc660c7ef4434793d532ff1cb7be4e9e3f9)]
56
+ - use tabs [Dobricean Ioan Dorian - [`9ac7028`](https://github.com/eea/volto-citation/commit/9ac7028f892c2fec82b3ef63dbabca5798fb518c)]
7
57
  ### [0.1.2](https://github.com/eea/volto-citation/compare/0.1.1...0.1.2) - 25 July 2023
8
58
 
9
59
  #### :hammer_and_wrench: Others
package/DEVELOP.md CHANGED
@@ -2,6 +2,30 @@
2
2
 
3
3
  ## Develop
4
4
 
5
+ 1. Make sure you have `docker` and `docker compose` installed and running on your machine:
6
+
7
+ ```Bash
8
+ git clone https://github.com/eea/volto-citation.git
9
+ cd volto-citation
10
+ git checkout -b bugfix-123456 develop
11
+ make
12
+ make start
13
+ ```
14
+
15
+ 1. Wait for `Volto started at 0.0.0.0:3000` meesage
16
+
17
+ 1. Go to http://localhost:3000
18
+
19
+ 1. Initialize git hooks
20
+
21
+ ```Bash
22
+ yarn prepare
23
+ ```
24
+
25
+ 1. Happy hacking!
26
+
27
+ ### Or add @eeacms/volto-citation to your Volto project
28
+
5
29
  Before starting make sure your development environment is properly set. See [Volto Developer Documentation](https://docs.voltocms.com/getting-started/install/)
6
30
 
7
31
  1. Make sure you have installed `yo`, `@plone/generator-volto` and `mrs-developer`
@@ -26,18 +50,15 @@ Before starting make sure your development environment is properly set. See [Vol
26
50
 
27
51
  1. Install
28
52
 
29
- yarn develop
53
+ make develop
30
54
  yarn
31
55
 
32
56
  1. Start backend
33
57
 
34
- docker pull plone
35
- docker run -d --name plone -p 8080:8080 -e SITE=Plone -e PROFILES="profile-plone.restapi:blocks" plone
58
+ docker run --pull always -it --rm --name plone -p 8080:8080 -e SITE=Plone plone/plone-backend
36
59
 
37
60
  ...wait for backend to setup and start - `Ready to handle requests`:
38
61
 
39
- docker logs -f plone
40
-
41
62
  ...you can also check http://localhost:8080/Plone
42
63
 
43
64
  1. Start frontend
@@ -49,3 +70,37 @@ Before starting make sure your development environment is properly set. See [Vol
49
70
  1. Happy hacking!
50
71
 
51
72
  cd src/addons/volto-citation/
73
+
74
+ ## Cypress
75
+
76
+ To run cypress locally, first make sure you don't have any Volto/Plone running on ports `8080` and `3000`.
77
+
78
+ You don't have to be in a `clean-volto-project`, you can be in any Volto Frontend
79
+ project where you added `volto-citation` to `mrs.developer.json`
80
+
81
+ Go to:
82
+
83
+ ```BASH
84
+ cd src/addons/volto-citation/
85
+ ```
86
+
87
+ Start:
88
+
89
+ ```Bash
90
+ make
91
+ make start
92
+ ```
93
+
94
+ This will build and start with Docker a clean `Plone backend` and `Volto Frontend` with `volto-citation` block installed.
95
+
96
+ Open Cypress Interface:
97
+
98
+ ```Bash
99
+ make cypress-open
100
+ ```
101
+
102
+ Or run it:
103
+
104
+ ```Bash
105
+ make cypress-run
106
+ ```
package/README.md CHANGED
@@ -25,10 +25,23 @@ Volto Citation shows users how to cite an article. It supports four types of cit
25
25
 
26
26
  ## Getting started
27
27
 
28
+ ### Try volto-citation with Docker
29
+
30
+ git clone https://github.com/eea/volto-citation.git
31
+ cd volto-citation
32
+ make
33
+ make start
34
+
35
+ Go to http://localhost:3000
36
+
28
37
  ### Add volto-citation to your Volto project
29
38
 
30
39
  1. Make sure you have a [Plone backend](https://plone.org/download) up-and-running at http://localhost:8080/Plone
31
40
 
41
+ ```Bash
42
+ docker compose up backend
43
+ ```
44
+
32
45
  1. Start Volto frontend
33
46
 
34
47
  * If you already have a volto project, just update `package.json`:
package/cypress.config.js CHANGED
@@ -2,12 +2,12 @@ const { defineConfig } = require('cypress');
2
2
 
3
3
  module.exports = defineConfig({
4
4
  viewportWidth: 1280,
5
- defaultCommandTimeout: 8888,
5
+ defaultCommandTimeout: 5000,
6
6
  chromeWebSecurity: false,
7
7
  reporter: 'junit',
8
8
  video: true,
9
9
  retries: {
10
- runMode: 8,
10
+ runMode: 1,
11
11
  openMode: 0,
12
12
  },
13
13
  reporterOptions: {
@@ -0,0 +1,32 @@
1
+ version: "3"
2
+ services:
3
+ backend:
4
+ image: eeacms/plone-backend
5
+ ports:
6
+ - "8080:8080"
7
+ environment:
8
+ SITE: "Plone"
9
+ PROFILES: "eea.kitkat:testing"
10
+
11
+ frontend:
12
+ build:
13
+ context: ./
14
+ dockerfile: ./Dockerfile
15
+ args:
16
+ ADDON_NAME: "${ADDON_NAME}"
17
+ ADDON_PATH: "${ADDON_PATH}"
18
+ VOLTO_VERSION: ${VOLTO_VERSION:-16}
19
+ ports:
20
+ - "3000:3000"
21
+ - "3001:3001"
22
+ depends_on:
23
+ - backend
24
+ volumes:
25
+ - ./:/app/src/addons/${ADDON_PATH}
26
+ environment:
27
+ CI: "true"
28
+ NODE_ENV: "development"
29
+ RAZZLE_JEST_CONFIG: "src/addons/${ADDON_PATH}/jest-addon.config.js"
30
+ RAZZLE_INTERNAL_API_PATH: "http://backend:8080/Plone"
31
+ RAZZLE_DEV_PROXY_API_PATH: "http://backend:8080/Plone"
32
+ HOST: "0.0.0.0"
@@ -0,0 +1,73 @@
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: \n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: \n"
6
+ "PO-Revision-Date: \n"
7
+ "Last-Translator: \n"
8
+ "Language: \n"
9
+ "Language-Team: \n"
10
+ "Content-Type: \n"
11
+ "Content-Transfer-Encoding: \n"
12
+ "Plural-Forms: \n"
13
+
14
+ #: schema
15
+ # defaultMessage: The authors that have contributed to the article
16
+ msgid "AauthorsDescription"
17
+ msgstr ""
18
+
19
+ #: schema
20
+ # defaultMessage: One of the authors
21
+ msgid "AuthorDescription"
22
+ msgstr ""
23
+
24
+ #: Citation/CitationSidebar
25
+ #: schema
26
+ # defaultMessage: Citation
27
+ msgid "Citation"
28
+ msgstr ""
29
+
30
+ #: Citation/CitationSidebar
31
+ # defaultMessage: No Citation selected
32
+ msgid "No Citation selected"
33
+ msgstr ""
34
+
35
+ #: schema
36
+ # defaultMessage: The title of the article
37
+ msgid "TitleDescription"
38
+ msgstr ""
39
+
40
+ #: schema
41
+ # defaultMessage: URL
42
+ msgid "URL"
43
+ msgstr ""
44
+
45
+ #: schema
46
+ # defaultMessage: The url where the article can be found
47
+ msgid "URLDescription"
48
+ msgstr ""
49
+
50
+ #: schema
51
+ # defaultMessage: The year when the article was published
52
+ msgid "YearDescription"
53
+ msgstr ""
54
+
55
+ #: schema
56
+ # defaultMessage: Author
57
+ msgid "author"
58
+ msgstr ""
59
+
60
+ #: schema
61
+ # defaultMessage: Authors
62
+ msgid "authors"
63
+ msgstr ""
64
+
65
+ #: schema
66
+ # defaultMessage: Title
67
+ msgid "title"
68
+ msgstr ""
69
+
70
+ #: schema
71
+ # defaultMessage: Year
72
+ msgid "year"
73
+ msgstr ""
@@ -0,0 +1,73 @@
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: \n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: \n"
6
+ "PO-Revision-Date: \n"
7
+ "Last-Translator: \n"
8
+ "Language: \n"
9
+ "Language-Team: \n"
10
+ "Content-Type: \n"
11
+ "Content-Transfer-Encoding: \n"
12
+ "Plural-Forms: \n"
13
+
14
+ #: schema
15
+ # defaultMessage: The authors that have contributed to the article
16
+ msgid "AauthorsDescription"
17
+ msgstr ""
18
+
19
+ #: schema
20
+ # defaultMessage: One of the authors
21
+ msgid "AuthorDescription"
22
+ msgstr ""
23
+
24
+ #: Citation/CitationSidebar
25
+ #: schema
26
+ # defaultMessage: Citation
27
+ msgid "Citation"
28
+ msgstr ""
29
+
30
+ #: Citation/CitationSidebar
31
+ # defaultMessage: No Citation selected
32
+ msgid "No Citation selected"
33
+ msgstr ""
34
+
35
+ #: schema
36
+ # defaultMessage: The title of the article
37
+ msgid "TitleDescription"
38
+ msgstr ""
39
+
40
+ #: schema
41
+ # defaultMessage: URL
42
+ msgid "URL"
43
+ msgstr ""
44
+
45
+ #: schema
46
+ # defaultMessage: The url where the article can be found
47
+ msgid "URLDescription"
48
+ msgstr ""
49
+
50
+ #: schema
51
+ # defaultMessage: The year when the article was published
52
+ msgid "YearDescription"
53
+ msgstr ""
54
+
55
+ #: schema
56
+ # defaultMessage: Author
57
+ msgid "author"
58
+ msgstr ""
59
+
60
+ #: schema
61
+ # defaultMessage: Authors
62
+ msgid "authors"
63
+ msgstr ""
64
+
65
+ #: schema
66
+ # defaultMessage: Title
67
+ msgid "title"
68
+ msgstr ""
69
+
70
+ #: schema
71
+ # defaultMessage: Year
72
+ msgid "year"
73
+ msgstr ""
@@ -0,0 +1,73 @@
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: \n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: \n"
6
+ "PO-Revision-Date: \n"
7
+ "Last-Translator: \n"
8
+ "Language: \n"
9
+ "Language-Team: \n"
10
+ "Content-Type: \n"
11
+ "Content-Transfer-Encoding: \n"
12
+ "Plural-Forms: \n"
13
+
14
+ #: schema
15
+ # defaultMessage: The authors that have contributed to the article
16
+ msgid "AauthorsDescription"
17
+ msgstr ""
18
+
19
+ #: schema
20
+ # defaultMessage: One of the authors
21
+ msgid "AuthorDescription"
22
+ msgstr ""
23
+
24
+ #: Citation/CitationSidebar
25
+ #: schema
26
+ # defaultMessage: Citation
27
+ msgid "Citation"
28
+ msgstr ""
29
+
30
+ #: Citation/CitationSidebar
31
+ # defaultMessage: No Citation selected
32
+ msgid "No Citation selected"
33
+ msgstr ""
34
+
35
+ #: schema
36
+ # defaultMessage: The title of the article
37
+ msgid "TitleDescription"
38
+ msgstr ""
39
+
40
+ #: schema
41
+ # defaultMessage: URL
42
+ msgid "URL"
43
+ msgstr ""
44
+
45
+ #: schema
46
+ # defaultMessage: The url where the article can be found
47
+ msgid "URLDescription"
48
+ msgstr ""
49
+
50
+ #: schema
51
+ # defaultMessage: The year when the article was published
52
+ msgid "YearDescription"
53
+ msgstr ""
54
+
55
+ #: schema
56
+ # defaultMessage: Author
57
+ msgid "author"
58
+ msgstr ""
59
+
60
+ #: schema
61
+ # defaultMessage: Authors
62
+ msgid "authors"
63
+ msgstr ""
64
+
65
+ #: schema
66
+ # defaultMessage: Title
67
+ msgid "title"
68
+ msgstr ""
69
+
70
+ #: schema
71
+ # defaultMessage: Year
72
+ msgid "year"
73
+ msgstr ""
@@ -0,0 +1,73 @@
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: \n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: \n"
6
+ "PO-Revision-Date: \n"
7
+ "Last-Translator: \n"
8
+ "Language: \n"
9
+ "Language-Team: \n"
10
+ "Content-Type: \n"
11
+ "Content-Transfer-Encoding: \n"
12
+ "Plural-Forms: \n"
13
+
14
+ #: schema
15
+ # defaultMessage: The authors that have contributed to the article
16
+ msgid "AauthorsDescription"
17
+ msgstr ""
18
+
19
+ #: schema
20
+ # defaultMessage: One of the authors
21
+ msgid "AuthorDescription"
22
+ msgstr ""
23
+
24
+ #: Citation/CitationSidebar
25
+ #: schema
26
+ # defaultMessage: Citation
27
+ msgid "Citation"
28
+ msgstr ""
29
+
30
+ #: Citation/CitationSidebar
31
+ # defaultMessage: No Citation selected
32
+ msgid "No Citation selected"
33
+ msgstr ""
34
+
35
+ #: schema
36
+ # defaultMessage: The title of the article
37
+ msgid "TitleDescription"
38
+ msgstr ""
39
+
40
+ #: schema
41
+ # defaultMessage: URL
42
+ msgid "URL"
43
+ msgstr ""
44
+
45
+ #: schema
46
+ # defaultMessage: The url where the article can be found
47
+ msgid "URLDescription"
48
+ msgstr ""
49
+
50
+ #: schema
51
+ # defaultMessage: The year when the article was published
52
+ msgid "YearDescription"
53
+ msgstr ""
54
+
55
+ #: schema
56
+ # defaultMessage: Author
57
+ msgid "author"
58
+ msgstr ""
59
+
60
+ #: schema
61
+ # defaultMessage: Authors
62
+ msgid "authors"
63
+ msgstr ""
64
+
65
+ #: schema
66
+ # defaultMessage: Title
67
+ msgid "title"
68
+ msgstr ""
69
+
70
+ #: schema
71
+ # defaultMessage: Year
72
+ msgid "year"
73
+ msgstr ""
package/locales/volto.pot CHANGED
@@ -0,0 +1,75 @@
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Plone\n"
4
+ "POT-Creation-Date: 2023-08-29T17:31:41.550Z\n"
5
+ "Last-Translator: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
6
+ "Language-Team: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
7
+ "MIME-Version: 1.0\n"
8
+ "Content-Type: text/plain; charset=utf-8\n"
9
+ "Content-Transfer-Encoding: 8bit\n"
10
+ "Plural-Forms: nplurals=1; plural=0;\n"
11
+ "Language-Code: en\n"
12
+ "Language-Name: English\n"
13
+ "Preferred-Encodings: utf-8\n"
14
+ "Domain: volto\n"
15
+
16
+ #: schema
17
+ # defaultMessage: The authors that have contributed to the article
18
+ msgid "AauthorsDescription"
19
+ msgstr ""
20
+
21
+ #: schema
22
+ # defaultMessage: One of the authors
23
+ msgid "AuthorDescription"
24
+ msgstr ""
25
+
26
+ #: Citation/CitationSidebar
27
+ #: schema
28
+ # defaultMessage: Citation
29
+ msgid "Citation"
30
+ msgstr ""
31
+
32
+ #: Citation/CitationSidebar
33
+ # defaultMessage: No Citation selected
34
+ msgid "No Citation selected"
35
+ msgstr ""
36
+
37
+ #: schema
38
+ # defaultMessage: The title of the article
39
+ msgid "TitleDescription"
40
+ msgstr ""
41
+
42
+ #: schema
43
+ # defaultMessage: URL
44
+ msgid "URL"
45
+ msgstr ""
46
+
47
+ #: schema
48
+ # defaultMessage: The url where the article can be found
49
+ msgid "URLDescription"
50
+ msgstr ""
51
+
52
+ #: schema
53
+ # defaultMessage: The year when the article was published
54
+ msgid "YearDescription"
55
+ msgstr ""
56
+
57
+ #: schema
58
+ # defaultMessage: Author
59
+ msgid "author"
60
+ msgstr ""
61
+
62
+ #: schema
63
+ # defaultMessage: Authors
64
+ msgid "authors"
65
+ msgstr ""
66
+
67
+ #: schema
68
+ # defaultMessage: Title
69
+ msgid "title"
70
+ msgstr ""
71
+
72
+ #: schema
73
+ # defaultMessage: Year
74
+ msgid "year"
75
+ msgstr ""
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-citation",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "@eeacms/volto-citation: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -25,8 +25,31 @@
25
25
  "@plone/scripts": "*",
26
26
  "babel-plugin-transform-class-properties": "^6.24.1",
27
27
  "cypress-fail-fast": "^5.0.1",
28
+ "husky": "*",
29
+ "lint-staged": "*",
28
30
  "md5": "^2.3.0"
29
31
  },
32
+ "lint-staged": {
33
+ "src/**/*.{js,jsx,ts,tsx,json}": [
34
+ "make lint-fix",
35
+ "make prettier-fix"
36
+ ],
37
+ "src/**/*.{jsx}": [
38
+ "make i18n"
39
+ ],
40
+ "theme/**/*.{css,less}": [
41
+ "make stylelint-fix"
42
+ ],
43
+ "src/**/*.{css,less}": [
44
+ "make stylelint-fix"
45
+ ],
46
+ "theme/**/*.overrides": [
47
+ "make stylelint-fix"
48
+ ],
49
+ "src/**/*.overrides": [
50
+ "make stylelint-fix"
51
+ ]
52
+ },
30
53
  "scripts": {
31
54
  "release": "release-it",
32
55
  "release-major-beta": "release-it major --preRelease=beta",
@@ -44,6 +67,7 @@
44
67
  "lint:fix": "make lint-fix",
45
68
  "i18n": "make i18n",
46
69
  "cypress:run": "make cypress-run",
47
- "cypress:open": "make cypress-open"
70
+ "cypress:open": "make cypress-open",
71
+ "prepare": "husky install"
48
72
  }
49
73
  }
@@ -1,16 +1,19 @@
1
1
  import React, { useState, useEffect } from 'react';
2
- import './styles.less';
3
- import { Menu } from 'semantic-ui-react';
2
+ import { Tab, Label, Menu } from 'semantic-ui-react';
4
3
  import { useCopyToClipboard } from '@eeacms/volto-citation/helpers';
5
- import copySVG from '@plone/volto/icons/copy.svg';
6
- import checkSVG from '@plone/volto/icons/check.svg';
7
4
  import { Icon } from '@plone/volto/components';
8
5
 
9
6
  import Cite from 'citation-js';
10
7
 
11
- const CopyUrlButton = ({ citation }) => {
8
+ import copySVG from '@plone/volto/icons/copy.svg';
9
+ import checkSVG from '@plone/volto/icons/check.svg';
10
+
11
+ import './styles.less';
12
+
13
+ const CopyUrlButton = ({ citation, className }) => {
12
14
  const [copyUrlStatus, copyUrl] = useCopyToClipboard(citation);
13
15
  const [icon, setIcon] = useState(copySVG);
16
+
14
17
  useEffect(() => {
15
18
  if (copyUrlStatus === 'copied') {
16
19
  setIcon(checkSVG);
@@ -20,115 +23,162 @@ const CopyUrlButton = ({ citation }) => {
20
23
  }
21
24
  }, [copyUrlStatus]);
22
25
 
23
- return <Icon className="citation-copy" name={icon} onClick={copyUrl} />;
26
+ return (
27
+ <Label
28
+ floating
29
+ basic
30
+ tabIndex={0}
31
+ onKeyDown={(e) => {
32
+ if (e.key === 'Enter') copyUrl();
33
+ }}
34
+ >
35
+ <Icon
36
+ name={icon}
37
+ onClick={copyUrl}
38
+ className="citation-copy"
39
+ tabIndex={0}
40
+ />
41
+ </Label>
42
+ );
24
43
  };
25
44
 
26
45
  function Citation({ title, authors, link, type = 'article', year, mode }) {
27
- const [format, setFormat] = useState('bibliography');
28
- const [subFormat, setSubFormat] = useState('html');
29
- const [citation, setCitation] = useState();
30
-
31
- React.useEffect(() => {
32
- let citation = new Cite({
46
+ const cite = (format, subFormat) => {
47
+ const citationObject = new Cite({
33
48
  title: title,
34
49
  type: type,
35
- author: authors,
50
+ author: authors.map((author) => {
51
+ return {
52
+ literal: author,
53
+ };
54
+ }),
55
+
36
56
  issued: { 'date-parts': [[year]] },
37
57
  URL: link,
38
58
  });
39
- let output = citation.format(format, {
40
- format: subFormat,
41
- template: 'apa',
42
- });
43
- setCitation(output);
44
- if (subFormat === 'html')
45
- setCitation(
46
- `<blockquote> <p>(${year}).</p> <p>${title}</p> <p>
47
- ${authors.map((author, index) => {
48
- let separator = '';
49
- if (index < authors.length - 1) separator = ' , ';
50
- return (
51
- author?.family + ' ' + author.given?.charAt(0) + '.' + separator
52
- );
53
- })}
54
- </p> <a href=${link}>${link}</a> </blockquote>`,
55
- );
56
- }, [authors, format, year, link, subFormat, title, type]);
57
-
58
- const handleChangeFormat = (format, subformat) => {
59
- setFormat(format);
60
- setSubFormat(subformat);
59
+
60
+ if (format === 'html')
61
+ return `<blockquote>
62
+ <p>(${year}).</p>
63
+ <p>${title}</p>
64
+ <p>${authors.map((author, index) => {
65
+ const separator = index < authors.length - 1 ? ', ' : '';
66
+ return (author || '') + separator;
67
+ })}
68
+ </p>
69
+ <a href=${link}>${link}</a>
70
+ </blockquote>`;
71
+ else
72
+ return citationObject
73
+ .format(format, {
74
+ format: subFormat,
75
+ template: 'apa',
76
+ })
77
+ .replace(/(^[ \t]*\n)/gm, '');
61
78
  };
62
- return (
63
- <div className="citation-block">
64
- <Menu pointing>
79
+
80
+ const modes = [
81
+ {
82
+ menuItem: (
65
83
  <Menu.Item
66
- name="html"
67
- as="a"
68
- active={subFormat === 'html'}
69
- onClick={() => {
70
- handleChangeFormat('bibliography', 'html');
84
+ tabIndex={0}
85
+ onKeyDown={(e) => {
86
+ if (e.key === 'Enter') e.target.click();
71
87
  }}
72
88
  >
73
- HTML
89
+ Html
74
90
  </Menu.Item>
91
+ ),
92
+ render: () => (
93
+ <Tab.Pane attached={false}>
94
+ <blockquote className="text">
95
+ <p>({year}).</p>
96
+ <p>{title}</p>
97
+ <p>
98
+ {authors.map((author, index) => {
99
+ let separator = '';
100
+ if (index < authors.length - 1) separator = ', ';
101
+ return (author || '') + separator;
102
+ })}
103
+ </p>
104
+ {mode === 'edit' ? <p>{link}</p> : <a href={link}>{link}</a>}
75
105
 
106
+ <CopyUrlButton citation={cite('html')} />
107
+ </blockquote>
108
+ </Tab.Pane>
109
+ ),
110
+ },
111
+ {
112
+ menuItem: (
76
113
  <Menu.Item
77
- name="text"
78
- active={subFormat === 'text'}
79
- onClick={() => {
80
- handleChangeFormat('bibliography', 'text');
114
+ tabIndex={0}
115
+ onKeyDown={(e) => {
116
+ if (e.key === 'Enter') e.target.click();
81
117
  }}
82
118
  >
83
119
  Text
84
120
  </Menu.Item>
121
+ ),
122
+ render: () => (
123
+ <Tab.Pane attached={false}>
124
+ <div className="text">
125
+ <pre>{cite('bibliography', 'text')}</pre>
85
126
 
127
+ <CopyUrlButton citation={cite('bibliography', 'text')} />
128
+ </div>
129
+ </Tab.Pane>
130
+ ),
131
+ },
132
+ {
133
+ menuItem: (
86
134
  <Menu.Item
87
- name="ris"
88
- active={format === 'ris'}
89
- onClick={() => {
90
- handleChangeFormat('ris', '');
135
+ tabIndex={0}
136
+ onKeyDown={(e) => {
137
+ if (e.key === 'Enter') e.target.click();
91
138
  }}
92
139
  >
93
- RIS
140
+ Ris
94
141
  </Menu.Item>
142
+ ),
143
+ render: () => (
144
+ <Tab.Pane attached={false}>
145
+ <div className="text">
146
+ <pre>{cite('ris')}</pre>
147
+
148
+ <CopyUrlButton citation={cite('ris')} />
149
+ </div>
150
+ </Tab.Pane>
151
+ ),
152
+ },
153
+ {
154
+ menuItem: (
95
155
  <Menu.Item
96
- name="BibTex"
97
- active={format === 'bibtex'}
98
- onClick={() => {
99
- handleChangeFormat('bibtex');
156
+ tabIndex={0}
157
+ onKeyDown={(e) => {
158
+ if (e.key === 'Enter') e.target.click();
100
159
  }}
101
160
  >
102
161
  BibTex
103
162
  </Menu.Item>
104
- <Menu.Menu position="right">
105
- <Menu.Item>
106
- <CopyUrlButton citation={citation} />
107
- </Menu.Item>
108
- </Menu.Menu>
109
- </Menu>
110
- {subFormat === 'text' || format === 'bibtex' || format === 'ris' ? (
111
- <pre>{citation}</pre>
112
- ) : (
113
- <blockquote>
114
- <p>({year}).</p>
115
- <p>{title}</p>
116
- <p>
117
- {authors.map((author, index) => {
118
- let separator = '';
119
- if (index < authors.length - 1) separator = ' , ';
120
- return (
121
- (author?.family || '') +
122
- ' ' +
123
- (author.given?.charAt(0) || '') +
124
- '.' +
125
- separator
126
- );
127
- })}
128
- </p>
129
- {mode === 'edit' ? <p>{link}</p> : <a href={link}>{link}</a>}
130
- </blockquote>
131
- )}
163
+ ),
164
+ render: () => (
165
+ <Tab.Pane attached={false}>
166
+ <div className="text">
167
+ <pre>{cite('bibtex')}</pre>
168
+
169
+ <CopyUrlButton citation={cite('bibtex')} />
170
+ </div>
171
+ </Tab.Pane>
172
+ ),
173
+ },
174
+ ];
175
+
176
+ return (
177
+ <div className="citation-block tabs-block">
178
+ <Tab
179
+ panes={modes}
180
+ menu={{ className: 'ui green fluid pointing secondary menu' }}
181
+ />
132
182
  </div>
133
183
  );
134
184
  }
@@ -9,7 +9,7 @@ function CitationBlockEdit(props) {
9
9
  <div>
10
10
  <Citation
11
11
  title={data?.title || ''}
12
- authors={data.author || []}
12
+ authors={(data.authors || []).map((field) => field.author)}
13
13
  link={data.url || ''}
14
14
  year={data.year ?? 'n.d.'}
15
15
  mode={'edit'}
@@ -6,7 +6,7 @@ function CitationBlockView({ data }) {
6
6
  <div>
7
7
  <Citation
8
8
  title={data?.title || ''}
9
- authors={data.author || []}
9
+ authors={(data?.authors || []).map((field) => field.author)}
10
10
  link={data.url || ''}
11
11
  year={data.year ?? 'n.d.'}
12
12
  />
@@ -5,16 +5,43 @@
5
5
  cursor: pointer;
6
6
  }
7
7
 
8
+ .active.tab {
9
+ border: 0;
10
+ }
11
+
12
+ .ui.segment {
13
+ background: transparent !important;
14
+ }
15
+
16
+ .text {
17
+ position: relative;
18
+
19
+ .basic.floating {
20
+ border: none !important;
21
+ margin: -0.5em 0em 0em -3em !important;
22
+ background-color: transparent !important;
23
+ }
24
+ }
25
+
26
+ .citation-copy {
27
+ height: 1.5rem !important;
28
+ padding: 0.1em 1.3em !important;
29
+ }
30
+
31
+ .text {
32
+ .floating.label {
33
+ top: -1rem;
34
+ }
35
+ }
36
+
8
37
  pre {
9
38
  display: block;
10
- overflow: scroll;
39
+ overflow: auto;
11
40
  padding: 9.5px;
12
41
  border: 1px solid #ccc;
13
42
  margin: 0 0 10px;
14
43
  background-color: #f5f5f5;
15
44
  border-radius: 4px;
16
- color: #333333;
17
- font-size: 13px;
18
45
  line-height: 1.428571429;
19
46
  word-break: break-all;
20
47
  word-wrap: break-word;
@@ -22,15 +49,11 @@
22
49
 
23
50
  blockquote {
24
51
  position: relative;
25
- width: 60%;
52
+ width: 80%;
26
53
  padding: 1.2em 30px 1.2em 75px;
27
54
  border-left: 8px solid @secondaryColor;
28
55
  margin: 50px auto;
29
56
  background: #ededed;
30
- color: #555555;
31
- font-family: Open Sans;
32
- font-size: 1.4em;
33
- font-style: italic;
34
57
  line-height: 1.6;
35
58
  word-break: break-all;
36
59
  }
@@ -41,7 +64,6 @@
41
64
  left: 10px;
42
65
  color: @secondaryColor;
43
66
  content: '\201C';
44
- font-family: Arial;
45
67
  font-size: 4em;
46
68
  }
47
69
 
@@ -52,7 +74,6 @@
52
74
  blockquote span {
53
75
  display: block;
54
76
  margin-top: 1em;
55
- color: #333333;
56
77
  font-style: normal;
57
78
  font-weight: bold;
58
79
  }
@@ -72,5 +93,9 @@
72
93
  width: 0 !important;
73
94
  }
74
95
  }
96
+
97
+ .ui.tabular.menu .item {
98
+ padding: 0.875em 1.2em;
99
+ }
75
100
  }
76
101
  }
@@ -1 +1 @@
1
- export useCopyToClipboard from './useCopyToClipboard';
1
+ export { default as useCopyToClipboard } from './useCopyToClipboard';
@@ -2,11 +2,13 @@ import React from 'react';
2
2
 
3
3
  const useCopyToClipboard = (text) => {
4
4
  const [copyStatus, setCopyStatus] = React.useState('inactive');
5
+
5
6
  const copy = React.useCallback(() => {
6
- navigator.clipboard.writeText(text).then(
7
- () => setCopyStatus('copied'),
8
- () => setCopyStatus('failed'),
9
- );
7
+ if (navigator?.clipboard)
8
+ navigator.clipboard.writeText(text).then(
9
+ () => setCopyStatus('copied'),
10
+ () => setCopyStatus('failed'),
11
+ );
10
12
  }, [text]);
11
13
 
12
14
  React.useEffect(() => {
package/src/schema.js CHANGED
@@ -9,6 +9,26 @@ const messages = defineMessages({
9
9
  id: 'URL',
10
10
  defaultMessage: 'URL',
11
11
  },
12
+ CitationUrlDescription: {
13
+ id: 'URLDescription',
14
+ defaultMessage: 'The url where the article can be found',
15
+ },
16
+ YearDescription: {
17
+ id: 'YearDescription',
18
+ defaultMessage: 'The year when the article was published',
19
+ },
20
+ TitleDescription: {
21
+ id: 'TitleDescription',
22
+ defaultMessage: 'The title of the article',
23
+ },
24
+ AuthorsDescription: {
25
+ id: 'AauthorsDescription',
26
+ defaultMessage: 'The authors that have contributed to the article',
27
+ },
28
+ AuthorDescription: {
29
+ id: 'AuthorDescription',
30
+ defaultMessage: 'One of the authors',
31
+ },
12
32
  Year: {
13
33
  id: 'year',
14
34
  defaultMessage: 'Year',
@@ -17,38 +37,32 @@ const messages = defineMessages({
17
37
  id: 'title',
18
38
  defaultMessage: 'Title',
19
39
  },
40
+ Authors: {
41
+ id: 'authors',
42
+ defaultMessage: 'Authors',
43
+ },
20
44
  Author: {
21
45
  id: 'author',
22
46
  defaultMessage: 'Author',
23
47
  },
24
- Given: {
25
- id: 'given',
26
- defaultMessage: 'Given',
27
- },
28
- Family: {
29
- id: 'family',
30
- defaultMessage: 'Family',
31
- },
32
48
  });
33
49
 
34
50
  export const CitationBlockSchema = (props) => {
35
51
  const authorSchema = {
36
52
  title: props.intl.formatMessage(messages.Author),
53
+
37
54
  fieldsets: [
38
55
  {
39
56
  id: 'default',
40
57
  title: 'Default',
41
- fields: ['given', 'family'],
58
+ fields: ['author'],
42
59
  },
43
60
  ],
44
61
  properties: {
45
- given: {
46
- title: props.intl.formatMessage(messages.Given),
47
- widget: 'default',
48
- },
49
- family: {
50
- title: props.intl.formatMessage(messages.Family),
51
- widget: 'default',
62
+ author: {
63
+ title: props.intl.formatMessage(messages.Author),
64
+ a: 'default',
65
+ description: props.intl.formatMessage(messages.AuthorDescription),
52
66
  },
53
67
  },
54
68
  required: [],
@@ -60,7 +74,7 @@ export const CitationBlockSchema = (props) => {
60
74
  {
61
75
  id: 'default',
62
76
  title: 'Default',
63
- fields: ['url', 'year', 'title', 'author'],
77
+ fields: ['title', 'year', 'authors', 'url'],
64
78
  },
65
79
  ],
66
80
 
@@ -68,19 +82,23 @@ export const CitationBlockSchema = (props) => {
68
82
  url: {
69
83
  title: props.intl.formatMessage(messages.CitationUrl),
70
84
  widget: 'url',
85
+ description: props.intl.formatMessage(messages.CitationUrlDescription),
71
86
  },
72
87
  year: {
73
88
  title: props.intl.formatMessage(messages.Year),
74
89
  widget: 'default',
90
+ description: props.intl.formatMessage(messages.YearDescription),
75
91
  },
76
92
  title: {
77
93
  title: props.intl.formatMessage(messages.Title),
78
94
  widget: 'default',
95
+ description: props.intl.formatMessage(messages.TitleDescription),
79
96
  },
80
- author: {
81
- title: props.intl.formatMessage(messages.Author),
97
+ authors: {
98
+ title: props.intl.formatMessage(messages.Authors),
82
99
  widget: 'object_list',
83
100
  schema: authorSchema,
101
+ description: props.intl.formatMessage(messages.AuthorsDescription),
84
102
  },
85
103
  },
86
104
  required: [],
@@ -1 +0,0 @@
1
- module.exports = require('@plone/volto/babel');