Skip to content
Permalink
Browse files

feat: remove magnolia source to narrow Paperboys domain

  • Loading branch information...
Arne Diekmann
Arne Diekmann committed May 22, 2019
1 parent 6f301af commit 05f3332425c069d6a0bf7cc23c710bd461320f78
Showing with 4,749 additions and 8,485 deletions.
  1. +33 −127 README.md
  2. +5 −1 docker-compose.nats.yml
  3. +5 −1 docker-compose.rabbitmq.yml
  4. +0 −1,080 paperboy-cli/package-lock.json
  5. +4 −5 paperboy-cli/package.json
  6. +10 −23 paperboy-cli/paperboy-cli.js
  7. +1,006 −0 paperboy-cli/yarn.lock
  8. +6 −1 paperboy-core/.dockerignore
  9. +3 −0 paperboy-core/.prettierrc
  10. +7 −0 paperboy-core/Dockerfile
  11. +7 −17 paperboy-core/README.md
  12. +0 −17 paperboy-core/config/default.json
  13. +0 −5,069 paperboy-core/package-lock.json
  14. +17 −12 paperboy-core/package.json
  15. +1 −3 paperboy-core/src/index.ts
  16. +10 −5 paperboy-core/src/interfaces/paperboy-options.interface.ts
  17. +0 −6 paperboy-core/src/interfaces/sink-options.interface.ts
  18. +0 −9 paperboy-core/src/interfaces/source-options.interface.ts
  19. +0 −10 paperboy-core/src/interfaces/source.interface.ts
  20. +36 −39 paperboy-core/src/paperboy.ts
  21. +30 −0 paperboy-core/src/service/nats.service.ts
  22. +36 −0 paperboy-core/src/service/queue.service.ts
  23. +77 −0 paperboy-core/src/service/rabbitmq.service.ts
  24. +0 −42 paperboy-core/src/sink.ts
  25. +8 −0 paperboy-core/src/test.ts
  26. +11 −16 paperboy-core/tslint.json
  27. +3,428 −0 paperboy-core/yarn.lock
  28. +1 −1 paperboy-push-service/src/queue/nats/nats.service.ts
  29. +7 −4 paperboy-push-service/src/queue/queue.service.ts
  30. BIN paperboy-source-magnolia/.DS_Store
  31. +0 −2 paperboy-source-magnolia/.gitignore
  32. +0 −1,286 paperboy-source-magnolia/package-lock.json
  33. +0 −40 paperboy-source-magnolia/package.json
  34. +0 −130 paperboy-source-magnolia/src/dam.util.ts
  35. +0 −41 paperboy-source-magnolia/src/index.ts
  36. +0 −10 paperboy-source-magnolia/src/magnolia-loading-params.interface.ts
  37. +0 −18 paperboy-source-magnolia/src/magnolia-source-options.interface.ts
  38. +0 −181 paperboy-source-magnolia/src/magnolia-source.module.ts
  39. +0 −262 paperboy-source-magnolia/src/pages.util.ts
  40. +0 −19 paperboy-source-magnolia/tsconfig.json
  41. +1 −8 release.sh
160 README.md
@@ -12,12 +12,9 @@ To leverage the flexibility of a content management system while having the perf

1. This setup works by add a Magnolia module to both
instances, which listens for content changes and publishes
details of those changes to a Webhook which publishes a message in an AMQP compatible queue
details of those changes to a Webhook which publishes a message to a RabbitMQ or NATS server
2. A client-side library then subscribes to this queue
3. When a message is received, the library fetches the
content via the delivery endpoint released with Magnolia 5.6, transforms the JSON data (e.g. to ease the use of
assets)
4. Finally it will execute an arbitrary command to trigger
3. Finally it will execute an arbitrary command to trigger
the actual rebuild of the frontend

In case we don't want to operate the delivery tier ourselves and instead use a CDN like [Netlify](https://www.netlify.com) you can use the Magnolia Module to publish directly to a webhook by the CDN provider:
@@ -29,13 +26,30 @@ In case we don't want to operate the delivery tier ourselves and instead use a C
For the content management tier we provide two submodules which together with a queue handle the propagation of content change events:

1. [Paperboy push service](./paperboy-push-service): A small HTTP service that can be used as a webhook.
2. [Paperboy Magnolia module](./paperboy-magolia-module): A module that integrates directly into Magnolia and sends HTTP messages to the push service whenever a change in a watched workspace occurs.
2. [Paperboy Magnolia module](./paperboy-magolia-module): A module that integrates directly into Magnolia and sends HTTP messages to the push service (or an arbitrary webhook) whenever a change in a watched workspace occurs.

The subscriber part of this system is currently comprised of three submodules in this repository:

1. [Paperboy Core](./paperboy-core): The core library which handles all generic configuration and knows how to execute the commands to trigger rebuilds.
2. [Paperboy CLI](./paperboy-cli): A simple CLI to ease usage and setup
3. [Paperboy Magnolia Source](./paperboy-magnolia-source): A plug-in for the core which can fetch and transpose JSON data obtained from Magnolia.

## Demo

Run the following command to start a queue, push service and a simple 'frontend':

```bash
$ docker-compose -f docker-compose.nats.yml up
```

When all three services are up an running execute the follow command to send a message via the push service:

```bash
$ curl -X POST \
http://localhost:8080/ \
-H 'Authorization: Bearer supersecret' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'payload=%7B%22foo%22%3A%22bar%22%7D&source=foo'
```

## Quickstart

