pageflow 15.1.0.beta2 → 15.1.0.beta3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of pageflow might be problematic. Click here for more details.

Files changed (162) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +141 -1
  3. data/README.md +3 -6
  4. data/admins/pageflow/entry.rb +1 -1
  5. data/app/assets/javascripts/pageflow/dist/editor.js +1241 -1281
  6. data/app/assets/javascripts/pageflow/dist/react-client.js +3 -3
  7. data/app/assets/javascripts/pageflow/dist/react-server.js +2 -2
  8. data/app/assets/javascripts/pageflow/dist/ui.js +241 -57
  9. data/app/assets/javascripts/pageflow/editor/base.js +0 -20
  10. data/app/assets/javascripts/pageflow/editor/vendor.js +16 -0
  11. data/app/assets/stylesheets/pageflow/admin/embedded_index_table.scss +5 -1
  12. data/app/controllers/concerns/pageflow/controller_delegation.rb +31 -0
  13. data/app/controllers/concerns/pageflow/entry_password_protection.rb +4 -4
  14. data/app/controllers/pageflow/editor/entries_controller.rb +35 -0
  15. data/app/controllers/pageflow/editor/file_import_controller.rb +1 -1
  16. data/app/controllers/pageflow/editor/files_controller.rb +1 -1
  17. data/app/controllers/pageflow/entries_controller.rb +29 -71
  18. data/app/controllers/pageflow/revisions_controller.rb +16 -5
  19. data/app/helpers/pageflow/common_entry_seed_helper.rb +9 -24
  20. data/app/helpers/pageflow/config_helper.rb +25 -3
  21. data/app/helpers/pageflow/editor/config_helper.rb +12 -0
  22. data/app/helpers/pageflow/editor/entries_helper.rb +10 -0
  23. data/app/helpers/pageflow/editor/files_helper.rb +24 -0
  24. data/app/helpers/pageflow/entries_helper.rb +5 -4
  25. data/app/helpers/pageflow/entry_json_seed_helper.rb +1 -0
  26. data/app/helpers/pageflow/files_helper.rb +14 -13
  27. data/app/helpers/pageflow/page_types_helper.rb +4 -1
  28. data/app/helpers/pageflow/render_json_helper.rb +30 -5
  29. data/app/models/concerns/pageflow/auto_generated_perma_id.rb +16 -0
  30. data/app/models/concerns/pageflow/feature_target.rb +3 -3
  31. data/app/models/pageflow/draft_entry.rb +3 -0
  32. data/app/models/pageflow/home_button.rb +3 -1
  33. data/app/models/pageflow/page.rb +1 -6
  34. data/app/models/pageflow/published_entry.rb +1 -0
  35. data/app/models/pageflow/revision.rb +3 -0
  36. data/app/models/pageflow/storyline.rb +0 -2
  37. data/app/views/admin/entries/_links.html.arb +1 -1
  38. data/app/views/admin/features/_form.html.erb +1 -1
  39. data/app/views/components/pageflow/admin/add_membership_button.rb +13 -1
  40. data/app/views/layouts/pageflow/application.html.erb +3 -19
  41. data/app/views/layouts/pageflow/editor.html.erb +18 -0
  42. data/app/views/pageflow/admin/accounts/_cannot_add_account.html.erb +0 -0
  43. data/app/views/pageflow/admin/entries/_cannot_add_user.html.erb +5 -0
  44. data/app/views/pageflow/admin/users/_cannot_add.html.erb +8 -0
  45. data/app/views/pageflow/admin/users/_cannot_add_account.html.erb +0 -0
  46. data/app/views/pageflow/admin/users/_cannot_add_entry.html +0 -0
  47. data/app/views/pageflow/{config/_editor_seeds.json.jbuilder → editor/config/_seeds.json.jbuilder} +3 -2
  48. data/app/views/pageflow/editor/entries/seed.json.erb +5 -4
  49. data/app/views/pageflow/{entries/edit.html.erb → editor/entries/show.html.erb} +5 -9
  50. data/app/views/pageflow/{entries → editor/entries}/show.json.jbuilder +0 -0
  51. data/app/views/pageflow/entries/{show.css.erb → stylesheet.css.erb} +0 -0
  52. data/app/views/pageflow/entry_json_seed/_entry.json.jbuilder +2 -8
  53. data/config/initializers/entry_types.rb +4 -0
  54. data/config/initializers/features.rb +0 -10
  55. data/config/initializers/help_entries.rb +0 -8
  56. data/config/locales/de.yml +4 -0
  57. data/config/locales/en.yml +4 -0
  58. data/config/routes.rb +10 -5
  59. data/db/migrate/20191202145757_create_pageflow_scrolled_sections.rb +21 -0
  60. data/db/migrate/20191202150657_create_pageflow_scrolled_chapters.rb +11 -0
  61. data/db/migrate/20191202154723_create_pageflow_scrolled_content_elements.rb +21 -0
  62. data/db/migrate/20191219143450_add_position_to_content_elements.rb +5 -0
  63. data/db/migrate/20191220100946_create_pageflow_scrolled_storylines.rb +24 -0
  64. data/entry_types/paged/app/assets/javascripts/pageflow_paged/dist/editor.js +9805 -114
  65. data/entry_types/paged/app/assets/javascripts/pageflow_paged/editor.js +7 -0
  66. data/entry_types/paged/app/assets/stylesheets/pageflow_paged/editor.scss +1 -0
  67. data/entry_types/paged/app/controllers/concerns/pageflow_paged/without_controller_namespace_partial_path_prefix.rb +21 -0
  68. data/entry_types/paged/app/controllers/pageflow_paged/application_controller.rb +25 -0
  69. data/entry_types/paged/app/controllers/pageflow_paged/editor/entries_controller.rb +17 -0
  70. data/entry_types/paged/app/controllers/pageflow_paged/entries_controller.rb +25 -0
  71. data/{app/views/layouts/pageflow → entry_types/paged/app/views/layouts/pageflow_paged}/_ie_include_tags.html.erb +0 -0
  72. data/{app/views/layouts/pageflow → entry_types/paged/app/views/layouts/pageflow_paged}/_loading_spinner_inline_script.html.erb +0 -0
  73. data/entry_types/paged/app/views/layouts/pageflow_paged/application.html.erb +33 -0
  74. data/entry_types/paged/app/views/pageflow_paged/chapters/_chapter.html.erb +7 -0
  75. data/entry_types/paged/app/views/pageflow_paged/editor/entries/_body.html.erb +4 -0
  76. data/entry_types/paged/app/views/pageflow_paged/editor/entries/_head.html.erb +12 -0
  77. data/entry_types/paged/app/views/pageflow_paged/editor/entries/_indicators_seed.html.erb +3 -0
  78. data/entry_types/paged/app/views/pageflow_paged/editor/entries/_seed.json.jbuilder +0 -0
  79. data/entry_types/paged/app/views/pageflow_paged/editor/entries/partials.html.erb +3 -0
  80. data/{app/views/pageflow → entry_types/paged/app/views/pageflow_paged}/entries/_entry.html.erb +7 -5
  81. data/{app/views/pageflow → entry_types/paged/app/views/pageflow_paged}/entries/_header.html.erb +0 -0
  82. data/{app/views/pageflow → entry_types/paged/app/views/pageflow_paged}/entries/_ie8_hint.html.erb +0 -0
  83. data/{app/views/pageflow → entry_types/paged/app/views/pageflow_paged}/entries/_indicators.html.erb +0 -0
  84. data/{app/views/pageflow → entry_types/paged/app/views/pageflow_paged}/entries/_multimedia_alert.html.erb +0 -0
  85. data/{app/views/pageflow → entry_types/paged/app/views/pageflow_paged}/entries/_non_js_hint.html.erb +0 -0
  86. data/entry_types/paged/app/views/pageflow_paged/entries/_overview.html.erb +1 -0
  87. data/{app/views/pageflow → entry_types/paged/app/views/pageflow_paged}/entries/_skip_links.html.erb +0 -0
  88. data/{app/views/pageflow → entry_types/paged/app/views/pageflow_paged}/entries/overview/_chapter.html.erb +3 -1
  89. data/{app/views/pageflow → entry_types/paged/app/views/pageflow_paged}/entries/overview/_entry.html.erb +1 -1
  90. data/{app/views/pageflow → entry_types/paged/app/views/pageflow_paged}/entries/overview/_page.html.erb +0 -0
  91. data/{app/views/pageflow → entry_types/paged/app/views/pageflow_paged}/entries/show.html.erb +3 -3
  92. data/{app/views/pageflow → entry_types/paged/app/views/pageflow_paged}/pages/_page.html.erb +1 -1
  93. data/entry_types/paged/config/initializers/features.rb +16 -0
  94. data/entry_types/paged/config/initializers/page_types.rb +16 -0
  95. data/entry_types/paged/config/routes.rb +3 -0
  96. data/entry_types/paged/lib/pageflow_paged.rb +19 -0
  97. data/entry_types/paged/lib/pageflow_paged/configuration.rb +16 -0
  98. data/entry_types/paged/lib/pageflow_paged/engine.rb +7 -0
  99. data/entry_types/paged/lib/pageflow_paged/plugin.rb +8 -0
  100. data/entry_types/scrolled/app/assets/stylesheets/pageflow_scrolled/editor.scss +1 -0
  101. data/entry_types/scrolled/app/controllers/pageflow_scrolled/editor/chapters_controller.rb +56 -0
  102. data/entry_types/scrolled/app/controllers/pageflow_scrolled/editor/content_elements_controller.rb +61 -0
  103. data/entry_types/scrolled/app/controllers/pageflow_scrolled/editor/entries_controller.rb +8 -0
  104. data/entry_types/scrolled/app/controllers/pageflow_scrolled/editor/sections_controller.rb +59 -0
  105. data/entry_types/scrolled/app/controllers/pageflow_scrolled/entries_controller.rb +10 -0
  106. data/entry_types/scrolled/app/helpers/pageflow_scrolled/editor/seed_html_helper.rb +21 -0
  107. data/entry_types/scrolled/app/helpers/pageflow_scrolled/entry_json_seed_helper.rb +33 -0
  108. data/entry_types/scrolled/app/models/pageflow_scrolled/chapter.rb +40 -0
  109. data/entry_types/scrolled/app/models/pageflow_scrolled/content_element.rb +17 -0
  110. data/entry_types/scrolled/app/models/pageflow_scrolled/section.rb +26 -0
  111. data/entry_types/scrolled/app/models/pageflow_scrolled/storyline.rb +39 -0
  112. data/entry_types/scrolled/app/views/pageflow_scrolled/chapters/_chapter.json.jbuilder +8 -0
  113. data/entry_types/scrolled/app/views/pageflow_scrolled/content_elements/_content_element.json.jbuilder +9 -0
  114. data/entry_types/scrolled/app/views/pageflow_scrolled/editor/entries/_body.html.erb +1 -0
  115. data/entry_types/scrolled/app/views/pageflow_scrolled/editor/entries/_head.html.erb +12 -0
  116. data/entry_types/scrolled/app/views/pageflow_scrolled/editor/entries/_seed.json.jbuilder +1 -0
  117. data/entry_types/scrolled/app/views/pageflow_scrolled/entries/show.html.erb +22 -0
  118. data/entry_types/scrolled/app/views/pageflow_scrolled/entry_json_seed/_entry.json.jbuilder +35 -0
  119. data/entry_types/scrolled/app/views/pageflow_scrolled/sections/_section.json.jbuilder +8 -0
  120. data/entry_types/scrolled/config/routes.rb +23 -0
  121. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/install_generator.rb +34 -0
  122. data/entry_types/scrolled/lib/pageflow_scrolled.rb +19 -0
  123. data/entry_types/scrolled/lib/pageflow_scrolled/configuration.rb +6 -0
  124. data/entry_types/scrolled/lib/pageflow_scrolled/plugin.rb +16 -0
  125. data/entry_types/scrolled/lib/pageflow_scrolled/seeds.rb +133 -0
  126. data/entry_types/scrolled/spec/factories/chapters.rb +12 -0
  127. data/entry_types/scrolled/spec/factories/content_elements.rb +36 -0
  128. data/entry_types/scrolled/spec/factories/sections.rb +26 -0
  129. data/entry_types/scrolled/spec/factories/storylines.rb +12 -0
  130. data/entry_types/scrolled/spec/fixtures/image.jpg +0 -0
  131. data/lib/generators/pageflow/active_admin_initializer/active_admin_initializer_generator.rb +1 -1
  132. data/lib/generators/pageflow/assets/assets_generator.rb +2 -2
  133. data/lib/pageflow/built_in_page_types_plugin.rb +5 -3
  134. data/lib/pageflow/built_in_widget_types_plugin.rb +38 -12
  135. data/lib/pageflow/configuration.rb +76 -15
  136. data/lib/pageflow/editor_controller.rb +44 -0
  137. data/lib/pageflow/engine.rb +2 -3
  138. data/lib/pageflow/entries_controller_env_helper.rb +44 -0
  139. data/lib/pageflow/entry_type.rb +19 -2
  140. data/lib/pageflow/entry_type_configuration.rb +44 -0
  141. data/lib/pageflow/entry_types.rb +22 -0
  142. data/lib/pageflow/feature.rb +11 -5
  143. data/lib/pageflow/file_importers.rb +2 -2
  144. data/lib/pageflow/file_type.rb +3 -2
  145. data/lib/pageflow/file_types.rb +23 -3
  146. data/lib/pageflow/global_config_api.rb +11 -4
  147. data/lib/pageflow/page_types.rb +30 -0
  148. data/lib/pageflow/partial_editor_fragment_renderer.rb +37 -0
  149. data/lib/pageflow/revision_component.rb +2 -5
  150. data/lib/pageflow/revision_components.rb +18 -0
  151. data/lib/pageflow/version.rb +1 -1
  152. data/lib/pageflow/widget_type.rb +3 -0
  153. data/lib/pageflow/widget_types.rb +1 -1
  154. data/spec/factories/draft_entries.rb +11 -0
  155. data/spec/factories/published_entries.rb +17 -0
  156. data/vendor/assets/javascripts/dash.all.min.js +0 -1
  157. metadata +146 -29
  158. data/app/views/pageflow/chapters/_chapter.html.erb +0 -5
  159. data/app/views/pageflow/editor/entries/_indicators_seed.html.erb +0 -3
  160. data/app/views/pageflow/entries/_overview.html.erb +0 -1
  161. data/app/views/pageflow/entries/partials.html.erb +0 -3
  162. data/config/initializers/page_type_helpers.rb +0 -8
