MediaWiki-Docker/Extension/WikibaseMediaInfo

From mediawiki.org
Jump to navigation Jump to search

Requirements[edit]

Instructions[edit]

  • Clone Mediawiki Core
  • Create a new file called docker-compose.override.yml in the root of the repository.
#
# docker-compose override file for Structured Data projects.
# See https://www.mediawiki.org/wiki/MediaWiki-Docker
#
version: '3.7'
services:
  # These lines ensure file ownership is set to your host user/group
  mediawiki:
    user: "${MW_DOCKER_UID}:${MW_DOCKER_GID}"
    # Linux users only: this extra_hosts section is necessary for Xdebug:
    extra_hosts:
      - "host.docker.internal:host-gateway"
  mediawiki-web:
    user: "${MW_DOCKER_UID}:${MW_DOCKER_GID}"
  mediawiki-jobrunner:
    user: "${MW_DOCKER_UID}:${MW_DOCKER_GID}"
  elasticsearch:
    image: docker-registry.wikimedia.org/dev/stretch-elasticsearch:0.1.0
    volumes:
      - esdata:/usr/share/elasticsearch/data
    environment:
      - discovery.type=single-node
    ports:
      - 9200:9200
      - 9300:9300
volumes:
  esdata:
    driver: local
  • Follow the instructions in DEVELOPERS.md under "Start environment and install MediaWiki" to get Docker running
  • Create a new file called setup.sh in the root of the repository.
# #!/usr/bin/env bash

# # After following the instructions in DEVELOPERS.md run this script to install dependencies relevant to WikibaseMediaInfo

# set -eu

git clone https://gerrit.wikimedia.org/r/mediawiki/skins/Vector ./skins/Vector
git clone https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue ./skins/MinervaNeue

git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/CirrusSearch ./extensions/CirrusSearch
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/CommonsMetadata ./extensions/CommonsMetadata
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo ./extensions/Echo
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Elastica ./extensions/Elastica
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/EventLogging ./extensions/EventLogging
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/EventStreamConfig ./extensions/EventStreamConfig
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/JsonConfig ./extensions/JsonConfig
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Kartographer ./extensions/Kartographer
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/MobileFrontend ./extensions/MobileFrontend
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/ParserFunctions ./extensions/ParserFunctions
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto ./extensions/Scribunto
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/TemplateData ./extensions/TemplateData
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/TemplateStyles ./extensions/TemplateStyles
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/UniversalLanguageSelector ./extensions/UniversalLanguageSelector
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/UploadWizard ./extensions/UploadWizard
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Wikibase ./extensions/Wikibase
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/WikibaseCirrusSearch ./extensions/WikibaseCirrusSearch
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/WikibaseMediaInfo ./extensions/WikibaseMediaInfo

# Save the default settings from the Mediawiki installation to be added back later.
defaultSettings=`cat LocalSettings.php`

cat <<EOL >> LocalSettings.php
wfLoadSkin( 'Vector' );
wfLoadSkin( 'MinervaNeue' );

wfLoadExtension( 'CirrusSearch' );
wfLoadExtension( 'Elastica' );
wfLoadExtension( 'MobileFrontend' );
wfLoadExtension( 'UniversalLanguageSelector' );
wfLoadExtension( 'UploadWizard' );

\$wgDisableSearchUpdate = true;
require_once "\$IP/extensions/CirrusSearch/tests/jenkins/FullyFeaturedConfig.php";
\$wgCirrusSearchServers = [ "elasticsearch" ];
EOL

# Search
docker-compose exec mediawiki composer --working-dir=/var/www/html/w/extensions/Elastica install
docker-compose exec mediawiki composer --working-dir=/var/www/html/w/extensions/CirrusSearch install
docker-compose exec mediawiki php maintenance/update.php

# Configure the search index and populate it with content
docker-compose exec mediawiki php extensions/CirrusSearch/maintenance/updateSearchIndexConfig.php

echo "$defaultSettings" > LocalSettings.php

cat <<EOL >> LocalSettings.php
wfLoadSkin( 'Vector' );
wfLoadSkin( 'MinervaNeue' );

wfLoadExtension( 'CirrusSearch' );
wfLoadExtension( 'Elastica' );
wfLoadExtension( 'MobileFrontend' );
wfLoadExtension( 'UniversalLanguageSelector' );
wfLoadExtension( 'UploadWizard' );

require_once "\$IP/extensions/CirrusSearch/tests/jenkins/FullyFeaturedConfig.php";
\$wgCirrusSearchServers = [ "elasticsearch" ];
EOL

docker-compose exec mediawiki php extensions/CirrusSearch/maintenance/forceSearchIndex.php --skipLinks --indexOnSkip
docker-compose exec mediawiki php extensions/CirrusSearch/maintenance/forceSearchIndex.php --skipParse
# Process the job queue. You need to do this any time you add/update content and want it updated in ElasticSearch
docker-compose exec mediawiki php maintenance/runJobs.php

cat <<EOL >> LocalSettings.php
\$wgSearchType = 'CirrusSearch';

EOL

# Wikibase
touch composer.local.json
cat > composer.local.json <<EOL
{
  "extra": {
    "merge-plugin": {
       "include": [
         "extensions/Wikibase/composer.json"
       ]
    }
  }
}
EOL

