refinerycms-pages 0.9.9.13 → 0.9.9.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/models/page.rb +24 -0
- data/db/migrate/20110329080451_create_seo_meta.rb +72 -0
- data/lib/gemspec.rb +1 -0
- data/lib/refinerycms-pages.rb +3 -2
- data/refinerycms-pages.gemspec +5 -3
- metadata +15 -3
data/app/models/page.rb
CHANGED
@@ -3,6 +3,30 @@ require 'globalize3'
|
|
3
3
|
class Page < ActiveRecord::Base
|
4
4
|
|
5
5
|
translates :title, :meta_keywords, :meta_description, :browser_title, :custom_title if self.respond_to?(:translates)
|
6
|
+
|
7
|
+
# Set up support for meta tags through translations.
|
8
|
+
if defined?(::Page::Translation) && Page::Translation.table_exists?
|
9
|
+
def translation
|
10
|
+
if @translation.nil? or @translation.try(:locale) != Globalize.locale
|
11
|
+
@translation = translations.with_locale(Globalize.locale).first
|
12
|
+
@translation ||= translations.build(:locale => Globalize.locale)
|
13
|
+
end
|
14
|
+
|
15
|
+
@translation
|
16
|
+
end
|
17
|
+
|
18
|
+
# Instruct the Translation model to have meta tags.
|
19
|
+
::Page::Translation.module_eval do
|
20
|
+
is_seo_meta
|
21
|
+
end
|
22
|
+
|
23
|
+
# Delegate all SeoMeta attributes to the active translation.
|
24
|
+
fields = ::SeoMeta.attributes.keys.map{|a| [a, :"#{a}="]}.flatten
|
25
|
+
fields << {:to => :translation}
|
26
|
+
delegate *fields
|
27
|
+
after_save proc {|m| m.translation.save}
|
28
|
+
end
|
29
|
+
|
6
30
|
attr_accessor :locale # to hold temporarily
|
7
31
|
validates :title, :presence => true
|
8
32
|
|
@@ -0,0 +1,72 @@
|
|
1
|
+
class CreateSeoMeta < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def self.up
|
4
|
+
create_table :seo_meta do |t|
|
5
|
+
t.integer :seo_meta_id
|
6
|
+
t.string :seo_meta_type
|
7
|
+
|
8
|
+
t.string :browser_title
|
9
|
+
t.string :meta_keywords
|
10
|
+
t.text :meta_description
|
11
|
+
|
12
|
+
t.timestamps
|
13
|
+
end
|
14
|
+
|
15
|
+
add_index :seo_meta, :id
|
16
|
+
add_index :seo_meta, [:seo_meta_id, :seo_meta_type]
|
17
|
+
|
18
|
+
# Grab the attributes of the records that currently exist
|
19
|
+
existing_translations = ::Page::Translation.all.map(&:attributes)
|
20
|
+
|
21
|
+
# Remove columns
|
22
|
+
::SeoMeta.attributes.keys.each do |field|
|
23
|
+
if ::Page::Translation.column_names.map(&:to_sym).include?(field)
|
24
|
+
remove_column ::Page::Translation.table_name, field
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Reset column information because otherwise the old columns will still exist.
|
29
|
+
::Page::Translation.reset_column_information
|
30
|
+
|
31
|
+
# Re-attach seo_meta
|
32
|
+
::Page::Translation.module_eval do
|
33
|
+
is_seo_meta
|
34
|
+
end
|
35
|
+
|
36
|
+
# Migrate data
|
37
|
+
existing_translations.each do |translation|
|
38
|
+
::Page::Translation.find(translation['id']).update_attributes(
|
39
|
+
::SeoMeta.attributes.keys.inject({}) {|attributes, name|
|
40
|
+
attributes.merge(name => translation[name.to_s])
|
41
|
+
}
|
42
|
+
)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.down
|
47
|
+
# Grab the attributes of the records that currently exist
|
48
|
+
existing_translations = ::Page::Translation.all.map(&:attributes)
|
49
|
+
|
50
|
+
# Add columns back to your model
|
51
|
+
::SeoMeta.attributes.each do |field, field_type|
|
52
|
+
unless ::Page::Translation.column_names.map(&:to_sym).include?(field)
|
53
|
+
add_column ::Page::Translation.table_name, field, field_type
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Reset column information because otherwise the new columns won't exist yet.
|
58
|
+
::Page::Translation.reset_column_information
|
59
|
+
|
60
|
+
# Migrate data
|
61
|
+
existing_translations.each do |translation|
|
62
|
+
::Page::Translation.find(translation['id']).update_attributes(
|
63
|
+
::SeoMeta.attributes.keys.inject({}) {|attributes, name|
|
64
|
+
attributes.merge(name => translation[name.to_s])
|
65
|
+
}
|
66
|
+
)
|
67
|
+
end
|
68
|
+
|
69
|
+
drop_table :seo_meta
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
data/lib/gemspec.rb
CHANGED
data/lib/refinerycms-pages.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'refinerycms-core'
|
2
2
|
require 'awesome_nested_set'
|
3
3
|
require 'globalize3'
|
4
|
+
require 'seo_meta'
|
4
5
|
|
5
6
|
module Refinery
|
6
7
|
module Pages
|
@@ -23,7 +24,7 @@ module Refinery
|
|
23
24
|
require File.expand_path('../pages/tabs', __FILE__)
|
24
25
|
end
|
25
26
|
|
26
|
-
refinery.
|
27
|
+
refinery.after_inclusion do
|
27
28
|
::ApplicationController.send :include, ::Refinery::Pages::InstanceMethods
|
28
29
|
end
|
29
30
|
|
@@ -31,7 +32,7 @@ module Refinery
|
|
31
32
|
::Refinery::Plugin.register do |plugin|
|
32
33
|
plugin.name = "refinery_pages"
|
33
34
|
plugin.directory = "pages"
|
34
|
-
plugin.version = %q{0.9.9}
|
35
|
+
plugin.version = %q{0.9.9.13}
|
35
36
|
plugin.menu_match = /(refinery|admin)\/page(_part)?s(_dialogs)?$/
|
36
37
|
plugin.activity = {
|
37
38
|
:class => Page,
|
data/refinerycms-pages.gemspec
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{refinerycms-pages}
|
5
|
-
s.version = %q{0.9.9.
|
5
|
+
s.version = %q{0.9.9.14}
|
6
6
|
s.summary = %q{Pages engine for Refinery CMS}
|
7
7
|
s.description = %q{The default content engine of Refinery CMS. This engine handles the administration and display of user-editable pages.}
|
8
|
-
s.date = %q{2011-03-
|
8
|
+
s.date = %q{2011-03-31}
|
9
9
|
s.email = %q{info@refinerycms.com}
|
10
10
|
s.homepage = %q{http://refinerycms.com}
|
11
11
|
s.rubyforge_project = %q{refinerycms}
|
@@ -87,6 +87,7 @@ Gem::Specification.new do |s|
|
|
87
87
|
'db/migrate/20101216194133_remove_cached_slug_from_pages.rb',
|
88
88
|
'db/migrate/20110307025652_translate_custom_title_on_pages.rb',
|
89
89
|
'db/migrate/20110314213540_remove_translated_fields_from_pages.rb',
|
90
|
+
'db/migrate/20110329080451_create_seo_meta.rb',
|
90
91
|
'db/seeds',
|
91
92
|
'db/seeds/pages.rb',
|
92
93
|
'features',
|
@@ -114,5 +115,6 @@ Gem::Specification.new do |s|
|
|
114
115
|
'spec/models/page_spec.rb'
|
115
116
|
]
|
116
117
|
|
117
|
-
s.add_dependency 'refinerycms-core', '~> 0.9.9.
|
118
|
+
s.add_dependency 'refinerycms-core', '~> 0.9.9.14'
|
119
|
+
s.add_dependency 'seo_meta', '~> 1.0.2'
|
118
120
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: refinerycms-pages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.9.9.
|
5
|
+
version: 0.9.9.14
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Resolve Digital
|
@@ -13,7 +13,7 @@ autorequire:
|
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
15
|
|
16
|
-
date: 2011-03-
|
16
|
+
date: 2011-03-31 00:00:00 +13:00
|
17
17
|
default_executable:
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
@@ -24,9 +24,20 @@ dependencies:
|
|
24
24
|
requirements:
|
25
25
|
- - ~>
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 0.9.9.
|
27
|
+
version: 0.9.9.14
|
28
28
|
type: :runtime
|
29
29
|
version_requirements: *id001
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: seo_meta
|
32
|
+
prerelease: false
|
33
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ~>
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 1.0.2
|
39
|
+
type: :runtime
|
40
|
+
version_requirements: *id002
|
30
41
|
description: The default content engine of Refinery CMS. This engine handles the administration and display of user-editable pages.
|
31
42
|
email: info@refinerycms.com
|
32
43
|
executables: []
|
@@ -93,6 +104,7 @@ files:
|
|
93
104
|
- db/migrate/20101216194133_remove_cached_slug_from_pages.rb
|
94
105
|
- db/migrate/20110307025652_translate_custom_title_on_pages.rb
|
95
106
|
- db/migrate/20110314213540_remove_translated_fields_from_pages.rb
|
107
|
+
- db/migrate/20110329080451_create_seo_meta.rb
|
96
108
|
- db/seeds/pages.rb
|
97
109
|
- features/manage_pages.feature
|
98
110
|
- features/step_definitions/page_steps.rb
|