refinerycms-pages 0.9.9.8 → 0.9.9.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,13 +2,15 @@ module Admin
2
2
  class PagesController < Admin::BaseController
3
3
 
4
4
  crudify :page,
5
- :conditions => {:parent_id => nil},
5
+ :conditions => nil,
6
6
  :order => "lft ASC",
7
- :include => [:parts, :slugs, :children, :parent, :translations],
7
+ :include => [:slugs, :translations],
8
8
  :paging => false
9
9
 
10
10
  rescue_from FriendlyId::ReservedError, :with => :show_errors_for_reserved_slug
11
11
 
12
+ after_filter lambda{::Page.expire_page_caching}, :only => [:update_positions]
13
+
12
14
  def new
13
15
  @page = Page.new
14
16
  Page.default_parts.each_with_index do |page_part, index|
data/app/models/page.rb CHANGED
@@ -27,19 +27,22 @@ class Page < ActiveRecord::Base
27
27
  :custom_title, :browser_title, :all_page_part_content]
28
28
 
29
29
  before_destroy :deletable?
30
- after_save :reposition_parts!
31
- after_save :invalidate_child_cached_url
30
+ after_save :reposition_parts!, :invalidate_child_cached_url, :expire_page_caching
31
+ after_destroy :expire_page_caching
32
32
 
33
33
  scope :live, where(:draft => false)
34
+ scope :by_title, lambda {|t|
35
+ where(:id => Page::Translation.where(:locale => Globalize.locale, :title => t).map(&:page_id))
36
+ }
34
37
 
35
- # shows all pages with :show_in_menu set to true, but it also
38
+ # Shows all pages with :show_in_menu set to true, but it also
36
39
  # rejects any page that has not been translated to the current locale.
40
+ # This works using a query against the translated content first and then
41
+ # using all of the page_ids we further filter against this model's table.
37
42
  scope :in_menu, lambda {
38
- pages = Arel::Table.new(Page.table_name)
39
- translations = Arel::Table.new(Page.translations_table_name)
40
-
41
- includes(:translations).where(:show_in_menu => true).where(
42
- translations[:locale].eq(Globalize.locale)).where(pages[:id].eq(translations[:page_id]))
43
+ where(:show_in_menu => true).joins(:translations).includes(:translations).where(
44
+ :id => Page::Translation.where(:locale => Globalize.locale).map(&:page_id)
45
+ )
43
46
  }
44
47
 
45
48
  # when a dialog pops up to link to a page, how many pages per page should there be
@@ -126,6 +129,8 @@ class Page < ActiveRecord::Base
126
129
  end
127
130
 
128
131
  def link_url_localised?
132
+ return link_url unless defined?(::Refinery::I18n)
133
+
129
134
  current_url = link_url
130
135
 
131
136
  if current_url =~ %r{^/} && ::Refinery::I18n.current_frontend_locale != ::Refinery::I18n.default_frontend_locale
@@ -231,6 +236,12 @@ class Page < ActiveRecord::Base
231
236
  def use_marketable_urls?
232
237
  RefinerySetting.find_or_set(:use_marketable_urls, true, :scoping => 'pages')
233
238
  end
239
+
240
+ def expire_page_caching
241
+ if File.writable?(Rails.cache.cache_path)
242
+ Pathname.glob(File.join(Rails.cache.cache_path, '**', '*pages*')).each(&:delete)
243
+ end
244
+ end
234
245
  end
235
246
 
236
247
  # Accessor method to get a page part from a page.
@@ -282,7 +293,7 @@ class Page < ActiveRecord::Base
282
293
  sluggified
283
294
  end
284
295
 
285
- private
296
+ private
286
297
 
287
298
  def invalidate_child_cached_url
288
299
  return true unless self.class.use_marketable_urls?
@@ -292,4 +303,8 @@ class Page < ActiveRecord::Base
292
303
  Rails.cache.delete(child.path_cache_key)
293
304
  end
294
305
  end
306
+
307
+ def expire_page_caching
308
+ self.class.expire_page_caching
309
+ end
295
310
  end
@@ -28,8 +28,10 @@
28
28
  </span>
29
29
  </div>
