refinerycms-pages 1.0.11 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/refinery/admin/page_parts_controller.rb +26 -0
- data/app/controllers/refinery/admin/pages_controller.rb +77 -0
- data/app/controllers/refinery/admin/pages_dialogs_controller.rb +91 -0
- data/app/controllers/refinery/page_sweeper.rb +29 -0
- data/app/controllers/refinery/pages_controller.rb +103 -0
- data/app/helpers/refinery/pages/content_pages_helper.rb +26 -0
- data/app/helpers/refinery/pages_helper.rb +4 -0
- data/app/models/refinery/page.rb +467 -0
- data/app/models/refinery/page_part.rb +33 -0
- data/app/presenters/refinery/page_presenter.rb +7 -0
- data/app/views/admin/pages/_sortable_list.html.erb +7 -4
- data/app/views/{admin → refinery/admin}/pages/_actions.html.erb +5 -4
- data/app/views/refinery/admin/pages/_form.html.erb +63 -0
- data/app/views/{admin → refinery/admin}/pages/_form_advanced_options.html.erb +35 -16
- data/app/views/refinery/admin/pages/_form_advanced_options_seo.html.erb +3 -0
- data/app/views/{admin → refinery/admin}/pages/_form_fields_after_title.html.erb +0 -0
- data/app/views/{admin → refinery/admin}/pages/_form_new_page_parts.html.erb +5 -7
- data/app/views/{admin → refinery/admin}/pages/_form_page_parts.html.erb +19 -11
- data/app/views/{admin → refinery/admin}/pages/_locale_picker.html.erb +3 -3
- data/app/views/refinery/admin/pages/_page.html.erb +48 -0
- data/app/views/{admin → refinery/admin}/pages/_page_part_field.html.erb +1 -1
- data/app/views/refinery/admin/pages/_records.html.erb +14 -0
- data/app/views/refinery/admin/pages/_sortable_list.html.erb +4 -0
- data/app/views/refinery/admin/pages/children.html.erb +1 -0
- data/app/views/refinery/admin/pages/edit.html.erb +1 -0
- data/app/views/refinery/admin/pages/index.html.erb +9 -0
- data/app/views/refinery/admin/pages/new.html.erb +1 -0
- data/app/views/refinery/admin/pages_dialogs/_page_link.html.erb +20 -0
- data/app/views/{admin → refinery/admin}/pages_dialogs/link_to.html.erb +31 -36
- data/app/views/refinery/pages/home.html.erb +1 -0
- data/app/views/refinery/pages/show.html.erb +1 -0
- data/config/locales/bg.yml +81 -73
- data/config/locales/cs.yml +71 -72
- data/config/locales/da.yml +69 -72
- data/config/locales/de.yml +69 -72
- data/config/locales/el.yml +70 -72
- data/config/locales/en.yml +88 -73
- data/config/locales/es.yml +70 -73
- data/config/locales/fi.yml +70 -73
- data/config/locales/fr.yml +69 -72
- data/config/locales/it.yml +92 -89
- data/config/locales/ja.yml +72 -0
- data/config/locales/ko.yml +83 -0
- data/config/locales/lt.yml +71 -73
- data/config/locales/lv.yml +71 -74
- data/config/locales/nb.yml +69 -72
- data/config/locales/nl.yml +68 -71
- data/config/locales/pl.yml +70 -73
- data/config/locales/pt-BR.yml +70 -73
- data/config/locales/pt-PT.yml +75 -0
- data/config/locales/rs.yml +69 -72
- data/config/locales/ru.yml +77 -96
- data/config/locales/sk.yml +69 -72
- data/config/locales/sl.yml +68 -71
- data/config/locales/sv.yml +69 -72
- data/config/locales/vi.yml +69 -72
- data/config/locales/zh-CN.yml +75 -72
- data/config/locales/zh-TW.yml +69 -72
- data/config/routes.rb +10 -5
- data/db/migrate/20100913234708_create_refinerycms_pages_schema.rb +49 -43
- data/db/seeds.rb +41 -0
- data/lib/generators/refinery/pages/pages_generator.rb +21 -0
- data/lib/generators/refinery/pages/templates/config/initializers/refinery/pages.rb.erb +44 -0
- data/lib/refinery/pages/admin/instance_methods.rb +10 -8
- data/lib/refinery/pages/configuration.rb +44 -0
- data/lib/refinery/pages/content_page_presenter.rb +33 -0
- data/lib/refinery/pages/content_presenter.rb +56 -0
- data/lib/refinery/pages/engine.rb +73 -0
- data/lib/refinery/pages/instance_methods.rb +12 -26
- data/lib/refinery/pages/page_part_section_presenter.rb +19 -0
- data/lib/refinery/pages/section_presenter.rb +69 -0
- data/lib/{pages/tabs.rb → refinery/pages/tab.rb} +0 -0
- data/lib/refinery/pages/title_section_presenter.rb +14 -0
- data/lib/refinery/pages/type.rb +17 -0
- data/lib/refinery/pages/types.rb +32 -0
- data/lib/refinery/pages.rb +55 -0
- data/lib/refinerycms-pages.rb +1 -61
- data/refinerycms-pages.gemspec +17 -118
- data/spec/factories/pages.rb +5 -0
- data/spec/helpers/refinery/pages/content_pages_helper_spec.rb +44 -0
- data/spec/lib/generators/refinery/pages/pages_generator_spec.rb +29 -0
- data/spec/lib/pages/content_page_presenter_spec.rb +43 -0
- data/spec/lib/pages/content_presenter_spec.rb +97 -0
- data/spec/lib/pages/page_part_section_presenter_spec.rb +35 -0
- data/spec/lib/pages/section_presenter_spec.rb +86 -0
- data/spec/lib/pages/title_section_presenter_spec.rb +21 -0
- data/spec/lib/pages_spec.rb +26 -0
- data/spec/models/refinery/page_spec.rb +415 -0
- data/spec/requests/refinery/admin/pages_spec.rb +581 -0
- data/spec/requests/refinery/pages_spec.rb +302 -0
- metadata +162 -153
- data/app/controllers/admin/page_parts_controller.rb +0 -24
- data/app/controllers/admin/pages_controller.rb +0 -68
- data/app/controllers/admin/pages_dialogs_controller.rb +0 -85
- data/app/controllers/pages_controller.rb +0 -33
- data/app/helpers/pages_helper.rb +0 -2
- data/app/models/page.rb +0 -391
- data/app/models/page_part.rb +0 -29
- data/app/presenters/page_presenter.rb +0 -7
- data/app/views/admin/pages/_form.html.erb +0 -61
- data/app/views/admin/pages/_form_advanced_options_seo.html.erb +0 -4
- data/app/views/admin/pages/_page.html.erb +0 -33
- data/app/views/admin/pages/_records.html.erb +0 -14
- data/app/views/admin/pages/edit.html.erb +0 -1
- data/app/views/admin/pages/index.html.erb +0 -11
- data/app/views/admin/pages/new.html.erb +0 -1
- data/app/views/admin/pages_dialogs/_page_link.html.erb +0 -14
- data/app/views/pages/home.html.erb +0 -1
- data/app/views/pages/show.html.erb +0 -1
- data/config/locales/jp.yml +0 -75
- data/config/locales/lolcat.yml +0 -76
- data/db/migrate/20101214040815_translate_page_plugin.rb +0 -29
- data/db/migrate/20101216194133_remove_cached_slug_from_pages.rb +0 -11
- data/db/migrate/20110307025652_translate_custom_title_on_pages.rb +0 -26
- data/db/migrate/20110314213540_remove_translated_fields_from_pages.rb +0 -13
- data/db/migrate/20110329080451_create_seo_meta.rb +0 -89
- data/db/seeds/pages.rb +0 -42
- data/features/manage_pages.feature +0 -48
- data/features/step_definitions/page_steps.rb +0 -72
- data/features/support/paths.rb +0 -28
- data/features/translate_pages.feature +0 -40
- data/features/visit_pages.feature +0 -68
- data/lib/gemspec.rb +0 -40
- data/lib/generators/refinerycms_pages_generator.rb +0 -8
- data/lib/pages/marketable_routes.rb +0 -12
- data/spec/models/page_spec.rb +0 -235
data/config/locales/zh-TW.yml
CHANGED
@@ -1,77 +1,74 @@
|
|
1
1
|
zh-TW:
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
reorder_pages_done: 完成頁面順序編排
|
70
|
-
records:
|
71
|
-
no_pages_yet: 目前沒有任何頁面. 點選 "新增頁面" 來加入您的第一個頁面.
|
2
|
+
refinery:
|
3
|
+
plugins:
|
4
|
+
refinery_pages:
|
5
|
+
title: 頁面
|
6
|
+
description: 管理頁面
|
7
|
+
admin:
|
8
|
+
pages_dialogs:
|
9
|
+
page_link:
|
10
|
+
link_to_this_page: 此頁面連結
|
11
|
+
link_to:
|
12
|
+
insert: 插入
|
13
|
+
your_page:
|
14
|
+
tab_name: 您的頁面
|
15
|
+
web_address:
|
16
|
+
tab_name: 網站
|
17
|
+
location: 位置
|
18
|
+
new_window: 新視窗
|
19
|
+
new_window_label: 勾選這個框框來取得在瀏覽器新視窗開啟的連結.
|
20
|
+
not_sure: 不確定該在上面的框框放入什麼?
|
21
|
+
step1: 在網路上找尋您要連結的頁面.
|
22
|
+
step2: 複製您瀏覽器網址列的網頁位置, 然後複製到上面的框框.
|
23
|
+
email_address:
|
24
|
+
tab_name: 電子郵件地址
|
25
|
+
subject_line_optional: 額外的標題
|
26
|
+
body_optional: 額外的內容
|
27
|
+
not_sure: 不確定該在上面的框框放入什麼?
|
28
|
+
step1_html: 輸入或複製貼上 (例如從您的通訊錄) 用來連結到上面 '<strong>電子郵件地址</strong>' 框框的電子郵件地址.
|
29
|
+
step2_html: 如果您想要用<strong>預寫的標題列</strong>來編輯訊息, 請使用上面的 '<strong>標題列</strong>' 框框.
|
30
|
+
step3_html: 如果您想要用<strong>預寫的訊息</strong>來編輯訊息, 請使用上面的<strong>電子郵件內容</strong>框框.
|
31
|
+
your_resource:
|
32
|
+
tab_name: 您的檔案
|
33
|
+
link_to_this_resource: 此檔案連結
|
34
|
+
pages:
|
35
|
+
delete: 永遠地移除這個頁面
|
36
|
+
edit: 編輯頁面
|
37
|
+
page:
|
38
|
+
view_live_html: 瀏覽這個頁面 <br/><em>(在新視窗中開啟)</em>
|
39
|
+
hidden: 隱藏
|
40
|
+
draft: 草稿
|
41
|
+
form_new_page_parts:
|
42
|
+
title: 標題
|
43
|
+
form_page_parts:
|
44
|
+
create_content_section: 新增內容區
|
45
|
+
delete_content_section: 刪除內容區
|
46
|
+
form_advanced_options:
|
47
|
+
toggle_advanced_options: 存取 meta 標籤設定與選單選項
|
48
|
+
page_options: 頁面選項
|
49
|
+
parent_page: 父頁面
|
50
|
+
advanced_options: 進階選項
|
51
|
+
custom_title: 自訂標題
|
52
|
+
show_in_menu_title: 在選單中顯示
|
53
|
+
show_in_menu_description: 在網站選單中顯示這個頁面
|
54
|
+
show_in_menu_help: 如果您想要將這個頁面移除您的網站選單請不要勾選這個框框. 如果您想要有個可以直接連結的頁面但又不想讓它出現在選單上, 這是個便利的功能.
|
55
|
+
save_as_draft: 儲存草稿
|
56
|
+
skip_to_first_child: 略過第一層頁面
|
57
|
+
skip_to_first_child_label: 將訪客重新導向到第一個次層頁面.
|
58
|
+
skip_to_first_child_help: 這個選項讓這個頁面可以連結到第一個頁面之下. 當您想要分類頁面的時這會很有用.
|
59
|
+
link_url: 將這個頁面重新導向到另外一個網站或是頁面
|
60
|
+
link_url_help: 如果您想要在選單中點選這個頁面就跳到另外一個網站或是頁面的話, 在這裡輸入網址, 例如 http://google.com, 不然就空白不填
|
61
|
+
parent_page_help: 您可以在列表中讓一個頁面依附在另一個頁面之下. 如果您想要讓這個頁面是第一層的頁面, 就不要填這個欄位.
|
62
|
+
custom_title_help: 如果您想要這個頁面有個跟選單中不同的名稱, 請選擇 '文字' , 然後在這裡輸入.
|
63
|
+
actions:
|
64
|
+
create_new_page: 新增頁面
|
65
|
+
reorder_pages: 重新編排頁面順序
|
66
|
+
reorder_pages_done: 完成頁面順序編排
|
67
|
+
records:
|
68
|
+
no_pages_yet: 目前沒有任何頁面. 點選 "新增頁面" 來加入您的第一個頁面.
|
72
69
|
activerecord:
|
73
70
|
models:
|
74
|
-
page: 頁面
|
71
|
+
refinery/page: 頁面
|
75
72
|
attributes:
|
76
|
-
page:
|
73
|
+
refinery/page:
|
77
74
|
title: 標題
|
data/config/routes.rb
CHANGED
@@ -1,11 +1,16 @@
|
|
1
|
-
|
1
|
+
Refinery::Core::Engine.routes.draw do
|
2
|
+
root :to => 'pages#home'
|
3
|
+
post 'pages/preview' => 'pages#preview', :as => :preview_pages
|
4
|
+
match 'pages/*path/preview' => 'pages#preview', :as => :preview_page, :via => [:get, :put]
|
2
5
|
get '/pages/:id', :to => 'pages#show', :as => :page
|
3
6
|
|
4
|
-
|
7
|
+
namespace :admin, :path => 'refinery' do
|
8
|
+
get 'pages/*path/edit', :to => 'pages#edit'
|
9
|
+
get 'pages/*path/children', :to => 'pages#children', :as => 'children_pages'
|
10
|
+
put 'pages/*path', :to => 'pages#update'
|
11
|
+
delete 'pages/*path', :to => 'pages#destroy'
|
5
12
|
resources :pages, :except => :show do
|
6
|
-
collection
|
7
|
-
post :update_positions
|
8
|
-
end
|
13
|
+
post :update_positions, :on => :collection
|
9
14
|
end
|
10
15
|
|
11
16
|
resources :pages_dialogs, :only => [] do
|
@@ -1,52 +1,58 @@
|
|
1
1
|
class CreateRefinerycmsPagesSchema < ActiveRecord::Migration
|
2
|
-
def
|
3
|
-
create_table
|
4
|
-
t.integer
|
5
|
-
t.string
|
6
|
-
t.text
|
7
|
-
t.integer
|
8
|
-
|
9
|
-
t.
|
2
|
+
def up
|
3
|
+
create_table :refinery_page_parts do |t|
|
4
|
+
t.integer :refinery_page_id
|
5
|
+
t.string :title
|
6
|
+
t.text :body
|
7
|
+
t.integer :position
|
8
|
+
|
9
|
+
t.timestamps
|
10
10
|
end
|
11
11
|
|
12
|
-
add_index
|
13
|
-
add_index
|
14
|
-
|
15
|
-
create_table
|
16
|
-
t.
|
17
|
-
t.
|
18
|
-
t.
|
19
|
-
t.
|
20
|
-
t.
|
21
|
-
t.
|
22
|
-
t.
|
23
|
-
t.
|
24
|
-
t.boolean
|
25
|
-
t.
|
26
|
-
t.
|
27
|
-
t.
|
28
|
-
t.string
|
29
|
-
t.string
|
30
|
-
|
31
|
-
t.
|
32
|
-
t.boolean "skip_to_first_child", :default => false
|
33
|
-
t.integer "lft"
|
34
|
-
t.integer "rgt"
|
35
|
-
t.integer "depth"
|
12
|
+
add_index :refinery_page_parts, :id
|
13
|
+
add_index :refinery_page_parts, :refinery_page_id
|
14
|
+
|
15
|
+
create_table :refinery_pages do |t|
|
16
|
+
t.integer :parent_id
|
17
|
+
t.string :path
|
18
|
+
t.string :slug
|
19
|
+
t.boolean :show_in_menu, :default => true
|
20
|
+
t.string :link_url
|
21
|
+
t.string :menu_match
|
22
|
+
t.boolean :deletable, :default => true
|
23
|
+
t.boolean :draft, :default => false
|
24
|
+
t.boolean :skip_to_first_child, :default => false
|
25
|
+
t.integer :lft
|
26
|
+
t.integer :rgt
|
27
|
+
t.integer :depth
|
28
|
+
t.string :view_template
|
29
|
+
t.string :layout_template
|
30
|
+
|
31
|
+
t.timestamps
|
36
32
|
end
|
37
33
|
|
38
|
-
add_index
|
39
|
-
add_index
|
40
|
-
add_index
|
41
|
-
add_index
|
42
|
-
add_index
|
34
|
+
add_index :refinery_pages, :depth
|
35
|
+
add_index :refinery_pages, :id
|
36
|
+
add_index :refinery_pages, :lft
|
37
|
+
add_index :refinery_pages, :parent_id
|
38
|
+
add_index :refinery_pages, :rgt
|
39
|
+
|
40
|
+
Refinery::PagePart.create_translation_table!({
|
41
|
+
:body => :text
|
42
|
+
})
|
43
|
+
|
44
|
+
Refinery::Page.create_translation_table!({
|
45
|
+
:title => :string,
|
46
|
+
:custom_slug => :string,
|
47
|
+
:menu_title => :string,
|
48
|
+
:slug => :string
|
49
|
+
})
|
43
50
|
end
|
44
51
|
|
45
|
-
def
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
52
|
+
def down
|
53
|
+
drop_table :refinery_page_parts
|
54
|
+
drop_table :refinery_pages
|
55
|
+
Refinery::PagePart.drop_translation_table!
|
56
|
+
Refinery::Page.drop_translation_table!
|
51
57
|
end
|
52
58
|
end
|
data/db/seeds.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
if Refinery::Page.where(:menu_match => "^/$").empty?
|
2
|
+
home_page = Refinery::Page.create!({:title => "Home",
|
3
|
+
:deletable => false,
|
4
|
+
:link_url => "/",
|
5
|
+
:menu_match => "^/$"})
|
6
|
+
home_page.parts.create({
|
7
|
+
:title => "Body",
|
8
|
+
:body => "<p>Welcome to our site. This is just a place holder page while we gather our content.</p>",
|
9
|
+
:position => 0
|
10
|
+
})
|
11
|
+
home_page.parts.create({
|
12
|
+
:title => "Side Body",
|
13
|
+
:body => "<p>This is another block of content over here.</p>",
|
14
|
+
:position => 1
|
15
|
+
})
|
16
|
+
|
17
|
+
home_page_position = -1
|
18
|
+
page_not_found_page = home_page.children.create(:title => "Page not found",
|
19
|
+
:menu_match => "^/404$",
|
20
|
+
:show_in_menu => false,
|
21
|
+
:deletable => false)
|
22
|
+
page_not_found_page.parts.create({
|
23
|
+
:title => "Body",
|
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
|
+
:position => 0
|
26
|
+
})
|
27
|
+
end
|
28
|
+
|
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
|
+
})
|
41
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Refinery
|
2
|
+
class PagesGenerator < Rails::Generators::Base
|
3
|
+
source_root File.expand_path('../templates', __FILE__)
|
4
|
+
|
5
|
+
def generate_pages_initializer
|
6
|
+
template "config/initializers/refinery/pages.rb.erb", File.join(destination_root, "config", "initializers", "refinery", "pages.rb")
|
7
|
+
end
|
8
|
+
|
9
|
+
def append_load_seed_data
|
10
|
+
create_file "db/seeds.rb" unless File.exists?(File.join(destination_root, 'db', 'seeds.rb'))
|
11
|
+
append_file 'db/seeds.rb', :verbose => true do
|
12
|
+
<<-EOH
|
13
|
+
|
14
|
+
# Added by Refinery CMS Pages extension
|
15
|
+
Refinery::Pages::Engine.load_seed
|
16
|
+
EOH
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
Refinery::Pages.configure do |config|
|
2
|
+
# Configure specific page templates
|
3
|
+
# config.types.register :home do |home|
|
4
|
+
# home.parts = %w[intro body]
|
5
|
+
# end
|
6
|
+
|
7
|
+
# Configure global page default parts
|
8
|
+
# config.default_parts = <%= Refinery::Pages.default_parts.inspect %>
|
9
|
+
|
10
|
+
# Configure how many pages per page should be displayed when a dialog is presented that contains a links to pages
|
11
|
+
# config.pages_per_dialog = <%= Refinery::Pages.pages_per_dialog.inspect %>
|
12
|
+
|
13
|
+
# Configure how many pages per page should be displayed in the list of pages in the admin area
|
14
|
+
# config.pages_per_admin_index = <%= Refinery::Pages.pages_per_admin_index.inspect %>
|
15
|
+
|
16
|
+
# Configure whether to strip diacritics from Western characters
|
17
|
+
# config.approximate_ascii = <%= Refinery::Pages.approximate_ascii.inspect %>
|
18
|
+
|
19
|
+
# Configure whether to strip non-ASCII characters from the friendly_id string
|
20
|
+
# config.strip_non_ascii = <%= Refinery::Pages.strip_non_ascii.inspect %>
|
21
|
+
|
22
|
+
# Set this to true if you want to override slug which automatically gets generated
|
23
|
+
# when you create a page
|
24
|
+
# config.use_custom_slugs = <%= Refinery::Pages.use_custom_slugs.inspect %>
|
25
|
+
|
26
|
+
# Set this to true if you want backend pages to be cached
|
27
|
+
# config.cache_pages_backend = <%= Refinery::Pages.cache_pages_backend.inspect %>
|
28
|
+
|
29
|
+
# Set this to true to activate full-page-cache
|
30
|
+
# config.cache_pages_full = <%= Refinery::Pages.cache_pages_full.inspect %>
|
31
|
+
|
32
|
+
# Set this to true to fully expand the page hierarchy in the admin
|
33
|
+
# config.auto_expand_admin_tree = <%= Refinery::Pages.auto_expand_admin_tree.inspect %>
|
34
|
+
|
35
|
+
# config.layout_template_whitelist = <%= Refinery::Pages.layout_template_whitelist.inspect %>
|
36
|
+
|
37
|
+
# config.view_template_whitelist = <%= Refinery::Pages.view_template_whitelist.inspect %>
|
38
|
+
|
39
|
+
# config.use_layout_templates = <%= Refinery::Pages.use_layout_templates.inspect %>
|
40
|
+
|
41
|
+
# config.use_view_templates = <%= Refinery::Pages.use_view_templates.inspect %>
|
42
|
+
|
43
|
+
# config.absolute_page_links = <%= Refinery::Pages.absolute_page_links.inspect %>
|
44
|
+
end
|
@@ -4,18 +4,20 @@ module Refinery
|
|
4
4
|
module InstanceMethods
|
5
5
|
|
6
6
|
def error_404(exception=nil)
|
7
|
-
if (@page = Page.where(:menu_match => "^/404$").includes(:parts
|
7
|
+
if (@page = ::Refinery::Page.where(:menu_match => "^/404$").includes(:parts).first).present?
|
8
8
|
params[:action] = 'error_404'
|
9
|
-
# change any links in the copy to the
|
9
|
+
# change any links in the copy to the refinery_admin_root_path
|
10
10
|
# and any references to "home page" to "Dashboard"
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
# TODO
|
12
|
+
=begin
|
13
|
+
part_symbol = Refinery::Pages.default_parts.first.to_sym
|
14
|
+
@page.content_for(part_symbol) = @page.content_for(part_symbol).to_s.gsub(
|
15
|
+
/href=(\'|\")\/(\'|\")/, "href='#{refinery_admin_root_path}'"
|
14
16
|
).gsub("home page", "Dashboard")
|
17
|
+
=end
|
15
18
|
|
16
|
-
render :template => "/pages/show",
|
17
|
-
|
18
|
-
:status => 404
|
19
|
+
render :template => "/pages/show", :layout => layout?, :status => 404
|
20
|
+
return false
|
19
21
|
else
|
20
22
|
super
|
21
23
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Refinery
|
2
|
+
module Pages
|
3
|
+
include ActiveSupport::Configurable
|
4
|
+
|
5
|
+
config_accessor :pages_per_dialog, :pages_per_admin_index, :new_page_parts,
|
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
|
12
|
+
|
13
|
+
self.pages_per_dialog = 14
|
14
|
+
self.pages_per_admin_index = 20
|
15
|
+
self.new_page_parts = false
|
16
|
+
self.marketable_urls = true
|
17
|
+
self.approximate_ascii = false
|
18
|
+
self.strip_non_ascii = false
|
19
|
+
self.default_parts = ["Body", "Side Body"]
|
20
|
+
self.use_custom_slugs = false
|
21
|
+
self.cache_pages_backend = false
|
22
|
+
self.cache_pages_full = false
|
23
|
+
self.layout_template_whitelist = ["application"]
|
24
|
+
self.view_template_whitelist = ["home", "show"]
|
25
|
+
self.use_layout_templates = false
|
26
|
+
self.use_view_templates = false
|
27
|
+
self.page_title = {
|
28
|
+
:chain_page_title => false,
|
29
|
+
:ancestors => {
|
30
|
+
:separator => " | ",
|
31
|
+
:class => 'ancestors',
|
32
|
+
:tag => 'span'
|
33
|
+
},
|
34
|
+
:page_title => {
|
35
|
+
:class => nil,
|
36
|
+
:tag => nil,
|
37
|
+
:wrap_if_not_chained => false
|
38
|
+
}
|
39
|
+
}
|
40
|
+
self.absolute_page_links = false
|
41
|
+
self.types = Types.registered
|
42
|
+
self.auto_expand_admin_tree = true
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Refinery
|
2
|
+
module Pages
|
3
|
+
# A type of ContentPresenter which specifically knows how to render the html for a Refinery CMS
|
4
|
+
# page object. Pass the page object into the constructor, and it will build sections from the
|
5
|
+
# page's parts. The page is not retained internally, so if the page changes, you need to rebuild
|
6
|
+
# this ContentPagePresenter.
|
7
|
+
class ContentPagePresenter < ContentPresenter
|
8
|
+
def initialize(page, page_title)
|
9
|
+
super()
|
10
|
+
add_default_title_section(page_title) if page_title.present?
|
11
|
+
add_page_parts(page.parts) if page
|
12
|
+
add_default_post_page_sections
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def add_default_title_section(title)
|
18
|
+
add_section TitleSectionPresenter.new(:id => :body_content_title, :fallback_html => title)
|
19
|
+
end
|
20
|
+
|
21
|
+
def add_default_post_page_sections
|
22
|
+
add_section_if_missing(:id => :body_content_left)
|
23
|
+
add_section_if_missing(:id => :body_content_right)
|
24
|
+
end
|
25
|
+
|
26
|
+
def add_page_parts(parts)
|
27
|
+
parts.each do |part|
|
28
|
+
add_section PagePartSectionPresenter.new(part)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Refinery
|
2
|
+
module Pages
|
3
|
+
# Knows how to render a set of sections as html. This can be used in any refinery view that is built from
|
4
|
+
# a group of sections. Pass the sections into the constructor or call add_section on the instance,
|
5
|
+
# then render by calling to_html.
|
6
|
+
class ContentPresenter
|
7
|
+
include ActionView::Helpers::TagHelper
|
8
|
+
|
9
|
+
def initialize(initial_sections = [])
|
10
|
+
@sections = initial_sections
|
11
|
+
end
|
12
|
+
|
13
|
+
def blank_section_css_classes(can_use_fallback = true)
|
14
|
+
@sections.reject {|section| section.has_content?(can_use_fallback)}.map(&:not_present_css_class)
|
15
|
+
end
|
16
|
+
|
17
|
+
def hide_sections(ids_to_hide)
|
18
|
+
@sections.select {|section| ids_to_hide.include?(section.id)}.each(&:hide) unless ids_to_hide.empty?
|
19
|
+
end
|
20
|
+
|
21
|
+
def fetch_template_overrides
|
22
|
+
@sections.each do |section|
|
23
|
+
if section.id.present?
|
24
|
+
section.override_html = yield section.id
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def add_section(new_section)
|
30
|
+
@sections << new_section
|
31
|
+
end
|
32
|
+
|
33
|
+
def get_section(index)
|
34
|
+
@sections[index]
|
35
|
+
end
|
36
|
+
|
37
|
+
def to_html(can_use_fallback = true)
|
38
|
+
content_tag :section, sections_html(can_use_fallback), :id => 'body_content', :class => blank_section_css_classes(can_use_fallback).join(' ')
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def sections_html(can_use_fallback)
|
44
|
+
@sections.map {|section| section.wrapped_html(can_use_fallback)}.compact.join("\n").html_safe
|
45
|
+
end
|
46
|
+
|
47
|
+
def add_section_if_missing(options)
|
48
|
+
add_section SectionPresenter.new(options) unless has_section?(options[:id])
|
49
|
+
end
|
50
|
+
|
51
|
+
def has_section?(id)
|
52
|
+
@sections.detect {|section| section.id == id}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module Refinery
|
2
|
+
module Pages
|
3
|
+
class Engine < ::Rails::Engine
|
4
|
+
include Refinery::Engine
|
5
|
+
|
6
|
+
isolate_namespace Refinery
|
7
|
+
engine_name :refinery_pages
|
8
|
+
|
9
|
+
config.autoload_paths += %W( #{config.root}/lib )
|
10
|
+
|
11
|
+
config.to_prepare do |app|
|
12
|
+
Refinery::Page.translation_class.send(:is_seo_meta)
|
13
|
+
Refinery::Page.translation_class.send(:attr_accessible, :browser_title, :meta_description, :meta_keywords, :locale)
|
14
|
+
end
|
15
|
+
|
16
|
+
before_inclusion do
|
17
|
+
::ApplicationController.send :helper, Refinery::Pages::ContentPagesHelper
|
18
|
+
Refinery::AdminController.send :helper, Refinery::Pages::ContentPagesHelper
|
19
|
+
end
|
20
|
+
|
21
|
+
after_inclusion do
|
22
|
+
::ApplicationController.send :include, Refinery::Pages::InstanceMethods
|
23
|
+
Refinery::AdminController.send :include, Refinery::Pages::Admin::InstanceMethods
|
24
|
+
end
|
25
|
+
|
26
|
+
initializer "register refinery_pages plugin" do
|
27
|
+
Refinery::Plugin.register do |plugin|
|
28
|
+
plugin.pathname = root
|
29
|
+
plugin.name = 'refinery_pages'
|
30
|
+
plugin.version = %q{2.0.0}
|
31
|
+
plugin.menu_match = %r{refinery/page(_part|s_dialog)?s$}
|
32
|
+
plugin.activity = {
|
33
|
+
:class_name => :'refinery/page'
|
34
|
+
}
|
35
|
+
plugin.url = { :controller => '/refinery/admin/pages' }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
initializer "append marketable routes" do
|
40
|
+
if Refinery::Pages.marketable_urls
|
41
|
+
append_marketable_routes
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
initializer "add marketable route parts to reserved words", :after => :set_routes_reloader_hook do |app|
|
46
|
+
if Refinery::Pages.marketable_urls
|
47
|
+
add_route_parts_as_reserved_words(app)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
config.after_initialize do
|
52
|
+
Refinery.register_extension(Refinery::Pages)
|
53
|
+
end
|
54
|
+
|
55
|
+
protected
|
56
|
+
|
57
|
+
def append_marketable_routes
|
58
|
+
Refinery::Core::Engine.routes.append do
|
59
|
+
get '*path', :to => 'pages#show'
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# Add any parts of routes as reserved words.
|
64
|
+
def add_route_parts_as_reserved_words(app)
|
65
|
+
route_paths = app.routes.named_routes.routes.map { |name, route| route.path.spec }
|
66
|
+
route_paths.reject! {|path| path.to_s =~ %r{^/(rails|refinery)}}
|
67
|
+
Refinery::Page.friendly_id_config.reserved_words |= route_paths.map { |path|
|
68
|
+
path.to_s.gsub(%r{^/}, '').to_s.split('(').first.to_s.split(':').first.to_s.split('/')
|
69
|
+
}.flatten.reject { |w| w =~ %r{_|\.} }.uniq
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|