allow to deploy sections
Didier Lafforgue
committed Apr 30, 2018
commit 77164b01ca7db8465d2cb581cc159a3834696fb5
Showing 6
changed files with
59 additions
and 5 deletions
Gemfile
+2
-2
| @@ | @@ -12,8 +12,8 @@ gem 'rb-fsevent', '~> 0.9.1' |
| # gem 'duktape', github: 'judofyr/duktape.rb', ref: '20ef6a5' | |
| # Local development | |
| - | # gem 'locomotivecms_coal', path: '../coal', require: false |
| - | # gem 'locomotivecms_steam', path: '../steam', require: false |
| + | gem 'locomotivecms_coal', path: '../coal', require: false |
| + | gem 'locomotivecms_steam', path: '../steam', require: false |
| # gem 'locomotivecms_common', path: '../common', require: false | |
| group :development, :test do | |
locomotive/wagon/commands/push_command.rb b/lib/locomotive/wagon/commands/push_command.rb
+1
-1
| @@ | @@ -14,7 +14,7 @@ module Locomotive::Wagon |
| class PushCommand < Struct.new(:env, :path, :options, :shell) | |
| - | RESOURCES = %w(site content_types content_entries pages snippets theme_assets translations).freeze |
| + | RESOURCES = %w(site content_types content_entries pages snippets sections theme_assets translations).freeze |
| RESOURCES_WITH_CONTENT = %w(content_entries translations).freeze | |
locomotive/wagon/commands/push_sub_commands/push_sections_command.rb b/lib/locomotive/wagon/commands/push_sub_commands/push_sections_command.rb
+23
-0
| @@ | @@ -0,0 +1,23 @@ |
| + | module Locomotive::Wagon |
| + | |
| + | class PushSectionsCommand < PushBaseCommand |
| + | |
| + | def entities |
| + | repositories.section.all |
| + | end |
| + | |
| + | def decorate(entity) |
| + | SectionDecorator.new(entity, content_assets_pusher) |
| + | end |
| + | |
| + | def persist(decorated_entity) |
| + | api_client.sections.update(decorated_entity.slug, decorated_entity.to_hash) |
| + | end |
| + | |
| + | def label_for(decorated_entity) |
| + | decorated_entity.name |
| + | end |
| + | |
| + | end |
| + | |
| + | end |
locomotive/wagon/decorators/sections_decorator.rb b/lib/locomotive/wagon/decorators/sections_decorator.rb
+31
-0
| @@ | @@ -0,0 +1,31 @@ |
| + | module Locomotive |
| + | module Wagon |
| + | |
| + | class SectionDecorator < Locomotive::Steam::Decorators::TemplateDecorator |
| + | |
| + | include ToHashConcern |
| + | include PersistAssetsConcern |
| + | |
| + | attr_accessor :__content_assets_pusher__ |
| + | |
| + | def initialize(object, content_assets_pusher) |
| + | self.__content_assets_pusher__ = content_assets_pusher |
| + | super(object, nil, nil) |
| + | end |
| + | |
| + | def __attributes__ |
| + | %i(name slug template definition) |
| + | end |
| + | |
| + | def id |
| + | slug |
| + | end |
| + | |
| + | def template |
| + | replace_with_content_assets!(self.liquid_source) |
| + | end |
| + | |
| + | end |
| + | |
| + | end |
| + | end |
locomotivecms_wagon.gemspec
+1
-1
| @@ | @@ -22,7 +22,7 @@ Gem::Specification.new do |gem| |
| gem.add_development_dependency 'rake', '~> 10.0.4' | |
| gem.add_dependency 'thor', '~> 0.19.4' | |
| - | gem.add_dependency 'thin', '~> 1.7.0' |
| + | gem.add_dependency 'thin', '~> 1.7.2' |
| gem.add_dependency 'rubyzip', '~> 1.2.1' | |
| gem.add_dependency 'netrc', '~> 0.11.0' | |
spec/integration/commands/push_command_spec.rb
+1
-1
| @@ | @@ -38,7 +38,7 @@ describe Locomotive::Wagon::PushCommand do |
| resources << payload[:name] | |
| end | |
| is_expected.not_to eq nil | |
| - | expect(resources).to eq %w(site content_types content_entries pages snippets theme_assets translations) |
| + | expect(resources).to eq %w(site content_types content_entries pages snippets sections theme_assets translations) |
| end | |
| context 'no previous authentication' do | |