pageflow 15.8.0 → 16.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +33 -130
  3. data/admins/pageflow/accounts.rb +12 -16
  4. data/admins/pageflow/entry.rb +28 -25
  5. data/admins/pageflow/entry_templates.rb +5 -7
  6. data/admins/pageflow/sites.rb +50 -0
  7. data/app/assets/javascripts/pageflow/admin/entries.js +16 -7
  8. data/app/controllers/pageflow/entries_controller.rb +2 -2
  9. data/app/helpers/pageflow/admin/permalinks_helper.rb +2 -2
  10. data/app/helpers/pageflow/common_entry_seed_helper.rb +1 -1
  11. data/app/helpers/pageflow/embed_code_helper.rb +1 -1
  12. data/app/helpers/pageflow/entries_helper.rb +15 -15
  13. data/app/helpers/pageflow/sites_helper.rb +11 -0
  14. data/app/helpers/pageflow/social_share_helper.rb +2 -2
  15. data/app/models/pageflow/account.rb +7 -33
  16. data/app/models/pageflow/{cname_theming_request_scope.rb → cname_site_request_scope.rb} +3 -3
  17. data/app/models/pageflow/customized_theme.rb +1 -1
  18. data/app/models/pageflow/entry.rb +3 -4
  19. data/app/models/pageflow/entry_at_revision.rb +2 -2
  20. data/app/models/pageflow/entry_duplicate.rb +1 -1
  21. data/app/models/pageflow/entry_template.rb +4 -4
  22. data/app/models/pageflow/home_button.rb +7 -7
  23. data/app/models/pageflow/permalink.rb +3 -3
  24. data/app/models/pageflow/permalink_directory.rb +2 -2
  25. data/app/models/pageflow/published_entry.rb +2 -2
  26. data/app/models/pageflow/site.rb +59 -0
  27. data/app/models/pageflow/theme_customization.rb +1 -1
  28. data/app/policies/pageflow/account_policy.rb +2 -2
  29. data/app/policies/pageflow/entry_policy.rb +2 -2
  30. data/app/policies/pageflow/entry_template_policy.rb +1 -1
  31. data/app/policies/pageflow/{theming_policy.rb → site_policy.rb} +13 -11
  32. data/app/views/admin/accounts/_entry_template_details.html.arb +1 -1
  33. data/app/views/admin/accounts/_form.html.erb +4 -22
  34. data/app/views/admin/accounts/_site_defaults_inline_help.html.erb +5 -0
  35. data/app/views/admin/entries/_form.html.erb +4 -13
  36. data/app/views/admin/entries/_permalink_inputs.html.erb +2 -2
  37. data/app/views/admin/entries/_site_input.html.erb +15 -0
  38. data/app/views/admin/entries/{entry_type_name_input.html.erb → entry_site_and_type_name_input.html.erb} +3 -0
  39. data/app/views/admin/entry_templates/_form.html.erb +5 -5
  40. data/app/views/admin/sites/_attributes_table.html.arb +9 -0
  41. data/app/views/admin/sites/_fields.html.erb +17 -0
  42. data/app/views/admin/sites/_form.html.erb +5 -0
  43. data/app/views/components/pageflow/admin/entries_tab.rb +1 -2
  44. data/app/views/components/pageflow/admin/entry_templates_tab.rb +10 -11
  45. data/app/views/components/pageflow/admin/features_tab.rb +1 -1
  46. data/app/views/components/pageflow/admin/sites_tab.rb +32 -0
  47. data/app/views/components/pageflow/admin/users_tab.rb +1 -2
  48. data/app/views/pageflow/editor/entries/seed.json.erb +1 -1
  49. data/app/views/pageflow/editor/sites/_site.json.jbuilder +1 -0
  50. data/app/views/pageflow/entries/{_theming.css.erb → _site.css.erb} +0 -0
  51. data/app/views/pageflow/entries/stylesheet.css.erb +1 -1
  52. data/app/views/pageflow/social_share/_entry_meta_tags.html.erb +1 -1
  53. data/app/views/pageflow/social_share/_page_meta_tags.html.erb +1 -1
  54. data/config/initializers/admin_resource_tabs.rb +29 -12
  55. data/config/locales/de.yml +19 -17
  56. data/config/locales/en.yml +19 -17
  57. data/db/migrate/20221215101134_rename_theming_to_site.rb +9 -0
  58. data/db/migrate/20221215120856_associate_entry_templates_with_sites.rb +34 -0
  59. data/db/migrate/20221219203023_add_name_to_sites.rb +5 -0
  60. data/db/migrate/20230103155934_associate_theme_customizations_with_sites.rb +27 -0
  61. data/entry_types/paged/app/assets/javascripts/pageflow_paged/dist/editor.js +10 -10
  62. data/entry_types/paged/app/assets/javascripts/pageflow_paged/dist/frontend.js +5 -5
  63. data/entry_types/paged/app/assets/javascripts/pageflow_paged/dist/react-client.js +1 -1
  64. data/entry_types/paged/app/assets/javascripts/pageflow_paged/dist/react-server.js +1 -1
  65. data/entry_types/scrolled/app/views/pageflow_scrolled/entry_json_seed/_entry.json.jbuilder +5 -5
  66. data/entry_types/scrolled/lib/pageflow_scrolled/seeds.rb +1 -1
  67. data/entry_types/scrolled/package/frontend/{EditableInlineText.module-c6672f27.js → EditableInlineText.module-14c7b097.js} +2 -2
  68. data/entry_types/scrolled/package/frontend/{PhonePlatformContext-22e65f92.js → PhonePlatformContext-f6093cc6.js} +47 -219
  69. data/entry_types/scrolled/package/frontend/{Viewer-6b05522f.js → Viewer-b6becc57.js} +2 -2
  70. data/entry_types/scrolled/package/frontend/{arrowRight-7e3d9dd5.js → arrowRight-78a7cee4.js} +1 -1
  71. data/entry_types/scrolled/package/frontend/{components-487daafa.js → components-b3160dd7.js} +2 -2
  72. data/entry_types/scrolled/package/frontend/index.css +1 -1
  73. data/entry_types/scrolled/package/frontend/index.js +195 -12
  74. data/entry_types/scrolled/package/widgets/defaultNavigation.css +2 -2
  75. data/entry_types/scrolled/package/widgets/defaultNavigation.js +16 -9
  76. data/lib/pageflow/ability_mixin.rb +16 -8
  77. data/lib/pageflow/admin/attributes_table_rows.rb +1 -1
  78. data/lib/pageflow/admin/form_inputs.rb +1 -1
  79. data/lib/pageflow/admin/tabs.rb +1 -1
  80. data/lib/pageflow/configuration/permissions.rb +3 -3
  81. data/lib/pageflow/configuration.rb +17 -17
  82. data/lib/pageflow/entry_export_import/entry_serialization.rb +1 -1
  83. data/lib/pageflow/primary_domain_entry_redirect.rb +7 -7
  84. data/lib/pageflow/seeds.rb +10 -10
  85. data/lib/pageflow/theme_customizations.rb +10 -10
  86. data/lib/pageflow/version.rb +1 -1
  87. data/package/editor.js +7 -7
  88. data/spec/factories/accounts.rb +5 -2
  89. data/spec/factories/draft_entries.rb +2 -2
  90. data/spec/factories/entries.rb +2 -2
  91. data/spec/factories/entry_templates.rb +1 -1
  92. data/spec/factories/permalink_directory.rb +1 -1
  93. data/spec/factories/published_entries.rb +2 -2
  94. data/spec/factories/sites.rb +9 -0
  95. metadata +27 -18
  96. data/app/helpers/pageflow/themings_helper.rb +0 -11
  97. data/app/models/pageflow/theming.rb +0 -30
  98. data/app/views/admin/accounts/_theming_defaults_inline_help.html.erb +0 -5
  99. data/app/views/admin/accounts/_theming_details.html.arb +0 -5
  100. data/app/views/pageflow/editor/themings/_theming.json.jbuilder +0 -1
  101. data/spec/factories/themings.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1bbd00f3c57790e6bdeb0ffd65d56fa29eb3c239b31a1b92c11fed242f9423e
