]> git.openstreetmap.org Git - chef.git/blob - cookbooks/mediawiki/templates/default/LocalSettings.php.erb
Configure $wgLogos for mediawiki sites
[chef.git] / cookbooks / mediawiki / templates / default / LocalSettings.php.erb
1 <?php
2 # DO NOT EDIT - This file is being maintained by Chef
3
4 # Protect against web entry
5 if ( !defined( 'MEDIAWIKI' ) ) {
6         exit;
7 }
8
9 ## Uncomment this to disable output compression
10 # $wgDisableOutputCompression = true;
11
12 $wgSitename      = '<%= @mediawiki[:sitename] %>';
13 $wgMetaNamespace = '<%= @mediawiki[:metanamespace] %>';
14
15 ## The URL base path to the directory containing the wiki;
16 ## defaults for all runtime URL paths are based off of this.
17 ## For more information on customizing the URLs
18 ## (like /w/index.php/Page_title to /wiki/Page_title) please see:
19 ## https://www.mediawiki.org/wiki/Manual:Short_URL
20 $wgScriptPath       = "/w";
21 $wgArticlePath      = '/wiki/$1';
22 $wgUsePathInfo      = true;
23 $wgScriptExtension  = ".php";
24
25 ## The protocol and server name to use in fully-qualified URLs
26 $wgServer           = "//<%= @name %>";
27 $wgInternalServer   = 'https://<%= @name %>';
28 $wgCanonicalServer  = 'https://<%= @name %>';
29
30 $wgSecureLogin = true;
31 $wgDefaultUserOptions['prefershttps'] = 1;
32 $wgCookieSecure = true;
33
34 ## The relative URL path to the skins directory
35 $wgStylePath        = "$wgScriptPath/skins";
36
37 ## The relative URL path to the logo.  Make sure you change this from the default,
38 ## or else you'll overwrite your logo when you upgrade!
39 $wgLogo             = "<%= @mediawiki[:logo] %>";
40 $wgLogos            = [
41   "1x" => "<%= @mediawiki[:logo] %>"
42 ];
43                     
44 ## UPO means: this is also a user preference option
45
46 $wgEnableEmail      = true;
47 $wgEnableUserEmail  = true; # UPO
48
49 $wgEmergencyContact = "<%= @mediawiki[:email_contact] %>";
50 $wgPasswordSender   = "<%= @mediawiki[:email_sender] %>";
51 $wgPasswordSenderName = "<%= @mediawiki[:email_sender_name] %>"; //Replaced by MediaWiki:Emailsender in v1.23.0
52 $wgNoReplyAddress = "<%= @mediawiki[:email_sender] %>";
53
54 $wgEnotifUserTalk      = true; # UPO
55 $wgEnotifWatchlist     = true; # UPO
56 $wgEmailAuthentication = true;
57
58 $wgEnotifUseJobQ       = true;
59
60 $wgSMTP = [
61   "host" => "localhost",
62   "socket_options" => [
63     "ssl" => [
64       "verify_peer_name" => false
65     ]
66   ]
67 ];
68
69 ## Database settings
70 $wgDBtype           = "mysql";
71 $wgDBserver         = "<%= @database_params[:host] %>";
72 $wgDBname           = "<%= @database_params[:name] %>";
73 $wgDBuser           = "<%= @database_params[:username] %>";
74 $wgDBpassword       = "<%= @database_params[:password] %>";
75
76 # MySQL specific settings
77 $wgDBprefix         = "";
78
79 # MySQL table options to use during installation or update
80 $wgDBTableOptions   = "ENGINE=InnoDB, DEFAULT CHARSET=binary";
81
82 # Experimental charset support for MySQL 5.0.
83 $wgDBmysql5 = false;
84
85 ## Shared memory settings
86 $wgMainCacheType    = CACHE_MEMCACHED;
87 $wgParserCacheType  = CACHE_MEMCACHED;
88 $wgMessageCacheType = CACHE_MEMCACHED;
89 $wgSessionCacheType = CACHE_MEMCACHED;
90 $wgMemCachedServers = array('127.0.0.1:11211');
91 $wgSessionsInObjectCache = TRUE;
92
93 ## To enable image uploads, make sure the 'images' directory
94 ## is writable, then set this to true:
95 $wgEnableUploads  = true;
96 $wgUseImageMagick = true;
97 $wgImageMagickConvertCommand = "/usr/bin/convert";
98
99 $wgGenerateThumbnailOnParse = false;
100 $wgMaxImageArea = 125000000;
101 $wgMaxShellMemory = 5524000;
102 $wgMaxShellFileSize = 819200;
103 $wgMaxShellTime = 360;
104 $wgMaxShellWallClockTime = 360;
105
106 # Allow some more upload extensions
107 $wgFileExtensions[] = 'pdf';
108 $wgFileExtensions[] = 'odt';
109 $wgFileExtensions[] = 'odp';
110 $wgFileExtensions[] = 'ods';
111 $wgFileExtensions[] = 'svg';
112 $wgFileExtensions[] = 'osm';
113 $wgFileExtensions[] = 'odg';
114 <% @mediawiki[:extra_file_extensions].each do |mw_extra_file_extension| -%>
115         $wgFileExtensions[] = '<%= mw_extra_file_extension %>';
116 <% end -%>
117
118 # Add OSM XML file format per http://www.iana.org/assignments/media-types/media-types.xhtml
119 # Shout out to Paul Norman for reserving this.
120 # Helps MimeMagic determine XML-based formats and chooses the correct MimeType
121 # for .osm files.
122 $wgXMLMimeTypes[] = array('osm' => 'application/vnd.openstreetmap.data+xml');
123
124 $wgTrustedMediaFormats[] = 'application/vnd.openstreetmap.data+xml';
125
126 $wgSVGConverters = array( 'rsvg' => '/usr/bin/rsvg-convert -w $width -h $height -o $output $input');
127 $wgSVGConverter = 'rsvg';
128 $wgSVGMaxSize = 2000;
129
130 ## If you use ImageMagick (or any other shell command) on a
131 ## Linux server, this will need to be set to the name of an
132 ## available UTF-8 locale
133 $wgShellLocale = "en_US.utf8";
134
135 ## If you want to use image uploads under safe mode,
136 ## create the directories images/archive, images/thumb and
137 ## images/temp, and make them all writable. Then uncomment
138 ## this, if it's not already uncommented:
139 #$wgHashedUploadDirectory = false;
140
141 ## Set $wgCacheDirectory to a writable directory on the web server
142 ## to make your wiki go slightly faster. The directory should not
143 ## be publically accessible from the web.
144 $wgCacheDirectory = "$IP/cache";
145
146 # Site language code, should be one of the list in ./languages/Names.php
147 $wgLanguageCode = "en";
148
149 ## Enable setting the page content language by users
150 $wgPageLanguageUseDB = true;
151 $wgGroupPermissions['user']['pagelang'] = true;
152
153 $wgSecretKey = '<%= @secret_key %>';
154
155 # Site upgrade key. Must be set to a string (default provided) to turn on the
156 # web installer while LocalSettings.php is in place
157 #$wgUpgradeKey = "6ad907e74fc65836";
158
159 ## Default skin: you can change the default skin. Use the internal symbolic
160 ## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook', 'vector':
161 $wgDefaultSkin = "<%= @mediawiki[:skin] %>";
162
163 ## For attaching licensing metadata to pages, and displaying an
164 ## appropriate copyright notice / icon. GNU Free Documentation
165 ## License and Creative Commons licenses are supported so far.
166 $wgRightsPage = "Wiki_content_license"; # Set to the title of a wiki page that describes your license/copyright
167 $wgRightsUrl  = "https://creativecommons.org/licenses/by-sa/2.0/";
168 $wgRightsText = "Creative Commons Attribution-ShareAlike 2.0 license";
169 $wgRightsIcon = "/cc-wiki.png";
170
171 # Path to the GNU diff3 utility. Used for conflict resolution.
172 $wgDiff3 = "/usr/bin/diff3";
173
174 $wgExternalDiffEngine = 'wikidiff2';
175
176 # Query string length limit for ResourceLoader. You should only set this if
177 # your web server has a query string length limit (then set it to that limit),
178 # or if you have suhosin.get.max_value_length set in php.ini (then set it to
179 # that value)
180 $wgResourceLoaderMaxQueryLength = -1;
181
182 # End of automatically generated settings.
183 # Add more configuration options below.
184
185 # Only Allow Signed-in users to edit
186 $wgGroupPermissions['*']['edit'] = false;
187
188 # Allow bureaucrat group access to oversight options
189 $wgGroupPermissions['bureaucrat']['hideuser'] = true;
190 $wgGroupPermissions['bureaucrat']['deletelogentry'] = true;
191 $wgGroupPermissions['bureaucrat']['deleterevision'] = true;
192 $wgGroupPermissions['bureaucrat']['suppressrevision'] = true;
193 $wgGroupPermissions['bureaucrat']['suppressionlog'] = true;
194
195 # Since 1.32 MW introduced interface-admin group to separate all UI-related rights. This makes sense for bigger sites,
196 # but for OSM it makes more sense to keep group structure simple.  Give all interface-admin rights to sysops.
197 # Also remove the interface-admin group to avoid confusion.
198 $wgGroupPermissions['sysop'] = array_merge( $wgGroupPermissions['sysop'], $wgGroupPermissions['interface-admin'] );
199 unset( $wgGroupPermissions['interface-admin'] );
200 unset( $wgRevokePermissions['interface-admin'] );
201 unset( $wgAddGroups['interface-admin'] );
202 unset( $wgRemoveGroups['interface-admin'] );
203 unset( $wgGroupsAddToSelf['interface-admin'] );
204 unset( $wgGroupsRemoveFromSelf['interface-admin'] );
205
206 # The v1.32+ gadget system also requires two additional rights
207 # See https://www.mediawiki.org/wiki/Extension:Gadgets
208 $wgGroupPermissions['sysop']['gadgets-edit'] = true;
209 $wgGroupPermissions['sysop']['gadgets-definition-edit'] = true;
210
211 # Create ipblock-exempt group to grant IP block exemption permission
212 $wgGroupPermissions['ipblock-exempt']['ipblock-exempt'] = true;
213
214 <% if @mediawiki[:private_accounts] -%>
215 # Prevent new user registrations except by existing users
216 $wgGroupPermissions['*']['createaccount'] = false;
217 $wgGroupPermissions['user']['createaccount'] = true;
218 <% end -%>
219
220 <% if @mediawiki[:private_site] -%>
221 # Disable reading by anonymous users
222 $wgGroupPermissions['*']['read'] = false;
223
224 # Allow anonymous users to access the login page
225 $wgWhitelistRead = array ("Special:Userlogin");
226
227 # Prevent new user registrations except by sysops
228 $wgGroupPermissions['*']['createaccount'] = false;
229
230 # Restrict access to the upload directory
231 $wgUploadPath = "$wgScriptPath/img_auth.php";
232 <% end -%>
233
234 # Allow Subpages on Main Namespace
235 $wgNamespacesWithSubpages[NS_MAIN] = true;
236
237 # DNS Blacklists to use
238 $wgEnableDnsBlacklist = true;
239 $wgDnsBlacklistUrls = [
240   'http.dnsbl.sorbs.net.',
241   'dnsbl-1.uceprotect.net.'
242 ];
243
244 # Require validated email to edit
245 $wgEmailConfirmToEdit = true;
246
247 # Extend autoblock period
248 $wgAutoblockExpiry = 7776000; // 90 days
249
250 # Disable Hit Counter for Performance
251 $wgDisableCounters = TRUE;
252 # Disable IP in Header to avoid cache issue
253 $wgShowIPinHeader = FALSE;
254
255 # Job Runs by cron
256 $wgJobRunRate = 0;
257
258 # dissolves double redirects automatically
259 $wgFixDoubleRedirects = TRUE;
260
261 # Allow external images from a few sites
262 $wgAllowExternalImagesFrom = [
263   'http://tile.openstreetmap.org/',
264   'https://tile.openstreetmap.org',
265   'http://josm.openstreetmap.de/'
266 ];
267
268 $wgNoFollowDomainExceptions = [
269   'www.openstreetmap.org',
270   'josm.openstreetmap.de',
271   'taginfo.openstreetmap.org',
272   'blog.openstreetmap.org',
273   'forum.openstreetmap.org',
274   'community.openstreetmap.org',
275   'lists.openstreetmap.org',
276   'help.openstreetmap.org',
277   'switch2osm.org',
278   'wiki.osmfoundation.org',
279   'www.openstreetmap.us',
280   'learnosm.org',
281   'nominatim.org',
282   'openstreetmap.community',
283   'www.openstreetbrowser.org',
284   'openinframap.org',
285   'leafletjs.com'
286 ];
287
288 # FIXME - move to specific
289 $wgAllowUserJs = TRUE;
290 $wgAllowUserCss = TRUE;
291
292 # Raise expensive lua (and other function) call limits to match WP
293 # Docs:  https://www.mediawiki.org/wiki/Manual:$wgExpensiveParserFunctionLimit
294 # Wikipedia's Config:  https://noc.wikimedia.org/conf/highlight.php?file=CommonSettings.php
295 $wgExpensiveParserFunctionLimit = 500;
296
297
298 <% if @mediawiki[:site_notice] -%>
299 $wgSiteNotice = "<%= @mediawiki[:site_notice] %>";
300 <% end -%>
301 <% if @mediawiki[:site_readonly] -%>
302 $wgReadOnly = ( PHP_SAPI === 'cli' ) ? false : "<%= @mediawiki[:site_readonly] %>";
303 <% end -%>
304
305 <% @mediawiki[:namespaces].each do |name, details| -%>
306 # <%= name %>
307 define('NS_<%= name.upcase %>', <%= details[:id] %>);
308 $wgExtraNamespaces[NS_<%= name.upcase %>] = '<%= name %>';
309 $wgNamespacesWithSubpages[NS_<%= name.upcase %>] = TRUE;
310 $wgContentNamespaces[] = NS_<%= name.upcase %>;
311 $wgNamespacesToBeSearchedDefault[NS_<%= name.upcase %>] = TRUE;
312 define('NS_<%= name.upcase %>_TALK', <%= details[:talk_id] %>);
313 $wgExtraNamespaces[NS_<%= name.upcase %>_TALK] = '<%= name %>_talk';
314 $wgNamespacesWithSubpages[NS_<%= name.upcase %>_TALK] = TRUE;
315
316 <% end -%>
317
318 <% unless @mediawiki[:force_ui_messages].empty? -%>
319 # defines which links of the sidebar are translatable
320 $wgForceUIMsgAsContentMsg = array( '<%= @mediawiki[:force_ui_messages].join("', '") %>' );
321 <% end -%>
322
323 # load extensions
324 <% Dir.glob("#{@directory}/LocalSettings.d/*.php") do |file| -%>
325 <%= "require_once('#{file}');" %>
326 <% end -%>
327
328 <% if @mediawiki[:watch_category_membership] -%>
329 # must be after extensions are loaded
330 $wgRCWatchCategoryMembership = true;
331 <% end -%>
332
333 <% if not(@mediawiki[:private_accounts]) and not(@mediawiki[:private_site]) -%>
334 # require user confirmation for certain actions
335 $wgGroupPermissions['user']['move'] = false;
336 $wgGroupPermissions['user']['movefile'] = false;
337 $wgGroupPermissions['user']['move-categorypages'] = false;
338 $wgGroupPermissions['user']['upload'] = false;
339 $wgGroupPermissions['autoconfirmed']['move'] = true;
340 $wgGroupPermissions['autoconfirmed']['movefile'] = true;
341 $wgGroupPermissions['autoconfirmed']['move-categorypages'] = true;
342 $wgGroupPermissions['autoconfirmed']['upload'] = true;
343 # Autopromote users to autoconfirmed
344 $wgAutoConfirmAge = 345600; // 4 days
345 $wgAutoConfirmCount = 10;
346
347 # user group "confirmed" with identical rights as "autoconfirmed", but assigned manually by sysops
348 $wgGroupPermissions['confirmed'] = $wgGroupPermissions['autoconfirmed'];
349 $wgAddGroups['sysop'][] = 'confirmed';
350 $wgRemoveGroups['sysop'][] = 'confirmed';
351 <% end -%>
352
353 <% if @mediawiki[:private_accounts] or @mediawiki[:private_site] -%>
354 # disable automatic confirmation of users, grant all "autoconfirmed" rights to all users
355 $wgAutoConfirmAge = 0;
356 $wgAutoConfirmCount = 0;
357 $wgGroupPermissions['user'] = array_merge( $wgGroupPermissions['user'], $wgGroupPermissions['autoconfirmed'] );
358
359 unset( $wgGroupPermissions['autoconfirmed'] );
360 unset( $wgRevokePermissions['autoconfirmed'] );
361 unset( $wgAddGroups['autoconfirmed'] );
362 unset( $wgRemoveGroups['autoconfirmed'] );
363 unset( $wgGroupsAddToSelf['autoconfirmed'] );
364 unset( $wgGroupsRemoveFromSelf['autoconfirmed'] );
365 <% end -%>
366
367 # Increase curl timeout to allow parsoid requests to heavy pages like Map Features
368 # Mediawiki 1.38 has fix to allow this to be set by $wgVirtualRestConfig
369 # https://phabricator.wikimedia.org/T285478
370 $wgHTTPTimeout = 240;
371
372 # Enable night mode for Minerva and Vector skins
373 # https://github.com/openstreetmap/operations/issues/1230
374 $wgMinervaNightMode['base'] = true;
375 $wgVectorNightMode['logged_in'] = true;
376 $wgVectorNightMode['logged_out'] = true;
377
378 # Set extremely low timeout to avoid PHP-FPM timeouts on slow connections to Wikimedia Commons (rate limiting) or similar
379 $wgHTTPMaxTimeout = 5;
380 $wgHTTPMaxConnectTimeout = 3;