Navigation Menu

Skip to content

Commit

Permalink
Move the meta_description field from Deventer.nl to DevCMS (part of #…
Browse files Browse the repository at this point in the history
…21761).
  • Loading branch information
vanderhoorn committed Apr 29, 2015
1 parent 9df94f1 commit 14de72e
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 15 deletions.
15 changes: 9 additions & 6 deletions app/models/news_item.rb
Expand Up @@ -9,12 +9,14 @@
# * +title+ - The title of the news item.
# * +preamble+ - The preamble of the news item.
# * +body+ - The body of the news item.
# * +meta_description+ - The meta description of the news item.
#
# Preconditions
#
# * Requires the presence of +title+.
# * Requires the presence of +body+.
# * Requires the presence of +news_archive+.
# * Requires the length of +meta_description+ to be maximum 160 characters.
#
# Child/parent type constraints
#
Expand All @@ -23,11 +25,11 @@
#
class NewsItem < ActiveRecord::Base
# Adds content node functionality to news items.
acts_as_content_node({
acts_as_content_node(
allowed_child_content_types: %w( Attachment AttachmentTheme Image ),
show_in_menu: false,
copyable: false
})
)

# This content type needs approval when created or altered by an editor.
needs_editor_approval
Expand All @@ -46,9 +48,10 @@ class NewsItem < ActiveRecord::Base
has_many :news_viewer_items, dependent: :destroy

# See the preconditions overview for an explanation of these validations.
validates :title, presence: true, length: { maximum: 255 }
validates :body, presence: true
validates :news_archive, presence: true
validates :title, presence: true, length: { maximum: 255 }
validates :body, presence: true
validates :news_archive, presence: true
validates :meta_description, length: { maximum: 160 }

scope :newest, lambda { includes(:node).where(['nodes.publication_start_date >= ?', (Settler['news_viewer_time_period'] ? Settler['news_viewer_time_period'].to_i : 2).weeks.ago]) }

Expand All @@ -74,7 +77,7 @@ def self.owms_type
I18n.t('owms.news_item')
end

protected
protected

def remove_associated_content
self.newsletter_edition_items.destroy_all
Expand Down
13 changes: 8 additions & 5 deletions app/models/page.rb
Expand Up @@ -8,11 +8,13 @@
# * +title+ - The title of the page.
# * +body+ - The body of the page.
# * +preamble+ - The preamble of the page.
# * +meta_description+ - The meta description of the page.
#
# Preconditions
#
# * Requires the presence of +title+.
# * Requires the presence of +body+.
# * Requires the length of +meta_description+ to be maximum 160 characters.
#
# Child/parent type constraints
#
Expand All @@ -21,13 +23,13 @@
#
class Page < ActiveRecord::Base
# Adds content node functionality to pages.
acts_as_content_node({
acts_as_content_node(
allowed_child_content_types: %w( Attachment AttachmentTheme Image ),
available_content_representations: ['content_box'],
has_own_content_box: true,
expirable: true,
expiration_required: true
})
)

# This content type needs approval when created or altered by an editor.
needs_editor_approval
Expand All @@ -40,8 +42,9 @@ class Page < ActiveRecord::Base
has_many :carrousel_items, as: :item, dependent: :destroy

# See the preconditions overview for an explanation of these validations.
validates :title, presence: true, length: { maximum: 255 }
validates :body, presence: true
validates :title, presence: true, length: { maximum: 255 }
validates :body, presence: true
validates :meta_description, length: { maximum: 160 }

after_paranoid_delete :remove_associated_content

Expand All @@ -59,7 +62,7 @@ def has_related_content?
node.tags.empty?
end

protected
protected

def remove_associated_content
self.newsletter_edition_items.destroy_all
Expand Down
3 changes: 3 additions & 0 deletions app/views/admin/news_items/_form.html.haml
Expand Up @@ -5,3 +5,6 @@
= form.text_area :preamble, :label => t('news.preamble'), :rows => 5
= form.html_editor :body, :label => t('news.text')
= form.check_box :commentable, :label => t('shared.commentable')

= field_set_tag 'Zoekmachine instellingen' do
= form.text_area :meta_description, :label => t('shared.meta_description'), :rows => 3
3 changes: 3 additions & 0 deletions app/views/admin/pages/_form.html.haml
Expand Up @@ -3,3 +3,6 @@

= form.text_area :preamble, label: t('pages.preamble'), rows: 5
= form.html_editor :body, label: t('pages.body')

= field_set_tag 'Zoekmachine instellingen' do
= form.text_area :meta_description, label: t('shared.meta_description'), rows: 3
1 change: 1 addition & 0 deletions config/locales/other.nl.yml
Expand Up @@ -21,6 +21,7 @@ nl:
failed: Opslaan mislukt!
last_updated: Laatst gewijzigd
locale: Taal van inhoud
meta_description: Meta-omschrijving
more_activities: meer activiteiten
more_permits: meer bekendmakingen
more_products: meer producten
Expand Down
@@ -0,0 +1,6 @@
class AddMetaDescriptionToPagesAndNewsItems < ActiveRecord::Migration
def change
add_column :pages, :meta_description, :string
add_column :news_items, :meta_description, :string
end
end
10 changes: 6 additions & 4 deletions test/dummy/db/schema.rb
Expand Up @@ -520,12 +520,13 @@
add_index "news_archives", ["updated_at"], :name => "index_news_archives_on_updated_at"

create_table "news_items", :force => true do |t|
t.string "title", :null => false
t.text "body", :null => false
t.string "title", :null => false
t.text "body", :null => false
t.datetime "created_at"
t.datetime "updated_at"
t.text "preamble"
t.datetime "deleted_at"
t.string "meta_description"
end

add_index "news_items", ["created_at"], :name => "index_news_items_on_created_at"
Expand Down Expand Up @@ -702,12 +703,13 @@
end

create_table "pages", :force => true do |t|
t.string "title", :null => false
t.text "body", :null => false
t.string "title", :null => false
t.text "body", :null => false
t.datetime "created_at"
t.datetime "updated_at"
t.text "preamble"
t.datetime "deleted_at"
t.string "meta_description"
end

add_index "pages", ["created_at"], :name => "index_pages_on_created_at"
Expand Down

0 comments on commit 14de72e

Please sign in to comment.