@@ -1,20 +0,0 @@
1
- //= require wysihtml-toolbar
2
- //= require jquery.minicolors
3
-
4
- //= require i18n
5
- //= require i18n/translations
6
-
7
- //= require cocktail
8
- //= require backbone.marionette
9
-
10
- //= require jquery-ui
11
- //= require jquery/layout
12
-
13
- //= require jquery-fileupload/vendor/load-image
14
- //= require jquery-fileupload/vendor/canvas-to-blob
15
- //= require jquery-fileupload/jquery.fileupload
16
- //= require jquery-fileupload/jquery.fileupload-fp
17
-
18
- //= require pageflow/dist/editor
19
-
20
- _.extend(pageflow, pageflow._editorGlobalInterop);
@@ -0,0 +1,16 @@
1
+ //= require i18n
2
+ //= require i18n/translations
3
+
4
+ //= require wysihtml-toolbar
5
+ //= require jquery.minicolors
6
+
7
+ //= require cocktail
8
+ //= require backbone.marionette
9
+
10
+ //= require jquery-ui
11
+ //= require jquery/layout
12
+
13
+ //= require jquery-fileupload/vendor/load-image
14
+ //= require jquery-fileupload/vendor/canvas-to-blob
15
+ //= require jquery-fileupload/jquery.fileupload
16
+ //= require jquery-fileupload/jquery.fileupload-fp
@@ -1,6 +1,10 @@
1
+ //since activeadmin 2.5.0 depends on ruby 2.4
2
+ //this is a temporary fix to use activeadmin < 2.5 for supporting ruby 2.3
3
+ $orderable-icon-url: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAABGCAYAAAAAVo4aAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAH5JREFUeNpi3LhlOwMU1AExGxDXwARYoHQLEFdD2cxAXAliMKFJgEAFEHfBJEHGMKLhMpgkTsAEdch/NNwCk2xCdiEQtML4LEgCf6EubUX3Cgh0oNvJ+P//f7wOGpUclRwYSZb41CyidNbB8giNM+9oXhmVHHm5bJjUSAABBgDKKiwMMUxPwgAAAABJRU5ErkJggg==" !default;
4
+
1
5
  .embedded_index_table {
2
6
  .sortable a {
3
- background: url("/assets/active_admin/orderable.png") no-repeat 100% 2px;
7
+ background: url($orderable-icon-url) no-repeat 100% 2px;
4
8
  padding-right: 13px;
5
9
  }
6
10
 
@@ -0,0 +1,31 @@
1
+ module Pageflow
2
+ # Allow delegating to another Rack app from a controller action.
3
+ #
4
+ # @api private
5
+ module ControllerDelegation
6
+ # Abort currently executed controller action, call passed Rack app
7
+ # and use its response instead. A block can be passed to mutate
8
+ # the response.
9
+ def delegate_to_rack_app!(app)
10
+ result = app.call(request.env)
11
+ yield(*result) if block_given?
12
+
13
+ throw(:delegate, result)
14
+ end
15
+
16
+ # Override ActionController::Metal#dispatch [1] which returns the
17
+ # Rack response triple generated by the controller. Calling
18
+ # `delegate_to_rack_app!` aborts execution of the current
19
+ # controller action and returns the response of the given Rack app
20
+ # instead.
21
+ #
22
+ # The second argument passed to `throw` is becomes the return
23
+ # value of `catch`. If `throw` is not called, `catch` passes the
24
+ # return value of its block.
25
+ #
26
+ # [1] https://github.com/rails/rails/blob/8bec77cc0f1fd47677a331a64f68c5918efd2ca9/actionpack/lib/action_controller/metal.rb#L188
27
+ def dispatch(*)
28
+ catch(:delegate) { super }
29
+ end
30
+ end
31
+ end
@@ -3,11 +3,11 @@ module Pageflow
3
3
  private
4
4
 
5
5
  def check_entry_password_protection(entry)
6
- return unless entry.password_protected?
6
+ return true unless entry.password_protected?
7
+ return true if authenticate_with_http_basic { |_, password| entry.authenticate(password) }
7
8
 
8
- authenticate_or_request_with_http_basic('Pageflow') do |_, password|
9
- entry.authenticate(password)
10
- end
9
+ request_http_basic_authentication('Pageflow')
10
+ false
11
11
  end
12
12
  end
13
13
  end
@@ -1,6 +1,8 @@
1
1
  module Pageflow
2
2
  module Editor
3
3
  class EntriesController < Pageflow::ApplicationController
4
+ layout 'pageflow/editor'
5
+
4
6
  respond_to :json
5
7
 
6
8
  before_action :authenticate_user!
@@ -16,6 +18,39 @@ module Pageflow
16
18
 
17
19
  @entry_config = Pageflow.config_for(@entry)
18
20
  end
21
+
22
+ def show
23
+ @entry = DraftEntry.find(params[:id])
24
+ authorize!(:edit, @entry.to_model)
25
+
26
+ @entry_config = Pageflow.config_for(@entry)
27
+
28
+ respond_to do |format|
29
+ format.html
30
+ format.json
31
+ end
32
+ end
33
+
34
+ def update
35
+ @entry = DraftEntry.find(params[:id])
36
+
37
+ authorize!(:update, @entry.to_model)
38
+ @entry.update_meta_data!(entry_params)
39
+
40
+ head(:no_content)
41
+ end
42
+
43
+ private
44
+
45
+ def entry_params
46
+ params.require(:entry).permit(:title, :summary, :credits, :manual_start,
47
+ :home_url, :home_button_enabled,
48
+ :overview_button_enabled,
49
+ :emphasize_chapter_beginning, :emphasize_new_pages,
50
+ :share_url, :share_image_id, :share_image_x, :share_image_y,
51
+ :locale, :author, :publisher, :keywords, :theme_name,
52
+ share_providers: {})
53
+ end
19
54
  end
20
55
  end
21
56
  end
@@ -81,7 +81,7 @@ module Pageflow
81
81
 
82
82
  def file_importer
83
83
  importer_key = params[:file_import_name]
84
- Pageflow.config.file_importers.find_by_name!(importer_key)
84
+ Pageflow.config_for(DraftEntry.find(entry_name)).file_importers.find_by_name!(importer_key)
85
85
  end
86
86
 
87
87
  def file_importer_credentials
@@ -40,7 +40,7 @@ module Pageflow
40
40
 
41
41
  file_reuse.save!
42
42
 
43
- redirect_to(entry_url(entry))
43
+ redirect_to(editor_entry_url(entry))
44
44
  end
45
45
 
46
46
  def retry
@@ -1,19 +1,10 @@
1
1
  module Pageflow
2
+ # @api private
2
3
  class EntriesController < Pageflow::ApplicationController
4
+ include ControllerDelegation
3
5
  include PublicHttpsMode
4
6
  include EntryPasswordProtection
5
7
 
6
- before_action :authenticate_user!, except: [:index, :show, :page]
7
-
8
- after_action :allow_iframe_for_embed, only: :show
9
-
10
- helper_method :render_to_string
11
-
12
- helper PagesHelper
13
- helper NavigationBarHelper
14
- helper BackgroundImageHelper
15
- helper RenderJsonHelper
16
-
17
8
  def index
18
9
  theming = Theming.for_request(request).with_home_url.first!
19
10
 
@@ -22,30 +13,22 @@ module Pageflow
22
13
 
23
14
  def show
24
15
  respond_to do |format|
25
- format.any(:html, :css) do
26
- @entry = PublishedEntry.find(params[:id], entry_request_scope)
27
- I18n.locale = @entry.locale
28
-
29
- if redirect_location = entry_redirect(@entry)
30
- return redirect_to(redirect_location, status: :moved_permanently)
31
- end
16
+ format.html do
17
+ entry = PublishedEntry.find(params[:id], entry_request_scope)
32
18
 
19
+ return if redirect_according_to_entry_redirect(entry)
33
20
  return if redirect_according_to_public_https_mode
21
+ return unless check_entry_password_protection(entry)
34
22
 
35
- if !request.format.css?
36
- check_entry_password_protection(@entry)
37
- end
38
-
39
- if params[:page].present?
40
- @entry.share_target = @entry.pages.find_by_perma_id(params[:page])
41
- else
42
- @entry.share_target = @entry
43
- end
23
+ delegate_to_entry_type_frontend_app!(entry)
44
24
  end
45
- format.json do
46
- authenticate_user!
47
- @entry = DraftEntry.find(params[:id])
48
- authorize!(:show, @entry.to_model)
25
+ end
26
+ end
27
+
28
+ def stylesheet
29
+ respond_to do |format|
30
+ format.css do
31
+ @entry = PublishedEntry.find(params[:id], entry_request_scope)
49
32
  end
50
33
  end
51
34
  end
@@ -57,57 +40,32 @@ module Pageflow
57
40
  redirect_to(short_entry_path(entry.to_model, :anchor => entry.pages[index].try(:perma_id)))
58
41
  end
59
42
 
60
- def partials
61
- authenticate_user!
62
- @entry = DraftEntry.find(params[:id])
63
- I18n.locale = @entry.locale
64
- authorize!(:show, @entry.to_model)
65
-
66
- respond_to do |format|
67
- format.html { render :action => 'partials', :layout => false }
68
- end
69
- end
70
-
71
- def edit
72
- @entry = DraftEntry.find(params[:id])
73
- authorize!(:edit, @entry.to_model)
74
-
75
- @entry_config = Pageflow.config_for(@entry)
76
- end
77
-
78
- def update
79
- @entry = DraftEntry.find(params[:id])
80
-
81
- authorize!(:update, @entry.to_model)
82
- @entry.update_meta_data!(entry_params)
83
-
84
- head(:no_content)
85
- end
86
-
87
43
  protected
88
44
 
89
- def entry_params
90
- params.require(:entry).permit(:title, :summary, :credits, :manual_start,
91
- :home_url, :home_button_enabled,
92
- :overview_button_enabled,
93
- :emphasize_chapter_beginning, :emphasize_new_pages,
94
- :share_url, :share_image_id, :share_image_x, :share_image_y,
95
- :locale, :author, :publisher, :keywords, :theme_name,
96
- share_providers: {})
97
- end
98
-
99
45
  def entry_request_scope
100
46
  Pageflow.config.public_entry_request_scope.call(Entry, request)
101
47
  end
102
48
 
49
+ def redirect_according_to_entry_redirect(entry)
50
+ return unless (redirect_location = entry_redirect(entry))
51
+
52
+ redirect_to(redirect_location, status: :moved_permanently)
53
+ end
54
+
103
55
  def entry_redirect(entry)
104
56
  Pageflow.config.public_entry_redirect.call(entry, request)
105
57
  end
106
58
 
107
- def allow_iframe_for_embed
108
- if params[:embed]
109
- response.headers.except! 'X-Frame-Options'
59
+ def delegate_to_entry_type_frontend_app!(entry)
60
+ EntriesControllerEnvHelper.add_entry_info_to_env(request.env, entry: entry, mode: :published)
61
+
62
+ delegate_to_rack_app!(entry.entry_type.frontend_app) do |_status, headers, _body|
63
+ allow_iframe_for_embed(headers)
110
64
  end
111
65
  end
66
+
67
+ def allow_iframe_for_embed(headers)
68
+ headers.except!('X-Frame-Options') if params[:embed]
69
+ end
112
70
  end
113
71
  end
@@ -1,20 +1,26 @@
1
1
  module Pageflow
2
2
  class RevisionsController < Pageflow::ApplicationController
3
+ include ControllerDelegation
3
4
  include QuotaVerification
4
5
 
5
- before_action :authenticate_user!, :unless => lambda { |controller| controller.request.format.css? }
6
+ before_action :authenticate_user!, except: [:stylesheet]
6
7
 
7
8
  respond_to :json
8
9
 
9
10
  def show
10
11
  revision = Revision.find(params[:id])
11
- authorize!(:show, revision) unless request.format.css?
12
+ authorize!(:show, revision)
13
+
14
+ entry = PublishedEntry.new(revision.entry, revision)
15
+ delegate_to_entry_type_frontend_app!(entry)
16
+ end
17
+
18
+ def stylesheet
19
+ revision = Revision.find(params[:id])
12
20
 
13
21
  @entry = PublishedEntry.new(revision.entry, revision)
14
- I18n.locale = @entry.locale
15
22
 
16
- @widget_scope = :preview
17
- render :template => 'pageflow/entries/show'
23
+ render template: 'pageflow/entries/stylesheet'
18
24
  end
19
25
 
20
26
  def depublish_current
@@ -30,5 +36,10 @@ module Pageflow
30
36
  def revision_params
31
37
  params.fetch(:revision, {}).permit(:published_until)
32
38
  end
39
+
40
+ def delegate_to_entry_type_frontend_app!(entry)
41
+ EntriesControllerEnvHelper.add_entry_info_to_env(request.env, entry: entry, mode: :preview)
42
+ delegate_to_rack_app!(entry.entry_type.frontend_app)
43
+ end
33
44
  end
34
45
  end
@@ -4,33 +4,18 @@ module Pageflow
4
4
  #
5
5
  # @api private
6
6
  module CommonEntrySeedHelper
7
- def common_entry_seed(entry)
8
- config = Pageflow.config_for(entry)
7
+ include ConfigHelper
9
8
 
10
- {
11
- locale: entry.locale,
12
- theming: entry.theming.as_json(only: [:privacy_link_url]),
13
- enabled_feature_names: entry.enabled_feature_names,
14
- page_types: PageTypesSeed.new(config).as_json,
15
- file_url_templates: FileUrlTemplatesSeed.new(config).as_json,
16
- file_model_types: config.file_types
17
- .index_by(&:collection_name)
18
- .transform_values { |file_type| file_type.model.name }
19
- }
20
- end
9
+ def common_entry_seed(json, entry)
10
+ config = Pageflow.config_for(entry)
21
11
 
22
- class FileUrlTemplatesSeed
23
- attr_reader :config
12
+ json.locale entry.locale
13
+ json.theming entry.theming.as_json(only: [:privacy_link_url])
14
+ json.enabled_feature_names entry.enabled_feature_names
15
+ json.page_types PageTypesSeed.new(config).as_json
24
16
 
25
- def initialize(config)
26
- @config = config
27
- end
28
-
29
- def as_json
30
- config.file_types.each_with_object({}) do |file_type, result|
31
- result[file_type.collection_name] = file_type.url_templates.call
32
- end
33
- end
17
+ json.file_url_templates { config_file_url_templates_seed(json, config) }
18
+ json.file_model_types { config_file_model_types_seed(json, config) }
34
19
  end
35
20
 
36
21
  class PageTypesSeed
@@ -1,9 +1,31 @@
1
1
  module Pageflow
2
+ # Generate seed data based on configuration objects
2
3
  module ConfigHelper
3
- include RenderJsonHelper
4
+ # Render seed data that can be used to build file urls.
5
+ #
6
+ # @param [JBuilder] json
7
+ # @param [Configuration] config
8
+ # @since 15.1
9
+ def config_file_url_templates_seed(json, config)
10
+ config.file_types.each do |file_type|
11
+ json.set!(file_type.collection_name) do
12
+ file_type.url_templates.call.each do |key, value|
13
+ json.set!(key, value)
14
+ end
15
+ end
16
+ end
17
+ end
4
18
 
5
- def editor_config_seeds
6
- render_json_partial('pageflow/config/editor_seeds')
19
+ # Render seed data that can be used map model names in
20
+ # parent_file_model_type attributes to file collection names.
21
+ #
22
+ # @param [JBuilder] json
23
+ # @param [Configuration] config
24
+ # @since 15.1
25
+ def config_file_model_types_seed(json, config)
26
+ config.file_types.index_by(&:collection_name).each do |collection_name, file_type|
27
+ json.set!(collection_name, file_type.model.name)
28
+ end
7
29
  end
8
30
  end
9
31
  end
@@ -0,0 +1,12 @@
1
+ module Pageflow
2
+ module Editor
3
+ # @api private
4
+ module ConfigHelper
5
+ include RenderJsonHelper
6
+
7
+ def editor_config_seeds(entry)
8
+ render_json_partial('pageflow/editor/config/seeds', entry: entry)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,10 @@
1
+ module Pageflow
2
+ module Editor
3
+ # @api private
4
+ module EntriesHelper
5
+ def editor_entry_type_fragment(entry, fragment_name)
6
+ entry.entry_type.editor_fragment_renderer.send("#{fragment_name}_fragment", entry)
7
+ end
8
+ end
9
+ end
10
+ end