30
30
  <ul class='nested'>
31
- <% if (children = page.children).any? -%>
32
- <%= render :partial => 'page', :collection => children %>
33
- <% end -%>
31
+ <%= render :partial => 'page',
32
+ :collection => collection.select{|p| p.parent_id == page.id},
33
+ :locals => {
34
+ :collection => collection
35
+ } if page.has_descendants? %>
34
36
  </ul>
35
37
  </li>
@@ -1,5 +1,9 @@
1
1
  <ul id='sortable_list'>
2
- <%= render :partial => "page", :collection => @pages %>
2
+ <%= render :partial => "page",
3
+ :collection => @pages.select{|p| p.parent_id.nil?},
4
+ :locals => {
5
+ :collection => @pages
6
+ }, %>
3
7
  </ul>
4
8
  <%= render :partial => "/shared/admin/sortable_list",
5
9
  :locals => {:continue_reordering => !!local_assigns[:continue_reordering]} %>
@@ -1,5 +1,8 @@
1
1
  <section id='records' class='tree'>
2
- <%= render :partial => 'records' %>
2
+ <% caching = RefinerySetting.find_or_set(:cache_pages_backend, false) && File.writable?(Rails.cache.cache_path) %>
3
+ <% cache_if(caching, [Refinery.base_cache_key, "pages_backend", Globalize.locale].join('_')) do %>
4
+ <%= render :partial => 'records' %>
5
+ <% end %>
3
6
  </section>
4
7
  <section id='actions'>
5
8
  <%= render :partial => 'actions' %>