4
- data.tar.gz: d9d44c5a5273ffd92086d3303bf5806347c16406083ff60ece793b6e09de7e71
3
+ metadata.gz: f961d4e469b058f29cbba131a2ab69068547a6215111a1e9dae04040b956ddcf
4
+ data.tar.gz: 91b70f55119f6c1b8f8b8f4d1b98555f9d58bf73160165d7e4d16f8026384d81
5
5
  SHA512:
6
- metadata.gz: 96f45b7ee97ae6218a92b973b9265437dafc8709587f50035d1a8cfb733022d7dbdfd82a79e3545fa71f5e6d8f45347fcd207c897a2c0cf961c6441045a60381
7
- data.tar.gz: 786c1620c4977004d401dcd85ee51868abfb5bb4ce6c48c0131ce4e79fa481e1f8880f05c2a3498bc782b409769eff81d6b7e6c45f496a56901a266b02a4bd59
6
+ metadata.gz: 82ac9717c4501f56715a6afc1a855ea9ce82f8cf1d3b6c3627ca8785960753a2967ba5114f5c348aa95608160c70b59edf338b9ea21d94fe1aee98cd7704adba
7
+ data.tar.gz: 0abd22f0d5bf02e29f6ac4b9fb6bc03732eec4a5e3cbd596aed79498f218e333a915bbbe1eee3b923bfe14ce213767f380c433c22180e5cb6294e38aa2694ab8
data/CHANGELOG.md CHANGED
@@ -1,152 +1,55 @@
1
1
  # CHANGELOG
