pageflow 15.2.2 → 15.6.1

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 (213) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -118
  3. data/README.md +2 -3
  4. data/admins/pageflow/accounts.rb +1 -98
  5. data/admins/pageflow/entry.rb +21 -1
  6. data/admins/pageflow/entry_templates.rb +140 -0
  7. data/admins/pageflow/membership.rb +12 -0
  8. data/admins/pageflow/user.rb +5 -5
  9. data/app/assets/javascripts/pageflow/admin/entries.js +65 -0
  10. data/app/assets/javascripts/pageflow/admin/users.js +1 -1
  11. data/app/assets/javascripts/pageflow/asset_urls.js.erb +1 -0
  12. data/app/assets/javascripts/pageflow/base.js +0 -12
  13. data/app/assets/javascripts/pageflow/components.js +2 -6
  14. data/app/assets/javascripts/pageflow/dist/ui.js +178 -55
  15. data/app/assets/javascripts/pageflow/editor/vendor.js +1 -0
  16. data/app/assets/javascripts/pageflow/vendor.js +12 -10
  17. data/app/assets/stylesheets/pageflow/base.scss +0 -7
  18. data/app/assets/stylesheets/pageflow/editor/base.scss +5 -2
  19. data/app/assets/stylesheets/pageflow/editor/composables.scss +5 -1
  20. data/app/assets/stylesheets/pageflow/editor/drop_down_button.scss +1 -1
  21. data/app/assets/stylesheets/pageflow/editor/emulation_mode_button.scss +44 -55
  22. data/app/assets/stylesheets/pageflow/editor/help.scss +2 -2
  23. data/app/assets/stylesheets/pageflow/editor/select_button.scss +1 -1
  24. data/app/assets/stylesheets/pageflow/editor/sidebar_footer.scss +1 -1
  25. data/app/assets/stylesheets/pageflow/entries.scss +1 -1
  26. data/app/assets/stylesheets/pageflow/loading_spinner.scss +4 -1
  27. data/app/assets/stylesheets/pageflow/navigation_mobile.scss +4 -4
  28. data/app/assets/stylesheets/pageflow/themes/default/anchors.scss +1 -1
  29. data/app/assets/stylesheets/pageflow/themes/default/logo/variant/watermark.scss +1 -1
  30. data/app/assets/stylesheets/pageflow/themes/default/page.scss +7 -0
  31. data/app/assets/stylesheets/pageflow/themes/default/page/anchors.scss +1 -1
  32. data/app/assets/stylesheets/pageflow/themes/default/player_controls/classic/control_bar.scss +1 -1
  33. data/app/assets/stylesheets/pageflow/themes/default/player_controls/classic/info_box.scss +1 -1
  34. data/app/assets/stylesheets/pageflow/themes/default/player_controls/shared/menu_bar.scss +2 -2
  35. data/app/assets/stylesheets/pageflow/themes/default/player_controls/slim/control_bar.scss +2 -2
  36. data/app/assets/stylesheets/pageflow/themes/default/player_controls/slim/info_box.scss +1 -1
  37. data/app/assets/stylesheets/pageflow/themes/default/player_controls/slim/quality_menu.scss +2 -2
  38. data/app/assets/stylesheets/pageflow/themes/default/player_controls/waveform/wave.scss +1 -1
  39. data/app/assets/stylesheets/pageflow/ui/forms.scss +9 -2
  40. data/app/assets/stylesheets/pageflow/ui/input/extended_select_input.scss +2 -2
  41. data/app/assets/stylesheets/pageflow/ui/tooltip.scss +17 -3
  42. data/app/helpers/pageflow/admin/entries_helper.rb +16 -0
  43. data/app/helpers/pageflow/structured_data_helper.rb +0 -2
  44. data/app/models/pageflow/account.rb +21 -1
  45. data/app/models/pageflow/account_role_query.rb +1 -1
  46. data/app/models/pageflow/chapter.rb +3 -9
  47. data/app/models/pageflow/entry.rb +9 -2
  48. data/app/models/pageflow/entry_duplicate.rb +1 -0
  49. data/app/models/pageflow/entry_template.rb +16 -2
  50. data/app/models/pageflow/managed_user_query.rb +1 -1
  51. data/app/models/pageflow/page.rb +1 -4
  52. data/app/models/pageflow/revision.rb +0 -4
  53. data/app/models/pageflow/storyline.rb +2 -9
  54. data/app/policies/pageflow/account_policy.rb +10 -0
  55. data/app/policies/pageflow/entry_template_policy.rb +5 -1
  56. data/app/policies/pageflow/folder_policy.rb +2 -2
  57. data/app/policies/pageflow/membership_policy.rb +2 -2
  58. data/app/policies/pageflow/theming_policy.rb +2 -2
  59. data/app/policies/pageflow/user_policy.rb +1 -1
  60. data/app/views/admin/accounts/_entry_template_details.html.arb +7 -5
  61. data/app/views/admin/accounts/_form.html.erb +3 -49
  62. data/app/views/admin/entries/_attributes_table.html.arb +5 -0
  63. data/app/views/admin/entries/_not_allowed_to_see_entry_types.json.jbuilder +2 -0
  64. data/app/views/admin/entries/entry_types.json.jbuilder +4 -0
  65. data/app/views/admin/entry_templates/_form.html.erb +58 -0
  66. data/app/views/admin/users/_not_allowed_to_see_user_quota.html.erb +3 -0
  67. data/app/views/components/pageflow/admin/entry_templates_tab.rb +48 -0
  68. data/app/views/pageflow/admin/initial_passwords/edit.html.erb +2 -1
  69. data/app/views/pageflow/admin/users/_quota_exhausted.html.erb +1 -1
  70. data/app/views/pageflow/themes/_theme.json.jbuilder +1 -1
  71. data/app/views/pageflow/video_files/_video_file.json.jbuilder +8 -1
  72. data/config/initializers/admin_resource_tabs.rb +5 -0
  73. data/config/initializers/help_entries.rb +1 -5
  74. data/config/initializers/revision_components.rb +5 -0
  75. data/config/locales/de.yml +88 -155
  76. data/config/locales/en.yml +79 -143
  77. data/db/migrate/20200515112500_add_constraints_to_entry_templates.rb +21 -0
  78. data/db/migrate/20200807135200_rename_pageflow_entry_template_entry_type_to_entry_type_name.rb +7 -0
  79. data/entry_types/paged/app/assets/javascripts/pageflow_paged/components.js +7 -0
  80. data/entry_types/paged/app/assets/javascripts/pageflow_paged/dist/editor.js +1528 -1349
  81. data/entry_types/paged/app/assets/javascripts/pageflow_paged/dist/frontend.js +9258 -0
  82. data/{app/assets/javascripts/pageflow → entry_types/paged/app/assets/javascripts/pageflow_paged}/dist/react-client.js +1 -1
  83. data/{app/assets/javascripts/pageflow → entry_types/paged/app/assets/javascripts/pageflow_paged}/dist/react-server.js +3 -3
  84. data/entry_types/paged/app/assets/javascripts/pageflow_paged/frontend.js +6 -0
  85. data/entry_types/paged/app/assets/javascripts/pageflow_paged/server_rendering.js +9 -0
  86. data/entry_types/paged/app/assets/javascripts/pageflow_paged/vendor.js +9 -0
  87. data/entry_types/paged/app/assets/javascripts/pageflow_paged/videojs.js +6 -0
  88. data/entry_types/paged/app/controllers/pageflow_paged/application_controller.rb +2 -2
  89. data/{app/helpers/pageflow → entry_types/paged/app/helpers/pageflow_paged}/page_background_asset_helper.rb +4 -3
  90. data/{app/helpers/pageflow → entry_types/paged/app/helpers/pageflow_paged}/react_server_side_rendering_helper.rb +23 -2
  91. data/entry_types/paged/app/views/layouts/pageflow_paged/_loading_spinner_inline_script.html.erb +1 -0
  92. data/entry_types/paged/app/views/layouts/pageflow_paged/application.html.erb +3 -3
  93. data/entry_types/paged/app/views/pageflow_paged/editor/entries/_head.html.erb +4 -2
  94. data/entry_types/paged/app/views/pageflow_paged/entries/_entry.html.erb +1 -1
  95. data/{app/views/pageflow → entry_types/paged/app/views/pageflow_paged}/page_background_asset/_element.html.erb +0 -0
  96. data/{app/views/pageflow → entry_types/paged/app/views/pageflow_paged}/react/_widget.html.erb +0 -0
  97. data/{app/views/pageflow → entry_types/paged/app/views/pageflow_paged}/react/page.html.erb +0 -0
  98. data/entry_types/paged/config/initializers/features.rb +1 -1
  99. data/entry_types/paged/config/initializers/help_entries.rb +17 -0
  100. data/entry_types/paged/config/locales/new/help.de.yml +162 -0
  101. data/entry_types/paged/config/locales/new/help.en.yml +153 -0
  102. data/entry_types/paged/lib/pageflow_paged/engine.rb +13 -0
  103. data/entry_types/paged/lib/pageflow_paged/plugin.rb +5 -1
  104. data/entry_types/paged/lib/pageflow_paged/react.rb +12 -0
  105. data/{lib/pageflow → entry_types/paged/lib/pageflow_paged}/react/page_type.rb +2 -2
  106. data/{lib/pageflow → entry_types/paged/lib/pageflow_paged}/react/widget_type.rb +2 -2
  107. data/entry_types/paged/lib/tasks/pageflow_paged_tasks.rake +7 -0
  108. data/entry_types/paged/vendor/assets/javascripts/development/pageflow_paged/vendor/react-server.js +20613 -0
  109. data/entry_types/paged/vendor/assets/javascripts/development/pageflow_paged/vendor/react.js +21495 -0
  110. data/{vendor/assets/javascripts → entry_types/paged/vendor/assets/javascripts/pageflow_paged/vendor}/dash.all.min.js +0 -0
  111. data/{vendor/assets/javascripts → entry_types/paged/vendor/assets/javascripts/pageflow_paged/vendor}/videojs-dash.js +0 -0
  112. data/{vendor/assets/javascripts → entry_types/paged/vendor/assets/javascripts/pageflow_paged/vendor}/videojs.js +0 -0
  113. data/entry_types/paged/vendor/assets/javascripts/production/pageflow_paged/vendor/react-server.js +24 -0
  114. data/entry_types/paged/vendor/assets/javascripts/production/pageflow_paged/vendor/react.js +24 -0
  115. data/entry_types/scrolled/app/assets/javascripts/pageflow_scrolled/legacy.js +0 -0
  116. data/entry_types/scrolled/app/controllers/pageflow_scrolled/editor/chapters_controller.rb +2 -2
  117. data/entry_types/scrolled/app/controllers/pageflow_scrolled/editor/content_elements_controller.rb +14 -4
  118. data/entry_types/scrolled/app/controllers/pageflow_scrolled/editor/sections_controller.rb +2 -2
  119. data/entry_types/scrolled/app/controllers/pageflow_scrolled/entries_controller.rb +10 -0
  120. data/entry_types/scrolled/app/helpers/pageflow_scrolled/editor/seed_html_helper.rb +7 -0
  121. data/entry_types/scrolled/app/helpers/pageflow_scrolled/entry_json_seed_helper.rb +2 -0
  122. data/entry_types/scrolled/app/helpers/pageflow_scrolled/favicon_helper.rb +21 -0
  123. data/entry_types/scrolled/app/helpers/pageflow_scrolled/react_server_side_rendering_helper.rb +40 -0
  124. data/entry_types/scrolled/app/helpers/pageflow_scrolled/themes_helper.rb +36 -0
  125. data/entry_types/scrolled/app/models/pageflow_scrolled/chapter.rb +3 -9
  126. data/entry_types/scrolled/app/models/pageflow_scrolled/content_element.rb +37 -2
  127. data/entry_types/scrolled/app/models/pageflow_scrolled/section.rb +3 -9
  128. data/entry_types/scrolled/app/models/pageflow_scrolled/storyline.rb +1 -9
  129. data/entry_types/scrolled/app/views/pageflow_scrolled/editor/content_elements/batch.json.jbuilder +2 -0
  130. data/entry_types/scrolled/app/views/pageflow_scrolled/editor/entries/_head.html.erb +1 -7
  131. data/entry_types/scrolled/app/views/pageflow_scrolled/entries/_global_notices.html.erb +10 -0
  132. data/entry_types/scrolled/app/views/pageflow_scrolled/entries/show.html.erb +28 -11
  133. data/entry_types/scrolled/app/views/pageflow_scrolled/entry_json_seed/_entry.json.jbuilder +3 -0
  134. data/entry_types/scrolled/app/views/pageflow_scrolled/entry_json_seed/_theme.json.jbuilder +8 -0
  135. data/entry_types/scrolled/app/views/pageflow_scrolled/favicons/_entry.html.erb +10 -0
  136. data/entry_types/scrolled/config/initializers/help_entries.rb +16 -0
  137. data/entry_types/scrolled/config/locales/de.yml +669 -0
  138. data/entry_types/scrolled/config/locales/en.yml +488 -0
  139. data/entry_types/scrolled/config/routes.rb +1 -0
  140. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/install_generator.rb +76 -6
  141. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/favicons/android-chrome-192x192.png +0 -0
  142. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/favicons/android-chrome-512x512.png +0 -0
  143. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/favicons/apple-touch-icon.png +0 -0
  144. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/favicons/browserconfig.xml +9 -0
  145. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/favicons/favicon-16x16.png +0 -0
  146. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/favicons/favicon-32x32.png +0 -0
  147. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/favicons/favicon.ico +0 -0
  148. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/favicons/mstile-150x150.png +0 -0
  149. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/favicons/safari-pinned-tab.svg +46 -0
  150. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/favicons/site.webmanifest +19 -0
  151. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/logoDesktop.svg +56 -0
  152. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/logoMobile.svg +22 -0
  153. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/theme/unmute.mp3 +0 -0
  154. data/entry_types/scrolled/lib/generators/pageflow_scrolled/install/templates/themes_plugin.rb.tt +26 -0
  155. data/entry_types/scrolled/lib/pageflow_scrolled/engine.rb +6 -0
  156. data/entry_types/scrolled/lib/pageflow_scrolled/plugin.rb +3 -1
  157. data/entry_types/scrolled/lib/pageflow_scrolled/seeds.rb +90 -30
  158. data/entry_types/scrolled/lib/tasks/pageflow_scrolled/create_bundle_symlinks_for_yarn.rake +33 -0
  159. data/entry_types/scrolled/lib/tasks/pageflow_scrolled/dummy.rake +8 -0
  160. data/entry_types/scrolled/lib/tasks/pageflow_scrolled/storybook.rake +173 -0
  161. data/entry_types/scrolled/package/config/webpack.js +11 -0
  162. data/entry_types/scrolled/package/contentElements-editor.js +316 -185
  163. data/entry_types/scrolled/package/contentElements-frontend.css +1 -0
  164. data/entry_types/scrolled/package/contentElements-frontend.js +940 -304
  165. data/entry_types/scrolled/package/editor.js +2930 -371
  166. data/entry_types/scrolled/package/frontend-server.js +228 -0
  167. data/entry_types/scrolled/package/frontend/EditableText-7093fd0e.js +1071 -0
  168. data/entry_types/scrolled/package/frontend/Viewer-e49e7807.js +387 -0
  169. data/entry_types/scrolled/package/frontend/Wavesurfer-0adf5667.js +375 -0
  170. data/entry_types/scrolled/package/frontend/components-6a6793ca.js +2534 -0
  171. data/entry_types/scrolled/package/frontend/getPrototypeOf-63c7c8e8.js +86 -0
  172. data/entry_types/scrolled/package/frontend/i18n-4dc6c377.js +1092 -0
  173. data/entry_types/scrolled/package/frontend/index.css +9 -0
  174. data/entry_types/scrolled/package/frontend/index.js +5686 -0
  175. data/entry_types/scrolled/package/frontend/useBrowserFeature-91a4c29d.js +33 -0
  176. data/entry_types/scrolled/package/package.json +30 -9
  177. data/entry_types/scrolled/spec/fixtures/audio.m4a +0 -0
  178. data/entry_types/scrolled/spec/fixtures/video.mp4 +0 -0
  179. data/lib/generators/pageflow/initializer/templates/pageflow.rb +14 -9
  180. data/lib/pageflow/ability_mixin.rb +14 -2
  181. data/lib/pageflow/configuration.rb +6 -5
  182. data/lib/pageflow/entry_export_import/revision_serialization.rb +15 -13
  183. data/lib/pageflow/entry_export_import/revision_serialization/import.rb +18 -26
  184. data/lib/pageflow/entry_type_configuration.rb +2 -0
  185. data/lib/pageflow/global_config_api.rb +5 -4
  186. data/lib/pageflow/nested_revision_component.rb +49 -0
  187. data/lib/pageflow/react.rb +4 -2
  188. data/lib/pageflow/revision_component.rb +6 -2
  189. data/lib/pageflow/themes.rb +4 -0
  190. data/lib/pageflow/user_mixin.rb +2 -1
  191. data/lib/pageflow/version.rb +1 -1
  192. data/{packages/pageflow → package}/config/jest/index.js +8 -2
  193. data/{packages/pageflow → package}/config/jest/transformers/jst.js +0 -0
  194. data/{packages/pageflow → package}/config/jest/transformers/upwardBabel.js +0 -0
  195. data/{packages/pageflow → package}/config/webpack.js +7 -0
  196. data/{packages/pageflow → package}/editor.js +482 -1130
  197. data/package/frontend.js +2553 -0
  198. data/{packages/pageflow → package}/package.json +3 -0
  199. data/{packages/pageflow → package}/testHelpers.js +114 -13
  200. data/{packages/pageflow → package}/ui.js +178 -55
  201. data/spec/factories/accounts.rb +3 -1
  202. data/spec/factories/entry_templates.rb +1 -0
  203. data/spec/factories/published_entries.rb +6 -1
  204. data/spec/factories/test_revision_components.rb +4 -0
  205. metadata +95 -36
  206. data/app/assets/javascripts/pageflow/dist/frontend.js +0 -5800
  207. data/app/assets/javascripts/pageflow/videojs.js +0 -6
  208. data/config/initializers/entry_types.rb +0 -4
  209. data/entry_types/scrolled/config/locales/new/de.yml +0 -269
  210. data/entry_types/scrolled/config/locales/new/en.yml +0 -264
  211. data/entry_types/scrolled/lib/tasks/pageflow_scrolled_tasks.rake +0 -96
  212. data/entry_types/scrolled/package/frontend.js +0 -2879
  213. data/packages/pageflow/config/jest/transformers/cssModules.js +0 -1
