aboutsummaryrefslogtreecommitdiffstats
path: root/lib/capistrano/tasks/refinerycms.rake
blob: 058905888ff24e5f44e5e04177906f446c1809f2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Recipes for installing RefineryCMS using Capistrano 3.x
# Copyright (C) 2015  Harald Eilertsen <haraldei@anduin.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

require 'capistrano/refinerycms/helpers'
require 'securerandom'
require 'active_support/inflector'

include Capistrano::RefineryCMS::Helpers

namespace :load do

  task :defaults do

    # Settings for config/initializers/refinery/core.rb
    set :refinerycms_site_name, 'RefineryCMS'
    set :refinerycms_force_ssl, false
    set :refinerycms_dragonfly_custom_backend_class, ''
    set :refinerycms_dragonfly_custom_backend_opts, []
    set :refinerycms_base_cache_key, -> { ActiveSupport::Inflector::parameterize(fetch(:refinerycms_site_name), '_') }
    set :refinerycms_google_analytics_page_code, 'UA-xxxxxx-x'
    set :refinerycms_authenticity_token_on_frontend, true
    set :refinerycms_dragonfly_secret, -> { SecureRandom.hex(24) }
    set :refinerycms_wymeditor_whitelist_tags, []
    set :refinerycms_extra_javascript, ''
    set :refinerycms_extra_stylesheet, ''
    set :refinerycms_backend_route, '/refinery'

    # Settings affecting the gem operation
    set :refinerycms_template_path, -> { File.join('config', 'deploy', 'templates') }

  end

end


namespace :deploy do
  namespace :refinerycms do

    desc 'Initialize refinery config for new deployments.'
    task :configure do
      output_file = File.join(shared_path, "config", "initializers", "refinery", "core.rb")
      on roles(:app) do
        unless test "[ -f #{output_file} ]"
          core = refinerycms_template('config_initializers_refinery_core.rb.erb')
          execute :mkdir, '-p', File.dirname(output_file)
          upload!(core, output_file)
        end
      end
    end

    desc 'Seed the database'
    task :seed do
      on roles(:db) do
        within release_path do
          execute :rake, 'db:seed', "RAILS_ENV=#{fetch(:rails_env)}"
        end
      end
    end

  end

  before 'deploy:check:linked_files', 'deploy:refinerycms:configure'
  after 'deploy:migrate', 'deploy:refinerycms:seed'
end