diff options
-rw-r--r-- | config/deploy.rb.example | 2 | ||||
-rw-r--r-- | config/deploy/production.rb.example | 4 | ||||
-rw-r--r-- | config/deploy/staging.rb.example | 4 | ||||
-rw-r--r-- | config/piwik.yml.erb | 33 | ||||
-rw-r--r-- | lib/capistrano/tasks/configure_piwik.rake | 20 |
5 files changed, 62 insertions, 1 deletions
diff --git a/config/deploy.rb.example b/config/deploy.rb.example index f08e859..51362d5 100644 --- a/config/deploy.rb.example +++ b/config/deploy.rb.example @@ -6,7 +6,7 @@ set :application, 'hmno' # change this to your fork set :repo_url, 'git@github.com:snake66/project-limestone.git' -set :linked_files, %w{config/initializers/refinery/core.rb config/initializers/secret_token.rb} +set :linked_files, %w{config/initializers/refinery/core.rb config/initializers/secret_token.rb config/piwik.yml} set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system} namespace :deploy do diff --git a/config/deploy/production.rb.example b/config/deploy/production.rb.example index f0ebff2..42248ee 100644 --- a/config/deploy/production.rb.example +++ b/config/deploy/production.rb.example @@ -14,3 +14,7 @@ set :branch, 'production' #setup for capistrano-rvm plugin: #set :rvm_type, :system #set :rvm_ruby_version, '2.1.1' + +# setup for piwik +set :piwik_site_id, 0 +set :piwik_url, '' diff --git a/config/deploy/staging.rb.example b/config/deploy/staging.rb.example index 2a92b4a..28a7564 100644 --- a/config/deploy/staging.rb.example +++ b/config/deploy/staging.rb.example @@ -14,3 +14,7 @@ set :branch, 'staging' #setup for capistrano-rvm plugin: #set :rvm_type, :system #set :rvm_ruby_version, '2.1.1' + +# setup for piwik +set :piwik_site_id, 0 +set :piwik_url, '' diff --git a/config/piwik.yml.erb b/config/piwik.yml.erb new file mode 100644 index 0000000..045ca08 --- /dev/null +++ b/config/piwik.yml.erb @@ -0,0 +1,33 @@ +# Configuration: +# +# disabled +# false if tracking tag should be shown +# use_async +# Set to true if you want to use asynchronous tracking +# url +# The url of your piwik instance (e.g. localhost/piwik/ +# id_site +# The id of your website inside Piwik +# +production: + piwik: + id_site: <%= site_id %> + url: <%= url %> + use_async: false + disabled: false + +development: + piwik: + id_site: <%= site_id %> + url: <%= url %> + disabled: true + use_async: false + hostname: localhost + +test: + piwik: + id_site: <%= site_id %> + url: <%= url %> + disabled: true + use_async: false + hostname: localhost diff --git a/lib/capistrano/tasks/configure_piwik.rake b/lib/capistrano/tasks/configure_piwik.rake new file mode 100644 index 0000000..e56f37e --- /dev/null +++ b/lib/capistrano/tasks/configure_piwik.rake @@ -0,0 +1,20 @@ +# :mode=ruby: +namespace :deploy do + namespace piwik do + desc 'Configure piwik for site' + task :configure do + output_file = File.join(shared_path, 'config', 'piwik.yml') + on roles(:app) do + unless test "[ -f #{output_file} ]" + template = IO.read(File.join('config', 'piwik.yml.erb')) + c = ERB.new(template) + site_id = fetch(:piwik_site_id) + url = fetch(:piwik_url) + upload!(StringIO.new(c.result(binding)), output_file) + end + end + end + end + + before 'deploy', 'deploy:piwik:config' +end
\ No newline at end of file |