manuscripts-article-editor
This repository contains the editor package of Manuscripts app to be used in a react application.
Dependencies
Manuscripts is highly modular: it is composed out of a series of NPM published modules following a few different themes.
Data model
Data synchronisation
Editor components
Export
Reusable UI components
Datasets
Utilities
Installation
Run yarn install @manuscripts/article-editor in your application.
Build (for production)
The variables listed in .env.example must all be defined as environment variables in your project.
Run yarn build to build the app to the dist folder.
Deploy the files to S3 with scripts/deploy.sh.
Running the client in development mode
cp .env.example .env. The variables listed in .env.example have appropriate default values for running in a mode where the backend API server is running locally (this is optional, and you can complete local development tasks in the absence of the backend services). See steps below under "Running the backend API in Docker" for steps to launch the API server locally.
- Run
docker volume create --name=yarn-cache to create a yarn cache for the backend services that you will launch in the next step. This step is only needed once.
docker-compose up jupyter to start the services needed for development.
yarn start to start the app in development mode (using webpack-dev-server and react-hot-loader).
- To avoid signing up an account, open
http://localhost:8080/developer to create a dummy user profile. Now you're good to go.
Running the backend API in Docker
- Add any environment variables needed for the API server in
docker/server/.env.
docker login registry.gitlab.com to log in to GitLab’s Container Registry using your GitLab username and password (or a deploy token for read-only access to the registry images).
- Run
docker-compose pull to pull the latest server Docker images.
- [first run] Initialize the backend services:
scripts/api/initialize.sh. If running on Windows or MacOS, it may be necessary to increase the RAM allocated to Docker. (This can be done through Docker Desktop > Preferences > Resources > Advanced > Memory.)
- [subsequent runs] Start the backend services:
docker-compose up api
- Run
docker-compose up jupyter to start the additional services.
- Open chrome://flags/#cookies-without-same-site-must-be-secure and set to Disabled.
- Run
yarn start to start the frontend.
- Open Chrome, and enter
http://localhost:8080/signup to create a user account. Confirmation emails generally won't be sent from a locally-running API, but you can ignore that message (see APP_SKIP_ACCOUNT_VERIFICATION in docker/server/defaults.env)
- To stop the service, run
docker-compose down. Add an optional -v flag to delete the data volumes.
Running the Manuscripts stack in Kubernetes via Docker Desktop
- Make sure
kubectl is using the appropriate context:
- Run
kubectl config current-context to show the current context.
- Run
kubectl config get-contexts to list the available contexts.
- Run
kubectl config set-context docker-desktop to set the context.
- To build the client image, run
docker-compose build client
- To start the services, run
docker stack deploy --compose-file <(docker-compose config) manuscripts
- To stop the services, run
docker stack rm manuscripts
Template publishing
- Make sure you are using the test environment. (@manuscripts/data fetch published templates from the test environment: https://gitlab.com/mpapp-public/manuscripts-data/-/blob/master/scripts/fetch-published-templates.js#L6)
- Make sure you are logged in as a user who is allowed to publish templates (APP_COUCHBASE_ALLOWED_OWNERS)
or you are using (have access to) one of the projects which is allowed to publish templates (APP_COUCHBASE_ALLOWED_PROJECTS).
- Create a manuscript, edit the title (will be used as the template title), and specify requirements. Then publish the template (This can be done through Project menu > Publish Template).
- Release new version of manuscripts-data. (The build process will fetch published, user-generated template data from a manuscripts-api endpoint and adds it to the data published as @manuscripts/data)
- Release new version of manuscripts-requirements after updating the @manuscripts/data dependency version. (Essential for the validation process and building the quality report.)
- Upgrade pressroom-js after updating @manuscripts/data and @manuscripts/requirements dependencies.
- Update fusion-kubernetes-env with the new pressroom-js image tag.
- Upgrade this repository dependencies (@manuscripts/data and @manuscripts/requirements).
Testing
Unit tests
Run yarn test to run the unit tests in Jest.
Running tests with Cypress
- Run
yarn run cypress:open to launch the Cypress runner.
- From the Cypress runner, select an individual test to run or select
Run all specs
Development
See the manuscripts-frontend wiki for more information.
Developing manuscripts-api
- If needed, initialize the backend services:
scripts/api/initialize.sh
- Start the other backend services in Docker:
docker-compose up sync-gateway jupyter
- Start the API:
scripts/api/start-local.sh
Developing @manuscripts/style-guide
- Clone
@manuscripts/style-guide to a folder alongside this one, run yarn install to install its dependencies, run yarn link to make it available as a local dependency, then run yarn dev in that folder to start building it.
- In this folder, run
yarn link @manuscripts/style-guide to use the linked module as a local dependency.
Analysis
Run yarn stats to generate a stats.json file, then yarn analyze to open webpack-bundle-analyzer's visualization of the webpack bundle.
Configuration
The service is configured using environment variables, .env.example file placed at the root of the repository.
- API_APPLICATION_ID
- The application ID acceptable by the server (manuscripts-api).
- API_BASE_URL
- The *server* app base URL (the manuscripts-api instance) corresponding to this service.
- BACKUP_REPLICATION_PATH
- Backup replication URL.
- BASE_URL
- The base URL of this service (the manuscripts-frontend instance).
- BEACON_HTTP_URL
- The URL of a service that tracks the user presence on a manuscript.
- BEACON_WS_URL
- The URL of WebSocket. Required for tracking users presence on a manuscript.
- COMMENTING
- If set to '1', enables commenting on a manuscript.
- DERIVED_DATA_BUCKET
- The name of a database bucket for derived data.
- DISABLE_ATTACH_CODE
- If set to '1', disables the ability to attach code with figure.
- DISCOURSE_HOST
- The base URL of the Discourse host (used to show updates).
- ENABLE_CONNECT_LOGIN_OPTION
- If set to '1', enables auth using connect.
- EXPORT_LITERATUM
- If set to '1', enables the ability to export manuscript as Literatum Digital Object.
- EXPORT_STS
- If set to '1', enables the ability to export manuscript as STS.
- EXPORT_TO_REVIEW
- If set to '1', show Submissions tab and enable submit to review option.
- EXTYLES_ARC_SECRET
- Secret used as part of pressroom request to import docx/doc via eXtyles Arc.
- FEATURE_FILE_MANAGEMENT
- If set to '1', enables the ability to manage files. Specially made for lean workflow purposes.
- FEATURE_PRODUCTION_NOTES
- If set to '1', enables the ability to manipulate notes on a manuscript. Specially made for lean workflow purposes.
- FEATURE_PROJECT_MANAGEMENT
- If set to '1', provide project management tools to users. Allow users to tag and track the status of parts of a manuscript, and assign work to collaborators.
- FEATURE_QUALITY_CONTROL
- If set to '1', enables the ability to display quality reports. Specially made for lean workflow purposes.
- FEATURE_SWITCH_TEMPLATE
- If set to '1', enables the ability to change the manuscript's template.
- FOOTNOTES_ENABLED
- If set to '1', allow providing footnotes.
- FRONTMATTER_URI
- The URL of the login or about page (generated by manuscripts-io-www)
- IAM_BASE_URL
- The base URL of the IAM server. Used when auth using Connect.
- JUPYTER_URL
- The base URL of Jupyter notebook server.
- JUPYTER_TOKEN
- Token used to authenticate requests to Jupyter notebook server.
- LEAN_WORKFLOW
- If set to '1', enables lean workflow mode (This mode include some UI changes and load the manuscript differently so that it can be tracked).
- LEAN_WORKFLOW_MANAGER_URL
- The base URL of lean workflow server.
- LEAN_WORKFLOW_GRAPHQL_ENDPOINT
- The endPoint for the graphql.
- LOG_SYNC_EVENTS
- If set to '1', console log sync events.
- NATIVE
- If set to '1', the build of manuscripts-frontend is intended for the native (Mac) app
- PICKER_ORIGINS
- List of acceptable security origins where the Manuscripts document picker is presented at
- PRESSROOM_URL
- The base URL of pressroom service (used for importing/exporting).
- PRODUCTION
- If set to 0, include a "Develop" menu in the menu bar.
- PROJECTS_BUCKET
- The name of a database bucket for projects data.
- PUBLISH_TEMPLATES
- If set to '1', enables the ability to publish template.
- SERVICEWORKER_ENABLED
- When set to '1', application is built with its [service worker](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers) enabled. Essential for offline support.
- SHACKLES_ENABLED
- If set to '1', enables the ability to show history (snapshots).
- SHACKLES_URL
- The base URL of shackles service (used to create/retrieve snapshots).
- SUPPORT_EMAIL
- The email address used to contact support.
- SUBMISSION_SERIES_CODE
- Required for export as a "Literatum bundle".
- SUBMISSION_GROUP_DOI
- Required for export as a "Literatum bundle".
- SUBMISSION_ID
- The ID of submission does exist in the lean workflow server. To be used for local development (to workaround the association between submission/manuscript to load manuscript properly) when lean workflow mode enabled.
- SYNC_GATEWAY_URL
- The base URL of Sync Gateway.
- ZOTERO_TRANSLATION_SERVER
- URL used as a citation search source.
- FEATURE_KEYWORDS_CATEGORIES
- Allow categories for the keywords.
- RXDB
- Enable RxDb Database.