2
2
 
3
- ### Version 15.8.0
3
+ ### Version 16.0.0
4
4
 
5
- 2022-12-23
5
+ 2023-01-11
6
6
 
7
- [Compare changes](https://github.com/codevise/pageflow/compare/15-7-stable...v15.8.0)
7
+ [Compare changes](https://github.com/codevise/pageflow/compare/15-x-stable...v16.0.0)
8
8
 
9
9
  #### Core
10
10
 
11
- ##### Rails Engine
11
+ ##### Breaking Changes
12
12
 
13
- - Permalinks
14
- ([#1883](https://github.com/codevise/pageflow/pull/1883))
15
- - Add user_changed hook
16
- ([#1859](https://github.com/codevise/pageflow/pull/1859))
17
- - Allow adding id in data attribute when adding editor main menu item
18
- ([#1837](https://github.com/codevise/pageflow/pull/1837))
13
+ - The `Theming` model has been renamed to `Site`.
14
+ ([#1903](https://github.com/codevise/pageflow/pull/1903),
15
+ [#1914](https://github.com/codevise/pageflow/pull/1914))
19
16
 
20
- ##### Admin
17
+ Related associations like `Entry#theming` or
18
+ `Account#default_theming` have been renamed to `Entry#site` and
19
+ `Account#default_site` accordingly.
21
20
 
22
- - Improve membership update
23
- ([#1862](https://github.com/codevise/pageflow/pull/1862))
21
+ - Entry templates and theme customizations now belong to sites instead
22
+ of accounts.
23
+ ([#1904](https://github.com/codevise/pageflow/pull/1904),
24
+ [#1915](https://github.com/codevise/pageflow/pull/1915))
24
25
 
25
- ##### Editor
26
-
27
- - Improve file import controller
28
- ([#1847](https://github.com/codevise/pageflow/pull/1847))
29
-
30
- ##### Published Entry
31
-
32
- - Display opt-out vendors as accepted by default on privacy page
33
- ([#1899](https://github.com/codevise/pageflow/pull/1899))
34
-
35
- ##### JavaScript API
36
-
37
- - Pass alt text in media events
38
- ([#1901](https://github.com/codevise/pageflow/pull/1901))
39
- - Provide more tracking data
40
- ([#1885](https://github.com/codevise/pageflow/pull/1885))
26
+ Accounts can now contain multiple sites with their own set of
27
+ templates and customized theme.
41
28
 
42
29
  ##### Internal
43
30
 
44
- - Migrate to supported setup-ruby action
45
- ([#1892](https://github.com/codevise/pageflow/pull/1892))
46
-
47
-
48
- #### Paged Entry Type
49
-
50
- ##### Published Entry
51
-
52
- - Add feature flag to enforce usage of FullHD videos
53
- ([#1879](https://github.com/codevise/pageflow/pull/1879))
54
- - Allow enforcing best video quality in Paged entries
55
- ([#1863](https://github.com/codevise/pageflow/pull/1863))
56
- - Ensure scroller content is accessible via OS X Spoken Content
57
- ([#1870](https://github.com/codevise/pageflow/pull/1870))
58
-
59
- ##### Internal
60
-
61
- - Missing semicolon in themes/default/page.scss
62
- ([#1898](https://github.com/codevise/pageflow/pull/1898))
31
+ - Add reusable GitHub workflow to run RSpec tests
32
+ ([#1905](https://github.com/codevise/pageflow/pull/1905))
63
33
 
64
34
  #### Scrolled Entry Type
65
35
 
66
- ##### Editor
67
-
68
- - Set correct lang attribute on html element in editor preview iframe
69
- ([#1867](https://github.com/codevise/pageflow/pull/1867),
70
- [#1872](https://github.com/codevise/pageflow/pull/1872))
71
- - Bug: Ensure link tooltip is readable in inverted sections
72
- ([#1849](https://github.com/codevise/pageflow/pull/1849))
73
-
74
- ##### Published Entry
75
-
76
- - Section and chapter inline links
77
- ([#1886](https://github.com/codevise/pageflow/pull/1886))
78
- - Typography variants
79
- ([#1842](https://github.com/codevise/pageflow/pull/1842),
80
- [#1845](https://github.com/codevise/pageflow/pull/1845))
81
- - Improve backdrop hiding
82
- ([#1882](https://github.com/codevise/pageflow/pull/1881),
83
- [#1881](https://github.com/codevise/pageflow/pull/1882))
84
- - Backdrop effects
85
- ([#1841](https://github.com/codevise/pageflow/pull/1841),
86
- [#1846](https://github.com/codevise/pageflow/pull/1846))
87
- - Make border radius of cards appearance configurable
88
- ([#1838](https://github.com/codevise/pageflow/pull/1838))
89
- - Allow using SVG images as backdrops and inline images
90
- ([#1860](https://github.com/codevise/pageflow/pull/1860))
91
- - Improve scrolled favicons
92
- ([#1858](https://github.com/codevise/pageflow/pull/1858))
93
- - Use public translations from pageflow-public-i18n in scrolled
94
- ([#1853](https://github.com/codevise/pageflow/pull/1853))
95
- - Rewrite backdrop/motif area logic based on CSS as experimental feature
96
- ([#1854](https://github.com/codevise/pageflow/pull/1854),
97
- [#1855](https://github.com/codevise/pageflow/pull/1855),
98
- [#1856](https://github.com/codevise/pageflow/pull/1856))
99
- - Bug: Prevent foreground shadow from overlaying next section
100
- ([#1900](https://github.com/codevise/pageflow/pull/1900))
101
- - Bug: Ensure backdrop covers viewport in iOS in-app browers
102
- ([#1884](https://github.com/codevise/pageflow/pull/1884))
103
-
104
- ##### Content Elements
105
-
106
- - Disable automatic hyphenation in text block headings
107
- ([#1875](https://github.com/codevise/pageflow/pull/1875))
108
- - Disable top padding for new headings
109
- ([#1896](https://github.com/codevise/pageflow/pull/1896))
110
- - Remove space before heading in cards appearance
111
- ([#1851](https://github.com/codevise/pageflow/pull/1851))
112
- - Text block line breaks
113
- ([#1869](https://github.com/codevise/pageflow/pull/1869),
114
- [#1871](https://github.com/codevise/pageflow/pull/1871))
115
- - Improve mobile block quote size
116
- ([#1868](https://github.com/codevise/pageflow/pull/1868))
117
- - Preserve Tweet hide when unloading
118
- ([#1864](https://github.com/codevise/pageflow/pull/1864))
119
- - Question content element
120
- ([#1861](https://github.com/codevise/pageflow/pull/1861))
121
- - Improve video embed content element
122
- ([#1848](https://github.com/codevise/pageflow/pull/1848),
123
- [#1850](https://github.com/codevise/pageflow/pull/1850))
124
-
125
- ##### Widgets
126
-
127
- - Fix info box position when all share providers are disabled
128
- ([#1877](https://github.com/codevise/pageflow/pull/1877))
129
- - Add option to prevent collapsing default navigation on desktop
130
- ([#1891](https://github.com/codevise/pageflow/pull/1891))
131
- - Options for scrolled default navigation
132
- ([#1866](https://github.com/codevise/pageflow/pull/1866))
133
-
134
- ##### Themes
135
-
136
- - Let themes define external link list variants
137
- ([#1880](https://github.com/codevise/pageflow/pull/1880))
138
- - Text block theme properties
139
- ([#1873](https://github.com/codevise/pageflow/pull/1873))
140
- - Add theme properties for cards colors
141
- ([#1865](https://github.com/codevise/pageflow/pull/1865))
142
- - Pass consistent arguments when transforming theme options
143
- ([#1844](https://github.com/codevise/pageflow/pull/1844))
36
+ - Simplify borders in default navigation mobile chapter menu
37
+ ([#1913](https://github.com/codevise/pageflow/pull/1913))
38
+ - Add theme property for chapter link separator color
39
+ ([#1912](https://github.com/codevise/pageflow/pull/1912))
40
+ - Add widget slot to default navigation
41
+ ([#1911](https://github.com/codevise/pageflow/pull/1911))
42
+ - Improve theme property for default navigation progress bar height
43
+ ([#1910](https://github.com/codevise/pageflow/pull/1910))
44
+ - Add theme option to use smaller menu icon variant
45
+ ([#1909](https://github.com/codevise/pageflow/pull/1909))
46
+ - Allow using custom icons for share options
47
+ ([#1907](https://github.com/codevise/pageflow/pull/1907))
144
48
 
145
- ##### Internal
49
+ [Compare changes](https://github.com/codevise/pageflow/compare/15-x-stable...master)
146
50
 
147
- - Also set Webpack public path for editor JS.
148
- ([#1874](https://github.com/codevise/pageflow/pull/1874))
51
+ None so far.
149
52
 
150
53
  See
151
- [15-7-stable branch](https://github.com/codevise/pageflow/blob/15-7-stable/CHANGELOG.md)
54
+ [15-x-stable branch](https://github.com/codevise/pageflow/blob/15-x-stable/CHANGELOG.md)
152
55
  for previous changes.
@@ -59,12 +59,11 @@ module Pageflow
59
59
 
60
60
  show :title => :name do |account|
61
61
  render 'account_details', :account => account
62
- render 'theming_details', :account => account
63
62
 
64
- tabs_view(Pageflow.config.admin_resource_tabs.find_by_resource(account.default_theming),
63
+ tabs_view(Pageflow.config.admin_resource_tabs.find_by_resource(account),
65
64
  i18n: 'pageflow.admin.resource_tabs',
66
- authorize: :see_theming_admin_tab,
67
- build_args: [account.default_theming])
65
+ authorize: :see_account_admin_tab,
66
+ build_args: [account])
68
67
  end
69
68
 
70
69
  controller do
@@ -76,14 +75,14 @@ module Pageflow
76
75
 
77
76
  def new
78
77
  @account = Account.new
79
- @account.build_default_theming
78
+ @account.build_default_site
80
79
  end
81
80
 
82
81
  def create
83
82
  account_params = permitted_params[:account] || {}
84
83
  @account = Account.new(account_params)
85
- @account.build_default_theming(permitted_params.fetch(:account, {})[
86
- :default_theming_attributes])
84
+ @account.build_default_site(permitted_params.fetch(:account, {})[
85
+ :default_site_attributes])
87
86
  super
88
87
  end
89
88
 
@@ -100,7 +99,7 @@ module Pageflow
100
99
  end
101
100
 
102
101
  def scoped_collection
103
- super.includes(:default_theming)
102
+ super.includes(:default_site)
104
103
  end
105
104
 
106
105
  private
@@ -115,12 +114,12 @@ module Pageflow
115
114
  [
116
115
  :name,
117
116
  :default_file_rights,
118
- default_theming_attributes: permitted_theming_attributes
117
+ default_site_attributes: permitted_site_attributes
119
118
  ] +
120
119
  permitted_attributes_for(:account)
121
120
  end
122
121
 
123
- def permitted_theming_attributes
122
+ def permitted_site_attributes
124
123
  [
125
124
  :cname,
126
125
  :additional_cnames,
@@ -131,15 +130,12 @@ module Pageflow
131
130
  :privacy_link_url,
132
131
  :home_url
133
132
  ] +
134
- permitted_attributes_for(:theming)
133
+ permitted_attributes_for(:site)
135
134
  end
136
135
 
137
136
  def permitted_attributes_for(resource_name)
138
- if params[:id]
139
- Pageflow.config_for(resource).admin_form_inputs.permitted_attributes_for(resource_name)
140
- else
141
- []
142
- end
137
+ config = params[:id] ? Pageflow.config_for(resource) : Pageflow.config
138
+ config.admin_form_inputs.permitted_attributes_for(resource_name)
143
139
  end
144
140
 
145
141
  def permit_feature_states(attributes)
@@ -99,13 +99,13 @@ module Pageflow
99
99
  .order(:name)
100
100
  end)
101
101
 
102
- searchable_select_options(name: :eligible_themings,
103
- text_attribute: :name,
102
+ searchable_select_options(name: :eligible_sites,
103
+ text_attribute: :name_with_account_prefix,
104
104
  scope: lambda do |params|
105
- entry = Entry.find(params[:entry_id])
106
- ThemingPolicy::Scope
107
- .new(current_user, Theming)
108
- .themings_allowed_for(entry.account)
105
+ account = Account.find(params[:account_id])
106
+ SitePolicy::Scope
107
+ .new(current_user, Site)
108
+ .sites_allowed_for(account)
109
109
  end,
110
110
  filter: lambda do |term, scope|
111
111
  scope.ransack(account_name_cont: term).result
@@ -139,11 +139,13 @@ module Pageflow
139
139
  end
140
140
  end
141
141
 
142
- collection_action :entry_type_name_input do
142
+ collection_action :entry_site_and_type_name_input do
143
143
  account = Pageflow::Account.find(params[:account_id])
144
144
  @entry = Pageflow::Entry.new(account: account,
145
145
  type_name: params[:entry_type_name])
146
146
 
147
+ apply_entry_defaults(@entry)
148
+
147
149
  if authorized?(:see_entry_types, account)
148
150
  render(layout: false)
149
151
  else
@@ -197,7 +199,7 @@ module Pageflow
197
199
  helper FoldersHelper
198
200
  helper EntriesHelper
199
201
  helper EmbedCodeHelper
200
- helper ThemingsHelper
202
+ helper SitesHelper
201
203
  helper Admin::EntriesHelper
202
204
  helper Admin::FeaturesHelper
203
205
  helper Admin::FormHelper
@@ -206,6 +208,7 @@ module Pageflow
206
208
  helper Admin::RevisionsHelper
207
209
 
208
210
  helper_method :account_policy_scope
211
+ helper_method :site_policy_scope
209
212
 
210
213
  after_build do |entry|
211
214
  apply_entry_defaults(entry)
@@ -218,8 +221,8 @@ module Pageflow
218
221
  end
219
222
 
220
223
  before_update do |entry|
221
- if entry.account_id_changed? && !authorized?(:update_theming_on, resource)
222
- entry.theming = entry.account.default_theming
224
+ if entry.account_id_changed? && !authorized?(:update_site_on, resource)
225
+ entry.site = entry.account.default_site
223
226
  end
224
227
  end
225
228
 
@@ -232,7 +235,7 @@ module Pageflow
232
235
  def scoped_collection
233
236
  result =
234
237
  super
235
- .includes(:theming,
238
+ .includes(:site,
236
239
  {permalink: :directory},
237
240
  :account,
238
241
  {memberships: :user},
@@ -256,15 +259,15 @@ module Pageflow
256
259
 
257
260
  def apply_entry_defaults(entry)
258
261
  entry.account ||= account_policy_scope.entry_creatable.first || Account.first
259
- entry.theming ||= entry.account.default_theming
262
+ entry.site ||= entry.account.default_site
260
263
  end
261
264
 
262
265
  def account_policy_scope
263
266
  AccountPolicy::Scope.new(current_user, Account)
264
267
  end
265
268
 
266
- def theming_policy_scope
267
- ThemingPolicy::Scope.new(current_user, Theming)
269
+ def site_policy_scope
270
+ SitePolicy::Scope.new(current_user, Site)
268
271
  end
269
272
 
270
273
  def permitted_attributes
@@ -286,10 +289,10 @@ module Pageflow
286
289
  if params[:id]
287
290
  accounts = resource.account
288
291
  else
289
- accounts = account_policy_scope.themings_accessible
292
+ accounts = account_policy_scope.sites_accessible
290
293
  end
291
294
 
292
- result += permitted_theming_attributes(accounts)
295
+ result += permitted_site_attributes(accounts)
293
296
 
294
297
  result
295
298
  end
@@ -301,26 +304,26 @@ module Pageflow
301
304
  end
302
305
  end
303
306
 
304
- def permitted_theming_attributes(accounts)
305
- if (create_or_new_action? || authorized?(:update_theming_on, resource)) &&
306
- theming_params_present? && theming_in_allowed_themings_for?(accounts)
307
- [:theming_id]
307
+ def permitted_site_attributes(accounts)
308
+ if (create_or_new_action? || authorized?(:update_site_on, resource)) &&
309
+ site_params_present? && site_in_allowed_sites_for?(accounts)
310
+ [:site_id]
308
311
  else
309
312
  []
310
313
  end
311
314
  end
312
315
 
313
- def theming_params_present?
314
- params[:entry] && params[:entry][:theming_id]
316
+ def site_params_present?
317
+ params[:entry] && params[:entry][:site_id]
315
318
  end
316
319
 
317
320
  def create_or_new_action?
318
321
  [:create, :new, :permalink_inputs].include?(action_name.to_sym)
319
322
  end
320
323
 
321
- def theming_in_allowed_themings_for?(accounts)
322
- theming_policy_scope.themings_allowed_for(accounts)
323
- .include?(Theming.find(params[:entry][:theming_id]))
324
+ def site_in_allowed_sites_for?(accounts)
325
+ site_policy_scope.sites_allowed_for(accounts)
326
+ .include?(Site.find(params[:entry][:site_id]))
324
327
  end
325
328
 
326
329
  def permitted_account_attributes
@@ -5,7 +5,7 @@ module Pageflow
5
5
  actions :index, :new, :create, :edit, :update
6
6
  form partial: 'form'
7
7
 
8
- belongs_to :account, parent_class: Pageflow::Account
8
+ belongs_to :site, parent_class: Pageflow::Site
9
9
 
10
10
  breadcrumb do
11
11
  breadcrumb_links.first 3
@@ -20,9 +20,7 @@ module Pageflow
20
20
  end
21
21
 
22
22
  def new
23
- account = Account.find(params[:account_id])
24
- @entry_template = EntryTemplate.new(
25
- account: account,
23
+ @entry_template = parent.entry_templates.build(
26
24
  entry_type_name: params[:entry_type_name]
27
25
  )
28
26
 
@@ -32,8 +30,8 @@ module Pageflow
32
30
  end
33
31
 
34
32
  def create
35
- @entry_template = EntryTemplate.new(
36
- entry_template_params.merge(account_id: permitted_params[:account_id])
33
+ @entry_template = parent.entry_templates.build(
34
+ entry_template_params
37
35
  )
38
36
  @page_title = page_title('new', @entry_template.entry_type_name)
39
37
  authorize!(:create, @entry_template)
@@ -87,7 +85,7 @@ module Pageflow
87
85
  end
88
86
 
89
87
  def redirect_path
90
- admin_account_path(params[:account_id], tab: 'entry_templates')
88
+ admin_account_site_path(parent.account, parent, tab: 'entry_templates')
91
89
  end
92
90
 
93
91
  def entry_template_params
@@ -0,0 +1,50 @@
1
+ module Pageflow
2
+ ActiveAdmin.register Site, as: 'Site' do
3
+ belongs_to :account
4
+
5
+ menu false
6
+ actions :index, :show, :new, :edit, :create, :update
7
+
8
+ show do
9
+ render 'attributes_table', site: site
10
+
11
+ tabs_view(Pageflow.config.admin_resource_tabs.find_by_resource(site),
12
+ i18n: 'pageflow.admin.resource_tabs',
13
+ authorize: :see_site_admin_tab,
14
+ build_args: [site])
15
+ end
16
+
17
+ form partial: 'form'
18
+
19
+ permit_params do
20
+ [
21
+ :name,
22
+ :cname,
23
+ :additional_cnames,
24
+ :imprint_link_url,
25
+ :imprint_link_label,
26
+ :copyright_link_url,
27
+ :copyright_link_label,
28
+ :privacy_link_url,
29
+ :home_url
30
+ ] + permitted_admin_form_input_params
31
+ end
32
+
33
+ controller do
34
+ helper Pageflow::Admin::FormHelper
35
+
36
+ def index
37
+ redirect_to admin_account_path(parent, tab: 'sites')
38
+ end
39
+
40
+ private
41
+
42
+ def permitted_admin_form_input_params
43
+ Pageflow
44
+ .config_for(parent)
45
+ .admin_form_inputs
46
+ .permitted_attributes_for(:site)
47
+ end
48
+ end
49
+ end
50
+ end
@@ -88,17 +88,26 @@ jQuery(function($) {
88
88
 
89
89
  $('.admin_entries form.pageflow_entry').each(function() {
90
90
  var accountSelect = $('#entry_account_id', this);
91
- var themingSelect = $('#entry_theming_id', this);
91
+ var siteSelect = $('#entry_site_id', this);
92
92
  var titleInput = $('#entry_title', this);
93
93
 
94
- function updateEntryTypeInput() {
94
+ function updateSiteAndEntryTypeInput() {
95
95
  var selectedAccountId = accountSelect.val();
96
96
 
97
- $.get('/admin/entries/entry_type_name_input' +
97
+ $.get('/admin/entries/entry_site_and_type_name_input' +
98
98
  '?account_id=' + selectedAccountId +
99
99
  '&entry_type_name=' + $('[name="entry[type_name]"]').val())
100
100
  .done(function(response) {
101
- $('#entry_type_name_input').replaceWith(response);
101
+ $('#entry_type_name_input').replaceWith($(response).filter('#entry_type_name_input'));
102
+ $('#entry_site_input').replaceWith($(response).filter('#entry_site_input'));
103
+
104
+ // Set up searchable select
105
+ $(document).trigger('page:load');
106
+
107
+ siteSelect = $('#entry_site_id');
108
+ siteSelect.on('change', updatePermalinkInput);
109
+
110
+ updatePermalinkInput();
102
111
  });
103
112
  }
104
113
 
@@ -119,15 +128,15 @@ jQuery(function($) {
119
128
  function fetchPermalinkInput(callback) {
120
129
  $.get('/admin/entries/permalink_inputs' +
121
130
  '?entry[account_id]=' + accountSelect.val() +
122
- (themingSelect.val() ? '&entry[theming_id]=' + themingSelect.val() : '') +
131
+ (siteSelect.val() ? '&entry[site_id]=' + siteSelect.val() : '') +
123
132
  '&entry[title]=' + encodeURIComponent(titleInput.val()))
124
133
  .done(callback);
125
134
  }
126
135
 
127
- accountSelect.on('change', updateEntryTypeInput);
136
+ accountSelect.on('change', updateSiteAndEntryTypeInput);
128
137
 
129
138
  accountSelect.on('change', updatePermalinkInput);
130
- themingSelect.on('change', updatePermalinkInput);
139
+ siteSelect.on('change', updatePermalinkInput);
131
140
 
132
141
  titleInput.on('change keyup', debounce(updateSlugPlaceholder, 300));
133
142
  });
@@ -6,9 +6,9 @@ module Pageflow
6
6
  include EntryPasswordProtection
7
7
 
8
8
  def index
9
- theming = Theming.for_request(request).with_home_url.first!
9
+ site = Site.for_request(request).with_home_url.first!
10
10
 
11
- redirect_to(theming.home_url)
11
+ redirect_to(site.home_url)
12
12
  end
13
13
 
14
14
  def show
@@ -2,9 +2,9 @@ module Pageflow
2
2
  module Admin
3
3
  # @api private
4
4
  module PermalinksHelper
5
- def collection_for_permalink_directories(theming, permalink)
5
+ def collection_for_permalink_directories(site, permalink)
6
6
  options_from_collection_for_select(
7
- theming.permalink_directories,
7
+ site.permalink_directories,
8
8
  'id',
9
9
  'path',
10
10
  permalink.directory_id
@@ -10,7 +10,7 @@ module Pageflow
10
10
  config = Pageflow.config_for(entry)
11
11
 
12
12
  json.locale entry.locale
13
- json.theming entry.theming.as_json(only: [:privacy_link_url])
13
+ json.site entry.site.as_json(only: [:privacy_link_url])
14
14
  json.enabled_feature_names entry.enabled_feature_names
15
15
  json.page_types PageTypesSeed.new(config).as_json
16
16
 
@@ -24,7 +24,7 @@ module Pageflow
24
24
 
25
25
  def entry_embed_url_options(entry)
26
26
  options = Pageflow.config.entry_embed_url_options
27
- options = options.call(entry.theming) if options.respond_to?(:call)
27
+ options = options.call(entry.site) if options.respond_to?(:call)
28
28
  options
29
29
  end
30
30
  end