refinerycms-pages 0.9.9.15 → 0.9.9.16

Sign up to get free protection for your applications and to get access to all the features.
@@ -28,7 +28,12 @@ module Admin
28
28
 
29
29
  # Check whether we need to override e.g. on the pages form.
30
30
  unless params[:switch_locale] or @page.nil? or @page.slugs.where(:locale => Refinery::I18n.current_locale).nil? or !@page.persisted?
31
- Thread.current[:globalize_locale] = @page.slug.locale
31
+ if @page.slug.nil? and @page.slugs.length > 0
32
+ @page.slug = @page.slugs[0]
33
+ end
34
+ if @page.slug
35
+ Thread.current[:globalize_locale] = @page.slug.locale
36
+ end
32
37
  end
33
38
  else
34
39
  Thread.current[:globalize_locale] = nil
data/app/models/page.rb CHANGED
@@ -5,11 +5,11 @@ class Page < ActiveRecord::Base
5
5
  translates :title, :meta_keywords, :meta_description, :browser_title, :custom_title if self.respond_to?(:translates)
6
6
 
7
7
  # Set up support for meta tags through translations.
8
- if defined?(::Page::Translation) && Page::Translation.table_exists?
8
+ if defined?(::Page::Translation) && ::Page::Translation.table_exists?
9
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)
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
13
  end
14
14
 
15
15
  @translation
@@ -262,8 +262,10 @@ class Page < ActiveRecord::Base
262
262
  end
263
263
 
264
264
  def expire_page_caching
265
- if File.writable?(Rails.cache.cache_path)
266
- Pathname.glob(File.join(Rails.cache.cache_path, '**', '*pages*')).each(&:delete)
265
+ begin
266
+ Rails.cache.delete_matched(/.*pages.*/)
267
+ rescue NotImplementedError
268
+ warn "**** [REFINERY] The cache store you are using is not compatible with Rails.cache#delete_matched so please disable caching to ensure proper operation. ***"
267
269
  end
268
270
  end
269
271
  end
@@ -291,7 +293,12 @@ class Page < ActiveRecord::Base
291
293
 
292
294
  # In the admin area we use a slightly different title to inform the which pages are draft or hidden pages
293
295
  def title_with_meta
294
- title = [self.title.to_s]
296
+ if self.title.nil?
297
+ title = [::Page::Translation.where(:page_id => self.id).first.title.to_s]
298
+ else
299
+ title = [self.title.to_s]
300
+ end
301
+
295
302
  title << "<em>(#{::I18n.t('hidden', :scope => 'admin.pages.page')})</em>" unless show_in_menu?
296
303
  title << "<em>(#{::I18n.t('draft', :scope => 'admin.pages.page')})</em>" if draft?
297
304
 
@@ -1,6 +1,6 @@
1
1
  <section id='records' class='tree'>
2
- <% caching = RefinerySetting.find_or_set(:cache_pages_backend, false) && File.writable?(Rails.cache.cache_path) %>
3
- <% cache_if(caching && !user_signed_in?, [Refinery.base_cache_key, "pages_backend", Globalize.locale].join('_')) do %>
2
+ <% caching = RefinerySetting.find_or_set(:cache_pages_backend, false) %>
3
+ <% cache_if(caching, [Refinery.base_cache_key, "pages_backend", Globalize.locale].join('_')) do %>
4
4
  <%= render :partial => 'records' %>
5
5
  <% end %>
6
6
  </section>
data/lib/gemspec.rb CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
26
26
  ]
27
27
 
28
28
  s.add_dependency 'refinerycms-core', '= #{::Refinery::Version}'
29
- s.add_dependency 'seo_meta', '~> 1.0.2'
29
+ s.add_dependency 'seo_meta', '~> 1.0.3'
30
30
  end
31
31
  EOF
32
32
 
