refinerycms-pages 2.0.10 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/refinery/admin/pages_controller.rb +23 -17
  3. data/app/controllers/refinery/admin/pages_dialogs_controller.rb +8 -45
  4. data/app/controllers/refinery/pages/admin/preview_controller.rb +38 -0
  5. data/app/controllers/refinery/pages_controller.rb +26 -43
  6. data/app/helpers/refinery/admin/pages_helper.rb +19 -14
  7. data/app/models/refinery/page.rb +133 -194
  8. data/app/models/refinery/page_part.rb +1 -1
  9. data/{lib → app/presenters}/refinery/pages/content_page_presenter.rb +1 -5
  10. data/{lib → app/presenters}/refinery/pages/content_presenter.rb +1 -15
  11. data/app/presenters/refinery/pages/menu_presenter.rb +118 -0
  12. data/{lib → app/presenters}/refinery/pages/page_part_section_presenter.rb +0 -0
  13. data/{lib → app/presenters}/refinery/pages/section_presenter.rb +0 -0
  14. data/{lib → app/presenters}/refinery/pages/title_section_presenter.rb +0 -0
  15. data/app/sweepers/refinery/pages/page_sweeper.rb +29 -0
  16. data/app/views/refinery/admin/pages/_form.html.erb +4 -4
  17. data/app/views/refinery/admin/pages/_form_advanced_options.html.erb +3 -18
  18. data/app/views/refinery/admin/pages/_form_page_parts.html.erb +2 -2
  19. data/app/views/refinery/admin/pages/_page.html.erb +5 -5
  20. data/app/views/refinery/admin/pages/_records.html.erb +1 -3
  21. data/app/views/refinery/admin/pages/_sortable_list.html.erb +1 -1
  22. data/app/views/refinery/admin/pages/index.html.erb +1 -1
  23. data/app/views/refinery/admin/pages_dialogs/link_to.html.erb +0 -2
  24. data/config/locales/bg.yml +0 -11
  25. data/config/locales/cs.yml +1 -3
  26. data/config/locales/da.yml +15 -5
  27. data/config/locales/de.yml +16 -5
  28. data/config/locales/el.yml +0 -3
  29. data/config/locales/en.yml +1 -12
  30. data/config/locales/es.yml +0 -3
  31. data/config/locales/fi.yml +0 -3
  32. data/config/locales/fr.yml +0 -11
  33. data/config/locales/hu.yml +85 -0
  34. data/config/locales/it.yml +0 -10
  35. data/config/locales/ja.yml +0 -3
  36. data/config/locales/ko.yml +0 -11
  37. data/config/locales/lt.yml +0 -3
  38. data/config/locales/lv.yml +0 -3
  39. data/config/locales/nb.yml +0 -3
  40. data/config/locales/nl.yml +51 -40
  41. data/config/locales/pl.yml +23 -4
  42. data/config/locales/pt-BR.yml +0 -3
  43. data/config/locales/pt.yml +85 -0
  44. data/config/locales/rs.yml +0 -3
  45. data/config/locales/ru.yml +0 -3
  46. data/config/locales/sk.yml +0 -11
  47. data/config/locales/sl.yml +0 -3
  48. data/config/locales/sv.yml +0 -3
  49. data/config/locales/tr.yml +85 -0
  50. data/config/locales/uk.yml +82 -0
  51. data/config/locales/vi.yml +0 -3
  52. data/config/locales/zh-CN.yml +8 -11
  53. data/config/locales/zh-TW.yml +0 -3
  54. data/config/routes.rb +11 -5
  55. data/db/seeds.rb +16 -14
  56. data/lib/generators/refinery/pages/templates/config/initializers/refinery/pages.rb.erb +8 -4
  57. data/lib/refinery/pages.rb +5 -9
  58. data/lib/refinery/pages/caching.rb +60 -0
  59. data/lib/refinery/pages/configuration.rb +11 -7
  60. data/lib/refinery/pages/engine.rb +7 -8
  61. data/lib/refinery/pages/instance_methods.rb +4 -11
  62. data/lib/refinery/pages/render_options.rb +27 -0
  63. data/lib/refinery/pages/tab.rb +15 -4
  64. data/lib/refinery/pages/url.rb +74 -0
  65. data/refinerycms-pages.gemspec +4 -3
  66. data/spec/controllers/refinery/pages_controller_spec.rb +24 -0
  67. data/spec/factories/pages.rb +1 -1
  68. data/spec/{requests → features}/refinery/admin/pages_spec.rb +125 -42
  69. data/spec/{requests → features}/refinery/pages_spec.rb +139 -23
  70. data/spec/helpers/refinery/pages/admin/pages_helper_spec.rb +25 -25
  71. data/spec/lib/refinery/pages/caching_spec.rb +90 -0
  72. data/spec/lib/refinery/pages/tab_spec.rb +89 -0
  73. data/spec/lib/refinery/pages/url_spec.rb +74 -0
  74. data/spec/models/refinery/page_spec.rb +196 -71
  75. data/spec/{lib → presenters/refinery}/pages/content_page_presenter_spec.rb +0 -0
  76. data/spec/{lib → presenters/refinery}/pages/content_presenter_spec.rb +0 -0
  77. data/spec/presenters/refinery/pages/menu_presenter_spec.rb +58 -0
  78. data/spec/{lib → presenters/refinery}/pages/page_part_section_presenter_spec.rb +0 -0
  79. data/spec/{lib → presenters/refinery}/pages/section_presenter_spec.rb +0 -0
  80. data/spec/{lib → presenters/refinery}/pages/title_section_presenter_spec.rb +0 -0
  81. data/spec/support/refinery/pages/caching.rb +19 -0
  82. data/spec/support/refinery/pages/caching_helpers.rb +22 -0
  83. metadata +77 -33
  84. data/app/controllers/refinery/page_sweeper.rb +0 -34
  85. data/app/helpers/refinery/pages_helper.rb +0 -20
  86. data/app/views/refinery/admin/pages/_locale_picker.html.erb +0 -11
  87. data/config/locales/pt-PT.yml +0 -75
  88. data/spec/controllers/refinery/admin/pages_controller_spec.rb +0 -17
  89. data/spec/helpers/refinery/pages/pages_helper_spec.rb +0 -30