@@ -10,4 +10,4 @@
10
10
  :locals => {
11
11
  :child => (child ||= 0) + 1,
12
12
  :link_to_arguments => link_args
13
- } if page_link.children.any? -%>
13
+ } if page_link.has_descendants? -%>
@@ -0,0 +1,83 @@
1
+ jp:
2
+ plugins:
3
+ refinery_pages:
4
+ title: ページ
5
+ description: ページの管理
6
+ admin:
7
+ pages_dialogs:
8
+ page_link:
9
+ link_to_this_page: このページへのリンク
10
+ link_to:
11
+ insert: 挿入
12
+ your_page:
13
+ tab_name: Your page
14
+ web_address:
15
+ tab_name: サイト
16
+ location: 場所
17
+ new_window: 新規ウィンドウ
18
+ step1: リンクするページを探す
19
+ step2: ブラウザのアドレスバーに表示されているアドレスをコピーして上欄にペーストする
20
+ email_address:
21
+ tab_name: メールアドレス
22
+ subject_line_optional: 件名(無くても可)
23
+ body_optional: 本文(無くても可)
24
+ not_sure: 何を記入すべきか解りませんか?
25
+ step1_html: "メールアドレスを上の'<strong>メールアドレス</strong>'欄に直接書き込むかアドレス帳などからコピーしたものをペーストする"
26
+ step2_html: "<strong>予め決められた件名</strong>を使ってメールを作成するには上の'<strong>件名</strong>'欄を使います"
27
+ step3_html: "<strong>予め決められた本文</strong>を使ってメールを作成するには上の'<strong>本文</strong>'欄を使います"
28
+ your_resource:
29
+ tab_name: ファイル
30
+ link_to_this_resource: このファイルへのリンク
31
+ pages:
32
+ delete: ページを削除
33
+ edit: ページを編集
34
+ reserved_system_word: "このタイトルはシステム用ですので使用出来ません。"
35
+ page:
36
+ view_live_html: "このページを表示する<br/><em>(新しいウィンドウが開きます)</em>"
37
+ hidden: 隠す
38
+ draft: 準備稿
39
+ form_new_page_parts:
40
+ title: タイトル
41
+ form_page_parts:
42
+ create_content_section: コンテンツを追加
43
+ delete_content_section: コンテンツを削除
44
+ form_advanced_options:
45
+ toggle_advanced_options: メタタグの設定とメニューオプションの設定
46
+ page_options: ページの設定
47
+ parent_page: 親ページ
48
+ advanced_options: その他の設定
49
+ custom_title: カスタマイズしたタイトル
50
+ title_types:
51
+ none: 無し
52
+ text: テキスト
53
+ show_in_menu_title: メニューで表示する
54
+ show_in_menu_description: このページをサイトメニューで表示する
55
+ show_in_menu_help: サイトメニューからこのページを削除する時はこのチェックボックスのチェックを外して下さい。ユーザに直接アクセスしてもらいたいページで、サイトメニューには表示したくないページがある場合などに便利です。
56
+ save_as_draft: 準備稿として保存する
57
+ skip_to_first_child: トップレベルのページを飛ばす
58
+ skip_to_first_child_label: この直ぐ下の階層のページにユーザを飛ばす
59
+ skip_to_first_child_help: このオプションを使うと、リンクは直ぐ下の階層のページのうちの先頭のものにリンクします。幾つかのページを一まとめにする場合などに便利です。
60
+ link_url: 他のウェブサイトやページに転送する
61
+ link_url_help: メニューでこのページへのリンクをクリックした時、他のウェブサイトやページに転送するようにするにはURL(例 http://google.com)を書き入れます。そうでない場合は空欄のままにします。
62
+ parent_page_help: リストから選んで、ページを他のページの下に置く事が出来ます。空にするとこのページは一番上の階層のページとして扱われます。
63
+ custom_title_help: このページにメニューに表示されているもの以外のタイトルを付けたい時にはここに書いて下さい。
64
+ form_advanced_options_seo:
65
+ seo: 検索エンジン最適化
66
+ seo_override_title: ブラウザのタイトル
67
+ seo_override_title_help: このページの内容を要約する短いタイトルを入れて下さい。
68
+ meta_keywords_title: メタキーワード
69
+ meta_keywords_help: このページに関係のあるキーワードを5つから10個ほど入れて下さい。区切りの記号はコンマです。
70
+ meta_description_title: メタの説明
71
+ meta_description_help: このページの内容を説明する簡潔な文章を二三入れて下さい。
72
+ actions:
73
+ create_new_page: 新規ページを追加
74
+ reorder_pages: ページを並べ替える
75
+ reorder_pages_done: 並べ替えを終了する
76
+ records:
77
+ no_pages_yet: まだページはありません。"新規ページを追加"をクリックして下さい。
78
+ activerecord:
79
+ models:
80
+ page: ページ
81
+ attributes:
82
+ page:
83
+ title: タイトル
@@ -0,0 +1,13 @@
1
+ class RemoveTranslatedFieldsFromPages < ActiveRecord::Migration
2
+ def self.up
3
+ ::Page.translated_attribute_names.map(&:to_sym).each do |column_name|
4
+ remove_column ::Page.table_name, column_name if ::Page.column_names.map(&:to_sym).include?(column_name)
5
+ end
6
+ end
7
+
8
+ def self.down
9
+ ::Page.translated_attribute_names.map(&:to_sym).each do |column_name|
10
+ add_column ::Page.table_name, column_name, Page::Translation.columns.detect{|c| c.name.to_sym == column_name}.type
11
+ end
12
+ end
13
+ end
@@ -1,12 +1,11 @@
1
1
  Given /^I (only )?have a page titled "?([^\"]*)"? with a custom url "?([^\"]*)"?$/ do |only, title, link_url|
2
2
  Page.delete_all if only
3
3
 
4
- Page.create(:title => title,
5
- :link_url => link_url)
4
+ Page.create(:title => title, :link_url => link_url)
6
5
  end
7
6
 
8
7
  Given /^the page titled "?([^\"]*)"? has a menu match "?([^\"]*)"?$/ do |title, menu_match|
9
- Page.where(:title => title).first.update_attribute(:menu_match, menu_match)
8
+ Page.by_title(title).first.update_attribute(:menu_match, menu_match)
10
9
  end
11
10
 
12
11
  Given /^I (only )?have pages titled "?([^\"]*)"?$/ do |only, titles|
@@ -29,15 +28,15 @@ Given /^I (only )?have a page titled "?([^\"]*)"?$/ do |only, title|
29
28
  end
30
29
 
31
30
  Given /^the page titled "?([^\"]*)"? is a child of "?([^\"]*)"?$/ do |title, parent_title|
32
- Page.where(:title => title).first.update_attribute(:parent, Page.where(:title => parent_title).first)
31
+ Page.by_title(title).first.update_attribute(:parent, Page.by_title(parent_title).first)
33
32
  end
34
33
 
35
34
  Given /^the page titled "?([^\"]*)"? is not shown in the menu$/ do |title|
36
- Page.where(:title => title).first.update_attribute(:show_in_menu, false)
35
+ Page.by_title(title).first.update_attribute(:show_in_menu, false)
37
36
  end
38
37
 
39
38
  Given /^the page titled "?([^\"]*)"? is draft$/ do |title|
40
- Page.where(:title => title).first.update_attribute(:draft, true)
39
+ Page.by_title(title).first.update_attribute(:draft, true)
41
40
  end
42
41
 
43
42
  Then /^I should have ([0-9]+) pages?$/ do |count|
@@ -11,7 +11,7 @@ module NavigationHelpers
11
11
  new_admin_page_path
12
12
  else
13
13
  begin
14
- if page_name =~ /the page titled "?([^\"]*)"?/ and (page = Page.where(:title => $1).first).present?
14
+ if page_name =~ /the page titled "?([^\"]*)"?/ and (page = Page.by_title($1).first).present?
15
15
  self.url_for(page.url)
16
16
  else
17
17
  nil
@@ -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.8}
5
+ s.version = %q{0.9.9.9}
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-11}
8
+ s.date = %q{2011-03-15}
9
9
  s.email = %q{info@refinerycms.com}
