Defined Type: mediawiki::interwiki

Defined in:
puppet/modules/mediawiki/manifests/interwiki.pp

Overview

Define: mediawiki::interwiki

Uses MediaWiki's maintenance scripts to add or remove (non-local) MediaWiki interwiki table entries.

Parameters

url

Interwiki URL, with $1 for title.

api

API URL of the remote wiki.

prefix

Interwiki prefix.

transclusion

Allow scary transclusion for this interwiki when $wgEnableScaryTranscluding is on (default: no).

db_name

Which wiki to add interwiki links for. Defaults to the main wiki.

ensure

'present' to add the entry, 'absent' to remove it. All parameters other than the prefix are optional for 'absent'.

Parameters:

  • url (Any)
  • api (Any)
  • prefix (Any) (defaults to: $title)
  • transclusion (Any) (defaults to: false)
  • db_name (Any) (defaults to: $::mediawiki::db_name)
  • ensure (Any) (defaults to: 'present')


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
# File 'puppet/modules/mediawiki/manifests/interwiki.pp', line 28

define mediawiki::interwiki(
    $url,
    $api,
    $prefix       = $title,
    $transclusion = false,
    $db_name      = $::mediawiki::db_name,
    $ensure       = 'present',
) {
    include ::mediawiki

    validate_ensure($ensure)
    if ( $ensure == 'present' ) {
        $num_transclusion = $transclusion ? {
            true    => 1,
            default => 0,
        }
        mysql::sql { "add interwiki ${prefix} for ${db_name}":
            sql    => "REPLACE INTO ${db_name}.interwiki(iw_prefix, iw_url, iw_api, iw_wikiid, iw_local, iw_trans) VALUES ('${prefix}', '${url}', '${api}', '', 0, ${num_transclusion})",
            unless => "SELECT 1 FROM ${db_name}.interwiki WHERE iw_prefix = '${prefix}' AND iw_url = '${url}' AND iw_api = '${api}' AND iw_trans = '${num_transclusion}'",
        }
    } else {
        mysql::sql { "remove interwiki ${prefix} for ${db_name}":
            sql    => "DELETE FROM ${db_name}.interwiki WHERE iw_prefix = '${prefix}'",
            unless => "SELECT IF(count(*), 0, 1) FROM ${db_name}.interwiki WHERE iw_prefix = '${prefix}'",
        }
    }

    Mediawiki::Wiki <| |> -> MediaWiki::Interwiki <| |>
}