Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Support for Knot.x setup in gradle aem multi #65

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
7 changes: 5 additions & 2 deletions aem/gradle/environment.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ configure<AemExtension> {
"example.com",
"demo.example.com",
"author.example.com",
"dispatcher.example.com"
"dispatcher.example.com",
"knotx.example.com"
)
distributions {
download("http://download.macromedia.com/dispatcher/download/dispatcher-apache2.4-linux-x86_64-4.3.2.tar.gz").then {
Expand All @@ -15,7 +16,8 @@ configure<AemExtension> {
}
directories {
regular(
"httpd/logs"
"httpd/logs",
"knotx/logs"
)
cache(
"httpd/cache/content/example/live",
Expand All @@ -27,6 +29,7 @@ configure<AemExtension> {
url("Demo site", "http://demo.example.com/en-us.html", text = "English")
url("Author login", "http://author.example.com/libs/granite/core/content/login.html" +
"?resource=%2F&\$\$login\$\$=%24%24login%24%24&j_reason=unknown&j_reason_code=unknown", text = "AEM Sign In")
url("Knot.x", "http://knotx.example.com/products/details.html", text = "Hello Knot.x with GAP")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<3

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dislike comments / code looking like a poc. I more like looking like as much as production as it is possible

}
}

Expand Down
10 changes: 10 additions & 0 deletions aem/gradle/environment/docker-compose.yml.peb
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,15 @@ services:
extra_hosts:
- "host.docker.internal:10.0.2.2"
{% endif %}
knotx:
image: knotx/knotx:2.0.0-RC5
command: ["knotx", "run-knotx"]
volumes:
- "{{ environment.dockerConfigPath }}/knotx/conf:/usr/local/knotx/conf"
- "{{ environment.dockerRootPath }}/knotx/logs:/var/log/knotx"
ports:
- "8092:8092"
networks:
- docker-net
networks:
docker-net:
2 changes: 1 addition & 1 deletion aem/gradle/environment/httpd/conf/httpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ LoadModule dir_module modules/mod_dir.so
#LoadModule speling_module modules/mod_speling.so
#LoadModule userdir_module modules/mod_userdir.so
LoadModule alias_module modules/mod_alias.so
#LoadModule rewrite_module modules/mod_rewrite.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule dispatcher_module modules/mod_dispatcher.so

<IfModule disp_apache2.c>
Expand Down
14 changes: 14 additions & 0 deletions aem/gradle/environment/httpd/conf/vhost/knotx.example.com.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<VirtualHost *:80>
ServerName knotx.example.com

RewriteEngine On

RewriteCond %{REQUEST_METHOD} =GET
RewriteRule ^(.*\.html)$ - [E=KNOTX_REQ:true]

RewriteCond %{ENV:KNOTX_REQ} ^true$
RewriteRule ^/(.*)$ http://knotx:8092/$1 [P,L]

RewriteRule ^/(.*)$ http://demo.example.com/$1 [P,L]

</VirtualHost>
12 changes: 12 additions & 0 deletions aem/gradle/environment/knotx/conf/application.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
########### Modules to start ###########
# Modules map specify a list of verticles to be started by Knot.x.
# Each line should have a form of <alias>=<verticle-class-name>
# where alias is just a name that you can use later in order to define configuration for the module
# verticle-class-name is a fully qualified class name of the verticle.
#
# This JSON object is filled in included files.
modules {}


include required(classpath("server.conf"))
include required(classpath("knots/templateEngineStack.conf"))
15 changes: 15 additions & 0 deletions aem/gradle/environment/knotx/conf/bootstrap.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"configRetrieverOptions": {
"scanPeriod": 5000,
"stores": [
{
"type": "file",
"format": "conf",
"config": {
"path": "${KNOTX_HOME}/conf/application.conf"
},
"optional": false
}
]
}
}
26 changes: 26 additions & 0 deletions aem/gradle/environment/knotx/conf/knots/templateEngineKnot.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Vert.x event bus delivery options used when communicating with other verticles
address = knotx.knot.te.handlebars

engine {
factory = handlebars
config = {
# Algorithm used to build a hash key of the compiled handlebars snippets.
# The hash is computed for the snippet handlebars source code using a selected algorithm.
# The name should be a standard Java Security name (such as "SHA", "MD5", and so on).
# Default value is MD5
#
# cacheKeyAlgorithm = MD5

# Size of the compiled snippets cache. After reaching the max size, new elements will replace the oldest one.
cacheSize = 1000

# Symbol used as a start delimiter of handlebars expression. If not use, a default '{{' is used
#
# startDelimiter =

# Symbol used as a end delimiter of handlebars expression. If not use, a default '}}' is used
#
# endDelimiter =
}
}

11 changes: 11 additions & 0 deletions aem/gradle/environment/knotx/conf/knots/templateEngineStack.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
########### Data Bridge Stack ###########
modules {
templateEngine = "io.knotx.te.core.TemplateEngineKnot"
}

########### Modules configurations ###########
config.templateEngine {
options.config {
include required(classpath("knots/templateEngineKnot.conf"))
}
}
41 changes: 41 additions & 0 deletions aem/gradle/environment/knotx/conf/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (C) 2019 Knot.x Project

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->
<configuration>
<property name="LOG_PATH" value="/var/log/knotx"/>

<include resource="io/knotx/logging/logback/defaults.xml"/>
<include resource="io/knotx/logging/logback/file-appender.xml"/>
<include resource="io/knotx/logging/logback/access.xml"/>

<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
</Pattern>
</layout>
</appender>

<logger name="io.knotx" level="TRACE"/>
<logger name="io.vertx" level="TRACE"/>

<root level="INFO">
<appender-ref ref="FILE"/>
<appender-ref ref="CONSOLE"/>
</root>
</configuration>
32 changes: 32 additions & 0 deletions aem/gradle/environment/knotx/conf/openapi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
openapi: "3.0.0"
info:
version: 1.0.0
title: Knot.x Stack OAS
description: This is the server API specification.

servers:
- url: https://{domain}:{port}
description: The local API server
variables:
domain:
default: localhost
description: api domain
port:
enum:
- '8092'
- '443'
default: '8092'

paths:
/products/*:
get:
operationId: products-get
responses:
default:
description: Remote repository template processing with http action and te
/assets/*:
get:
operationId: assets-get
responses:
default:
description: Return assets as is from the repository
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
########### This configuration is overloaded in integration tests! ###########
tasks {
hello-world {
action = hello-inline
onTransitions {
_success {
action = te-hbs
}
}
}
}

actions {
hello-inline {
factory = inline-payload
config {
alias = hello
payload {
_result {
message = "Hello Knot.x with GAP"
}
}
}
}
te-hbs {
factory = knot
config {
address = knotx.knot.te.handlebars
deliveryOptions {
sendTimeout = 3000
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Vert.x event bus delivery options used when communicating with other verticles
# see http://vertx.io/docs/vertx-core/dataobjects.html#HttpClientOptions for the details what can be configured
#
clientOptions {
maxPoolSize = 1000
idleTimeout = 120 # seconds
tryUseCompression = true

# If you're going to use SSL (clientDestination.scheme='https') then here you'd need to configure
# some aspects related to the SSL negotiation and validation.
#
# Whether all server certificated should be trusted or not (e.g. self-signed certificates)
# trustAll = true
#
# Hostname verification
# verifyHost = false
#
# It will force SSL SNI (Server Name Indication). The SNI will be set to the same value as 'hostHeader' (set in ClientDestination)
# forceSni = true
}

# HTTP Repository connection details
clientDestination {
# Connection scheme: http or https
scheme = http

# domain or the IP of the host: e.g. localhost, 10.0.11.2
domain = httpd

## Port on which the host listens, e.g. 8080, 3001, etc.
port = 80

# Host header override to be used with a communication to the repository. If it's set, it overrides any value in the 'Host' header, and sets the SNI SSL to the same value.
hostHeader = demo.example.com
}

# List of allowed request headers that will be send to HTTP repository.
# Each item is a string that defines regex, e.g. to match any char use `.*`
#
allowedRequestHeaders = [
"Accept.*"
Authorization
Connection
Cookie
Date
"Edge.*"
"If.*"
Origin
Pragma
Proxy-Authorization
"Surrogate.*"
User-Agent
Via
"X-.*"
"Host.*"
]

# Statically defined HTTP request header sent in every request to the repository
customHttpHeader = {
name = X-User-Agent
value = Knot.x
}
30 changes: 30 additions & 0 deletions aem/gradle/environment/knotx/conf/routes/operations.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
routingOperations = ${routingOperations} [
{
operationId = products-get
handlers = ${config.server.handlers.common.request} [
{
name = httpRepoConnectorHandler
config = { include required(classpath("routes/handlers/httpRepoConnectorHandler.conf")) }
},
{
name = fragmentsProviderHtmlSplitter
},
{
name = fragmentsHandler
config = { include required(classpath("routes/handlers/fragmentsHandler.conf")) }
},
{
name = fragmentsAssemblerHandler
}
] ${config.server.handlers.common.response}
}
{
operationId = assets-get
handlers = ${config.server.handlers.common.request} [
{
name = httpRepoConnectorHandler
config = { include required(classpath("routes/handlers/httpRepoConnectorHandler.conf")) }
}
] ${config.server.handlers.common.response}
}
]
Loading