Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/maven/fixes/7.0' into maven/rele…
Browse files Browse the repository at this point in the history
…ase/7.0
  • Loading branch information
metaventis-build committed Sep 12, 2023
2 parents 159fe7e + 1dba4f9 commit 2fd1297
Show file tree
Hide file tree
Showing 27 changed files with 408 additions and 705 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ To use the H5P editor you need to install and configure a database. At this time
- __DBPASSWORD__ the users password
- __DBNAME__ name of the database
- Create database tables by executing `php eduConnector/install/createDb.php`

To enable the h5p editing, please add the following into your `edu-sharing.conf` in the repository (Admin Tools / Global system configuration):
```
connectorList.connectors+={
id:"H5P", icon:"edit", showNew: true, onlyDesktop: true, hasViewMode: false,
filetypes:[
{mimetype: "application/zip",filetype: "h5p", ccressourcetype: "h5p", createable: true,editable: true}
]
}
```

### OnlyOffice
- Setup the OnlyOffice Document Server (see https://helpcenter.onlyoffice.com/de/server/document.aspx)
- Set values for
Expand Down
2 changes: 1 addition & 1 deletion deploy/docker/build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@
</build>

<modules>
<module>mysql</module>
<module>postgresql</module>
</modules>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>edu_sharing-community-services-connector-deploy-docker-build-mysql</artifactId>
<artifactId>edu_sharing-community-services-connector-deploy-docker-build-postgres</artifactId>
<packaging>jar</packaging>

<name>edu_sharing-community-services-connector-deploy-docker-build-mysql</name>
<name>edu_sharing-community-services-connector-deploy-docker-build-posgtres</name>


<build>
Expand Down Expand Up @@ -42,7 +42,7 @@
<configuration>
<images>
<image>
<name>${docker.repository}/${docker.prefix}-deploy-docker-build-mysql:${docker.tag}</name>
<name>${docker.repository}/${docker.prefix}-deploy-docker-build-postgresql:${docker.tag}</name>
</image>
</images>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ${docker.from.mysql}
FROM ${docker.from.postgresql.server}

########################################################################################################################

Expand Down
15 changes: 8 additions & 7 deletions deploy/docker/compose/src/main/compose/2_connector-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ version: "3.9"

services:
services-edu-connector-database:
image: "${docker.repository}/${docker.prefix}-deploy-docker-build-mysql:${docker.tag}"
image: "${docker.repository}/${docker.prefix}-deploy-docker-build-postgresql:${docker.tag}"
container_name: "services-edu-connector-database_${COMPOSE_PROJECT_NAME}"
environment:
MYSQL_USER: "${SERVICES_EDU_CONNECTOR_DATABASE_USER:-connector}"
MYSQL_PASSWORD: "${SERVICES_EDU_CONNECTOR_DATABASE_PASS:-connector}"
MYSQL_DATABASE: "${SERVICES_EDU_CONNECTOR_DATABASE_NAME:-connector}"
MYSQL_ROOT_PASSWORD: "${SERVICES_EDU_CONNECTOR_DATABASE_ROOT_PASS:-connector}"
POSTGRESQL_USERNAME: "${SERVICES_EDU_CONNECTOR_DATABASE_USER:-connector}"
POSTGRESQL_POSTGRES_PASSWORD: "${SERVICES_EDU_CONNECTOR_DATABASE_PASS:-connector}"
POSTGRESQL_DATABASE: "${SERVICES_EDU_CONNECTOR_DATABASE_NAME:-connector}"
POSTGRESQL_PASSWORD: "${SERVICES_EDU_CONNECTOR_DATABASE_ROOT_PASS:-connector}"
volumes:
- services-edu-connector-database-data:/bitnami/mysql/data
- "services-edu-connector-database-data:/bitnami/postgresql"

services-edu-connector-service:
image: "${docker.repository}/${docker.prefix}-service:${docker.tag}"
Expand All @@ -20,8 +20,9 @@ services:
HOST_EXTERNAL: "${SERVICES_EDU_CONNECTOR_HOST_EXTERNAL:-edu.connector.127.0.0.1.nip.io}"
PORT_EXTERNAL: "${SERVICES_EDU_CONNECTOR_PORT_EXTERNAL:-9200}"
PATH_EXTERNAL: "${SERVICES_EDU_CONNECTOR_PATH_EXTERNAL:-}"
DATABASE_TYPE: pgsql
DATABASE_HOST: services-edu-connector-database
DATABASE_PORT: "3306"
DATABASE_PORT: "5432"
DATABASE_NAME: "${SERVICES_EDU_CONNECTOR_DATABASE_NAME:-connector}"
DATABASE_USER: "${SERVICES_EDU_CONNECTOR_DATABASE_USER:-connector}"
DATABASE_PASSWORD: "${SERVICES_EDU_CONNECTOR_DATABASE_PASS:-connector}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: '3.7'
services:

services-edu-connector-database:
image: "${docker.registry}/${docker.repository}/${docker.prefix}-deploy-docker-build-mysql:${docker.tag}"
image: "${docker.registry}/${docker.repository}/${docker.prefix}-deploy-docker-build-postgres:${docker.tag}"

services-edu-connector-service:
image: "${docker.registry}/community/${docker.prefix}-service:${docker.tag}"
Expand Down
22 changes: 10 additions & 12 deletions deploy/docker/helm/src/main/chart/templates/statefulset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,15 @@ spec:
spec:
containers:
- name: edu-sharing-connector-db
image: mysql:8.0.31-debian
image: docker.edu-sharing.com/community/edu_sharing-community-services-edu-connector-deploy-docker-build-postgresql:{{ .Values.version }}
env:
- name: MYSQL_DATABASE
- name: POSTGRESQL_DATABASE
value: connector
- name: MYSQL_USER
- name: POSTGRESQL_USERNAME
value: connector
- name: MYSQL_ROOT_HOST
value: "%"
- name: MYSQL_PASSWORD
- name: POSTGRESQL_PASSWORD
value: {{ .Values.passwordDB }}
- name: MYSQL_ROOT_PASSWORD
- name: POSTGRESQL_POSTGRES_PASSWORD
value: {{ .Values.passwordDB }}
resources:
limits:
Expand All @@ -107,12 +105,12 @@ spec:
requests:
cpu: "1000m"
memory: "2Gi"
volumeMounts:
- name: data
mountPath: /var/lib/mysql
ports:
- containerPort: 3306
name: db
- name: db
containerPort: 5432
volumeMounts:
- name: data
mountPath: /bitnami/postgresql

volumeClaimTemplates:
- metadata:
Expand Down
8 changes: 7 additions & 1 deletion deploy/docker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@
<name>edu_sharing-community-services-connector-deploy-docker</name>

<properties>
<docker.from.mysql>dockerio.mirror.docker.edu-sharing.com/bitnami/mysql:8.0.32</docker.from.mysql>
<postgresql.version.major>13</postgresql.version.major>
<postgresql.version.minor>9</postgresql.version.minor>
<postgresql.version.patch>0</postgresql.version.patch>
<postgresql.version>${postgresql.version.major}.${postgresql.version.minor}.${postgresql.version.patch}</postgresql.version>
<docker.from.postgresql.server>
dockerio.mirror.docker.edu-sharing.com/bitnami/postgresql:${postgresql.version}
</docker.from.postgresql.server>
</properties>

<modules>
Expand Down
5 changes: 3 additions & 2 deletions service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ FROM dockerio.mirror.docker.edu-sharing.com/php:8.1.12-apache

RUN set -eux \
&& apt-get update \
&& apt-get install -yqq wait-for-it libzip-dev curl xmlstarlet jq nano \
&& apt-get install -yqq wait-for-it libpq-dev libzip-dev curl xmlstarlet jq nano \
&& a2enmod rewrite \
&& ln -s $PHP_INI_DIR/php.ini-production $PHP_INI_DIR/php.ini \
&& sed -i 's/max_execution_time = 30/max_execution_time = 120/g' $PHP_INI_DIR/php.ini \
&& docker-php-ext-install pdo pdo_mysql zip \
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
&& docker-php-ext-install pdo pdo_pgsql pgsql zip \
&& apt-get clean \
&& rm -r /var/lib/apt/lists/*

Expand Down
10 changes: 6 additions & 4 deletions service/src/main/docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ connector_database_port=${DATABASE_PORT//\/&/\\&}
connector_database_user=${DATABASE_USER//\/&/\\&}
connector_database_password=${DATABASE_PASSWORD//\/&/\\&}
connector_database_name=${DATABASE_NAME//\/&/\\&}
connector_database_path=${connector_database_host}:${connector_database_port}


# OPTIONALS

Expand All @@ -38,7 +36,9 @@ sed -i "s|define('WWWURL', '.*')|define('WWWURL', '${connector_url}')|g" "${conf
sed -i "s|define('DOCROOT', '.*')|define('DOCROOT', '${ROOT}')|g" "${conf}"
sed -i "s|define('DATA', '.*')|define('DATA', '${DATA}')|g" "${conf}"
sed -i "s|define('LOG_MODE', '.*')|define('LOG_MODE', 'stdout')|g" "${conf}"
sed -i "s|define('DBHOST', '.*')|define('DBHOST', '${connector_database_path}')|g" "${conf}"
sed -i "s|define('DBTYPE', '.*')|define('DBTYPE', 'pgsql')|g" "${conf}"
sed -i "s|define('DBHOST', '.*')|define('DBHOST', '${connector_database_host}')|g" "${conf}"
sed -i "s|define('DBPORT', '.*')|define('DBPORT', '${connector_database_port}')|g" "${conf}"
sed -i "s|define('DBUSER', '.*')|define('DBUSER', '${connector_database_user}')|g" "${conf}"
sed -i "s|define('DBPASSWORD', '.*')|define('DBPASSWORD', '${connector_database_password}')|g" "${conf}"
sed -i "s|define('DBNAME', '.*')|define('DBNAME', '${connector_database_name}')|g" "${conf}"
Expand All @@ -53,7 +53,7 @@ sed -i "s|define('MOODLE_TOKEN', '.*')|define('MOODLE_TOKEN', '${moodle_token}')
echo "Installing..."
php install/install.php

printf "\nWaiting for mysql to come active\n"
printf "\nWaiting for postgres to come active\n"
until wait-for-it "${connector_database_host}:${connector_database_port}" -t 3
do
sleep 5
Expand All @@ -62,6 +62,8 @@ done
echo "Initializing database..."
php install/createDb.php

echo ""
echo ""
echo "Connector is ready. Please register it at your repository (Admin Tools -> Remote-Systems) with the following url:"
echo "${connector_url}/metadata"
echo ""
Expand Down
13 changes: 5 additions & 8 deletions service/src/main/php/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

$app->get('/', function (Request $request, Response $response) {
$this->get('log')->info($request->getUri());
$connector = new Connector($this->get('log'));
$connector = new Connector($this->get('log'), $this, $response);
});

$app->get('/error/{errorid}[/{language}]', function (Request $request, Response $response, $args) {
Expand Down Expand Up @@ -81,8 +81,7 @@
//ajax.php needed because h5p concatenates GET parameters
$app->post('/ajax/ajax.php', function (Request $request, Response $response) {
global $db;
$db = new \PDO('mysql:host=' . DBHOST . ';dbname=' . DBNAME, DBUSER, DBPASSWORD);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db = new \connector\lib\Database();
$contentHandler = new \connector\tools\h5p\H5PContentHandler();
$h5p = \connector\tools\h5p\H5P::getInstance();

Expand All @@ -93,7 +92,7 @@
}

if(isset($request->getQueryParams()['action']) && $request->getQueryParams()['action']==='h5p_libraries') {
$db = new \PDO('mysql:host='.DBHOST.';dbname='.DBNAME, DBUSER, DBPASSWORD);
$db = new \connector\lib\Database();
$db->setAttribute( \PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION );
$libs = $h5p->H5PEditor->ajax->action(H5PEditorEndpoints::LIBRARIES);
return $response->withStatus(200)
Expand All @@ -102,8 +101,7 @@
}

if(isset($request->getQueryParams()['action']) && $request->getQueryParams()['action']==='h5p_library-install') {
$db = new \PDO('mysql:host='.DBHOST.';dbname='.DBNAME, DBUSER, DBPASSWORD);
$db->setAttribute( \PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION );
$db = new \connector\lib\Database();
$token = '';//$_GET['token'];
$libs = $h5p->H5PEditor->ajax->action(H5PEditorEndpoints::LIBRARY_INSTALL, $token, $request->getQueryParams()['id']);
return $response->withStatus(200)
Expand Down Expand Up @@ -153,8 +151,7 @@
$this->get('log')->info($request->getUri());
global $db;
try {
$db = new \PDO('mysql:host='.DBHOST.';dbname='.DBNAME, DBUSER, DBPASSWORD);
$db->setAttribute( \PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION );
$db = new \connector\lib\Database();
$h5p = \connector\tools\h5p\H5P::getInstance();

if(isset($request->getQueryParams()['machineName']) && isset($request->getQueryParams()['majorVersion']) && isset($request->getQueryParams()['minorVersion'])) {
Expand Down
3 changes: 3 additions & 0 deletions service/src/main/php/config.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
define('LOG_MODE', 'file');

/*h5p*/
// either pgsql or mysql
define('DBTYPE', 'pgsql');
define('DBHOST', '');
define('DBPORT', '5432');
define('DBUSER', '');
define('DBPASSWORD', '');
define('DBNAME', '');
Expand Down
11 changes: 9 additions & 2 deletions service/src/main/php/css/h5p.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,18 @@ body, html {
max-Width: 100% !important;
text-align: center;
padding-bottom: 30px !important;
height: 100%;
}

#h5p-content-form {
width: 100%;
display: inline-flex;
flex-direction: column;
justify-self: center;
max-width: 960px;
display: inline-block;
padding: 0 20px;
padding: 20px 20px;
}
.h5p-create {
flex-grow: 1;
min-height: 100vh;
}
85 changes: 85 additions & 0 deletions service/src/main/php/install/_tmpl/sql/h5p.ddl
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
CREATE TABLE h5p_libraries_languages (
library_id integer NOT NULL,
translation text NOT NULL,
language_code varchar(31) NOT NULL);