docker-compose exec mediawiki composer require wikimedia/composer-merge-plugin:1.4.1
docker-compose exec mediawiki php maintenance/update.php

# Create final LocalSettings file with default settings and (organized) custom settings.
echo "$defaultSettings" > LocalSettings.php

cat <<EOL >> LocalSettings.php
wfLoadSkin( 'Vector' );
wfLoadSkin( 'MinervaNeue' );

wfLoadExtension( 'CirrusSearch' );
wfLoadExtension( 'CommonsMetadata' );
wfLoadExtension( 'Echo' );
wfLoadExtension( 'Elastica' );
wfLoadExtension( 'EventLogging' );
wfLoadExtension( 'EventStreamConfig' );
wfLoadExtension( 'JsonConfig' );
wfLoadExtension( 'Kartographer' );
wfLoadExtension( 'MobileFrontend' );
wfLoadExtension( 'ParserFunctions' );
wfLoadExtension( 'Scribunto' );
wfLoadExtension( 'TemplateData' );
wfLoadExtension( 'TemplateStyles' );
wfLoadExtension( 'UniversalLanguageSelector' );
wfLoadExtension( 'UploadWizard' );
wfLoadExtension( 'WikibaseCirrusSearch' );
wfLoadExtension( 'WikibaseMediaInfo' );

\$wgUseInstantCommons = true;
\$wgEnableUploads = true;
\$wgUseImageMagick = true;
\$wgScribuntoDefaultEngine = 'luastandalone';
\$wgMediaViewerEnableByDefault = true;
\$wgPFEnableStringFunctions = true;
\$wgApiFrameOptions = 'SAMEORIGIN';
\$wgCacheDirectory = "\$IP/cache";

// Cirrus Search
require_once "\$IP/extensions/CirrusSearch/tests/jenkins/FullyFeaturedConfig.php";
\$wgCirrusSearchServers = [ "elasticsearch" ];
\$wgSearchType = 'CirrusSearch';

// Wikibase
\$wgEnableWikibaseRepo = true;
\$wgEnableWikibaseClient = true;
require_once "\$IP/extensions/Wikibase/repo/Wikibase.php";
require_once "\$IP/extensions/Wikibase/repo/ExampleSettings.php";
require_once "\$IP/extensions/Wikibase/client/WikibaseClient.php";
require_once "\$IP/extensions/Wikibase/client/ExampleSettings.php";

// WikibaseMediaInfo
\$wgMediaInfoEnableFilePageDepicts = true;
\$wgMediaInfoEnableOtherStatements = true;
\$wgMediaInfoShowQualifiers = true;
\$wgMediaInfoProperties = [
	'depicts' => 'P1',
];
\$wgDepictsQualifierProperties = [
	'depicts' => 'P1',
];

\$wgUseImageMagick = true;

// UploadWizard
\$wgEnableUploads = true;
\$wgUseImageMagick = true;
\$wgUploadWizardConfig[ 'wikibase' ][ 'enabled' ] = true;
\$wgUploadWizardConfig[ 'wikibase' ][ 'captions' ] = true;
\$wgUploadWizardConfig[ 'wikibase' ][ 'depicts' ] = true;

EOL

cd extensions/Wikibase
git submodule update --init --recursive

cd ../..
docker-compose exec mediawiki composer --working-dir=/var/www/html/w/extensions/WikibaseCirrusSearch install
docker-compose exec mediawiki php maintenance/update.php
docker-compose exec mediawiki php --working-dir=/var/www/html/w/extensions/Wikibase lib/maintenance/populateSitesTable.php
docker-compose exec mediawiki php --working-dir=/var/www/html/w/extensions/Wikibase repo/maintenance/rebuildItemsPerSite.php
docker-compose exec mediawiki php --working-dir=/var/www/html/w/extensions/Wikibase client/maintenance/populateInterwiki.php

# Other extensions
docker-compose exec mediawiki composer --working-dir=/var/www/html/w/extensions/CommonsMetadata install
docker-compose exec mediawiki composer --working-dir=/var/www/html/w/extensions/Echo install
docker-compose exec mediawiki composer --working-dir=/var/www/html/w/extensions/EventLogging install
docker-compose exec mediawiki composer --working-dir=/var/www/html/w/extensions/EventStreamConfig install
docker-compose exec mediawiki composer --working-dir=/var/www/html/w/extensions/JsonConfig install
docker-compose exec mediawiki composer --working-dir=/var/www/html/w/extensions/Kartographer install
docker-compose exec mediawiki composer --working-dir=/var/www/html/w/extensions/MobileFrontend install
docker-compose exec mediawiki composer --working-dir=/var/www/html/w/extensions/ParserFunctions install
docker-compose exec mediawiki composer --working-dir=/var/www/html/w/extensions/Scribunto install
docker-compose exec mediawiki composer --working-dir=/var/www/html/w/extensions/TemplateData install
docker-compose exec mediawiki composer --working-dir=/var/www/html/w/extensions/TemplateStyles install
docker-compose exec mediawiki composer --working-dir=/var/www/html/w/extensions/UniversalLanguageSelector install
docker-compose exec mediawiki composer --working-dir=/var/www/html/w/extensions/UploadWizard install