@@ -70,79 +84,39 @@ Afterwards add the Paperboy Magnolia Module to the webapp's POM.xml:
<dependency>
<groupId>de.neoskop.magnolia</groupId>
<artifactId>paperboy</artifactId>
<version>1.0.0</version>
<version>2.0.0</version>
</dependency>
```

Build the WAR and deploy it in a servlet container.

### Custom delivery layer

In case of a custom deliver layer, start the push service and a RabbitMQ server by running the following command in the root folder of this repository:
In case of a custom deliver layer, start the push service and a NATS server by running the following command in the root folder of this repository:

```bash
$ docker-compose up
$ docker-compose -f docker-compose.nats.yml up
```

(Substitute `docker-compose.nats.yml` with `docker-compose.rabbitmq.yml` to use an RabbitMQ server)

When the containers are up and running, import the following config into Magnolia's configuration under `/modules/paperboy/config`:

```yaml
webhookConfig:
webhookConfig:
authorization: BEARER_TOKEN
bearerToken: eash9uk3eejak6ena7thi8DooMih5eax
bearerToken: supersecret
url: http://push-service:8080/
```

To configure the frontend, create a file called `paperboy.config.json` with the following contents:

```json
{
"sourceOptions": {
"name": "magnolia",
"output": {
"json": "src",
"assets": "src/assets",
"excludedProperties": [
"jcr:created",
"jcr:createdBy",
"jcr:lastModifiedBy",
"jcr:lastActivated",
"jcr:lastActivatedBy",
"jcr:activationStatus",
"jcr:lastActivatedVersion",
"jcr:lastActivatedVersionCreated",
"jcr:primaryType",
"mgnl:created",
"mgnl:createdBy",
"mgnl:lastModifiedBy",
"mgnl:lastActivated",
"mgnl:lastActivatedBy",
"mgnl:activationStatus",
"mgnl:lastActivatedVersion",
"mgnl:lastActivatedVersionCreated",
"mgnl:primaryType"
]
},
"magnolia": {
"url": "http://localhost:8080",
"damJsonEndpoint": "/.rest/delivery/dam/v1",
"pagesEndpoint": "/.rest/delivery/website/v1",
"sitemapEndpoint": "/sitemap",
"auth": {
"header": "Basic cGFwZXJib3k6d0xGYkxqTkN4QVg4dzR0RVFHdzQyRDZP"
}
},
"queue": {
"uri": "amqp://admin:Boo4bah3ohcohthaeHa5ohter0iSeeS0@localhost:5672",
"exchangeName": "paperboy_preview"
}
"queue": {
"uri": "nats://queue:4222"
},
"sinkOptions": {
"async": true,
"command": "npm start",
"restartOnChange": false,
"workDir": "."
}
"command": "npm start"
}
```

@@ -154,75 +128,7 @@ $ paperboy start

### Netlify

To configure the frontend, create a fiel called `paperboy.config.json` with the following contents:

```json
{
"sourceOptions": {
"name": "magnolia",
"output": {
"json": "src",
"assets": "src/assets",
"excludedProperties": [
"jcr:created",
"jcr:createdBy",
"jcr:lastModifiedBy",
"jcr:lastActivated",
"jcr:lastActivatedBy",
"jcr:activationStatus",
"jcr:lastActivatedVersion",
"jcr:lastActivatedVersionCreated",
"jcr:primaryType",
"mgnl:created",
"mgnl:createdBy",
"mgnl:lastModifiedBy",
"mgnl:lastActivated",
"mgnl:lastActivatedBy",
"mgnl:activationStatus",
"mgnl:lastActivatedVersion",
"mgnl:lastActivatedVersionCreated",
"mgnl:primaryType"
]
},
"magnolia": {
"url": "http://localhost:8080",
"damJsonEndpoint": "/.rest/delivery/dam/v1",
"pagesEndpoint": "/.rest/delivery/website/v1",
"sitemapEndpoint": "/sitemap",
"auth": {
"header": "Basic cGFwZXJib3k6d0xGYkxqTkN4QVg4dzR0RVFHdzQyRDZP"
}
}
},
"sinkOptions": {
"async": false,
"command": "npm run build",
"restartOnChange": false,
"workDir": "."
}
}
```

To configure the netlify build create a file called `netlify.toml` with the following contents:

```toml
[Settings]
ID = "paperboy-netlify-demo"
[build]
base = "/"
publish = "dist/"
[context.develop]
command = "paperboy build"
[context.master]
command = "paperboy build"
```

This setup alone will only fetch the content from Magnolia whenever a change in the repository triggers a rebuild of the site on Netlify.

To also trigger a rebuild of the frontend whenever a change in Magnolia's content occurs, create a webhook in Netlify under `Settings > Build & Deploy` in your project.
To trigger a rebuild of the frontend whenever a change in Magnolia's content occurs, create a webhook in Netlify under `Settings > Build & Deploy` in your project.

Click "Add build hook":

@@ -239,7 +145,7 @@ Copy the webhook's URL:
Finally import the following config into Magnolia's configuration under `/modules/paperboy/config`:

```yaml
webhookConfig:
webhookConfig:
authorization: NONE
url: https://api.netlify.com/build_hooks/<webhook-id>
```
@@ -3,12 +3,16 @@ services:
queue:
image: nats:1.4.1-linux
hostname: paperboy_queue
frontend:
build: paperboy-core
environment:
QUEUE_URI: nats://queue:4222
push-service:
build:
context: paperboy-push-service
target: development
ports:
- "8081:8080"
- "8080:8080"
environment:
CONFIG: nats
depends_on:
@@ -9,12 +9,16 @@ services:
ports:
- "15672:15672"
- "5672:5672"
frontend:
build: paperboy-core
environment:
QUEUE_URI: amqp://admin:admin@queue:5672
push-service:
build:
context: paperboy-push-service
target: development
ports:
- "8081:8080"
- "8080:8080"
environment:
CONFIG: rabbitmq
depends_on:

0 comments on commit 05f3332

Please sign in to comment.
You can’t perform that action at this time.