CREATE TABLE h5p_libraries (
id SERIAL PRIMARY KEY,
fullscreen integer NOT NULL,
runnable integer NOT NULL,
name varchar(127) NOT NULL,
title varchar(255) NOT NULL,
has_icon integer NOT NULL DEFAULT '0' ,
restricted integer NOT NULL DEFAULT '0' ,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
major_version integer NOT NULL,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
embed_types varchar(255) NOT NULL,
minor_version integer NOT NULL,
patch_version integer NOT NULL,
drop_library_css text NULL,
preloaded_js text NULL,
preloaded_css text NULL,
tutorial_url varchar(1023) NOT NULL,
semantics text NOT NULL);

CREATE INDEX idx_h5p_libraries_name
ON h5p_libraries (name, title);

CREATE TABLE h5p_libraries_libraries (
library_id integer NOT NULL,
required_library_id integer NOT NULL,
dependency_type varchar(31) NOT NULL);

CREATE TABLE h5p_contents (
id SERIAL PRIMARY KEY,
library_id integer NOT NULL,
user_id integer NOT NULL,
license varchar(7) NULL,
parameters text NOT NULL,
title varchar(255) NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
author varchar(127) NULL,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
slug varchar(127) NOT NULL,
keywords text NULL,
disable integer NOT NULL DEFAULT '0' ,
content_type varchar(127) NULL,
embed_type varchar(127) NOT NULL,
filtered text NOT NULL,
description text NULL);

CREATE INDEX idx_h5p_contents_title
ON h5p_contents (title);

CREATE TABLE h5p_contents_libraries (
id SERIAL PRIMARY KEY,
library_id integer NOT NULL,
drop_css integer NOT NULL,
content_id integer NOT NULL,
weight integer NOT NULL DEFAULT '0' ,
dependency_type varchar(31) NOT NULL);

CREATE TABLE h5p_libraries_hub_cache (
id SERIAL PRIMARY KEY,
machine_name varchar(127) NOT NULL,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
keywords text NULL,
owner varchar(511) NULL,
screenshots text NULL,
tutorial varchar(511) NULL,
title varchar(255) NOT NULL,
minor_version integer NOT NULL,
popularity integer NOT NULL,
description text NOT NULL,
h5p_minor_version integer NULL,
h5p_major_version integer NULL,
categories text NULL,
icon varchar(511) NOT NULL,
license text NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
major_version integer NOT NULL,
summary text NOT NULL,
patch_version integer NOT NULL,
is_recommended integer NOT NULL,
example varchar(511) NOT NULL);
Loading

0 comments on commit 2fd1297

Please sign in to comment.