@@ -7,7 +7,7 @@ zh-CN:
7
7
  admin:
8
8
  pages_dialogs:
9
9
  page_link:
10
- link_to_this_page: 页面连接
10
+ link_to_this_page: 页面链接
11
11
  link_to:
12
12
  insert: 插入
13
13
  your_page:
@@ -16,21 +16,21 @@ zh-CN:
16
16
  tab_name: 网站
17
17
  location: 位置
18
18
  new_window: 新窗口
19
- new_window_label: 勾选这个方框使得此连接在新浏览器窗口中打开.
19
+ new_window_label: 勾选这个方框使得此链接在新浏览器窗口中打开.
20
20
  not_sure: 不确定放什么东西到上面的方框?
21
- step1: 在网上寻找要连接去的页面.
21
+ step1: 在网上寻找要链接去的页面.
22
22
  step2: 在浏览器地址栏复制网页地址然后粘贴到上面的方框.
23
23
  email_address:
24
24
  tab_name: Email 地址
25
25
  subject_line_optional: 可选的主题
26
26
  body_optional: 可选的内容
27
27
  not_sure: 不确定放什么东西到上面那些方框?
28
- step1_html: 输入或复制然后粘贴 (例如从您的通讯录) email 地址用来连接到上面方框的 '<strong>邮件地址</strong>'.
28
+ step1_html: 输入或复制然后粘贴 (例如从您的通讯录) email 地址用来链接到上面方框的 '<strong>邮件地址</strong>'.
29
29
  step2_html: 如果您想使用 <strong>预写的标题列</strong> 来编辑信息, 请使用上面的 '<strong>标题列</strong>' 方框.
30
30
  step3_html: 如果您想使用 <strong>预写的信息</strong> 来编辑信息, 请使用上面的 <strong>Email 内容</strong> 方框.
31
31
  your_resource:
32
32
  tab_name: 您的文件
33
- link_to_this_resource: 连接到此文件
33
+ link_to_this_resource: 链接到此文件
34
34
  pages:
35
35
  delete: 永久删除此页面
36
36
  edit: 编辑此页面
@@ -45,20 +45,17 @@ zh-CN:
45
45
  create_content_section: 添加内容区
46
46
  delete_content_section: 删除内容区
47
47
  form_advanced_options:
