File size: 3,772 Bytes
5df73b6
 
 
 
 
0fa64f2
36599de
0fa64f2
36599de
5df73b6
 
 
 
 
 
 
 
 
 
8b4bf18
5df73b6
 
 
 
 
 
 
 
 
 
 
36599de
 
 
 
5df73b6
 
 
 
 
 
 
 
 
 
 
 
82413ac
b8bcec5
 
 
82413ac
 
 
 
 
 
 
 
b8bcec5
82413ac
 
b8bcec5
039c290
 
b8bcec5
5df73b6
36599de
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f264658
 
ad05a47
36599de
 
 
 
 
 
5df73b6
 
 
 
 
f052668
5df73b6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php

$wgSitename = "Local Chinese Wikipedia";
$wgMetaNamespace = "Project";
$wgScriptPath = "";

// Prefer MW_SERVER if set. Otherwise use the current Host header.
$wgServer = getenv("MW_SERVER") ?: "https://" . ($_SERVER['HTTP_HOST'] ?? "localhost:7860");
$wgCanonicalServer = $wgServer;
$wgResourceBasePath = $wgScriptPath;

$wgLanguageCode = "zh";
$wgDefaultLanguageVariant = "zh-cn";
$wgDisableLangConversion = false;

$wgArticlePath = "/wiki/$1";
$wgUsePathInfo = true;

$wgDBtype = "mysql";
$wgDBserver = "localhost:/run/mysqld/mysqld.sock";
$wgDBname = getenv("MW_DB_NAME") ?: "zhwiki";
$wgDBuser = getenv("MW_DB_USER") ?: "wiki";
$wgDBpassword = getenv("MW_DB_PASSWORD") ?: "wiki_pass";
$wgDBTableOptions = "ENGINE=InnoDB, DEFAULT CHARSET=binary";

$wgSecretKey = getenv("MW_SECRET_KEY") ?: "CHANGE_THIS_TO_A_LONG_RANDOM_SECRET_STRING_zhwiki_local";
$wgUpgradeKey = getenv("MW_UPGRADE_KEY") ?: "CHANGE_THIS_UPGRADE_KEY";

$wgEnableUploads = false;
$wgCompressRevisions = true;

// Flow requires an object cache. DB-backed cache is heavier than memcached,
// but avoids adding another daemon in a Hugging Face single-container Space.
$wgMainCacheType = CACHE_DB;
$wgMessageCacheType = CACHE_DB;
$wgParserCacheType = CACHE_DB;
$wgCacheDirectory = "/data/tmp";
$wgJobRunRate = 0;

wfLoadSkin( 'Vector' );
$wgDefaultSkin = 'vector';

wfLoadExtension( 'ParserFunctions' );
wfLoadExtension( 'Cite' );
wfLoadExtension( 'Scribunto' );
wfLoadExtension( 'TemplateStyles' );
wfLoadExtension( 'SyntaxHighlight_GeSHi' );
wfLoadExtension( 'JsonConfig' );
wfLoadExtension( 'GeoData' );
wfLoadExtension( 'Kartographer' );

// zhwiki templates/modules call mw.wikibase from Lua. Full Wikibase Client
// requires a large extension with git submodules and a Wikidata/repo setup.
// For a read-only/offline Wikipedia mirror, default to a tiny local Scribunto
// stub that exposes mw.wikibase and returns empty/nil data instead of crashing.
// Set WIKIBASE_CLIENT_MODE=0 to disable the stub. Set WIKIBASE_CLIENT_MODE=full
// only if you provide a complete Wikibase extension and repository configuration.
$wikibaseClientMode = getenv( 'WIKIBASE_CLIENT_MODE' ) ?: 'lite';
if ( $wikibaseClientMode === 'full' && is_file( "$IP/extensions/Wikibase/extension-client.json" ) ) {
    wfLoadExtension( 'WikibaseClient', "$IP/extensions/Wikibase/extension-client.json" );
    if ( is_file( "$IP/extensions/Wikibase/client/ExampleSettings.php" ) ) {
        require_once "$IP/extensions/Wikibase/client/ExampleSettings.php";
    }
} elseif ( $wikibaseClientMode !== '0' && is_file( "$IP/extensions/WikibaseClientLite/extension.json" ) ) {
    wfLoadExtension( 'WikibaseClientLite' );
}


// Parsoid is bundled with MediaWiki 1.43. StructuredDiscussions strongly
// recommends Parsoid, and WMF Flow deployments use HTML content format.
// Use the internal Apache endpoint so CLI/background import can reach rest.php
// even when MW_SERVER is the public Hugging Face URL.
wfLoadExtension( 'Parsoid', "$IP/vendor/wikimedia/parsoid/extension.json" );
$wgVirtualRestConfig['modules']['parsoid'] = [
    'url' => 'http://localhost:7860/rest.php',
    'domain' => 'localhost',
    'prefix' => 'localhost',
];

// Real Flow / StructuredDiscussions support.
// Echo is a required dependency of StructuredDiscussions.
wfLoadExtension( 'Echo' );
wfLoadExtension( 'MassMessage' );
wfLoadExtension( 'Gadgets' );
wfLoadExtension( 'SecurePoll' );
wfLoadExtension( 'Flow' );

// Match WMF-style Flow storage more closely by using Parsoid-backed HTML.
$wgFlowContentFormat = 'html';
$wgFlowServerCompileTemplates = false;

$wgScribuntoDefaultEngine = 'luastandalone';

$wgEnableEmail = false;
$wgEnableUserEmail = false;
$wgShowExceptionDetails = true;
$wgShowDBErrorBacktrace = true;
$wgDebugLogFile = false;