pages_core 3.4.3 → 3.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +81 -15
- data/Rakefile +1 -1
- data/app/assets/javascripts/pages/admin.es6.jsx +19 -0
- data/app/assets/javascripts/pages/admin/components.es6.jsx +1 -0
- data/app/assets/javascripts/pages/admin/components/page_tree.es6.jsx +330 -0
- data/app/assets/javascripts/pages/admin/components/page_tree_actions.es6.jsx +8 -0
- data/app/assets/javascripts/pages/admin/components/page_tree_node.es6.jsx +374 -0
- data/app/assets/javascripts/pages/admin/components/page_tree_store.es6.jsx +161 -0
- data/app/assets/javascripts/pages/admin/features/content_tabs.es6.jsx +63 -0
- data/app/assets/javascripts/pages/admin/features/edit_page.es6.jsx +141 -0
- data/app/assets/javascripts/pages/admin/features/editable_image.es6.jsx +145 -0
- data/app/assets/javascripts/pages/admin/features/modal.es6.jsx +90 -0
- data/app/assets/javascripts/pages/admin/features/page_images.es6.jsx +338 -0
- data/app/assets/javascripts/pages/admin/features/rich_text.es6.jsx +124 -0
- data/app/assets/javascripts/pages/admin/features/tag_editor.es6.jsx +160 -0
- data/app/assets/javascripts/pages/admin/lib/ajax_extensions.es6.jsx +21 -0
- data/app/assets/javascripts/pages/admin/lib/center_on_screen.es6.jsx +22 -0
- data/app/assets/javascripts/pages/admin/lib/tree.es6.jsx +294 -0
- data/app/assets/javascripts/pages/login_form.es6.jsx +21 -0
- data/app/assets/stylesheets/pages/admin.scss +148 -0
- data/app/assets/stylesheets/pages/admin/components/buttons.scss +5 -0
- data/app/assets/stylesheets/pages/admin/{editable_image.css.erb → components/editable_image.scss} +7 -8
- data/app/assets/stylesheets/pages/admin/components/forms.scss +71 -0
- data/app/assets/stylesheets/pages/admin/components/header.scss +169 -0
- data/app/assets/stylesheets/pages/admin/{images.css.scss.erb → components/images.scss} +6 -11
- data/app/assets/stylesheets/pages/admin/components/layout.scss +44 -0
- data/app/assets/stylesheets/pages/admin/components/links.scss +43 -0
- data/app/assets/stylesheets/pages/admin/components/list_table.scss +58 -0
- data/app/assets/stylesheets/pages/admin/{login.css.scss.erb → components/login.scss} +1 -1
- data/app/assets/stylesheets/pages/admin/{modal.css.erb → components/modal.scss} +3 -2
- data/app/assets/stylesheets/pages/admin/components/page_tree.scss +173 -0
- data/app/assets/stylesheets/pages/admin/{pagination.css.scss → components/pagination.scss} +13 -4
- data/app/assets/stylesheets/pages/admin/components/sidebar.scss +25 -0
- data/app/assets/stylesheets/pages/admin/{tag_editor.css.scss.erb → components/tag_editor.scss} +6 -0
- data/app/assets/stylesheets/pages/admin/components/textarea.scss +76 -0
- data/app/assets/stylesheets/pages/admin/controllers/pages.scss +196 -0
- data/app/assets/stylesheets/pages/admin/controllers/{users.css.erb → users.scss} +0 -0
- data/app/assets/stylesheets/pages/admin/mixins/breakpoints.scss +21 -0
- data/app/assets/stylesheets/pages/admin/mixins/clearfix.scss +7 -0
- data/app/assets/stylesheets/pages/admin/mixins/gradients.scss +7 -0
- data/app/assets/stylesheets/pages/admin/{print.css.erb → print.scss} +0 -0
- data/app/assets/stylesheets/pages/admin/vars.scss +8 -0
- data/app/controllers/admin/invites_controller.rb +10 -6
- data/app/controllers/admin/page_files_controller.rb +6 -8
- data/app/controllers/admin/page_images_controller.rb +14 -19
- data/app/controllers/admin/pages_controller.rb +44 -97
- data/app/controllers/admin/password_resets_controller.rb +7 -2
- data/app/controllers/concerns/pages_core/add_comments_controller.rb +67 -0
- data/app/controllers/concerns/pages_core/admin/news_page_controller.rb +58 -0
- data/app/controllers/concerns/pages_core/authentication.rb +1 -1
- data/app/controllers/concerns/pages_core/exception_handler.rb +44 -21
- data/app/controllers/concerns/pages_core/policies_helper.rb +10 -6
- data/app/controllers/concerns/pages_core/preview_pages_controller.rb +43 -0
- data/app/controllers/concerns/pages_core/process_titler.rb +2 -2
- data/app/controllers/concerns/pages_core/rss_controller.rb +25 -0
- data/app/controllers/concerns/pages_core/search_pages_controller.rb +40 -0
- data/app/controllers/errors_controller.rb +14 -2
- data/app/controllers/pages_core/admin_controller.rb +7 -5
- data/app/controllers/pages_core/frontend/page_files_controller.rb +5 -7
- data/app/controllers/pages_core/frontend/pages_controller.rb +41 -219
- data/app/controllers/pages_core/frontend_controller.rb +8 -2
- data/app/controllers/pages_core/sitemaps_controller.rb +5 -4
- data/app/formatters/pages_core/html_formatter.rb +33 -23
- data/app/helpers/admin/menu_helper.rb +12 -9
- data/app/helpers/admin/pages_helper.rb +40 -28
- data/app/helpers/pages_core/admin/admin_helper.rb +58 -56
- data/app/helpers/pages_core/admin/labelled_field_helper.rb +6 -7
- data/app/helpers/pages_core/admin/tag_editor_helper.rb +11 -9
- data/app/helpers/pages_core/application_helper.rb +13 -26
- data/app/helpers/pages_core/form_builder.rb +71 -134
- data/app/helpers/pages_core/head_tags_helper.rb +26 -168
- data/app/helpers/pages_core/images_helper.rb +3 -3
- data/app/helpers/pages_core/meta_tags_helper.rb +96 -0
- data/app/helpers/pages_core/open_graph_tags_helper.rb +51 -0
- data/app/helpers/pages_core/page_path_helper.rb +40 -0
- data/app/mailers/admin_mailer.rb +14 -14
- data/app/models/autopublisher.rb +2 -2
- data/app/models/category.rb +8 -8
- data/app/models/concerns/pages_core/has_roles.rb +2 -2
- data/app/models/concerns/pages_core/humanizable_param.rb +5 -5
- data/app/models/concerns/pages_core/page_model/autopublishable.rb +25 -0
- data/app/models/concerns/pages_core/page_model/commentable.rb +29 -0
- data/app/models/concerns/pages_core/page_model/images.rb +50 -0
- data/app/models/concerns/pages_core/page_model/localizable.rb +29 -0
- data/app/models/concerns/pages_core/page_model/pathable.rb +115 -0
- data/app/models/concerns/pages_core/page_model/redirectable.rb +36 -0
- data/app/models/concerns/pages_core/page_model/searchable.rb +41 -0
- data/app/models/concerns/pages_core/page_model/sortable.rb +54 -0
- data/app/models/concerns/pages_core/page_model/status.rb +50 -0
- data/app/models/concerns/pages_core/page_model/templateable.rb +82 -0
- data/app/models/concerns/pages_core/page_model/tree.rb +108 -0
- data/app/models/page.rb +30 -212
- data/app/models/page_builder.rb +4 -6
- data/app/models/page_category.rb +7 -0
- data/app/models/page_comment.rb +1 -1
- data/app/models/page_file.rb +4 -6
- data/app/models/page_image.rb +6 -7
- data/app/models/page_path.rb +46 -0
- data/app/models/password_reset_token.rb +5 -5
- data/app/models/role.rb +1 -1
- data/app/models/tag.rb +14 -16
- data/app/models/tagging.rb +2 -1
- data/app/models/user.rb +6 -7
- data/app/policies/page_policy.rb +8 -4
- data/app/policies/user_policy.rb +1 -1
- data/app/serializers/page_tree_serializer.rb +15 -0
- data/app/views/admin/invites/new.html.erb +2 -1
- data/app/views/admin/invites/show.html.erb +3 -4
- data/app/views/admin/pages/_edit_comments.html.erb +22 -6
- data/app/views/admin/pages/_edit_content.html.erb +4 -2
- data/app/views/admin/pages/_edit_images.html.erb +86 -75
- data/app/views/admin/pages/_edit_metadata.html.erb +22 -0
- data/app/views/admin/pages/_edit_options.html.erb +23 -15
- data/app/views/admin/pages/_pagelisting.html.erb +6 -6
- data/app/views/admin/pages/edit.html.erb +11 -6
- data/app/views/admin/pages/index.html.erb +12 -53
- data/app/views/admin/pages/new.html.erb +3 -3
- data/app/views/admin/pages/news.html.erb +1 -1
- data/app/views/admin_mailer/invite.text.erb +1 -1
- data/app/views/admin_mailer/password_reset.text.erb +1 -1
- data/app/views/errors/422.html.erb +7 -0
- data/app/views/errors/500_critical.html.erb +1 -1
- data/app/views/layouts/admin.html.erb +36 -32
- data/app/views/layouts/admin/_header.html.erb +2 -2
- data/config/locales/en.yml +38 -1
- data/config/routes.rb +40 -23
- data/db/migrate/20111219033112_create_pages_tables.rb +25 -29
- data/db/migrate/20121010055412_drop_removed_tables.rb +3 -3
- data/db/migrate/20130823133208_update_page_redirect_to.rb +0 -13
- data/db/migrate/20140203183900_create_roles.rb +5 -2
- data/db/migrate/20140920231700_convert_images_to_dis.rb +4 -2
- data/db/migrate/20150401131300_localize_images.rb +7 -8
- data/db/migrate/20151002174800_create_page_paths.rb +10 -0
- data/db/migrate/20151021103400_drop_binaries_table.rb +7 -0
- data/db/migrate/20151204151000_remove_page_content_order.rb +5 -0
- data/db/migrate/20160330220900_rename_pages_categories.rb +6 -0
- data/db/migrate/20160405202700_change_localization_limit.rb +9 -0
- data/lib/pages_core.rb +22 -27
- data/lib/pages_core/admin_menu_item.rb +16 -3
- data/lib/pages_core/archive_finder.rb +40 -13
- data/lib/pages_core/cache_sweeper.rb +72 -45
- data/lib/pages_core/configuration.rb +2 -2
- data/lib/pages_core/configuration/base.rb +4 -8
- data/lib/pages_core/configuration/pages.rb +6 -3
- data/lib/pages_core/engine.rb +23 -1
- data/lib/pages_core/extensions.rb +2 -2
- data/lib/pages_core/file_embedder.rb +40 -0
- data/lib/pages_core/page_path_constraint.rb +23 -0
- data/lib/pages_core/pages_plugin.rb +11 -0
- data/lib/pages_core/paginates.rb +3 -3
- data/lib/pages_core/plugin.rb +14 -8
- data/lib/pages_core/templates.rb +6 -6
- data/lib/pages_core/templates/block_configuration.rb +1 -1
- data/lib/pages_core/templates/configuration.rb +23 -24
- data/lib/pages_core/templates/configuration_handler.rb +1 -1
- data/lib/pages_core/templates/configuration_proxy.rb +7 -11
- data/lib/pages_core/templates/template_configuration.rb +55 -61
- data/lib/pages_core/version.rb +1 -1
- data/lib/rails/generators/pages_core/install/install_generator.rb +22 -48
- data/lib/rails/generators/pages_core/install/templates/page_templates_initializer.rb +1 -1
- data/lib/rails/generators/pages_core/install/templates/pages_initializer.rb +6 -3
- data/lib/rails/generators/pages_core/rspec/rspec_generator.rb +4 -1
- data/lib/rails/generators/pages_core/rspec/templates/factories.rb +1 -1
- data/lib/tasks/pages.rake +4 -4
- data/lib/tasks/pages/page_paths.rake +12 -0
- data/template.rb +2 -2
- data/vendor/assets/javascripts/reflux.min.js +1 -0
- metadata +173 -85
- data/app/assets/images/pages/admin/description-bg.gif +0 -0
- data/app/assets/images/pages/admin/drag-handle.gif +0 -0
- data/app/assets/images/pages/admin/flash-error-bg.gif +0 -0
- data/app/assets/images/pages/admin/formelement-bg.gif +0 -0
- data/app/assets/images/pages/admin/header-tab-current-bg.gif +0 -0
- data/app/assets/images/pages/admin/list-table-td-bg.gif +0 -0
- data/app/assets/images/pages/admin/sidebar-bg.gif +0 -0
- data/app/assets/images/pages/admin/textarea_controls.gif +0 -0
- data/app/assets/javascripts/pages/admin.js.coffee +0 -54
- data/app/assets/javascripts/pages/admin/controllers/base.js.coffee +0 -4
- data/app/assets/javascripts/pages/admin/controllers/pages_controller.js.coffee +0 -139
- data/app/assets/javascripts/pages/admin/controllers/users_controller.js.coffee +0 -9
- data/app/assets/javascripts/pages/admin/features/content_tabs.js.coffee +0 -47
- data/app/assets/javascripts/pages/admin/features/editable_image.js.coffee.erb +0 -122
- data/app/assets/javascripts/pages/admin/features/modal.js.coffee +0 -66
- data/app/assets/javascripts/pages/admin/features/page_images.js +0 -329
- data/app/assets/javascripts/pages/admin/features/rich_text.js.coffee +0 -40
- data/app/assets/javascripts/pages/admin/features/tag_editor.js +0 -159
- data/app/assets/javascripts/pages/admin/lib/ajax_extensions.js.coffee +0 -17
- data/app/assets/javascripts/pages/admin/lib/center_on_screen.js.coffee +0 -21
- data/app/assets/javascripts/pages/admin/lib/jrichtextarea.js +0 -57
- data/app/assets/javascripts/pages/login_form.js.coffee +0 -17
- data/app/assets/stylesheets/pages/admin.css.erb +0 -404
- data/app/assets/stylesheets/pages/admin/buttons.css.erb +0 -5
- data/app/assets/stylesheets/pages/admin/controllers/artists.css.erb +0 -94
- data/app/assets/stylesheets/pages/admin/controllers/files.css.erb +0 -58
- data/app/assets/stylesheets/pages/admin/controllers/pages.css.scss.erb +0 -178
- data/app/assets/stylesheets/pages/admin/forms.css.scss.erb +0 -73
- data/app/assets/stylesheets/pages/admin/header.css.erb +0 -129
- data/app/assets/stylesheets/pages/admin/links.css.erb +0 -34
- data/app/assets/stylesheets/pages/admin/list_table.css.erb +0 -56
- data/app/assets/stylesheets/pages/admin/sidebar.css.erb +0 -39
- data/app/assets/stylesheets/pages/admin/sortable_images.css.erb +0 -18
- data/app/assets/stylesheets/pages/admin/textarea.css.erb +0 -55
- data/app/models/concerns/pages_core/page_tree.rb +0 -85
- data/app/models/concerns/pages_core/searchable_page.rb +0 -33
- data/app/models/concerns/pages_core/templateable.rb +0 -85
- data/app/models/localization.rb +0 -27
- data/db/migrate/20140515130100_remove_sphinx_deltas.rb +0 -15
- data/lib/pages_core/localizable.rb +0 -49
- data/lib/pages_core/localizable/active_record_extension.rb +0 -41
- data/lib/pages_core/localizable/class_methods.rb +0 -51
- data/lib/pages_core/localizable/configuration.rb +0 -50
- data/lib/pages_core/localizable/instance_methods.rb +0 -130
- data/lib/pages_core/localizable/localizer.rb +0 -72
- data/lib/pages_core/localizable/scope_extension.rb +0 -22
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
module PagesCore
|
|
4
|
+
class PagePathConstraint
|
|
5
|
+
def matches?(request)
|
|
6
|
+
locale?(request.path_parameters[:locale]) &&
|
|
7
|
+
exists?(
|
|
8
|
+
request.path_parameters[:locale],
|
|
9
|
+
request.path_parameters[:path]
|
|
10
|
+
)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def locale?(str)
|
|
16
|
+
str.to_s =~ /\A[a-z]{2}\z/
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def exists?(locale, path)
|
|
20
|
+
PagePath.get(locale, path) ? true : false
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
module PagesCore
|
|
4
4
|
class PagesPlugin < Plugin
|
|
5
|
+
class << self
|
|
6
|
+
def configure_localizations!
|
|
7
|
+
unless @localizations_added
|
|
8
|
+
I18n.load_path += Dir[
|
|
9
|
+
new.root.join("config", "locales", "**", "*.{rb,yml}")
|
|
10
|
+
]
|
|
11
|
+
end
|
|
12
|
+
@localizations_added = true
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
5
16
|
paths["db/migrate"] = "db/migrate"
|
|
6
17
|
|
|
7
18
|
admin_menu_item "News", proc { news_admin_pages_path(@locale) }, :pages,
|
data/lib/pages_core/paginates.rb
CHANGED
|
@@ -51,7 +51,7 @@ module PagesCore
|
|
|
51
51
|
|
|
52
52
|
# Returns true if collection is paginated
|
|
53
53
|
def paginated?
|
|
54
|
-
|
|
54
|
+
@paginated ? true : false
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
# Returns next page, or nil if at last page.
|
|
@@ -61,7 +61,7 @@ module PagesCore
|
|
|
61
61
|
|
|
62
62
|
# Returns true/false depending on if there's a next page
|
|
63
63
|
def next_page?
|
|
64
|
-
|
|
64
|
+
next_page ? true : false
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
# Returns previous page, or nil if at first page.
|
|
@@ -71,7 +71,7 @@ module PagesCore
|
|
|
71
71
|
|
|
72
72
|
# Returns true/false depending on if there's a previous page
|
|
73
73
|
def previous_page?
|
|
74
|
-
|
|
74
|
+
previous_page ? true : false
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
# Number of pages
|
data/lib/pages_core/plugin.rb
CHANGED
|
@@ -12,10 +12,7 @@ module PagesCore
|
|
|
12
12
|
attr_accessor :called_from, :paths
|
|
13
13
|
|
|
14
14
|
def inherited(plugin)
|
|
15
|
-
plugin.paths ||=
|
|
16
|
-
"db/migrate" => "db/migrate",
|
|
17
|
-
"config/removed_migrations.yml" => "config/removed_migrations.yml"
|
|
18
|
-
}
|
|
15
|
+
plugin.paths ||= default_paths
|
|
19
16
|
plugin.called_from = begin
|
|
20
17
|
# Remove the line number from backtraces making sure we
|
|
21
18
|
# don't leave anything behind
|
|
@@ -64,6 +61,15 @@ module PagesCore
|
|
|
64
61
|
File.unlink Rails.root.join("db", "migrate", migration)
|
|
65
62
|
end
|
|
66
63
|
end
|
|
64
|
+
|
|
65
|
+
private
|
|
66
|
+
|
|
67
|
+
def default_paths
|
|
68
|
+
{
|
|
69
|
+
"db/migrate" => "db/migrate",
|
|
70
|
+
"config/removed_migrations.yml" => "config/removed_migrations.yml"
|
|
71
|
+
}
|
|
72
|
+
end
|
|
67
73
|
end
|
|
68
74
|
|
|
69
75
|
def root
|
|
@@ -88,8 +94,8 @@ module PagesCore
|
|
|
88
94
|
|
|
89
95
|
def migrations
|
|
90
96
|
Dir.entries(migrations_path)
|
|
91
|
-
|
|
92
|
-
|
|
97
|
+
.select { |f| f =~ /\.rb$/ }
|
|
98
|
+
.map { |f| migrations_path.join(f) }
|
|
93
99
|
end
|
|
94
100
|
|
|
95
101
|
def removed_migrations
|
|
@@ -103,13 +109,13 @@ module PagesCore
|
|
|
103
109
|
root_path = self.class.called_from
|
|
104
110
|
|
|
105
111
|
while root_path && File.directory?(root_path) &&
|
|
106
|
-
|
|
112
|
+
!File.exist?("#{root_path}/#{subfolder}")
|
|
107
113
|
parent = File.dirname(root_path)
|
|
108
114
|
root_path = parent != root_path && parent
|
|
109
115
|
end
|
|
110
116
|
|
|
111
117
|
unless File.exist?("#{root_path}/#{subfolder}")
|
|
112
|
-
|
|
118
|
+
raise "Could not find root path for #{self}"
|
|
113
119
|
end
|
|
114
120
|
|
|
115
121
|
Pathname.new(root_path).realpath
|
data/lib/pages_core/templates.rb
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# encoding: utf-8
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
require "pages_core/templates/block_configuration"
|
|
4
|
+
require "pages_core/templates/configuration_proxy"
|
|
5
|
+
require "pages_core/templates/configuration_handler"
|
|
6
|
+
require "pages_core/templates/configuration"
|
|
7
|
+
require "pages_core/templates/controller_actions"
|
|
8
|
+
require "pages_core/templates/template_configuration"
|
|
9
9
|
|
|
10
10
|
module PagesCore
|
|
11
11
|
module Templates
|
|
@@ -34,23 +34,13 @@ module PagesCore
|
|
|
34
34
|
def configure_template(template_name, setting, value, options = {})
|
|
35
35
|
template_name = template_name.to_sym
|
|
36
36
|
setting = setting.to_sym
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
value = false if value == :disabled
|
|
40
|
-
template_config = {
|
|
41
|
-
setting => {
|
|
42
|
-
value: value,
|
|
43
|
-
options: options
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
if template_name == :_defaults
|
|
47
|
-
set([:default], template_config)
|
|
48
|
-
else
|
|
49
|
-
set([:templates, template_name], template_config)
|
|
50
|
-
end
|
|
51
|
-
else
|
|
52
|
-
fail "Invalid template configuration value: #{setting.inspect}"
|
|
37
|
+
unless valid_template_options.include?(setting)
|
|
38
|
+
raise "Invalid template configuration value: #{setting.inspect}"
|
|
53
39
|
end
|
|
40
|
+
set(
|
|
41
|
+
template_path(template_name),
|
|
42
|
+
template_config(setting, value, options)
|
|
43
|
+
)
|
|
54
44
|
end
|
|
55
45
|
|
|
56
46
|
def blocks(template_name = :_defaults, &block)
|
|
@@ -60,22 +50,31 @@ module PagesCore
|
|
|
60
50
|
end
|
|
61
51
|
|
|
62
52
|
def templates(*tpl_args, &block)
|
|
63
|
-
|
|
53
|
+
names = tpl_args.flatten.map(&:to_sym)
|
|
64
54
|
proxy(block) do |name, *args|
|
|
65
55
|
if name == :blocks
|
|
66
56
|
proxy(args.first.is_a?(Proc) ? args.first : nil) do |n2, *a2|
|
|
67
|
-
|
|
68
|
-
configure_block(template_name, n2, *a2)
|
|
69
|
-
end
|
|
57
|
+
names.each { |t| configure_block(t, n2, *a2) }
|
|
70
58
|
end
|
|
71
59
|
else
|
|
72
|
-
|
|
73
|
-
configure_template(template_name, name, *args)
|
|
74
|
-
end
|
|
60
|
+
names.each { |t| configure_template(t, name, *args) }
|
|
75
61
|
end
|
|
76
62
|
end
|
|
77
63
|
end
|
|
78
|
-
|
|
64
|
+
alias template templates
|
|
65
|
+
|
|
66
|
+
private
|
|
67
|
+
|
|
68
|
+
def template_config(setting, value, options)
|
|
69
|
+
value = true if value == :enabled
|
|
70
|
+
value = false if value == :disabled
|
|
71
|
+
{ setting => { value: value, options: options } }
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def template_path(name)
|
|
75
|
+
return [:default] if name == :_defaults
|
|
76
|
+
[:templates, name]
|
|
77
|
+
end
|
|
79
78
|
end
|
|
80
79
|
end
|
|
81
80
|
end
|
|
@@ -9,18 +9,14 @@ module PagesCore
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def method_missing(method_name, *args, &block)
|
|
12
|
-
if @parent
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
if @parent && block_given?
|
|
13
|
+
@callback.call(@parent, method_name, block)
|
|
14
|
+
elsif @parent
|
|
15
|
+
@callback.call(@parent, method_name, *args)
|
|
16
|
+
elsif block_given?
|
|
17
|
+
@callback.call(method_name, block)
|
|
18
18
|
else
|
|
19
|
-
|
|
20
|
-
@callback.call(method_name, block)
|
|
21
|
-
else
|
|
22
|
-
@callback.call(method_name, *args)
|
|
23
|
-
end
|
|
19
|
+
@callback.call(method_name, *args)
|
|
24
20
|
end
|
|
25
21
|
end
|
|
26
22
|
end
|
|
@@ -108,15 +108,7 @@ module PagesCore
|
|
|
108
108
|
|
|
109
109
|
# Default template options
|
|
110
110
|
config.default do |default|
|
|
111
|
-
default
|
|
112
|
-
default.image :enabled, linkable: false
|
|
113
|
-
default.comments :disabled
|
|
114
|
-
default.comments_allowed :enabled
|
|
115
|
-
default.files :disabled
|
|
116
|
-
default.images :disabled
|
|
117
|
-
default.text_filter :textile
|
|
118
|
-
default.enabled_blocks [:headline, :excerpt, :body]
|
|
119
|
-
default.tags :disabled
|
|
111
|
+
default_configuration(default)
|
|
120
112
|
default_block_configuration(default)
|
|
121
113
|
end
|
|
122
114
|
end
|
|
@@ -125,7 +117,7 @@ module PagesCore
|
|
|
125
117
|
load_default_configuration unless defined? @configuration
|
|
126
118
|
@configuration
|
|
127
119
|
end
|
|
128
|
-
|
|
120
|
+
alias config configuration
|
|
129
121
|
|
|
130
122
|
def metadata_block_names
|
|
131
123
|
[
|
|
@@ -138,61 +130,63 @@ module PagesCore
|
|
|
138
130
|
|
|
139
131
|
private
|
|
140
132
|
|
|
133
|
+
def default_configuration(config)
|
|
134
|
+
config.template :autodetect, root: "index"
|
|
135
|
+
config.image :enabled, linkable: false
|
|
136
|
+
config.comments :disabled
|
|
137
|
+
config.comments_allowed :enabled
|
|
138
|
+
config.files :disabled
|
|
139
|
+
config.images :disabled
|
|
140
|
+
config.text_filter :textile
|
|
141
|
+
config.enabled_blocks [:headline, :excerpt, :body]
|
|
142
|
+
config.tags :disabled
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def default_blocks
|
|
146
|
+
{
|
|
147
|
+
name: { size: :field, class: "page_title" },
|
|
148
|
+
body: { size: :large },
|
|
149
|
+
headline: { size: :field },
|
|
150
|
+
excerpt: {},
|
|
151
|
+
boxout: {}
|
|
152
|
+
}.merge(default_meta_blocks)
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def default_meta_blocks
|
|
156
|
+
{
|
|
157
|
+
meta_title: { size: :field },
|
|
158
|
+
meta_description: { size: :small },
|
|
159
|
+
open_graph_title: { size: :field },
|
|
160
|
+
open_graph_description: { size: :small }
|
|
161
|
+
}
|
|
162
|
+
end
|
|
163
|
+
|
|
141
164
|
def default_block_configuration(default)
|
|
142
165
|
default.blocks do |block|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
block.body(
|
|
151
|
-
"Body",
|
|
152
|
-
size: :large
|
|
153
|
-
)
|
|
154
|
-
block.headline(
|
|
155
|
-
"Headline",
|
|
156
|
-
description: "Optional, use if the headline should differ from " \
|
|
157
|
-
"the page name.",
|
|
158
|
-
size: :field
|
|
159
|
-
)
|
|
160
|
-
block.excerpt(
|
|
161
|
-
"Standfirst",
|
|
162
|
-
description: "An introductory paragraph before the start " \
|
|
163
|
-
"of the body."
|
|
164
|
-
)
|
|
165
|
-
block.boxout(
|
|
166
|
-
"Boxout",
|
|
167
|
-
description: "Part of the page, usually background info or " \
|
|
168
|
-
"facts related to the article."
|
|
169
|
-
)
|
|
170
|
-
block.meta_title(
|
|
171
|
-
"Title",
|
|
172
|
-
size: :field,
|
|
173
|
-
description: "Document title. Will fall back to the page name " \
|
|
174
|
-
"if empty. Recommended length: Up to 56 characters."
|
|
175
|
-
)
|
|
176
|
-
block.meta_description(
|
|
177
|
-
"Description",
|
|
178
|
-
size: :small,
|
|
179
|
-
description: "Description for search engines. Will fall back to " \
|
|
180
|
-
"Standfirst if empty. Recommended length: Up to 156 characters."
|
|
181
|
-
)
|
|
182
|
-
block.open_graph_title(
|
|
183
|
-
"Open Graph Title",
|
|
184
|
-
size: :field,
|
|
185
|
-
description: "Page title for Facebook sharing. Will fall back to " \
|
|
186
|
-
"the document title."
|
|
187
|
-
)
|
|
188
|
-
block.open_graph_description(
|
|
189
|
-
"Open Graph Description",
|
|
190
|
-
size: :small,
|
|
191
|
-
description: "Description for Facebook sharing. Will fall back " \
|
|
192
|
-
"to Description or Standfirst if empty."
|
|
193
|
-
)
|
|
166
|
+
default_blocks.keys.each do |name|
|
|
167
|
+
block.send(
|
|
168
|
+
name,
|
|
169
|
+
template_block_localization("#{name}.name"),
|
|
170
|
+
default_block_options(name)
|
|
171
|
+
)
|
|
172
|
+
end
|
|
194
173
|
end
|
|
195
174
|
end
|
|
175
|
+
|
|
176
|
+
def default_block_options(name)
|
|
177
|
+
{
|
|
178
|
+
description: template_block_localization("#{name}.description")
|
|
179
|
+
}.merge(default_blocks[name])
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def template_block_localization(str)
|
|
183
|
+
# Templates are configured in an initializer, and
|
|
184
|
+
# localizations aren't usually configured at this time. This
|
|
185
|
+
# forces loading of localizations from the plugin.
|
|
186
|
+
PagesCore::PagesPlugin.configure_localizations!
|
|
187
|
+
|
|
188
|
+
I18n.t("templates.default.blocks.#{str}")
|
|
189
|
+
end
|
|
196
190
|
end
|
|
197
191
|
end
|
|
198
192
|
end
|
data/lib/pages_core/version.rb
CHANGED
|
@@ -23,57 +23,39 @@ module PagesCore
|
|
|
23
23
|
@sphinx_port ||= ask_with_fallback("Sphinx port?", "3312")
|
|
24
24
|
end
|
|
25
25
|
|
|
26
|
-
def add_gem_source
|
|
27
|
-
add_source "http://gems.manualdesign.no/"
|
|
28
|
-
end
|
|
29
|
-
|
|
30
26
|
def create_active_job_initializer
|
|
31
|
-
template(
|
|
32
|
-
|
|
33
|
-
File.join("config/initializers/active_job.rb")
|
|
34
|
-
)
|
|
27
|
+
template("active_job_initializer.rb",
|
|
28
|
+
File.join("config/initializers/active_job.rb"))
|
|
35
29
|
end
|
|
36
30
|
|
|
37
31
|
def create_application_controller
|
|
38
|
-
template(
|
|
39
|
-
|
|
40
|
-
File.join("app/controllers/application_controller.rb")
|
|
41
|
-
)
|
|
32
|
+
template("application_controller.rb",
|
|
33
|
+
File.join("app/controllers/application_controller.rb"))
|
|
42
34
|
end
|
|
43
35
|
|
|
44
36
|
def create_application_helper
|
|
45
|
-
template(
|
|
46
|
-
|
|
47
|
-
File.join("app/helpers/application_helper.rb")
|
|
48
|
-
)
|
|
37
|
+
template("application_helper.rb",
|
|
38
|
+
File.join("app/helpers/application_helper.rb"))
|
|
49
39
|
end
|
|
50
40
|
|
|
51
41
|
def create_frontend_controller
|
|
52
|
-
template(
|
|
53
|
-
|
|
54
|
-
File.join("app/controllers/frontend_controller.rb")
|
|
55
|
-
)
|
|
42
|
+
template("frontend_controller.rb",
|
|
43
|
+
File.join("app/controllers/frontend_controller.rb"))
|
|
56
44
|
end
|
|
57
45
|
|
|
58
46
|
def create_frontend_helper
|
|
59
|
-
template(
|
|
60
|
-
|
|
61
|
-
File.join("app/helpers/frontend_helper.rb")
|
|
62
|
-
)
|
|
47
|
+
template("frontend_helper.rb",
|
|
48
|
+
File.join("app/helpers/frontend_helper.rb"))
|
|
63
49
|
end
|
|
64
50
|
|
|
65
51
|
def create_pages_controller
|
|
66
|
-
template(
|
|
67
|
-
|
|
68
|
-
File.join("app/controllers/pages_controller.rb")
|
|
69
|
-
)
|
|
52
|
+
template("pages_controller.rb",
|
|
53
|
+
File.join("app/controllers/pages_controller.rb"))
|
|
70
54
|
end
|
|
71
55
|
|
|
72
56
|
def create_default_template
|
|
73
|
-
copy_file(
|
|
74
|
-
|
|
75
|
-
File.join("app/views/pages/templates/index.html.erb")
|
|
76
|
-
)
|
|
57
|
+
copy_file("default_page_template.html.erb",
|
|
58
|
+
File.join("app/views/pages/templates/index.html.erb"))
|
|
77
59
|
end
|
|
78
60
|
|
|
79
61
|
def create_delayed_job_script
|
|
@@ -82,34 +64,26 @@ module PagesCore
|
|
|
82
64
|
end
|
|
83
65
|
|
|
84
66
|
def create_delayed_job_initializer
|
|
85
|
-
template(
|
|
86
|
-
|
|
87
|
-
File.join("config/initializers/delayed_job.rb")
|
|
88
|
-
)
|
|
67
|
+
template("delayed_job_initializer.rb",
|
|
68
|
+
File.join("config/initializers/delayed_job.rb"))
|
|
89
69
|
end
|
|
90
70
|
|
|
91
71
|
def create_initializer_file
|
|
92
72
|
read_configuration!
|
|
93
|
-
template(
|
|
94
|
-
|
|
95
|
-
File.join("config/initializers/pages.rb")
|
|
96
|
-
)
|
|
73
|
+
template("pages_initializer.rb",
|
|
74
|
+
File.join("config/initializers/pages.rb"))
|
|
97
75
|
end
|
|
98
76
|
|
|
99
77
|
def create_cache_sweeper_initializer
|
|
100
78
|
read_configuration!
|
|
101
|
-
template(
|
|
102
|
-
|
|
103
|
-
File.join("config/initializers/cache_sweeper.rb")
|
|
104
|
-
)
|
|
79
|
+
template("cache_sweeper_initializer.rb",
|
|
80
|
+
File.join("config/initializers/cache_sweeper.rb"))
|
|
105
81
|
end
|
|
106
82
|
|
|
107
83
|
def create_template_initializer
|
|
108
84
|
read_configuration!
|
|
109
|
-
template(
|
|
110
|
-
|
|
111
|
-
File.join("config/initializers/page_templates.rb")
|
|
112
|
-
)
|
|
85
|
+
template("page_templates_initializer.rb",
|
|
86
|
+
File.join("config/initializers/page_templates.rb"))
|
|
113
87
|
end
|
|
114
88
|
|
|
115
89
|
def create_sphinx_config
|