48
- toggle_advanced_options: meta 标签设定与菜单选项
49
48
  page_options: 页面选项
50
- parent_page: 父业面
51
- advanced_options: 高级选项
49
+ parent_page: 父页面
52
50
  menu_title: 菜单项名称
53
51
  custom_slug: 自定义slug
54
52
  custom_title: 自定义标题
55
53
  show_in_menu_title: 在菜单中显示
56
54
  show_in_menu_description: 在网站菜单中显示这个页面
57
55
  show_in_menu_help: 如果您想在网站菜单中去除一个页面, 不勾选这个选项. 如果您想有个可以直接访问的页面但又不想显示在菜单里, 这个很方便的选项.
58
- save_as_draft: 另存为草稿
59
56
  skip_to_first_child: 跳过第一层页面
60
57
  skip_to_first_child_label: 重定向浏览者到第一个子层页.
61
- skip_to_first_child_help: 这个选项使得这个页面连接到第一个页面下面, 这对组合页面在一起的时候非常有用.
58
+ skip_to_first_child_help: 这个选项使得这个页面链接到第一个页面下面, 这对组合页面在一起的时候非常有用.
62
59
  link_url: 重定向这个页面到其他的网站或页面
63
60
  link_url_help: 如果您想要在菜单中点这个页面就跳到其他网站或是页面的话, 在这里输入网址, 例如 http://google.com, 不然就留空
64
61
  parent_page_help: 您可以在列表中让一个页面依附在另一个页面之下. 如果您想要让这个页面为第一层页面, 就不要填写.
@@ -71,7 +68,7 @@ zh-CN:
71
68
  reorder_pages_done: 完成编排
72
69
  records:
73
70
  no_pages_yet: 这里还没有页面. 点击 "添加新页面" 去添加您的第一个页面.
74
- translator_access: 您没有权限更改这种语言的页面
71
+ translator_access: 您没有权限来更改使用这种语言的页面
75
72
  activerecord:
76
73
  models:
77
74
  refinery/page: 页面
@@ -44,15 +44,12 @@ zh-TW:
44
44
  create_content_section: 新增內容區
45
45
  delete_content_section: 刪除內容區
46
46
  form_advanced_options:
47
- toggle_advanced_options: 存取 meta 標籤設定與選單選項
48
47
  page_options: 頁面選項
49
48
  parent_page: 父頁面
50
- advanced_options: 進階選項
51
49
  custom_title: 自訂標題
52
50
  show_in_menu_title: 在選單中顯示
53
51
  show_in_menu_description: 在網站選單中顯示這個頁面
54
52
  show_in_menu_help: 如果您想要將這個頁面移除您的網站選單請不要勾選這個框框. 如果您想要有個可以直接連結的頁面但又不想讓它出現在選單上, 這是個便利的功能.
55
- save_as_draft: 儲存草稿
56
53
  skip_to_first_child: 略過第一層頁面
57
54
  skip_to_first_child_label: 將訪客重新導向到第一個次層頁面.
58
55
  skip_to_first_child_help: 這個選項讓這個頁面可以連結到第一個頁面之下. 當您想要分類頁面的時這會很有用.
@@ -1,14 +1,22 @@
1
1
  Refinery::Core::Engine.routes.draw do
2
2
  root :to => 'pages#home', :via => :get
3
- post 'pages/preview' => 'pages#preview', :as => :preview_pages
4
- match 'pages/*path/preview' => 'pages#preview', :as => :preview_page, :via => [:get, :put]
5
3
  get '/pages/:id', :to => 'pages#show', :as => :page
6
4
 
7
- namespace :admin, :path => 'refinery' do
5
+ namespace :pages, :path => '' do
6
+ namespace :admin, :path => Refinery::Core.backend_route do
7
+ scope :path => :pages do
8
+ post 'preview', :to => 'preview#show', :as => :preview_pages
9
+ put 'preview/*path', :to => 'preview#show', :as => :preview_page
10
+ end
11
+ end
12
+ end
13
+
14
+ namespace :admin, :path => Refinery::Core.backend_route do
8
15
  get 'pages/*path/edit', :to => 'pages#edit'
9
16
  get 'pages/*path/children', :to => 'pages#children', :as => 'children_pages'
10
17
  put 'pages/*path', :to => 'pages#update'
