From 6249e05da388f0b3d6a3ecb6a608da51f8cf2f2c Mon Sep 17 00:00:00 2001 From: alexander-gesinn Date: Wed, 5 Jun 2024 10:28:35 +0200 Subject: [PATCH] first MW 1.39 version --- Makefile | 53 +- context/Dockerfile | 502 ++++++++++-------- context/LocalSettings.Include.php | 43 +- .../LocalSettings.Debug.php | 0 .../LocalSettings.Extensions.php | 25 +- .../LocalSettings.Include.php | 13 + .../LocalSettings.Namespaces.php | 71 +++ .../LocalSettings.Permissions.php | 15 + .../LocalSettings.Settings.php | 93 ++++ context/build-tools/composer-update.sh | 11 + .../extensions/VEForAll/extension.json.diff | 13 + context/tools/initialize-wiki.sh | 75 +++ context/tools/startup-container.sh | 2 +- docker-compose.yml | 49 +- 14 files changed, 661 insertions(+), 304 deletions(-) rename context/{ => LocalSettings.OpenResearchStack}/LocalSettings.Debug.php (100%) rename context/{ => LocalSettings.OpenResearchStack}/LocalSettings.Extensions.php (89%) create mode 100644 context/LocalSettings.OpenResearchStack/LocalSettings.Include.php create mode 100644 context/LocalSettings.OpenResearchStack/LocalSettings.Namespaces.php create mode 100644 context/LocalSettings.OpenResearchStack/LocalSettings.Permissions.php create mode 100644 context/LocalSettings.OpenResearchStack/LocalSettings.Settings.php create mode 100644 context/build-tools/composer-update.sh create mode 100644 context/patches/extensions/VEForAll/extension.json.diff create mode 100755 context/tools/initialize-wiki.sh diff --git a/Makefile b/Makefile index b159330..9f1b861 100644 --- a/Makefile +++ b/Makefile @@ -1,41 +1,60 @@ +show-current-target = @echo; echo "======= $@ ========" + +.PHONY: all +all: + +compose = docker compose $(COMPOSE_ARGS) +compose-run = $(compose) run --rm +compose-exec = $(compose) exec -T +compose-cp = docker compose cp +wiki-exec = $(compose-exec) wiki + +# ======== Build ======== + .PHONY: build build: docker build \ --tag ghcr.io/gesinn-it-pub/openresearch-stack:dev \ ./context -.PHONY: sqlite-up -sqlite-up: - docker-compose up -d +# ======== Run ======== + +.PHONY: up +up: + $(show-current-target) + $(compose) up -d -.PHONY: mysql-up -mysql-up: - MYSQL_HOST=mysql docker-compose --profile mysql up -d +.PHONY: wait-for-wiki +wait-for-wiki: + $(show-current-target) + $(compose-run) wait-for-wiki .PHONY: show-status show-status: - docker-compose ps + $(show-current-target) + $(compose) ps .PHONY: show-logs show-logs: - docker-compose logs -f || exit 0 + docker compose logs -f || exit 0 .PHONY: stop stop: - docker-compose stop + $(show-current-target) + $(compose) stop .PHONY: down down: - docker-compose down --volumes --remove-orphans - -.PHONY: backstop-test -backstop-test: - docker-compose run --rm backstop test + $(show-current-target) + $(compose) down -.PHONY: clean -clean: down - rm -rf data +.PHONY: destroy +destroy: + $(show-current-target) + $(compose) down --volumes --remove-orphans +# ======== Develop ======== .PHONY: bash bash: + $(show-current-target) $(compose) exec wiki bash diff --git a/context/Dockerfile b/context/Dockerfile index c6f8fce..bc7b481 100644 --- a/context/Dockerfile +++ b/context/Dockerfile @@ -2,47 +2,73 @@ # docker-openresearch-stack # ###################################### -ARG MEDIAWIKI_VERSION=1.35.10 -FROM gesinn/docker-mediawiki-sqlite:${MEDIAWIKI_VERSION} +ARG MEDIAWIKI_VERSION=1.39.7 +ARG OPENRESEARCH_STACK_VERSION=1.39.7-001 + +FROM gesinn/mediawiki:${MEDIAWIKI_VERSION} # start from scratch -RUN rm -rf LocalSettings.php /var/www/data +#RUN rm -rf LocalSettings.php /var/www/data + +# install required packages +RUN \ + ### install required apt packages + # + # cron 6) + # ghostscript 1) + # gnupg 3) + # imagemagick 1) + # libpng-dev 4) + # libzip-dev 5) + # poppler-utils 1) + # software-properties-common 3) + # wget 3) + # zip 5) + # zlib1g-dev 4) + # libldap2-dev 8) + # + # 1) PDFHandler + # 3) External_Data PlantUML + # 4) php-gd / QRLite (PNG) + # 5) SemanticResultFormats (phpoffice/phpspreadsheet) + # 6) running jobs + # 7) caching + # 8) LDAP + apt-get update && \ + apt-get install -y cron ghostscript gnupg imagemagick libpng-dev libzip-dev poppler-utils software-properties-common wget zip zlib1g-dev libldap2-dev && \ + rm -rf /var/lib/apt/lists/* && \ + # + # + ### install required php packages + # + # gd 1) + # zip 2) + # + # 1) QRLite (PNG) + # 2) SemanticResultFormats (phpoffice/phpspreadsheet) + docker-php-ext-install gd zip # add /build-tools and /tools -RUN curl -LJ https://github.com/gesinn-it-pub/docker-mediawiki-tools/tarball/1.7.3 \ +RUN curl -LJ https://github.com/gesinn-it-pub/docker-mediawiki-tools/archive/refs/tags/2.0.1.tar.gz \ | tar xzC / --strip-components 1 + # override by custom tools -COPY tools /tools +ADD tools /tools +ADD build-tools /build-tools RUN chmod +x /build-tools/* /tools/* ENV PATH="/tools:/build-tools:${PATH}" + +### apply MediaWiki patches ADD patches /patches -###################################### -# install required apt packages # -# -# cron 6) -# ghostscript 1) -# gnupg 3) -# graphviz 2) -# imagemagick 1) -# libpng-dev 4) -# libzip-dev 5) -# memcached 7) -# poppler-utils 1) -# software-properties-common 3) -# wget 3) -# zip 5) -# zlib1g-dev 4) -# -# 1) PDFHandler -# 2) External_Data Graphviz -# 3) External_Data PlantUML -# 4) php-gd / QRLite (PNG) -# 5) SemanticResultFormats (phpoffice/phpspreadsheet) -###################################### -RUN apt-get update && \ - apt-get install -y cron ghostscript gnupg graphviz imagemagick libpng-dev libzip-dev memcached poppler-utils software-properties-common wget zip zlib1g-dev && \ - rm -rf /var/lib/apt/lists/* +### add php-settings (production) +ADD php-settings /usr/local/etc/php/conf.d +RUN cp "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/conf.d/10-php.ini" && \ + chmod 644 /usr/local/etc/php/conf.d/* + +RUN chown -R www-data:www-data \ + /var/www/html/vendor \ + /var/www/html/composer.lock ###################################### # install Java # @@ -56,16 +82,6 @@ RUN mkdir -p /etc/apt/keyrings && \ apt-get install -y temurin-11-jre && \ rm -rf /var/lib/apt/lists/* -###################################### -# install required php packages # -# -# gd 1) -# zip 2) -# -# 1) QRLite (PNG) -# 2) SemanticResultFormats (phpoffice/phpspreadsheet) -###################################### -RUN docker-php-ext-install gd zip ###################################### # install PlantUML # @@ -73,179 +89,214 @@ RUN docker-php-ext-install gd zip RUN wget http://netcologne.dl.sourceforge.net/project/plantuml/1.2022.2/plantuml-nodot.1.2022.2.jar -P /usr/share/java && \ (cd /usr/share/java && ln -snf plantuml-nodot.1.2022.2.jar plantuml.jar) -###################################### -# Search Extensions # -###################################### - -### Elastica -RUN get-extension.sh Elastica https://github.com/gesinn-it/extdist.wmflabs.org/raw/main/dist/extensions/Elastica-REL1_35-cffef9d.tar.gz && \ - # explicitly require elasticsearch/elasticsearch 5.5.0 to avoid - # https://phabricator.wikimedia.org/T267106 - # see also https://phabricator.wikimedia.org/T276854 with note about SMW - #composer require --no-update elasticsearch/elasticsearch 5.5.0 && \ - (cd extensions/Elastica && chown -R www-data:www-data . && sudo -u www-data composer install --no-dev) - -### CirrusSearch (2022-02-07) -RUN get-github-extension.sh CirrusSearch bb6b3475dc813bfb328ba012c880fd938d8a88ce - -###################################### -# Visual Editor # -###################################### - -## VisualEditor -#RUN rm -rf extensions/VisualEditor && \ -# get-extension.sh VisualEditor https://github.com/gesinn-it/extdist.wmflabs.org/raw/main/dist/extensions/VisualEditor-REL1_35-4e63a2f.tar.gz - -###################################### -# Skin # -###################################### - -### Chameleon -RUN composer-require.sh mediawiki/chameleon-skin 4.2.1 - -###################################### -# Extensions # -###################################### - -### AdminLinks -RUN get-github-extension.sh AdminLinks 0.5 - -### ApprovedRevs -RUN get-github-extension.sh ApprovedRevs 16c6f25bf7b69f4f091d13c594f76652f2edeb87 - -### Arrays (2022-02-06) -RUN get-github-extension.sh Arrays ce3f62878a825ef5df7a79e51fc2da7c95893a65 - -### AutoCreatePage -RUN get-github-extension.sh AutoCreatePage 1597e3d gesinn-it-pub/AutoCreatePage - -### Extension:CategoryTree (TODO: required?) - -### Extension:WikiEditor -### Required by CodeEditor - -### Extension:CodeEditor -### Requires WikiEditor - -### CookieWarning (2022-02-06) -RUN get-github-extension.sh CookieWarning a91b78000f25bd907dcc30bf5b2e10371a837552 - -### ConfirmAccount (REL1_35 2022-03-28) -RUN get-github-extension.sh ConfirmAccount 2681e4d1712c4b2e9b6fcc02fb1aa01bf1f2404b - -### ConfirmEdit (enabled as shipped with MediaWiki) +USER www-data -### CSS (2022-02-06) -RUN get-github-extension.sh CSS 91f9d53fc0c58e2772719cf5e9d0bfd3d12151d4 - -### DateDiff -RUN get-github-extension.sh DateDiff 0.3.1 - -### DisplayTitle -RUN get-github-extension.sh DisplayTitle 81279533fa75a0f800067a24c296fccb24f4b907 gesinn-it-pub/mediawiki-extensions-DisplayTitle - -### Echo (REL1_35 2022-02-21) -RUN get-github-extension.sh Echo 8c593b995992d4d3ede9bef58d39bc070a6cdd8d - -### EditAccount -RUN get-github-extension.sh EditAccount 2.0.1 gesinn-it-pub/EditAccount - -### ExternalData -RUN get-github-extension.sh ExternalData 3.0 && \ - patch.sh extensions/ExternalData/sql/ExternalData.sql - -### IDProvider -RUN get-github-extension.sh IDProvider 2.0.3 gesinn-it/IDProvider - -#### ImageMap (enabled as shipped with MediaWiki) - -### JSBreadCrumbs -RUN get-github-extension.sh JSBreadCrumbs 1.1.0 - -### LegalLogin (2022-05-20) -RUN get-github-extension.sh LegalLogin 62fcc432c1a6b7281e48c40fb2e83268a91fcc4a - -### Loops (2021-12-13) -RUN get-github-extension.sh Loops 8415e0b22bbe6dce5cb4b34c5edf0c27b219e85b - -### Maps -RUN COMPOSER=composer.local.json composer require --no-update mediawiki/maps 10.1.0 - -### Matomo -RUN get-github-extension.sh Matomo v4.0.1 DaSchTour/matomo-mediawiki-extension - -### Mermaid -RUN COMPOSER=composer.local.json composer require --no-update mediawiki/mermaid 3.1.0 - -### Modern Timeline -RUN COMPOSER=composer.local.json composer require --no-update professional-wiki/modern-timeline 1.2.1 - -### MultimediaViewer (enabled as shipped with MediaWiki) - -### NativeSvgHandler (2021-12-05) -RUN get-github-extension.sh NativeSvgHandler 13c02680047ec77fff4a6b7c4919e23c4ce7b081 - -### NumberFormat (2022-02-25) -RUN get-github-extension.sh NumberFormat a704f8834afbe21545079d577390a0a89560f072 - -### OpenLayers (2022-02-25) -RUN get-github-extension.sh OpenLayers e61f5b7c6ff2ad9321ba7c1e3b3e1333b470f870 - -### ParserFunctions enabled as shipped with MediaWiki) - -### PageForms -RUN get-github-extension.sh PageForms 5.3.4.4 gesinn-it/mediawiki-extensions-PageForms - -### TextExtracts (enabled as shipped with MediaWiki) - -### PageImages (enabled as shipped with MediaWiki) - -### Popups (2022-03-06) -RUN get-github-extension.sh Popups b6eb2627ff3f1fc93060f663efc2f8b302dbb376 - -### RegexFunctions (2022-01-11) -RUN get-github-extension.sh RegexFunctions af37c1050139b0b83360285e8d7ff9454d4c6ecc - -### ReplaceText (enabled as shipped with MediaWiki) - -### SemanticMediaWiki -RUN COMPOSER=composer.local.json composer require --no-update mediawiki/semantic-media-wiki 4.1.2 -## ISO-P formatter -#RUN composer-require.sh mediawiki/semantic-media-wiki 'dev-master#779f4784210de69f104705b0ec6e136f38375698 as 4.0.2' - -### SemanticCompoundQueries -RUN COMPOSER=composer.local.json composer require --no-update mediawiki/semantic-compound-queries 2.2.0 - -### SemanticDependencyUpdater -RUN get-github-extension.sh SemanticDependencyUpdater 3.0.1 gesinn-it/SemanticDependencyUpdater - -### SemanticExtraSpecialProperties -RUN COMPOSER=composer.local.json composer require --no-update mediawiki/semantic-extra-special-properties 3.0.4 - -### SemanticResultFormats -RUN COMPOSER=composer.local.json composer require --no-update phpoffice/phpspreadsheet 1.22.0 -RUN COMPOSER=composer.local.json composer require --no-update mediawiki/semantic-result-formats 4.0.1 - -### SimpleTooltip -RUN get-github-extension.sh SimpleTooltip 2476bff8f4555f86795c26ca5fdb7db99bfe58d1 Fannon/SimpleTooltip - -### TitleIcon -RUN get-github-extension.sh TitleIcon 5.2 - -### UrlGetParameters (2021-11-13) -RUN get-github-extension.sh UrlGetParameters ae491b9472ca60ab4a0afa84874824632bd6c833 - -### UserFunctions (2021-12-12) -RUN get-github-extension.sh UserFunctions b6ac1ddfc3742cd88d71fa9039b06161cbc11b27 - -### UserMerge (REL1_35 2022-02-28) -RUN get-github-extension.sh UserMerge 81739e0c967286264b132a64941d0da9575d79a1 - -### Variables -RUN get-github-extension.sh Variables v2.5.1 - -### VEForAll -RUN get-github-extension.sh VEForAll 0.4 +RUN \ + ### Chameleon + composer-require.sh mediawiki/chameleon-skin 4.3.0 && \ + # + # + ### AdminLinks + get-github-extension.sh AdminLinks 0.6.2 && \ + # + # + ### ApprovedRevs + get-github-extension.sh ApprovedRevs 2.0 && \ + # + # + ### Arrays (2024-04-28) + get-github-extension.sh Arrays ad73997736fe27d31c7f531e494d827ab871d2ff && \ + # + # + ### AutoCreatePage + get-github-extension.sh AutoCreatePage 1945b9dbcdb69d63a31df50467451e4b4d3a5290 gesinn-it-pub/AutoCreatePage && \ + # + # + ### Extension:CategoryTree (TODO: required?) + # + # + ### Extension:WikiEditor + ### Required by CodeEditor + # + # + ### Extension:CodeEditor + ### Requires WikiEditor + # + # + ### CirrusSearch (dev-REL1_39) + # other approaches to install from extension distributor or from source fails + composer-require.sh mediawiki/cirrussearch dev-REL1_39 && \ + # + # + ### CookieWarning (2024-06-03) + get-github-extension.sh CookieWarning 7326d988c373cd5f0fba9a0004cb9da4a8c2ba78 && \ + # + # + ### ConfirmAccount (REL1_39 2024-06-03) + get-github-extension.sh ConfirmAccount 284b143df379afeb377d16e5b8ed6b5a3628439f && \ + # + # + ### ConfirmEdit (enabled as shipped with MediaWiki) + # + # + ### CSS (2022-02-06) + get-github-extension.sh CSS 91f9d53fc0c58e2772719cf5e9d0bfd3d12151d4 && \ + # + # + ### DateDiff (2024-05-18) + get-github-extension.sh DateDiff 574a03ec520dc2f2efc15bb7135d3d94d86874f1 && \ + # + # + ### DisplayTitle + get-github-extension.sh DisplayTitle 4.0.2 && \ + # + # + ### Echo (REL1_39 2024-05-13) + get-github-extension.sh Echo 1ca913d35f0540813cb646b622c47fcaadff7af9 && \ + # + # + ### EditAccount + get-github-extension.sh EditAccount 9cc42c10dcfb878ff7be002758673a2453ccb65f gesinn-it-pub/EditAccount && \ + # + # + ### Elastica + get-extension.sh Elastica https://github.com/gesinn-it/extdist.wmflabs.org/raw/main/dist/extensions/Elastica-REL1_39-f6c979e.tar.gz && \ + COMPOSER=composer.local.json composer config --json --merge extra.merge-plugin.include '["extensions/Elastica/composer.json"]' && \ + # + # + ### ExternalData + get-github-extension.sh ExternalData 3.3 && \ + # TODO: the following patch was created for 3.0. Do we still need it? + # patch.sh extensions/ExternalData/sql/ExternalData.sql + # + # + ### IDProvider + get-github-extension.sh IDProvider 2.0.3 gesinn-it/IDProvider && \ + # + # + #### ImageMap (enabled as shipped with MediaWiki) + # + # + ### JSBreadCrumbs + get-github-extension.sh JSBreadCrumbs 1.1.1 && \ + # + # + ### LegalLogin (2024-05-18) + get-github-extension.sh LegalLogin 88cbd83b53501a7f123e22cd81b6f1fd583a22ac && \ + # + # + ### Loops (REL1_39 2024-04-01) + get-github-extension.sh Loops 02e2937cb2dc4f2b3d206100d598ef2bf4f6619f && \ + # + # + ### Maps + composer-require.sh mediawiki/maps 10.2.0 && \ + # + # + ### Matomo + get-github-extension.sh Matomo v5.0.0 DaSchTour/matomo-mediawiki-extension && \ + # + # + ### Mermaid + composer-require.sh mediawiki/mermaid 3.1.0 && \ + # + # + ### Modern Timeline + composer-require.sh professional-wiki/modern-timeline 1.2.2 && \ + # + # + ### MultimediaViewer (enabled as shipped with MediaWiki) + # + # + ### NativeSvgHandler (2024-05-18) + get-github-extension.sh NativeSvgHandler 34c8fef31ad4229dcb845502375af5f84093c73c && \ + # + # + ### NumberFormat (2024-05-18) + get-github-extension.sh NumberFormat 77df860bf8157d468d080c09f06f62199986bbca && \ + # + # + ### OpenLayers (2024-05-18) + get-github-extension.sh OpenLayers cc52c04c68a8e7ee80241edf4de4ec1413bf705e && \ + # + # + ### ParserFunctions enabled as shipped with MediaWiki) + # + # + ### PageForms + get-github-extension.sh PageForms 5.3.4.8 gesinn-it-pub/mediawiki-extensions-PageForms && \ + # + # + ### TextExtracts (enabled as shipped with MediaWiki) + # + # + ### PageImages (enabled as shipped with MediaWiki) + # + # + ### Popups (2022-03-06) + # TODO + # RUN get-github-extension.sh Popups b6eb2627ff3f1fc93060f663efc2f8b302dbb376 + # + # + ### RegexFunctions (2024-05-19) + get-github-extension.sh RegexFunctions d04157129d1c0bb85416d90eb16b0ffc5b448adf && \ + # + # + ### ReplaceText (enabled as shipped with MediaWiki) + # + # + ### SemanticMediaWiki + composer-require.sh mediawiki/semantic-media-wiki 4.1.3 && \ + # + # + ### SemanticCompoundQueries + composer-require.sh mediawiki/semantic-compound-queries 2.2.0 && \ + # + # + ### SemanticDependencyUpdater + get-github-extension.sh SemanticDependencyUpdater 3.0.3 gesinn-it/SemanticDependencyUpdater && \ + # + # + ### SemanticExtraSpecialProperties (2024-05-24) + composer-require.sh mediawiki/semantic-extra-special-properties 3.0.5 && \ + # + # + ### SemanticResultFormats + composer-require.sh phpoffice/phpspreadsheet 1.29.0 && \ + composer-require.sh mediawiki/semantic-result-formats 4.2.1 && \ + # + # + ### SimpleTooltip + # TODO + # RUN get-github-extension.sh SimpleTooltip 2476bff8f4555f86795c26ca5fdb7db99bfe58d1 Fannon/SimpleTooltip + # + # + ### TitleIcon + get-github-extension.sh TitleIcon 6.1 && \ + # + # + ### UrlGetParameters (2024-05-19) + get-github-extension.sh UrlGetParameters cf2712be11210bdcc6c358ccd59935979e91b732 && \ + # + # + ### UserFunctions (2024-05-19) + get-github-extension.sh UserFunctions 1f98fedf1509a8b497834aac9b5830afa2673a21 && \ + # + # + ### UserMerge (2024-03-26) + # This is the last commit before MW 1.41 is required + get-github-extension.sh UserMerge 2b76ea5165cec8c686c097799e1dc4f84c9aad71 && \ + # + # + ### Variables + get-github-extension.sh Variables v2.5.3 && \ + # + # + ### VEForAll + #get-github-extension.sh VEForAll 0.5.2 && \ + get-github-extension.sh VEForAll 3a71f9016a1a27cc53a69805ba84025f4574688e && \ + ### (Warning: patch applied to this extension, adding ext.visualEditor.mwgallery) + patch.sh extensions/VEForAll/extension.json ###################################### # composer update # @@ -255,33 +306,34 @@ RUN composer-update.sh ###################################### # patches # ###################################### -RUN \ - # Autocompletion in search field does not work - sed -i "s!ApiBase::LIMIT_SML1!100!g" \ - includes/api/Validator/ApiParamValidator.php +# TODO +#RUN \ +# # Autocompletion in search field does not work +# sed -i "s!ApiBase::LIMIT_SML1!100!g" \ +# includes/api/Validator/ApiParamValidator.php ###################################### # add openresearch-stack settings # ###################################### -ADD includes includes/openresearch-stack -ADD LocalSettings.Include.php . -ADD LocalSettings.Extensions.php . -ADD LocalSettings.Debug.php . +ADD --chown=www-data:www-data LocalSettings.Include.php /var/www/html/. +ADD --chown=www-data:www-data LocalSettings.OpenResearchStack /var/www/html/LocalSettings.OpenResearchStack ###################################### # set openresearch-stack version # ###################################### -ARG OPENRESEARCH_STACK_VERSION=0.0.32 RUN echo $OPENRESEARCH_STACK_VERSION > openresearch-stack-version.txt && \ echo "\$wgOpenResearchStackVersion = '$OPENRESEARCH_STACK_VERSION';" >> LocalSettings.Include.php ###################################### # add php-settings # ###################################### -ADD php-settings /usr/local/etc/php/conf.d -RUN chmod 644 /usr/local/etc/php/conf.d/* +# TODO: needs to be changed +#ADD php-settings /usr/local/etc/php/conf.d +#RUN chmod 644 /usr/local/etc/php/conf.d/* # use as volume for persistent storage of data, e.g. the current LocalSettings.php -RUN mkdir /data +# TODO: do we need this? +# RUN mkdir /data +USER root CMD [ "startup-container.sh" ] diff --git a/context/LocalSettings.Include.php b/context/LocalSettings.Include.php index 842b4e6..f9ecf3c 100644 --- a/context/LocalSettings.Include.php +++ b/context/LocalSettings.Include.php @@ -1,44 +1,3 @@ 'http://localhost' . $wgScriptPath . '/rest.php', + 'forwardCookies' => 'true', +]; ## ======== VisualEditor ======== ////////////////////////////////////////// @@ -32,7 +41,7 @@ wfLoadExtension( 'Bootstrap' ); wfLoadSkin( 'chameleon' ); $wgDefaultSkin="chameleon"; -$egChameleonLayoutFile= __DIR__ . "/skins/chameleon/layouts/fixedhead.xml"; +$egChameleonLayoutFile= $IP . "/skins/chameleon/layouts/fixedhead.xml"; ## ======== Chameleon ======== ## -------- AdminLinks -------- @@ -71,7 +80,7 @@ ## ======== CSS ======== ## -------- DateDiff -------- -require_once( "$IP/extensions/DateDiff/DateDiff.php" ); +wfLoadExtension( "DateDiff" ); ## ======== DateDiff ======== ## -------- DisplayTitle -------- @@ -142,7 +151,7 @@ ## ======== NativeSvgHandler ======== ## -------- NumberFormat -------- -require_once( "$IP/extensions/NumberFormat/NumberFormat.php" ); +wfLoadExtension( "NumberFormat" ); ## ======== NumberFormat ======== ## -------- OpenLayers -------- @@ -218,7 +227,7 @@ ## ======== SemanticResultFormats ======== ## -------- SimpleTooltip -------- -require_once( "$IP/extensions/SimpleTooltip/SimpleTooltip.php" ); +# require_once( "$IP/extensions/SimpleTooltip/SimpleTooltip.php" ); ## ======== SimpleTooltip ======== ## -------- TitleIcon -------- diff --git a/context/LocalSettings.OpenResearchStack/LocalSettings.Include.php b/context/LocalSettings.OpenResearchStack/LocalSettings.Include.php new file mode 100644 index 0000000..1ae40a7 --- /dev/null +++ b/context/LocalSettings.OpenResearchStack/LocalSettings.Include.php @@ -0,0 +1,13 @@ + 'Test', +]; + +// Apply Namespaces +foreach ( $customNamespaces as $number => $name ) { + + $id = 'NS_' . strtoupper( $name ); + + define( $id, $number ); // Define namespace + define( $id . '_TALK', ( $number + 1 ) ); // Define talk namespace + + if ( isset( $wgExtraNamespaces[$number] ) ) { + die( 'Cannot declare namespace number twice: ' . $number . ' for ' . $name ); + } + + $wgExtraNamespaces[$number] = $name; + $wgExtraNamespaces[( $number + 1 )] = $name . '_Talk'; + + + // MediaWiki ------------------------------------------------------------------------------------------------------- + // https://www.mediawiki.org/wiki/Manual:$wgContentNamespaces + $wgContentNamespaces[] = $number; + + // https://www.mediawiki.org/wiki/Manual:$wgNamespacesWithSubpages + $wgNamespacesWithSubpages[$number] = true; + + // https://www.mediawiki.org/wiki/Manual:$wgNamespacesToBeSearchedDefault + $wgNamespacesToBeSearchedDefault[$number] = true; + + // don't enable VE for semantic:apps namespaces since edit via from is preferred + $wgVisualEditorAvailableNamespaces[$number] = false; + + // Page Forms ------------------------------------------------------------------------------------------------------ + // https://www.mediawiki.org/wiki/Extension:Page_Forms/Linking_to_forms#For_additional_namespaces + $wgPageFormsAutoeditNamespaces[$number] = true; + + // Semantic MediaWiki ---------------------------------------------------------------------------------------------- + // https://www.semantic-mediawiki.org/wiki/Help:$smwgNamespacesWithSemanticLinks + $smwgNamespacesWithSemanticLinks[$number] = true; + + // User Functions -------------------------------------------------------------------------------------------------- + // https://www.mediawiki.org/wiki/Extension:UserFunctions#Allowing_namespaces + $wgUFAllowedNamespaces[$number] = true; + +} + +// Declare common namespaces as semantic +$smwgNamespacesWithSemanticLinks[2] = true; // USER +$smwgNamespacesWithSemanticLinks[4] = true; // PROJECT +$wgContentNamespaces[] = 4; +$wgUFAllowedNamespaces[4] = true; +$smwgNamespacesWithSemanticLinks[6] = true; // FILE +$wgContentNamespaces[] = 6; +$wgUFAllowedNamespaces[6] = true; +$smwgNamespacesWithSemanticLinks[10] = true; // TEMPLATE +$wgUFAllowedNamespaces[10] = true; +$smwgNamespacesWithSemanticLinks[12] = true; // HELP +$wgContentNamespaces[] = 12; +$smwgNamespacesWithSemanticLinks[14] = true; // CATEGORY + +$smwgNamespacesWithSemanticLinks[102] = true; // PROPERTY +$smwgNamespacesWithSemanticLinks[106] = true; // FORM +$smwgNamespacesWithSemanticLinks[108] = true; // CONCEPT diff --git a/context/LocalSettings.OpenResearchStack/LocalSettings.Permissions.php b/context/LocalSettings.OpenResearchStack/LocalSettings.Permissions.php new file mode 100644 index 0000000..da0d7e6 --- /dev/null +++ b/context/LocalSettings.OpenResearchStack/LocalSettings.Permissions.php @@ -0,0 +1,15 @@ + 5, 'seconds' => 3600 ], [ 'count' => 2, 'seconds' => 300 ] ]; + +## E-Mail +$wgEnableEmail = true; +$wgEnableUserEmail = true; # UPO + +$wgEmergencyContact = "support@acme.com"; +$wgPasswordSender = "support@acme.com"; + +$wgEnotifUserTalk = true; # UPO +$wgEnotifWatchlist = true; # UPO +$wgEmailAuthentication = true; + +$wgSMTP = array( + 'host' => 'mail.acme.com', + 'IDHost' => 'acme.com', + 'port' => 25, +'username' => 'test', +'password' => 'secret', + 'auth' => true +); + + +## Timezone +$wgLocaltimezone = "Europe/Berlin"; +putenv("TZ=$wgLocaltimezone"); +$wgLocalTZoffset = date("Z") / 60; +$wgDefaultUserOptions['timecorrection'] = 'ZoneInfo|' . (date("I") ? 120 : 60) . '|Europe/Berlin'; + +#### User Preference Options +## Default Language UPO +$wgDefaultUserOptions['language'] = 'en'; + +## Files UPO +$wgDefaultUserOptions['thumbsize'] = 0; # 0 defaults to 60px + +## SMW UPO +$wgDefaultUserOptions['smw-prefs-general-options-time-correction'] = 1; +$wgDefaultUserOptions['smw-prefs-general-options-disable-search-info'] = 1; +$wgDefaultUserOptions['smw-prefs-general-options-suggester-textinput'] = 1; +#### + +## Edit Redlinks with VE by default +$wgHooks['HtmlPageLinkRendererBegin'][] = function ( $linkRenderer, $target, &$text, &$extraAttribs, &$query, &$ret ) { + $title = Title::newFromLinkTarget( $target ); + if ( !$title->isKnown() ) { + $query['veaction'] = 'edit'; + $query['action'] = 'view'; // Prevent MediaWiki from overriding veaction + } +}; + +## Disable Patrolled Edits +$wgUseRCPatrol = false; +$wgUseNPPatrol = false; + +## Files +$wgEnableUploads = true; +$wgFileExtensions = [ 'png', 'gif', 'jpg', 'jpeg', 'svg', 'webp' ]; +$wgVerifyMimeType = false; # required to allow e.g. docx diff --git a/context/build-tools/composer-update.sh b/context/build-tools/composer-update.sh new file mode 100644 index 0000000..557b878 --- /dev/null +++ b/context/build-tools/composer-update.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +COMPOSER_AUTH="{\"github-oauth\": {\"github.com\": \"$(cat /run/secrets/GH_API_TOKEN 2>/dev/null || echo no_token)\"}}" composer update --prefer-source + +# Only use COMPOSER_AUTH environment variable, if a token secret is available. +# Setting the environment variable inline with the command avoids to persist beyond that command. +if [ -f /run/secrets/GH_API_TOKEN ]; then + COMPOSER_AUTH="{\"github-oauth\": {\"github.com\": \"$(cat /run/secrets/GH_API_TOKEN 2>/dev/null || echo no_token)\"}}" composer update --prefer-source +else + composer update --prefer-source +fi \ No newline at end of file diff --git a/context/patches/extensions/VEForAll/extension.json.diff b/context/patches/extensions/VEForAll/extension.json.diff new file mode 100644 index 0000000..df3ae85 --- /dev/null +++ b/context/patches/extensions/VEForAll/extension.json.diff @@ -0,0 +1,13 @@ +Enable "Gallery" for Form Freetext +https://wiki.gesinn.it/wiki/Issue:3054 + +--- extension.json.orig 2022-07-05 16:42:29.127108500 +0200 ++++ extension.json 2022-07-05 16:42:38.662908400 +0200 +@@ -48,6 +48,7 @@ + "ext.visualEditor.mwimage", + "ext.visualEditor.mwlink", + "ext.visualEditor.mwtransclusion", ++ "ext.visualEditor.mwgallery", + "oojs-ui.styles.icons-editing-advanced" + ] + }, diff --git a/context/tools/initialize-wiki.sh b/context/tools/initialize-wiki.sh new file mode 100755 index 0000000..e93c292 --- /dev/null +++ b/context/tools/initialize-wiki.sh @@ -0,0 +1,75 @@ +#!/bin/bash + +set -euo pipefail + +ELASTICSEARCH_HOST=${ELASTICSEARCH_HOST:-} + +setup_local_settings() { + echo "--- Setting up LocalSettings.php ---" + + echo '$wgNetworkEnvironment = [];' >> LocalSettings.php; + if [ "$ELASTICSEARCH_HOST" != "" ]; then + echo "\$wgNetworkEnvironment[ 'ELASTICSEARCH_HOST' ] = '$ELASTICSEARCH_HOST';" >> LocalSettings.php; + fi + echo 'if (file_exists( "$IP/LocalSettings.Include.php" )) require_once( "$IP/LocalSettings.Include.php" );' >> LocalSettings.php + echo 'if (file_exists( "$IP/LocalSettings.TMP.php" )) require_once( "$IP/LocalSettings.TMP.php" );' >> LocalSettings.php + sudo -u www-data php maintenance/update.php --skip-external-dependencies --quick + echo "=== Setting up LocalSettings.php ===" +} + +initialize_cirrus() { + if [ "$ELASTICSEARCH_HOST" != "" ]; then + echo "--- Initializing Cirrus Search ---" + echo "Waiting for elasticsearch server to be ready..." + wait-for-it.sh -h $ELASTICSEARCH_HOST -p 9200 -t 60 + echo '> LocalSettings.TMP.php + php extensions/Cirrussearch/maintenance/UpdateSearchIndexConfig.php && \ + rm LocalSettings.TMP.php && \ + php extensions/Cirrussearch/maintenance/ForceSearchIndex.php --skipLinks --indexOnSkip && \ + php extensions/Cirrussearch/maintenance/ForceSearchIndex.php --skipParse + fi +} + +save_settings() { + echo "--- Saving LocalSettings for later ---" + save-wiki-settings.sh +} + +restore_settings() { + restore-wiki-settings.sh +} + +setup_cron_job() { + if [ "`type crontab 2>/dev/null`" != "" ]; then + echo "Setting up cron job for wiki jobs" + echo "*/1 * * * * /usr/bin/timeout -k 60 300 /usr/local/bin/php /var/www/html/maintenance/runJobs.php --maxtime 50 >> /dev/null 2>&1" | crontab -uwww-data - + fi +} + +if [ -e LocalSettings.php ]; then + # Case 1: The container has already been started before + echo ">>> LocalSettings.php exists. Nothing to do." +else + # Case 2: The container is starting the first time after creation from the image + echo ">>> LocalSettings.php is missing." + + # Ensure the log folder exists + mkdir -p /data/log && chown www-data:www-data /data/log + + configure-container.sh + + if [ -e /data/LocalSettings.php ]; then + # Case 2a: there has already been a running container for this environment + echo ">>> Settings in /data exist. Taking them." + restore_settings + else + # Case 2a: this is a completely fresh environment which has to be initialized first + echo ">>> /data/LocalSettings.php missing, too. Need to create one." + install-mediawiki.sh + setup_local_settings + initialize_cirrus + save_settings + run-jobs.sh + fi + setup_cron_job +fi \ No newline at end of file diff --git a/context/tools/startup-container.sh b/context/tools/startup-container.sh index 9c6e403..a8158b4 100644 --- a/context/tools/startup-container.sh +++ b/context/tools/startup-container.sh @@ -3,6 +3,6 @@ set -euxo pipefail service cron start -service memcached start initialize-wiki.sh + apache2-foreground diff --git a/docker-compose.yml b/docker-compose.yml index 7df1b3b..48fbe72 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,31 +1,52 @@ -version: '3' +x-variables: + - &wiki-image ${WIKI_IMAGE:-ghcr.io/gesinn-it-pub/openresearch-stack:dev} + - &environment_mysql_host MYSQL_HOST=mysql + - &environment_mysql_root_password MYSQL_ROOT_PASSWORD=database + - &volume_wiki_images wiki-images:/var/www/html/images services: wiki: - image: ghcr.io/gesinn-it-pub/openresearch-stack:dev - ports: - - ${WIKI_PORT:-80}:80 + image: *wiki-image volumes: - - ./backstop/backstop_data:/var/www/html/backstop + - wiki-data:/data + - *volume_wiki_images + - ./tests/backstop/backstop_data:/var/www/html/backstop + - ./tests/http-integration:/http-integration-test + - /http-integration-test/node_modules/ environment: - WIKI_DOMAIN=${WIKI_DOMAIN:-localhost} + - WIKI_PORT=${WIKI_PORT:-80} + - WIKI_LANGUAGE=en - ELASTICSEARCH_HOST=elasticsearch - - MYSQL_HOST + - *environment_mysql_host + extra_hosts: + - "host.docker.internal:host-gateway" + + memcached: + image: memcached:latest - # https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#docker elasticsearch: - image: elasticsearch:6.8.23 + image: elasticsearch:7.17.21 + volumes: + - elasticsearch-data:/usr/share/elasticsearch/data environment: - discovery.type=single-node - "ES_JAVA_OPTS=-Xms512m -Xmx512m" mysql: - image: mysql:5 + image: mysql:8 + command: --innodb_buffer_pool_size=1024M --innodb_log_file_size=256M + volumes: + - mysql-data:/var/lib/mysql environment: - MYSQL_ROOT_PASSWORD: database + - *environment_mysql_root_password + + wait-for-wiki: + image: mintel/docker-wait-for-it + entrypoint: ['/opt/wait-for-it.sh', 'wiki:80', '-t', '120'] profiles: - - mysql + - no-up backstop: image: backstopjs/backstopjs:6.0.4 @@ -33,3 +54,9 @@ services: - ./backstop:/src profiles: - no-profile + +volumes: + wiki-data: + wiki-images: + elasticsearch-data: + mysql-data: \ No newline at end of file