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 site_directory = node[:mediawiki][:sites][site][:site_directory]
24 mediawiki_directory = node[:mediawiki][:sites][site][:directory]
25 extension_directory = "#{mediawiki_directory}/extensions/#{name}"
26 source = params[:source]
27 template = params[:template]
28 template_variables = params[:variables]
31 remote_directory extension_directory do
34 owner node[:mediawiki][:user]
35 group node[:mediawiki][:group]
37 files_owner node[:mediawiki][:user]
38 files_group node[:mediawiki][:group]
42 repository = params[:repository] || "git://github.com/wikimedia/mediawiki-extensions-#{name}.git"
43 version = params[:version] || node[:mediawiki][:sites][site][:version]
46 reference = "refs/tags/#{tag}"
48 reference = "refs/heads/REL#{version}".tr(".", "_")
51 git extension_directory do
56 enable_submodules true
57 user node[:mediawiki][:user]
58 group node[:mediawiki][:group]
59 ignore_failure repository.start_with?("git://github.com/wikimedia/mediawiki-extensions")
60 notifies :run, resources(:execute => "#{mediawiki_directory}/maintenance/update.php")
65 template "#{mediawiki_directory}/LocalSettings.d/Ext-#{name}.inc.php" do
68 user node[:mediawiki][:user]
69 group node[:mediawiki][:group]
71 variables template_variables
72 notifies :create, resources(:template => "#{mediawiki_directory}/LocalSettings.php")
76 file "#{mediawiki_directory}/LocalSettings.d/Ext-#{name}.inc.php" do
77 action :create_if_missing
78 user node[:mediawiki][:user]
79 group node[:mediawiki][:group]
81 content "<?php require_once('#{extension_directory}/#{name}.php');\n"
82 only_if do File.exist?("#{extension_directory}/#{name}.php") end
83 notifies :create, resources(:template => "#{mediawiki_directory}/LocalSettings.php")