11
18
  delete 'pages/*path', :to => 'pages#destroy'
19
+
12
20
  resources :pages, :except => :show do
13
21
  post :update_positions, :on => :collection
14
22
  end
@@ -16,8 +24,6 @@ Refinery::Core::Engine.routes.draw do
16
24
  resources :pages_dialogs, :only => [] do
17
25
  collection do
18
26
  get :link_to
19
- get :test_url
20
- get :test_email
21
27
  end
22
28
  end
23
29
 
@@ -24,23 +24,23 @@ if Refinery::Page.where(:menu_match => "^/$").empty?
24
24
  :body => "<h2>Sorry, there was a problem...</h2><p>The page you requested was not found.</p><p><a href='/'>Return to the home page</a></p>",
25
25
  :position => 0
26
26
  })
27
- end
28
27
 
29
- if Refinery::Page.by_title("About").empty?
30
- about_us_page = ::Refinery::Page.create(:title => "About")
31
- about_us_page.parts.create({
32
- :title => "Body",
33
- :body => "<p>This is just a standard text page example. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin metus dolor, hendrerit sit amet, aliquet nec, posuere sed, purus. Nullam et velit iaculis odio sagittis placerat. Duis metus tellus, pellentesque ut, luctus id, egestas a, lorem. Praesent vitae mauris. Aliquam sed nulla. Sed id nunc vitae leo suscipit viverra. Proin at leo ut lacus consequat rhoncus. In hac habitasse platea dictumst. Nunc quis tortor sed libero hendrerit dapibus.\n\nInteger interdum purus id erat. Duis nec velit vitae dolor mattis euismod. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse pellentesque dignissim lacus. Nulla semper euismod arcu. Suspendisse egestas, erat a consectetur dapibus, felis orci cursus eros, et sollicitudin purus urna et metus. Integer eget est sed nunc euismod vestibulum. Integer nulla dui, tristique in, euismod et, interdum imperdiet, enim. Mauris at lectus. Sed egestas tortor nec mi.</p>",
34
- :position => 0
35
- })
36
- about_us_page.parts.create({
37
- :title => "Side Body",
38
- :body => "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus fringilla nisi a elit. Duis ultricies orci ut arcu. Ut ac nibh. Duis blandit rhoncus magna. Pellentesque semper risus ut magna. Etiam pulvinar tellus eget diam. Morbi blandit. Donec pulvinar mauris at ligula. Sed pellentesque, ipsum id congue molestie, lectus risus egestas pede, ac viverra diam lacus ac urna. Aenean elit.</p>",
39
- :position => 1
40
- })
28
+ if Refinery::Page.by_title("About").empty?
29
+ about_us_page = ::Refinery::Page.create(:title => "About")
30
+ about_us_page.parts.create({
31
+ :title => "Body",
32
+ :body => "<p>This is just a standard text page example. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin metus dolor, hendrerit sit amet, aliquet nec, posuere sed, purus. Nullam et velit iaculis odio sagittis placerat. Duis metus tellus, pellentesque ut, luctus id, egestas a, lorem. Praesent vitae mauris. Aliquam sed nulla. Sed id nunc vitae leo suscipit viverra. Proin at leo ut lacus consequat rhoncus. In hac habitasse platea dictumst. Nunc quis tortor sed libero hendrerit dapibus.\n\nInteger interdum purus id erat. Duis nec velit vitae dolor mattis euismod. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse pellentesque dignissim lacus. Nulla semper euismod arcu. Suspendisse egestas, erat a consectetur dapibus, felis orci cursus eros, et sollicitudin purus urna et metus. Integer eget est sed nunc euismod vestibulum. Integer nulla dui, tristique in, euismod et, interdum imperdiet, enim. Mauris at lectus. Sed egestas tortor nec mi.</p>",
33
+ :position => 0
34
+ })
35
+ about_us_page.parts.create({
36
+ :title => "Side Body",
37
+ :body => "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus fringilla nisi a elit. Duis ultricies orci ut arcu. Ut ac nibh. Duis blandit rhoncus magna. Pellentesque semper risus ut magna. Etiam pulvinar tellus eget diam. Morbi blandit. Donec pulvinar mauris at ligula. Sed pellentesque, ipsum id congue molestie, lectus risus egestas pede, ac viverra diam lacus ac urna. Aenean elit.</p>",
38
+ :position => 1
39
+ })
40
+ end
41
41
  end