@@ -0,0 +1,27 @@
1
+ module Refinery
2
+ module Pages
3
+ module Admin
4
+ module InstanceMethods
5
+
6
+ def error_404(exception=nil)
7
+ if (@page = Page.find_by_menu_match("^/404$", :include => [:parts, :slugs])).present?
8
+ params[:action] = 'error_404'
9
+ # change any links in the copy to the admin_root_path
10
+ # and any references to "home page" to "Dashboard"
11
+ part_symbol = Page.default_parts.first.to_sym
12
+ @page[part_symbol] = @page[part_symbol].to_s.gsub(
13
+ /href=(\'|\")\/(\'|\")/, "href='#{admin_root_path}'"
14
+ ).gsub("home page", "Dashboard")
15
+
16
+ render :template => "/pages/show",
17
+ :layout => layout?,
18
+ :status => 404
19
+ else
20
+ super
21
+ end
22
+ end
23
+
24
+ end
25
+ end
26
+ end
27
+ end
@@ -26,7 +26,7 @@ module Refinery
26
26
  private
27
27
  def store_current_location!
28
28
  unless admin?
29
- session[:website_return_to] = @page.url if @page.try(:present?)
29
+ session[:website_return_to] = url_for(@page.url) if @page.try(:present?)
30
30
  else
31
31
  super
32
32
  end
@@ -7,6 +7,9 @@ module Refinery
7
7
  module Pages
8
8
 
9
9
  autoload :InstanceMethods, File.expand_path('../refinery/pages/instance_methods', __FILE__)
10
+ module Admin
11
+ autoload :InstanceMethods, File.expand_path('../refinery/pages/admin/instance_methods', __FILE__)
12
+ end
10
13
 
11
14
  class << self
12
15
  attr_accessor :root
@@ -26,6 +29,7 @@ module Refinery
26
29
 
27
30
  refinery.after_inclusion do
28
31
  ::ApplicationController.send :include, ::Refinery::Pages::InstanceMethods
32
+ ::Admin::BaseController.send :include, ::Refinery::Pages::Admin::InstanceMethods
29
33
  end
30
34
 
31
35
  config.after_initialize do
@@ -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.15}
5
+ s.version = %q{0.9.9.16}
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-01}
8
+ s.date = %q{2011-04-07}
9
9
  s.email = %q{info@refinerycms.com}
10
10
  s.homepage = %q{http://refinerycms.com}
11
11
  s.rubyforge_project = %q{refinerycms}
@@ -106,6 +106,8 @@ Gem::Specification.new do |s|
106
106
  'lib/pages/tabs.rb',
107
107
  'lib/refinery',
108
108
  'lib/refinery/pages',
109
+ 'lib/refinery/pages/admin',
110
+ 'lib/refinery/pages/admin/instance_methods.rb',
109
111
  'lib/refinery/pages/instance_methods.rb',
110
112
  'lib/refinerycms-pages.rb',
111
113
  'license.md',
@@ -115,6 +117,6 @@ Gem::Specification.new do |s|
115
117
  'spec/models/page_spec.rb'
116
118
  ]
117
119
 
118
- s.add_dependency 'refinerycms-core', '= 0.9.9.15'
119
- s.add_dependency 'seo_meta', '~> 1.0.2'
120
+ s.add_dependency 'refinerycms-core', '= 0.9.9.16'
121
+ s.add_dependency 'seo_meta', '~> 1.0.3'
120
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.15
5
+ version: 0.9.9.16
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-04-01 00:00:00 +13:00
16
+ date: 2011-04-07 00:00:00 +12:00
17
17
  default_executable:
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
@@ -24,7 +24,7 @@ dependencies:
24
24
  requirements:
25
25
  - - "="
26
26
  - !ruby/object:Gem::Version
27
- version: 0.9.9.15
27
+ version: 0.9.9.16
28
28
  type: :runtime
29
29
  version_requirements: *id001
30
30
  - !ruby/object:Gem::Dependency
@@ -35,7 +35,7 @@ dependencies:
35
35
  requirements:
36
36
  - - ~>
37
37
  - !ruby/object:Gem::Version
38
- version: 1.0.2
38
+ version: 1.0.3
39
39
  type: :runtime
40
40
  version_requirements: *id002
41
41
  description: The default content engine of Refinery CMS. This engine handles the administration and display of user-editable pages.
@@ -114,6 +114,7 @@ files:
114
114
  - lib/generators/refinerycms_pages_generator.rb
115
115
  - lib/pages/marketable_routes.rb
116
116
  - lib/pages/tabs.rb
117
+ - lib/refinery/pages/admin/instance_methods.rb
117
118
  - lib/refinery/pages/instance_methods.rb
118
119
  - lib/refinerycms-pages.rb
119
120
  - license.md