diff --git a/lib/locomotive/steam/adapters/filesystem/sanitizers/page.rb b/lib/locomotive/steam/adapters/filesystem/sanitizers/page.rb index b44424c7..aae8eee4 100644 --- a/lib/locomotive/steam/adapters/filesystem/sanitizers/page.rb +++ b/lib/locomotive/steam/adapters/filesystem/sanitizers/page.rb @@ -97,7 +97,7 @@ def set_automatic_translations(page, locale) %i( title slug fullpath template_path redirect_url sections_content sections_dropzone_content - seo_title meta_description meta_keywords + seo_title meta_description meta_keywords meta_robots ).each do |name| page[name][locale] ||= page[name][default_locale] end diff --git a/lib/locomotive/steam/adapters/filesystem/yaml_loaders/page.rb b/lib/locomotive/steam/adapters/filesystem/yaml_loaders/page.rb index 2f2930b5..36b092ca 100644 --- a/lib/locomotive/steam/adapters/filesystem/yaml_loaders/page.rb +++ b/lib/locomotive/steam/adapters/filesystem/yaml_loaders/page.rb @@ -88,7 +88,7 @@ def complete_attributes_from_data(attributes, data, locale) # set the attributes %i( - title slug redirect_url seo_title meta_description meta_keywords + title slug redirect_url seo_title meta_description meta_keywords meta_robots listed published position sections_content sections_dropzone_content editable_elements raw_template ).each do |name| @@ -118,7 +118,7 @@ def build(filepath, fullpath, locale) } %i( - redirect_url seo_title meta_description meta_keywords + redirect_url seo_title meta_description meta_keywords meta_robots sections_content sections_dropzone_content ).each do |name| _attributes[name] = { locale => attributes.delete(name) } @@ -138,7 +138,7 @@ def update(leaf, filepath, fullpath, locale) update_editable_elements(leaf, attributes.delete(:editable_elements), locale) %i( - redirect_url seo_title meta_description meta_keywords + redirect_url seo_title meta_description meta_keywords meta_robots sections_content sections_dropzone_content ).each do |name| leaf[name][locale] ||= attributes.delete(name) diff --git a/lib/locomotive/steam/liquid/drops/content_entry.rb b/lib/locomotive/steam/liquid/drops/content_entry.rb index 1b809266..95956ea6 100644 --- a/lib/locomotive/steam/liquid/drops/content_entry.rb +++ b/lib/locomotive/steam/liquid/drops/content_entry.rb @@ -4,7 +4,7 @@ module Liquid module Drops class ContentEntry < I18nBase - delegate :_slug, :_translated, :seo_title, :meta_keywords, :meta_description, :created_at, :updated_at, to: :@_source + delegate :_slug, :_translated, :seo_title, :meta_keywords, :meta_description, :meta_robots, :created_at, :updated_at, to: :@_source alias :_permalink :_slug diff --git a/lib/locomotive/steam/liquid/drops/page.rb b/lib/locomotive/steam/liquid/drops/page.rb index 6e39575b..68f10821 100644 --- a/lib/locomotive/steam/liquid/drops/page.rb +++ b/lib/locomotive/steam/liquid/drops/page.rb @@ -5,7 +5,7 @@ module Drops class Page < I18nBase delegate :position, :fullpath, :depth, :redirect_url, :handle, to: :@_source - delegate :seo_title, :meta_keywords, :meta_description, to: :@_source + delegate :seo_title, :meta_keywords, :meta_description, :meta_robots, to: :@_source delegate :listed?, :published?, :redirect?, :index?, :is_layout?, :templatized?, to: :@_source delegate :sections_content, :sections_dropzone_content, to: :@_source diff --git a/lib/locomotive/steam/liquid/tags/seo.rb b/lib/locomotive/steam/liquid/tags/seo.rb index 5fa41af1..f635527f 100644 --- a/lib/locomotive/steam/liquid/tags/seo.rb +++ b/lib/locomotive/steam/liquid/tags/seo.rb @@ -26,6 +26,7 @@ def render_metadata(context) %{ + } end diff --git a/lib/locomotive/steam/middlewares/templatized_page.rb b/lib/locomotive/steam/middlewares/templatized_page.rb index 6c50dd09..e424b30b 100644 --- a/lib/locomotive/steam/middlewares/templatized_page.rb +++ b/lib/locomotive/steam/middlewares/templatized_page.rb @@ -28,8 +28,9 @@ def set_content_entry! # log it debug_log "Found content entry: #{entry._label}" else + log "C"*25 url = services.url_builder.url_for(page_not_found, locale) - redirect_to url, 302 + redirect_to url, 404 end end diff --git a/lib/locomotive/steam/repositories/content_entry_repository.rb b/lib/locomotive/steam/repositories/content_entry_repository.rb index 7619e002..faa9e40a 100644 --- a/lib/locomotive/steam/repositories/content_entry_repository.rb +++ b/lib/locomotive/steam/repositories/content_entry_repository.rb @@ -17,7 +17,7 @@ def initialize(adapter, site = nil, locale = nil, content_type_repository = nil) # Entity mapping mapping :content_entries, entity: ContentEntry do - localized_attributes :_slug, :seo_title, :meta_description, :meta_keywords + localized_attributes :_slug, :seo_title, :meta_description, :meta_keywords, :meta_robots default_attribute :content_type, -> (repository) { repository.content_type } end diff --git a/lib/locomotive/steam/repositories/page_repository.rb b/lib/locomotive/steam/repositories/page_repository.rb index 9c453093..8bf87294 100644 --- a/lib/locomotive/steam/repositories/page_repository.rb +++ b/lib/locomotive/steam/repositories/page_repository.rb @@ -10,7 +10,7 @@ class PageRepository localized_attributes :title, :slug, :permalink, :source, :raw_template, :template_path, :data_path, :redirect_url, :fullpath, :sections_content, :sections_dropzone_content, - :seo_title, :meta_description, :meta_keywords + :seo_title, :meta_description, :meta_keywords, :meta_robots embedded_association :editable_elements, EditableElementRepository end diff --git a/spec/fixtures/default/app/views/pages/index.liquid.haml b/spec/fixtures/default/app/views/pages/index.liquid.haml index aea5a48c..2f034caf 100644 --- a/spec/fixtures/default/app/views/pages/index.liquid.haml +++ b/spec/fixtures/default/app/views/pages/index.liquid.haml @@ -11,6 +11,7 @@ title: Home page %meta{ content: "{{ site.meta_description }}", name: "description" } %meta{ content: "{{ site.meta_keywords }}", name: "keywords" } + %meta{ content: "{{ site.meta_robots }}", name: "robots" } {{ '/foo/bar' | auto_discovery_link_tag: 'rel:alternate', 'type:application/atom+xml', 'title:A title' }} diff --git a/spec/unit/liquid/drops/content_entry_spec.rb b/spec/unit/liquid/drops/content_entry_spec.rb index d6f2bdf3..613fb3af 100644 --- a/spec/unit/liquid/drops/content_entry_spec.rb +++ b/spec/unit/liquid/drops/content_entry_spec.rb @@ -4,7 +4,7 @@ let(:site) { instance_double('Site', default_locale: 'en') } let(:type) { instance_double('Type', fields_by_name: { title: instance_double('Field', type: :string ) }) } - let(:entry) { instance_double('Article', _id: 42, localized_attributes: {}, content_type: type, title: 'Hello world', _label: 'Hello world', _slug: 'hello-world', _translated: false, seo_title: 'seo title', meta_keywords: 'keywords', meta_description: 'description', created_at: 0, updated_at: 1) } + let(:entry) { instance_double('Article', _id: 42, localized_attributes: {}, content_type: type, title: 'Hello world', _label: 'Hello world', _slug: 'hello-world', _translated: false, seo_title: 'seo title', meta_keywords: 'keywords', meta_description: 'description', meta_robots: 'noindex', created_at: 0, updated_at: 1) } let(:assigns) { {} } let(:services) { Locomotive::Steam::Services.build_instance } let(:context) { ::Liquid::Context.new(assigns, {}, { services: services, site: site, locale: 'en' }) } @@ -20,6 +20,7 @@ expect(subject.seo_title).to eq 'seo title' expect(subject.meta_keywords).to eq 'keywords' expect(subject.meta_description).to eq 'description' + expect(subject.meta_robots).to eq 'noindex' expect(subject.created_at).to eq 0 expect(subject.updated_at).to eq 1 end @@ -110,7 +111,7 @@ describe 'belong_to content type' do - let(:entry) { instance_double('Article', _id: 42, localized_attributes: {}, content_type: type, title: 'Hello world', _label: 'Hello world', _slug: 'hello-world', _translated: false, seo_title: 'seo title', meta_keywords: 'keywords', meta_description: 'description', created_at: 0, updated_at: 1, author: author) } + let(:entry) { instance_double('Article', _id: 42, localized_attributes: {}, content_type: type, title: 'Hello world', _label: 'Hello world', _slug: 'hello-world', _translated: false, seo_title: 'seo title', meta_keywords: 'keywords', meta_description: 'description', meta_robots: 'noindex', created_at: 0, updated_at: 1, author: author) } let(:type) { instance_double('Type', fields_by_name: { title: instance_double('StringField', type: :string ), author: instance_double('Author', type: :belongs_to), picture: instance_double('FileField', type: :file), category: instance_double('SelectField', type: :select) }) } let(:author) { instance_double('Author', _slug: 'john-doe', localized_attributes: {}) } let(:picture_field) { Locomotive::Steam::ContentEntry::FileField.new('foo.png', 'http://assets.dev', 0, 42) } @@ -147,7 +148,7 @@ describe '#as_json' do - let(:entry) { instance_double('Article', _id: 42, localized_attributes: {}, content_type: type, title: 'Hello world', _label: 'Hello world', _slug: 'hello-world', _translated: false, seo_title: 'seo title', meta_keywords: 'keywords', meta_description: 'description', created_at: 0, updated_at: 1, author: author, authors: authors) } + let(:entry) { instance_double('Article', _id: 42, localized_attributes: {}, content_type: type, title: 'Hello world', _label: 'Hello world', _slug: 'hello-world', _translated: false, seo_title: 'seo title', meta_keywords: 'keywords', meta_description: 'description', meta_robots: 'noindex', created_at: 0, updated_at: 1, author: author, authors: authors) } let(:type) { instance_double('Type', fields_by_name: { title: instance_double('StringField', type: :string ), author: instance_double('Author', type: :belongs_to), authors: instance_double('Author', type: :many_to_many), picture: instance_double('FileField', type: :file), category: instance_double('SelectField', type: :select) }) } let(:author) { instance_double('Author', _slug: 'john-doe', localized_attributes: {}) } let(:authors) { instance_double('Authors', all: [author]) } diff --git a/spec/unit/liquid/drops/page_spec.rb b/spec/unit/liquid/drops/page_spec.rb index 49769f6e..16fc417b 100644 --- a/spec/unit/liquid/drops/page_spec.rb +++ b/spec/unit/liquid/drops/page_spec.rb @@ -6,7 +6,7 @@ let(:services) { Locomotive::Steam::Services.build_instance } let(:site) { instance_double('Site', default_locale: 'en') } let(:context) { ::Liquid::Context.new(assigns, {}, { locale: 'en', services: services, site: site }) } - let(:page) { instance_double('Page', id: 42, localized_attributes: [], title: 'Index', slug: 'index', fullpath: 'index', content_type: nil, depth: 1, templatized?: false, listed?: true, published?: true, is_layout?: true, redirect?: false, seo_title: 'seo title', redirect_url: '/', handle: 'index', meta_keywords: 'keywords', meta_description: 'description') } + let(:page) { instance_double('Page', id: 42, localized_attributes: [], title: 'Index', slug: 'index', fullpath: 'index', content_type: nil, depth: 1, templatized?: false, listed?: true, published?: true, is_layout?: true, redirect?: false, seo_title: 'seo title', redirect_url: '/', handle: 'index', meta_keywords: 'keywords', meta_description: 'description', meta_robots: 'noindex') } let(:drop) { described_class.new(page).tap { |d| d.context = context } } subject { drop } @@ -25,6 +25,7 @@ expect(subject.seo_title).to eq 'seo title' expect(subject.meta_keywords).to eq 'keywords' expect(subject.meta_description).to eq 'description' + expect(subject.meta_robots).to eq 'robots' expect(subject.listed?).to eq true expect(subject.redirect?).to eq false expect(subject.is_layout?).to eq true diff --git a/spec/unit/liquid/tags/seo_spec.rb b/spec/unit/liquid/tags/seo_spec.rb index 9c9600fd..f760e8d6 100644 --- a/spec/unit/liquid/tags/seo_spec.rb +++ b/spec/unit/liquid/tags/seo_spec.rb @@ -5,7 +5,7 @@ let(:page) { nil } let(:content_entry) { nil } - let(:site) { liquid_instance_double('Site', name: 'Acme', seo_title: 'Acme (SEO)', meta_description: 'A short site description', meta_keywords: 'test only cat dog') } + let(:site) { liquid_instance_double('Site', name: 'Acme', seo_title: 'Acme (SEO)', meta_description: 'A short site description', meta_keywords: 'test only cat dog', meta_robots: 'noindex,nofollow') } let(:assigns) { { 'site' => site, 'page' => page, 'content_entry' => content_entry } } let(:context) { ::Liquid::Context.new(assigns, {}, {}) } @@ -30,7 +30,7 @@ describe 'no seo_title site property' do - let(:site) { liquid_instance_double('Site', name: 'Acme', seo_title: nil, meta_description: 'A short site description', meta_keywords: 'test only cat dog') } + let(:site) { liquid_instance_double('Site', name: 'Acme', seo_title: nil, meta_description: 'A short site description', meta_keywords: 'test only cat dog', meta_robots: 'noindex,nofollow') } it { is_expected.to eq '