@@ -15,7 +15,7 @@
15
15
 
16
16
  position: relative;
17
17
  z-index: 1;
18
- pointer-events: all;
18
+ pointer-events: auto;
19
19
  height: 70px;
20
20
 
21
21
  @media (min-height: 600px) {
@@ -24,7 +24,8 @@ label:hover span.name {
24
24
  select,
25
25
  textarea,
26
26
  input {
27
- font-family: Helvetica, "Sans-Serif";
27
+ font-family: Helvetica, Arial, "Sans-Serif";
28
+ font-size: 13px;
28
29
  display: block;
29
30
  width: 100%;
30
31
  border: solid 1px #888;
@@ -158,6 +159,12 @@ textarea.short {
158
159
  margin: 7px 0;
159
160
  float: left;
160
161
  }
162
+
163
+ &.disabled .slider,
164
+ &.disabled .value {
165
+ opacity: 0.5;
166
+ pointer-events: none;
167
+ }
161
168
  }
162
169
 
163
170
  .validation {
@@ -189,7 +196,7 @@ textarea.short {
189
196
  width: 20px;
190
197
  height: 17px;
191
198
  text-align: center;
192
- pointer-events: all;
199
+ pointer-events: auto;
193
200
  }
194
201
 
195
202
  position: absolute;
@@ -1,6 +1,6 @@
1
1
  .extended_select_input {
2
2
  .ui-selectmenu-button span.ui-selectmenu-text {
3
- font-family: Helvetica, Sans-Serif;
3
+ font-family: Helvetica, Arial, Sans-Serif;
4
4
  font-size: 13px;
5
5
  }
6
6
  }
@@ -91,7 +91,7 @@
91
91
  }
92
92
 
93
93
  .ui-widget {
94
- font-family: Helvetica, Sans-Serif;
94
+ font-family: Helvetica, Arial, Sans-Serif;
95
95
  font-size: 13px;
96
96
 
97
97
  .item-description {
@@ -1,10 +1,9 @@
1
1
  .tooltip {
2
- $background-color: rgba(0, 0, 0, 0.7);
2
+ $background-color: rgba(0, 0, 0, 0.9);
3
3
 
4
4
  position: absolute;
5
5
  z-index: 10001;
6
6
  top: 40px;
7
- left: 400px;
8
7
  max-width: 70%;
9
8
  padding: 10px 15px;
10
9
  color: #fff;
@@ -46,6 +45,21 @@
46
45
  }
47
46
  }
48
47
 
48
+ &.align_top_center {
49
+ transform: translate(-50%, -100%);
50
+
51
+ &:after {
52
+ border-top: solid 10px $background-color;
53
+ border-right: solid 10px transparent;
54
+ border-bottom: solid 10px transparent;
55
+ border-left: solid 10px transparent;
56
+
57
+ top: 100%;
58
+ left: 50%;
59
+ transform: translateX(-50%);
60
+ }
61
+ }
62
+
49
63
  &.align_bottom_right {
50
64
  @include transform(translateX(-100%));
51
65
 
@@ -54,4 +68,4 @@
54
68
  left: auto;
55
69
  }
56
70
  }
57
- }
71
+ }
@@ -18,6 +18,22 @@ module Pageflow
18
18
  I18n.t(state, scope: 'activerecord.values.pageflow/entry.publication_states')