10
10
  s.homepage = %q{http://refinerycms.com}
11
11
  s.rubyforge_project = %q{refinerycms}
@@ -63,6 +63,7 @@ Gem::Specification.new do |s|
63
63
  'config/locales/es.yml',
64
64
  'config/locales/fr.yml',
65
65
  'config/locales/it.yml',
66
+ 'config/locales/jp.yml',
66
67
  'config/locales/lolcat.yml',
67
68
  'config/locales/lt.yml',
68
69
  'config/locales/lv.yml',
@@ -85,6 +86,7 @@ Gem::Specification.new do |s|
85
86
  'db/migrate/20101214040815_translate_page_plugin.rb',
86
87
  'db/migrate/20101216194133_remove_cached_slug_from_pages.rb',
87
88
  'db/migrate/20110307025652_translate_custom_title_on_pages.rb',
89
+ 'db/migrate/20110314213540_remove_translated_fields_from_pages.rb',
88
90
  'db/seeds',
89
91
  'db/seeds/pages.rb',
90
92
  'features',
@@ -109,5 +111,5 @@ Gem::Specification.new do |s|
109
111
  'spec/models/page_spec.rb'
110
112
  ]
111
113
 
112
- s.add_dependency 'refinerycms-core', '~> 0.9.9.8'
114
+ s.add_dependency 'refinerycms-core', '~> 0.9.9.9'
113
115
  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.8
5
+ version: 0.9.9.9
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-11 00:00:00 +13:00
16
+ date: 2011-03-15 00:00:00 +13: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.8
27
+ version: 0.9.9.9
28
28
  type: :runtime
29
29
  version_requirements: *id001
30
30
  description: The default content engine of Refinery CMS. This engine handles the administration and display of user-editable pages.
@@ -71,6 +71,7 @@ files:
71
71
  - config/locales/es.yml
72
72
  - config/locales/fr.yml
73
73
  - config/locales/it.yml
74
+ - config/locales/jp.yml
74
75
  - config/locales/lolcat.yml
75
76
  - config/locales/lt.yml
76
77
  - config/locales/lv.yml
@@ -91,6 +92,7 @@ files:
91
92
  - db/migrate/20101214040815_translate_page_plugin.rb
92
93
  - db/migrate/20101216194133_remove_cached_slug_from_pages.rb
93
94
  - db/migrate/20110307025652_translate_custom_title_on_pages.rb
95
+ - db/migrate/20110314213540_remove_translated_fields_from_pages.rb
94
96
  - db/seeds/pages.rb
95
97
  - features/manage_pages.feature
96
98
  - features/step_definitions/page_steps.rb