2 # Cookbook Name:: mediawiki
3 # Definition:: mediawiki_extension
5 # Copyright 2013, OpenStreetMap Foundation
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
20 define :mediawiki_extension, :action => [ :enable ], :variables => {} do
23 mediawiki_directory = node[:mediawiki][:sites][site][:directory]
24 extension_directory = "#{mediawiki_directory}/extensions/#{name}"
25 source = params[:source]
26 template = params[:template]
27 template_variables = params[:variables]
30 remote_directory extension_directory do
33 owner node[:mediawiki][:user]
34 group node[:mediawiki][:group]
36 files_owner node[:mediawiki][:user]
37 files_group node[:mediawiki][:group]
41 repository = params[:repository] || "git://github.com/wikimedia/mediawiki-extensions-#{name}.git"
42 version = params[:version] || node[:mediawiki][:sites][site][:version]
45 reference = "refs/tags/#{tag}"
47 reference = "refs/heads/REL#{version}".tr(".", "_")
50 git extension_directory do
55 enable_submodules true
56 user node[:mediawiki][:user]
57 group node[:mediawiki][:group]
58 ignore_failure repository.start_with?("git://github.com/wikimedia/mediawiki-extensions")
59 notifies :run, resources(:execute => "#{mediawiki_directory}/maintenance/update.php")
64 template "#{mediawiki_directory}/LocalSettings.d/Ext-#{name}.inc.php" do
67 user node[:mediawiki][:user]
68 group node[:mediawiki][:group]
70 variables template_variables
71 notifies :create, resources(:template => "#{mediawiki_directory}/LocalSettings.php")
75 file "#{mediawiki_directory}/LocalSettings.d/Ext-#{name}.inc.php" do
76 action :create_if_missing
77 user node[:mediawiki][:user]
78 group node[:mediawiki][:group]
80 content "<?php require_once('#{extension_directory}/#{name}.php');\n"
81 only_if do File.exist?("#{extension_directory}/#{name}.php") end
82 notifies :create, resources(:template => "#{mediawiki_directory}/LocalSettings.php")