19
19
  end
20
20
  end
21
+
22
+ def entry_type_collection
23
+ entry_type_collection_for_config(Pageflow.config)
24
+ end
25
+
26
+ def entry_type_collection_for_account(target)
27
+ entry_type_collection_for_config(Pageflow.config_for(target))
28
+ end
29
+
30
+ private
31
+
32
+ def entry_type_collection_for_config(config)
33
+ config.entry_types.map(&:name).index_by do |type|
34
+ I18n.t(type, scope: 'activerecord.values.pageflow/entry.type_names')
35
+ end
36
+ end
21
37
  end
22
38
  end
23
39
  end
@@ -6,8 +6,6 @@ module Pageflow
6
6
  include MetaTagsHelper
7
7
 
8
8
  def structured_data_for_entry(entry)
9
- return '' unless Pageflow.config_for(entry).features.enabled?('structured_data')
10
-
11
9
  content_tag(:script, type: 'application/ld+json') do
12
10
  render_json_partial('pageflow/structured_data/entry',
13
11
  entry: entry,
@@ -27,7 +27,27 @@ module Pageflow
27
27
  end
28
28
 
29
29
  def first_paged_entry_template
30
- EntryTemplate.find_or_initialize_by(account: self, entry_type: 'paged')
30
+ EntryTemplate.find_or_initialize_by(account: self, entry_type_name: 'paged')
31
+ end
32
+
33
+ def existing_and_potential_entry_templates
34
+ entry_type_names = Pageflow.config_for(self).entry_types.map(&:name)
35
+ existing_entry_templates = EntryTemplate.where(account_id: id).load
36
+ allowed_existing_entry_templates =
37
+ existing_entry_templates.select do |template|
38
+ entry_type_names.include?(template.entry_type_name)
39
+ end
40
+ free_type_names =
41
+ entry_type_names - allowed_existing_entry_templates.map(&:entry_type_name)
42
+
43
+ potential_entry_templates = free_type_names.map do |type_name|
44
+ EntryTemplate.new(
45
+ account_id: id,
46
+ entry_type_name: type_name
47
+ )
48
+ end
49
+
50
+ allowed_existing_entry_templates + potential_entry_templates
31
51
  end
32
52
 
33
53
  def blacklist_for_serialization
@@ -32,7 +32,7 @@ module Pageflow
32
32
  INNER JOIN pageflow_memberships ON
33
33
  pageflow_memberships.user_id = :user_id AND
34
34
  pageflow_memberships.entity_id = pageflow_accounts.id AND
35
- pageflow_memberships.entity_type = "Pageflow::Account" AND
35
+ pageflow_memberships.entity_type = 'Pageflow::Account' AND
36
36
  pageflow_memberships.role IN (:roles)
37
37
  SQL
38
38
  end
@@ -1,10 +1,13 @@
1
1
  module Pageflow
2
2
  class Chapter < ApplicationRecord
3
3
  include SerializedConfiguration
4
+ include NestedRevisionComponent
4
5
 
5
6
  belongs_to :storyline, touch: true
6
7
  has_many :pages, -> { order('position ASC') }, dependent: :destroy, inverse_of: :chapter
7
8
 
9
+ nested_revision_components :pages
10
+
8
11
  attr_accessor :is_first
9
12
 
10
13
  delegate :entry, to: :storyline
@@ -12,14 +15,5 @@ module Pageflow
12
15
  def pages
13
16
  super.tap { |p| p.first.is_first = true if is_first && p.present? }
14
17
  end
15
-
16
- def copy_to(storyline)
17
- chapter = dup
18
- storyline.chapters << chapter
19
-
20
- pages.each do |page|
21
- page.copy_to(chapter)
22
- end
23
- end
24
18
  end
25
19
  end
@@ -37,6 +37,7 @@ module Pageflow
37
37
 
38
38
  validates :account, :theming, :presence => true
39
39
  validates :title, presence: true
40
+ validate :entry_type_is_available_for_account
40
41
  validate :folder_belongs_to_same_account
41
42
 
42
43
  scope :editing, -> { joins(:edit_lock).merge(Pageflow::EditLock.active) }
@@ -57,12 +58,12 @@ module Pageflow
57
58
  def entry_template
58
59
  @entry_template ||= EntryTemplate.find_or_initialize_by(
59
60
  account_id: account.id,
60
- entry_type: type_name
61
+ entry_type_name: type_name
61
62
  )
62
63
  end
63
64
 
64
65
  def entry_type
65
- Pageflow.config_for(self).entry_types.find_by_name!(type_name)
66
+ Pageflow.config.entry_types.find_by_name!(type_name)
66
67
  end
67
68
 
68
69
  def edit_lock
@@ -139,6 +140,12 @@ module Pageflow
139
140
  errors.add(:folder, :must_be_same_account) if folder.present? && folder.account_id != account_id
140
141
  end
141
142
 
143
+ def entry_type_is_available_for_account
144
+ return if Pageflow.config_for(account).entry_types.map(&:name).include?(type_name)
145
+
146
+ errors.add(:type_name, :must_be_available_for_account, type_name: type_name)
147
+ end
148
+
142
149
  def update_password!(options)
143
150
  if options[:password].present?
144
151
  self.password = options[:password]
@@ -35,6 +35,7 @@ module Pageflow
35
35
 
36
36
  def new_attributes
37
37
  {
38
+ type_name: original_entry.type_name,
38
39
  title: new_title,
39
40
  account: original_entry.account,
40
41
  theming: original_entry.theming,
@@ -4,12 +4,26 @@ module Pageflow
4
4
  include SerializedConfiguration
5
5
  serialize :default_share_providers, JSON
6
6
  belongs_to :account
7
+ delegate :enabled_feature_names, to: :account
7
8
  has_many :widgets, as: :subject, dependent: :destroy
8
9
 
9
10
  validates :account, presence: true
11
+ validates :entry_type_name, presence: true
12
+ validates :entry_type_name,
13
+ uniqueness: {
14
+ scope: :account
15
+ }
16
+
17
+ def entry_type
18
+ Pageflow.config.entry_types.find_by_name!(entry_type_name)
19
+ end
20
+
21
+ def translated_entry_type_name
22
+ I18n.t("activerecord.values.pageflow/entry.type_names.#{entry_type_name}")
23
+ end
10
24
 
11
25
  def resolve_widgets(options = {})
12
- widgets.resolve(Pageflow.config_for(account), options)
26
+ widgets.resolve(Pageflow.config_for(self), options)
13
27
  end
14
28
 
15
29
  def copy_defaults_to(revision)
@@ -45,7 +59,7 @@ module Pageflow
45
59
  end
46
60
 
47
61
  def available_themes
48
- Pageflow.config_for(account).themes
62
+ Pageflow.config_for(self).themes
49
63
  end
50
64
 
51
65
  def hashify_provider_array(arr)
@@ -26,7 +26,7 @@ module Pageflow
26
26
  <<-SQL
27
27
  INNER JOIN pageflow_memberships account_memberships ON
28
28
  account_memberships.user_id = users.id AND
29
- account_memberships.entity_type = "Pageflow::Account"
29
+ account_memberships.entity_type = 'Pageflow::Account'
30
30
  SQL
31
31
  end
32
32
 
@@ -1,6 +1,7 @@
1
1
  module Pageflow
2
2
  class Page < ApplicationRecord
3
3
  include SerializedConfiguration
4
+ include NestedRevisionComponent
4
5
  include AutoGeneratedPermaId
5
6
 
6
7
  belongs_to :chapter, touch: true
@@ -23,9 +24,5 @@ module Pageflow
23
24
  self.display_in_navigation = value['display_in_navigation']
24
25
  super
25
26
  end
26
-
27
- def copy_to(chapter)
28
- chapter.pages << dup
29
- end
30
27
  end
31
28
  end
@@ -170,10 +170,6 @@ module Pageflow
170
170
  widget.copy_to(revision)
171
171
  end
172
172
 
173
- storylines.each do |storyline|
174
- storyline.copy_to(revision)
175
- end
176
-
177
173
  file_usages.each do |file_usage|
178
174
  file_usage.copy_to(revision)
179
175
  end
@@ -10,15 +10,8 @@ module Pageflow
10
10
 
11
11
  has_many :pages, through: :chapters
12
12
 
13
- delegate :entry, to: :revision
14
-
15
- def copy_to(revision)
16
- storyline = dup
17
- revision.storylines << storyline
13
+ nested_revision_components :chapters
18
14
 
19
- chapters.each do |chapter|
20
- chapter.copy_to(storyline)
21
- end
22
- end
15
+ delegate :entry, to: :revision
23
16
  end
24
17
  end
@@ -88,6 +88,16 @@ module Pageflow
88
88
  query.has_at_least_role?(:manager))
89
89
  end
90
90
 
91
+ def see_user_quota?
92
+ user.admin? ||
93
+ query.has_at_least_role?(:manager)
94
+ end
95
+
96
+ def see_entry_types?
97
+ user.admin? ||
98
+ query.has_at_least_role?(:publisher)
99
+ end
100
+
91
101
  def edit_role_on?
92
102
  user.admin? || query.has_at_least_role?(:manager)
93
103
  end
@@ -5,7 +5,11 @@ module Pageflow
5
5
  @entry_template = entry_template
6
6
  end
7
7
 
8
- def edit?
8
+ def create?
9
+ update?
10
+ end
11
+
12
+ def update?
9
13
  allows?(%w(publisher manager))
10
14
  end
11
15
 
@@ -24,9 +24,9 @@ module Pageflow
24
24
  user.accounts.joins(sanitize_sql_array([
25
25
  'LEFT OUTER JOIN pageflow_memberships as pageflow_memberships_2 ON ' \
26
26
  'pageflow_memberships_2.user_id = :user_id AND ' \
27
- 'pageflow_memberships_2.entity_type = "Pageflow::Account" AND ' \
27
+ 'pageflow_memberships_2.entity_type = \'Pageflow::Account\' AND ' \
28
28
  'pageflow_memberships_2.entity_id = pageflow_accounts.id AND ' \
29
- 'pageflow_memberships_2.role IN ("previewer", "editor", "publisher", "manager")',
29
+ 'pageflow_memberships_2.role IN (\'previewer\', \'editor\', \'publisher\', \'manager\')',
30
30
  user_id: user.id])).where('pageflow_memberships_2.entity_id IS NOT NULL')
31
31
  end
32
32
  end
@@ -19,9 +19,9 @@ module Pageflow
19
19
  private
20
20
 
21
21
  def permissions_appropriate
22
- sanitize_sql_array(['pageflow_memberships.entity_type = "Pageflow::Account" AND ' \
22
+ sanitize_sql_array(['pageflow_memberships.entity_type = \'Pageflow::Account\' AND ' \
23
23
  'pageflow_memberships.entity_id IN (:managed_account_ids) OR ' \
24
- 'pageflow_memberships.entity_type = "Pageflow::Entry" AND ' \
24
+ 'pageflow_memberships.entity_type = \'Pageflow::Entry\' AND ' \
25
25
  'pageflow_memberships.entity_id IN (:common_entry_ids) OR '\
26
26
  'pageflow_memberships.user_id = :user_id',
27
27
  managed_account_ids: managed_account_ids,
@@ -25,8 +25,8 @@ module Pageflow
25
25
  'pageflow_memberships.user_id = :user_id AND ' \
26
26
  'pageflow_themings.account_id IN (:accounts_ids) AND ' \
27
27
  'pageflow_memberships.entity_id IN (:accounts_ids) AND ' \
28
- 'pageflow_memberships.entity_type = "Pageflow::Account" AND ' \
29
- 'pageflow_memberships.role IN ("publisher", "manager")',
28
+ 'pageflow_memberships.entity_type = \'Pageflow::Account\' AND ' \
29
+ 'pageflow_memberships.role IN (\'publisher\', \'manager\')',
30
30
  user_id: user.id, accounts_ids: accounts_ids])
31
31
  end
32
32
 
@@ -16,7 +16,7 @@ module Pageflow
16
16
  .new(@user, Account).member_addable.map(&:id)
17
17
 
18
18
  scope.joins(:memberships)
19
- .where('pageflow_memberships.entity_type = "Pageflow::Account"')
19
+ .where('pageflow_memberships.entity_type = \'Pageflow::Account\'')
20
20
  .where(membership_in_managed_account(manager_accounts_ids)).distinct
21
21
  end
22
22
  end
@@ -1,17 +1,19 @@
1
- extensible_attributes_table_for(account.first_paged_entry_template,
2
- Pageflow.config_for(account)
1
+ h5(entry_template.translated_entry_type_name)
2
+
3
+ extensible_attributes_table_for(entry_template,
4
+ Pageflow.config_for(entry_template.account)
3
5
  .admin_attributes_table_rows.for(:entry_template)) do
4
6
  row :theme, class: 'theme' do
5
- account.first_paged_entry_template.theme_name
7
+ entry_template.theme_name
6
8
  end
7
9
  row :default_locale, class: 'default_locale' do
8
- t('pageflow.public._language', locale: account.first_paged_entry_template.default_locale)
10
+ t('pageflow.public._language', locale: entry_template.default_locale)
9
11
  end
10
12
  row :default_author, class: 'default_author'
11
13
  row :default_publisher, class: 'default_publisher'
12
14
  row :default_keywords, class: 'default_keywords'
13
15
  row :default_share_providers, class: 'default_share_providers' do
14
- account.first_paged_entry_template.default_share_providers
16
+ entry_template.default_share_providers
15
17
  .select { |_k, v| v == true }.keys.map(&:camelize).join(', ')
16
18
  end
17
19
  end