42
42
 
43
- (Refinery.i18n_enabled? ? Refinery::I18n.frontend_locales : [:en]).each do |lang|
43
+ Refinery::I18n.frontend_locales.each do |lang|
44
44
  I18n.locale = lang
45
45
  {'home' => "Home",
46
46
  'page-not-found' => 'Page not found',
@@ -49,3 +49,5 @@ end
49
49
  Refinery::Page.by_title(title).each { |page| page.update_attributes(:slug => slug) }
50
50
  end
51
51
  end
52
+
53
+ I18n.locale = ::Refinery::I18n.default_locale
@@ -30,6 +30,12 @@ Refinery::Pages.configure do |config|
30
30
  # when you create a page
31
31
  # config.use_custom_slugs = <%= Refinery::Pages.use_custom_slugs.inspect %>
32
32
 
33
+ # Set this to true if page slugs generated by friendly_id should be scoped by parent.
34
+ # If false, page slugs are global, and are, in effect, custom routes that may contain slashes.
35
+ # By default, these routes will be flattened to the root, using the slugged page title,
36
+ # and will no longer be nested as children.
37
+ # config.scope_slug_by_parent = <%= Refinery::Pages.scope_slug_by_parent.inspect %>
38
+
33
39
  # Set this to true if you want backend pages to be cached
34
40
  # config.cache_pages_backend = <%= Refinery::Pages.cache_pages_backend.inspect %>
35
41
 
@@ -41,13 +47,11 @@ Refinery::Pages.configure do |config|
41
47
 
42
48
  # config.layout_template_whitelist = <%= Refinery::Pages.layout_template_whitelist.inspect %>
43
49
 
44
- # config.view_template_whitelist = <%= Refinery::Pages.view_template_whitelist.inspect %>
45
-
46
50
  # config.use_layout_templates = <%= Refinery::Pages.use_layout_templates.inspect %>
47
51
 
48
- # config.use_view_templates = <%= Refinery::Pages.use_view_templates.inspect %>
49
-
50
52
  # config.page_title = <%= Refinery::Pages.page_title.inspect %>
51
53
 
52
54
  # config.absolute_page_links = <%= Refinery::Pages.absolute_page_links.inspect %>
55
+
56
+ # config.show_title_in_body = <%= Refinery::Pages.show_title_in_body.inspect %>
53
57
  end
@@ -24,15 +24,11 @@ module Refinery
24
24
  end
25
25
 
26
26
  def valid_templates(*pattern)
27
- [Rails.root, Refinery::Plugins.registered.pathnames].flatten.uniq.map { |p|
28
- p.join(*pattern)
29
- }.map(&:to_s).map { |p|
30
- Dir[p]
31
- }.select(&:any?).flatten.map { |f|
32
- File.basename(f)
33
- }.map { |p|
34
- p.split('.').first
35
- }
27
+ ([Rails.root] | Refinery::Plugins.registered.pathnames).map { |p|
28
+ Dir[p.join(*pattern).to_s].flatten.map { |f|
29
+ File.basename(f).split('.').first
30
+ }
31
+ }.flatten.uniq
36
32
  end
37
33
 
38
34
  def default_parts_for(page)
@@ -0,0 +1,60 @@
1
+ module Refinery
2
+ module Pages
3
+ class Caching
4
+
5
+ attr_reader :cache_dir
6
+
7
+ def initialize(cache_dir = nil)
8
+ @cache_dir = cache_dir
9
+ end
10
+
11
+ def expire!
12
+ clear_caching!
13
+ delete_static_files!
14
+ end
15
+
16
+ private
17
+ delegate :cache, :to => Rails
18
+
19
+ def cache_dir_valid?
20
+ cache_dir.present? && cache_dir_path.directory?
21
+ end
22
+
23
+ def cache_dir_path
24
+ Pathname.new cache_dir.to_s
25
+ end
26
+
27
+ def clear_caching!
28
+ begin
29
+ cache.delete_matched(/.*pages.*/)
30
+ rescue NoMethodError, NotImplementedError
31
+ warn "**** [REFINERY] The cache store you are using is not compatible with Rails.cache#delete_matched - clearing entire cache instead ***"
32
+ cache.clear
33
+ end
34
+ end
35
+
36
+ def delete_static_files!
37
+ return unless cache_dir_valid?
38
+
39
+ delete_page_cache_directory!
40
+ delete_page_cache_index_file!
41
+ end
42
+
43
+ def delete_page_cache_directory!
44
+ page_cache_root.rmtree if page_cache_root.directory?
45
+ end
46
+
47
+ def delete_page_cache_index_file!
48
+ page_cache_index_file.delete if page_cache_index_file.file?
49
+ end
50
+
51
+ def page_cache_index_file
52
+ Pathname.new "#{page_cache_root}.html"
53
+ end
54
+
55
+ def page_cache_root
56
+ cache_dir_path.join 'refinery', 'cache', 'pages'
57
+ end
58
+ end
59
+ end
60
+ end
@@ -4,11 +4,10 @@ module Refinery
4
4
 
5
5
  config_accessor :pages_per_dialog, :pages_per_admin_index, :new_page_parts,
6
6
  :marketable_urls, :approximate_ascii, :strip_non_ascii,
7
- :default_parts, :use_custom_slugs, :cache_pages_backend,
8
- :cache_pages_full, :layout_template_whitelist,
9
- :view_template_whitelist, :use_layout_templates,
10
- :use_view_templates, :page_title, :absolute_page_links, :types,
11
- :auto_expand_admin_tree
7
+ :default_parts, :use_custom_slugs, :scope_slug_by_parent,
8
+ :cache_pages_backend, :cache_pages_full, :layout_template_whitelist,
9
+ :use_layout_templates, :page_title, :absolute_page_links, :types,
10
+ :auto_expand_admin_tree, :show_title_in_body
12
11
 
13
12
  self.pages_per_dialog = 14
14
13
  self.pages_per_admin_index = 20
@@ -18,12 +17,16 @@ module Refinery
18
17
  self.strip_non_ascii = false
19
18
  self.default_parts = ["Body", "Side Body"]
20
19
  self.use_custom_slugs = false
20
+ self.scope_slug_by_parent = true
21
21
  self.cache_pages_backend = false
22
22
  self.cache_pages_full = false
23
23
  self.layout_template_whitelist = ["application"]
24
- self.view_template_whitelist = ["home", "show"]
24
+ class << self
25
+ def layout_template_whitelist
26
+ Array(config.layout_template_whitelist).map(&:to_s)
27
+ end
28
+ end
25
29
  self.use_layout_templates = false
26
- self.use_view_templates = false
27
30
  self.page_title = {
28
31
  :chain_page_title => false,
29
32
  :ancestors => {
@@ -37,6 +40,7 @@ module Refinery
37
40
  :wrap_if_not_chained => false
38
41
  }
39
42
  }
43
+ self.show_title_in_body = true
40
44
  self.absolute_page_links = false
41
45
  self.types = Types.registered
42
46
  self.auto_expand_admin_tree = true
@@ -1,7 +1,7 @@
1
1
  module Refinery
2
2
  module Pages
3
3
  class Engine < ::Rails::Engine
4
- include Refinery::Engine
4
+ extend Refinery::Engine
5
5
 
6
6
  isolate_namespace Refinery
7
7
  engine_name :refinery_pages
@@ -14,26 +14,25 @@ module Refinery
14
14
  end
15
15
 
16
16
  after_inclusion do
17
- ::ApplicationController.send :include, Refinery::Pages::InstanceMethods
18
- Refinery::AdminController.send :include, Refinery::Pages::Admin::InstanceMethods
17
+ Refinery.include_once(::ApplicationController, Refinery::Pages::InstanceMethods)
18
+ Refinery.include_once(Refinery::AdminController, Refinery::Pages::Admin::InstanceMethods)
19
19
  end
20
20
 
21
- initializer "register refinery_pages plugin" do
21
+ initializer "refinery.pages register plugin" do
22
22
  Refinery::Plugin.register do |plugin|
23
23
  plugin.pathname = root
24
24
  plugin.name = 'refinery_pages'
25
- plugin.version = %q{2.0.0}
26
- plugin.menu_match = %r{refinery/page(_part|s_dialog)?s$}
25
+ plugin.menu_match = %r{refinery/page(_part|s_dialog)?s(/preview)?$}
27
26
  plugin.activity = {
28
27
  :class_name => :'refinery/page',
29
- :nested_with => [:uncached_nested_url],
28
+ :nested_with => [:nested_url],
30
29
  :use_record_in_nesting => false
31
30
  }
32
31
  plugin.url = proc { Refinery::Core::Engine.routes.url_helpers.admin_pages_path }
33
32
  end
34
33
  end
35
34
 
36
- initializer "append marketable routes", :after => :set_routes_reloader_hook do
35
+ initializer "refinery.pages append marketable routes", :after => :set_routes_reloader_hook do
37
36
  append_marketable_routes if Refinery::Pages.marketable_urls
38
37
  end
39
38
 
@@ -10,8 +10,8 @@ module Refinery
10
10
  def error_404(exception=nil)
11
11
  if (@page = ::Refinery::Page.where(:menu_match => "^/404$").includes(:parts).first).present?
12
12
  # render the application's custom 404 page with layout and meta.
13
- if self.respond_to? :render_with_templates?
14
- render_with_templates? :status => 404
13
+ if self.respond_to? :render_with_templates?, true
14
+ render_with_templates? @page, :status => 404
15
15
  else
16
16
  render :template => '/refinery/pages/show', :formats => [:html], :status => 404
17
17
  end
@@ -23,22 +23,15 @@ module Refinery
23
23
 
24
24
  # Compiles the default menu.
25
25
  def refinery_menu_pages
26
- ::Refinery::Menu.new(::Refinery::Page.fast_menu)
26
+ Menu.new Page.fast_menu
27
27
  end
28
28
 
29
29
  protected
30
30
  def render_with_presenters(*args)
31
- present(@page) unless admin? or @meta.present?
31
+ present @page unless admin? || @meta
32
32
  render_without_presenters(*args)
33
33
  end
34
34
 
35
- private
36
- def store_current_location!
37
- return super if admin?
38
-
39
- session[:website_return_to] = refinery.url_for(@page.url) if @page && @page.persisted?
40
- end
41
-
42
35
  end
43
36
  end
44
37
  end
@@ -0,0 +1,27 @@
1
+ module Refinery
2
+ module Pages
3
+ module RenderOptions
4
+
5
+ def render_options_for_template(page)
6
+ render_options = {}
7
+ if Refinery::Pages.use_layout_templates && page.layout_template.present?
8
+ render_options[:layout] = page.layout_template
9
+ end
10
+
11
+ template = page.link_url == "/" ? "home" : "show"
12
+
13
+ render_options[:template] = "refinery/pages/#{page.view_template.presence || template}"
14
+
15
+ render_options
16
+ end
17
+
18
+ def render_with_templates?(page = @page, render_options = {})
19
+ render_options.update render_options_for_template(page)
20
+ render render_options
21
+ end
22
+
23
+ protected :render_options_for_template, :render_with_templates?
24
+
25
+ end
26
+ end
27
+ end
@@ -1,14 +1,20 @@
1
1
  module Refinery
2
2
  module Pages
3
3
 
4
- attr_accessor :tabs
5
-
6
4
  def self.tabs
7
5
  @tabs ||= []
8
6
  end
9
7
 
8
+ def self.tabs_for_template(template)
9
+ return tabs unless template
10
+
11
+ tabs.select do |tab|
12
+ tab.templates.include?('all') || tab.templates.include?(template)
13
+ end
14
+ end
15
+
10
16
  class Tab
11
- attr_accessor :name, :partial
17
+ attr_accessor :name, :partial, :templates
12
18
 
13
19
  def self.register(&block)
14
20
  tab = self.new
@@ -17,12 +23,17 @@ module Refinery
17
23
 
18
24
  raise "A tab MUST have a name!: #{tab.inspect}" if tab.name.blank?
19
25
  raise "A tab MUST have a partial!: #{tab.inspect}" if tab.partial.blank?
26
+
27
+ tab.templates = %w[all] if tab.templates.blank?
28
+ tab.templates = Array(tab.templates)
29
+
30
+ tab
20
31
  end
21
32
 
22
33
  protected
23
34
 
24
35
  def initialize
25
- ::Refinery::Pages.tabs << self # add me to the collection of registered page tabs
36
+ Refinery::Pages.tabs << self # add me to the collection of registered page tabs
26
37
  end
27
38
  end
28
39