refinerycms-pages 0.9.9.16 → 0.9.9.17
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/admin/pages_controller.rb +7 -8
- data/app/controllers/admin/pages_dialogs_controller.rb +0 -2
- data/app/models/page.rb +47 -27
- data/app/models/page_part.rb +7 -1
- data/app/views/admin/pages_dialogs/link_to.html.erb +1 -1
- data/lib/gemspec.rb +1 -1
- data/lib/refinery/pages/instance_methods.rb +1 -1
- data/lib/refinerycms-pages.rb +1 -1
- data/refinerycms-pages.gemspec +4 -4
- metadata +5 -7
@@ -27,16 +27,15 @@ module Admin
|
|
27
27
|
super
|
28
28
|
|
29
29
|
# Check whether we need to override e.g. on the pages form.
|
30
|
-
unless params[:switch_locale]
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
if @page.slug
|
35
|
-
Thread.current[:globalize_locale] = @page.slug.locale
|
36
|
-
end
|
30
|
+
unless params[:switch_locale] || @page.nil? || @page.new_record? || @page.slugs.where({
|
31
|
+
:locale => Refinery::I18n.current_locale}
|
32
|
+
).nil?
|
33
|
+
@page.slug = @page.slugs.first if @page.slug.nil? && @page.slugs.any?
|
34
|
+
Thread.current[:globalize_locale] = @page.slug.locale if @page.slug
|
37
35
|
end
|
38
36
|
else
|
39
|
-
|
37
|
+
# Always display the tree of pages from the default frontend locale.
|
38
|
+
Thread.current[:globalize_locale] = params[:switch_locale].try(:to_sym) || ::Refinery::I18n.default_frontend_locale
|
40
39
|
end
|
41
40
|
end
|
42
41
|
|
data/app/models/page.rb
CHANGED
@@ -4,27 +4,39 @@ class Page < ActiveRecord::Base
|
|
4
4
|
|
5
5
|
translates :title, :meta_keywords, :meta_description, :browser_title, :custom_title if self.respond_to?(:translates)
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
@translation ||= translations.build(:locale => ::Globalize.locale)
|
13
|
-
end
|
7
|
+
attr_accessible :id, :deletable, :link_url, :menu_match, :meta_keywords,
|
8
|
+
:skip_to_first_child, :position, :show_in_menu, :draft,
|
9
|
+
:parts_attributes, :browser_title, :meta_description,
|
10
|
+
:custom_title_type, :parent_id, :custom_title,
|
11
|
+
:created_at, :updated_at, :page_id
|
14
12
|
|
15
|
-
|
13
|
+
# Set up support for meta tags through translations.
|
14
|
+
if defined?(::Page::Translation)
|
15
|
+
attr_accessible :title
|
16
|
+
# set allowed attributes for mass assignment
|
17
|
+
::Page::Translation.module_eval do
|
18
|
+
attr_accessible :browser_title, :meta_description, :meta_keywords,
|
19
|
+
:locale
|
16
20
|
end
|
21
|
+
if ::Page::Translation.table_exists?
|
22
|
+
def translation
|
23
|
+
if @translation.nil? or @translation.try(:locale) != ::Globalize.locale
|
24
|
+
@translation = translations.with_locale(::Globalize.locale).first
|
25
|
+
@translation ||= translations.build(:locale => ::Globalize.locale)
|
26
|
+
end
|
27
|
+
|
28
|
+
@translation
|
29
|
+
end
|
17
30
|
|
18
31
|
# Instruct the Translation model to have meta tags.
|
19
|
-
::Page::Translation.
|
20
|
-
is_seo_meta
|
21
|
-
end
|
32
|
+
::Page::Translation.send :is_seo_meta
|
22
33
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
34
|
+
# Delegate all SeoMeta attributes to the active translation.
|
35
|
+
fields = ::SeoMeta.attributes.keys.map{|a| [a, :"#{a}="]}.flatten
|
36
|
+
fields << {:to => :translation}
|
37
|
+
delegate *fields
|
38
|
+
after_save proc {|m| m.translation.save}
|
39
|
+
end
|
28
40
|
end
|
29
41
|
|
30
42
|
attr_accessor :locale # to hold temporarily
|
@@ -36,13 +48,15 @@ class Page < ActiveRecord::Base
|
|
36
48
|
has_friendly_id :title, :use_slug => true,
|
37
49
|
:default_locale => (::Refinery::I18n.default_frontend_locale rescue :en),
|
38
50
|
:reserved_words => %w(index new session login logout users refinery admin images wymiframe),
|
39
|
-
:approximate_ascii => RefinerySetting.find_or_set(:approximate_ascii, false, :scoping => "pages")
|
51
|
+
:approximate_ascii => RefinerySetting.find_or_set(:approximate_ascii, false, :scoping => "pages"),
|
52
|
+
:strip_non_ascii => RefinerySetting.find_or_set(:strip_non_ascii, false, :scoping => "pages")
|
40
53
|
|
41
54
|
has_many :parts,
|
42
55
|
:class_name => "PagePart",
|
43
56
|
:order => "position ASC",
|
44
57
|
:inverse_of => :page,
|
45
|
-
:dependent => :destroy
|
58
|
+
:dependent => :destroy,
|
59
|
+
:include => :translations
|
46
60
|
|
47
61
|
accepts_nested_attributes_for :parts, :allow_destroy => true
|
48
62
|
|
@@ -54,19 +68,25 @@ class Page < ActiveRecord::Base
|
|
54
68
|
after_save :reposition_parts!, :invalidate_child_cached_url, :expire_page_caching
|
55
69
|
after_destroy :expire_page_caching
|
56
70
|
|
57
|
-
|
58
|
-
scope :
|
59
|
-
|
71
|
+
# Wrap up the logic of finding the pages based on the translations table.
|
72
|
+
scope :with_globalize, lambda {|t|
|
73
|
+
if defined?(::Page::Translation)
|
74
|
+
t = {:locale => Globalize.locale}.merge(t || {})
|
75
|
+
where(:id => ::Page::Translation.where(t).select('page_id AS id'))
|
76
|
+
else
|
77
|
+
where(t)
|
78
|
+
end
|
60
79
|
}
|
61
80
|
|
81
|
+
scope :live, where(:draft => false)
|
82
|
+
scope :by_title, lambda {|t| with_globalize(:title => t)}
|
83
|
+
|
62
84
|
# Shows all pages with :show_in_menu set to true, but it also
|
63
85
|
# rejects any page that has not been translated to the current locale.
|
64
86
|
# This works using a query against the translated content first and then
|
65
87
|
# using all of the page_ids we further filter against this model's table.
|
66
88
|
scope :in_menu, lambda {
|
67
|
-
where(:show_in_menu => true).
|
68
|
-
:id => Page::Translation.where(:locale => Globalize.locale).map(&:page_id)
|
69
|
-
)
|
89
|
+
where(:show_in_menu => true).with_globalize({})
|
70
90
|
}
|
71
91
|
|
72
92
|
# when a dialog pops up to link to a page, how many pages per page should there be
|
@@ -293,10 +313,10 @@ class Page < ActiveRecord::Base
|
|
293
313
|
|
294
314
|
# In the admin area we use a slightly different title to inform the which pages are draft or hidden pages
|
295
315
|
def title_with_meta
|
296
|
-
if self.title.nil?
|
297
|
-
|
316
|
+
title = if self.title.nil?
|
317
|
+
[::Page::Translation.where(:page_id => self.id, :locale => Globalize.locale).first.try(:title).to_s]
|
298
318
|
else
|
299
|
-
|
319
|
+
[self.title.to_s]
|
300
320
|
end
|
301
321
|
|
302
322
|
title << "<em>(#{::I18n.t('hidden', :scope => 'admin.pages.page')})</em>" unless show_in_menu?
|
data/app/models/page_part.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
class PagePart < ActiveRecord::Base
|
2
2
|
|
3
|
+
attr_accessible :title, :content, :position, :body, :created_at,
|
4
|
+
:updated_at, :page_id
|
3
5
|
belongs_to :page
|
4
6
|
|
5
7
|
validates :title, :presence => true
|
@@ -12,7 +14,11 @@ class PagePart < ActiveRecord::Base
|
|
12
14
|
end
|
13
15
|
|
14
16
|
before_save :normalise_text_fields
|
15
|
-
|
17
|
+
if defined?(::PagePart::Translation)
|
18
|
+
::PagePart::Translation.module_eval do
|
19
|
+
attr_accessible :locale
|
20
|
+
end
|
21
|
+
end
|
16
22
|
protected
|
17
23
|
def normalise_text_fields
|
18
24
|
unless body.blank? or body =~ /^\</
|
@@ -109,7 +109,7 @@
|
|
109
109
|
<%= will_paginate @resources,
|
110
110
|
:param_name => :resource_page,
|
111
111
|
:renderer => Refinery::LinkRenderer,
|
112
|
-
:
|
112
|
+
:params => {:paginating => "resource_file"},
|
113
113
|
:id => 'resouces_paginate' %>
|
114
114
|
</div>
|
115
115
|
</div>
|
data/lib/gemspec.rb
CHANGED
data/lib/refinerycms-pages.rb
CHANGED
@@ -36,7 +36,7 @@ module Refinery
|
|
36
36
|
::Refinery::Plugin.register do |plugin|
|
37
37
|
plugin.name = "refinery_pages"
|
38
38
|
plugin.directory = "pages"
|
39
|
-
plugin.version = %q{0.9.9.
|
39
|
+
plugin.version = %q{0.9.9.17}
|
40
40
|
plugin.menu_match = /(refinery|admin)\/page(_part)?s(_dialogs)?$/
|
41
41
|
plugin.activity = {
|
42
42
|
: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.17}
|
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-04-
|
8
|
+
s.date = %q{2011-04-15}
|
9
9
|
s.email = %q{info@refinerycms.com}
|
10
10
|
s.homepage = %q{http://refinerycms.com}
|
11
11
|
s.rubyforge_project = %q{refinerycms}
|
@@ -117,6 +117,6 @@ Gem::Specification.new do |s|
|
|
117
117
|
'spec/models/page_spec.rb'
|
118
118
|
]
|
119
119
|
|
120
|
-
s.add_dependency 'refinerycms-core', '= 0.9.9.
|
121
|
-
s.add_dependency 'seo_meta', '~> 1.0.
|
120
|
+
s.add_dependency 'refinerycms-core', '= 0.9.9.17'
|
121
|
+
s.add_dependency 'seo_meta', '~> 1.0.4'
|
122
122
|
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.17
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Resolve Digital
|
@@ -13,8 +13,7 @@ autorequire:
|
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
15
|
|
16
|
-
date: 2011-04-
|
17
|
-
default_executable:
|
16
|
+
date: 2011-04-15 00:00:00 Z
|
18
17
|
dependencies:
|
19
18
|
- !ruby/object:Gem::Dependency
|
20
19
|
name: refinerycms-core
|
@@ -24,7 +23,7 @@ dependencies:
|
|
24
23
|
requirements:
|
25
24
|
- - "="
|
26
25
|
- !ruby/object:Gem::Version
|
27
|
-
version: 0.9.9.
|
26
|
+
version: 0.9.9.17
|
28
27
|
type: :runtime
|
29
28
|
version_requirements: *id001
|
30
29
|
- !ruby/object:Gem::Dependency
|
@@ -35,7 +34,7 @@ dependencies:
|
|
35
34
|
requirements:
|
36
35
|
- - ~>
|
37
36
|
- !ruby/object:Gem::Version
|
38
|
-
version: 1.0.
|
37
|
+
version: 1.0.4
|
39
38
|
type: :runtime
|
40
39
|
version_requirements: *id002
|
41
40
|
description: The default content engine of Refinery CMS. This engine handles the administration and display of user-editable pages.
|
@@ -120,7 +119,6 @@ files:
|
|
120
119
|
- license.md
|
121
120
|
- refinerycms-pages.gemspec
|
122
121
|
- spec/models/page_spec.rb
|
123
|
-
has_rdoc: true
|
124
122
|
homepage: http://refinerycms.com
|
125
123
|
licenses:
|
126
124
|
- MIT
|
@@ -144,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
142
|
requirements: []
|
145
143
|
|
146
144
|
rubyforge_project: refinerycms
|
147
|
-
rubygems_version: 1.
|
145
|
+
rubygems_version: 1.7.2
|
148
146
|
signing_key:
|
149
147
|
specification_version: 3
|
150
148
|
summary: Pages engine for Refinery CMS
|