integral 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -30
  3. data/Rakefile +1 -1
  4. data/app/assets/images/integral/defaults/no_image_available.jpg +0 -0
  5. data/app/assets/javascripts/integral/backend.js +102 -11
  6. data/app/assets/javascripts/integral/frontend.js +37 -0
  7. data/app/assets/javascripts/integral/support/confirm_modal.coffee +2 -2
  8. data/app/assets/javascripts/integral/support/gallery.coffee +71 -54
  9. data/app/assets/javascripts/integral/support/lib/lazysizes.js +755 -0
  10. data/app/assets/javascripts/integral/support/lib/materialize-tags.js +49 -44
  11. data/app/assets/javascripts/integral/support/ls.instagram.js +57 -0
  12. data/app/assets/javascripts/integral/support/ls.twitter.js +66 -0
  13. data/app/assets/javascripts/integral/support/record_selector.coffee +1 -1
  14. data/app/assets/javascripts/integral/support/remote_form.coffee +5 -2
  15. data/app/assets/stylesheets/integral/backend.sass +2 -1
  16. data/app/assets/stylesheets/integral/backend/_foundation_settings.scss +3 -4
  17. data/app/assets/stylesheets/integral/backend/dashboard-layout.scss +4 -1
  18. data/app/assets/stylesheets/integral/backend/materialize-tags.sass +1 -1
  19. data/app/assets/stylesheets/integral/backend/modules/timeline.scss +214 -0
  20. data/app/assets/stylesheets/integral/backend/shared.sass +80 -11
  21. data/app/assets/stylesheets/integral/frontend.scss +45 -0
  22. data/app/assets/stylesheets/integral/frontend/_foundation_settings.scss +2 -2
  23. data/app/assets/stylesheets/integral/frontend/blog.sass +155 -142
  24. data/app/assets/stylesheets/integral/frontend/layout.sass +3 -3
  25. data/app/assets/stylesheets/integral/frontend/modules/article-footer.scss +55 -0
  26. data/app/assets/stylesheets/integral/frontend/modules/article.scss +34 -0
  27. data/app/assets/stylesheets/integral/frontend/modules/horizontal-post.scss +44 -0
  28. data/app/assets/stylesheets/integral/frontend/modules/inline-articles.scss +23 -0
  29. data/app/assets/stylesheets/integral/frontend/modules/latest-post.scss +37 -0
  30. data/app/assets/stylesheets/integral/frontend/modules/list-widget.scss +50 -0
  31. data/app/assets/stylesheets/integral/frontend/modules/piped-list.scss +33 -0
  32. data/app/assets/stylesheets/integral/frontend/modules/post-tags.scss +19 -0
  33. data/app/assets/stylesheets/integral/frontend/modules/scroll-container.scss +9 -0
  34. data/app/assets/stylesheets/integral/frontend/modules/sidebar-articles.scss +42 -0
  35. data/app/assets/stylesheets/integral/frontend/modules/sidebar-tags.scss +6 -0
  36. data/app/assets/stylesheets/integral/frontend/modules/sidebar-widget.scss +47 -0
  37. data/app/assets/stylesheets/integral/frontend/modules/vertical-post.scss +31 -0
  38. data/app/assets/stylesheets/integral/frontend/share_modal.sass +0 -5
  39. data/app/assets/stylesheets/integral/support/gallery.sass +8 -0
  40. data/app/assets/stylesheets/integral/support/media-query-indicator.sass +6 -0
  41. data/app/controllers/integral/application_controller.rb +7 -1
  42. data/app/controllers/integral/backend/activities_controller.rb +13 -2
  43. data/app/controllers/integral/backend/base_controller.rb +60 -7
  44. data/app/controllers/integral/backend/categories_controller.rb +49 -0
  45. data/app/controllers/integral/backend/pages_controller.rb +7 -2
  46. data/app/controllers/integral/backend/posts_controller.rb +8 -3
  47. data/app/controllers/integral/backend/static_pages_controller.rb +4 -0
  48. data/app/controllers/integral/backend/users_controller.rb +13 -7
  49. data/app/controllers/integral/categories_controller.rb +31 -0
  50. data/app/controllers/integral/pages_controller.rb +1 -1
  51. data/app/controllers/integral/posts_controller.rb +5 -3
  52. data/app/decorators/integral/category_decorator.rb +30 -0
  53. data/app/decorators/integral/category_version_decorator.rb +7 -0
  54. data/app/decorators/integral/image_version_decorator.rb +7 -0
  55. data/app/decorators/integral/list_decorator.rb +1 -1
  56. data/app/decorators/integral/list_version_decorator.rb +7 -0
  57. data/app/decorators/integral/page_version_decorator.rb +7 -0
  58. data/app/decorators/integral/post_decorator.rb +9 -1
  59. data/app/decorators/integral/post_version_decorator.rb +7 -0
  60. data/app/decorators/integral/user_decorator.rb +1 -1
  61. data/app/decorators/integral/user_version_decorator.rb +7 -0
  62. data/app/decorators/integral/version_decorator.rb +51 -12
  63. data/app/helpers/integral/backend/base_helper.rb +56 -2
  64. data/app/helpers/integral/blog_helper.rb +21 -4
  65. data/app/jobs/integral/webhook/delivery_job.rb +37 -0
  66. data/app/mailers/integral/contact_mailer.rb +4 -1
  67. data/app/models/concerns/integral/lazy_contentable.rb +54 -0
  68. data/app/models/concerns/integral/webhook/delivery.rb +30 -0
  69. data/app/models/concerns/integral/webhook/observable.rb +23 -0
  70. data/app/models/integral/category.rb +20 -0
  71. data/app/models/integral/category_version.rb +8 -0
  72. data/app/models/integral/list_item.rb +1 -2
  73. data/app/models/integral/page.rb +18 -3
  74. data/app/models/integral/post.rb +28 -1
  75. data/app/models/integral/version.rb +2 -2
  76. data/app/models/integral/webhook/endpoint.rb +40 -0
  77. data/app/models/integral/webhook/event.rb +20 -0
  78. data/app/policies/integral/base_policy.rb +1 -0
  79. data/app/policies/integral/category_policy.rb +9 -0
  80. data/app/serializers/integral/post_serializer.rb +24 -0
  81. data/app/uploaders/integral/avatar_uploader.rb +1 -1
  82. data/app/views/integral/backend/activities/_activity.haml +21 -0
  83. data/app/views/integral/backend/activities/_grid.haml +1 -2
  84. data/app/views/integral/backend/activities/shared/_grid.haml +3 -2
  85. data/app/views/integral/backend/activities/shared/{_listing.haml → index.haml} +1 -0
  86. data/app/views/integral/backend/activities/shared/{_log.haml → show.haml} +0 -0
  87. data/app/views/integral/backend/categories/_modal.haml +25 -0
  88. data/app/views/integral/backend/lists/_child_fields.haml +1 -1
  89. data/app/views/integral/backend/lists/_item_container.haml +1 -1
  90. data/app/views/integral/backend/lists/_item_modal.haml +1 -1
  91. data/app/views/integral/backend/lists/_list_item_fields.haml +1 -1
  92. data/app/views/integral/backend/pages/_form.haml +1 -4
  93. data/app/views/integral/backend/pages/_grid.haml +34 -9
  94. data/app/views/integral/backend/pages/edit.haml +9 -3
  95. data/app/views/integral/backend/pages/index.haml +11 -21
  96. data/app/views/integral/backend/pages/list.haml +22 -0
  97. data/app/views/integral/backend/pages/show.haml +48 -0
  98. data/app/views/integral/backend/posts/_form.haml +8 -6
  99. data/app/views/integral/backend/posts/_grid.haml +33 -7
  100. data/app/views/integral/backend/posts/index.haml +13 -19
  101. data/app/views/integral/backend/posts/list.haml +20 -0
  102. data/app/views/integral/backend/posts/show.haml +54 -0
  103. data/app/views/integral/backend/shared/_activity_modal.haml +13 -0
  104. data/app/views/integral/backend/shared/cards/_categories.haml +34 -0
  105. data/app/views/integral/backend/{static_pages/_card.haml → shared/cards/_object.haml} +0 -0
  106. data/app/views/integral/backend/shared/cards/_recent_activity.haml +20 -0
  107. data/app/views/integral/backend/shared/cards/_recent_pages.haml +19 -0
  108. data/app/views/integral/backend/shared/cards/_recent_posts.haml +18 -0
  109. data/app/views/integral/backend/shared/cards/_recent_user_activity.haml +1 -0
  110. data/app/views/integral/backend/shared/cards/_recent_users.haml +19 -0
  111. data/app/views/integral/backend/shared/cards/_top_post_authors.haml +19 -0
  112. data/app/views/integral/backend/shared/record_selector/_record.haml +6 -4
  113. data/app/views/integral/backend/static_pages/dashboard.haml +13 -11
  114. data/app/views/integral/backend/users/_grid.haml +24 -7
  115. data/app/views/integral/backend/users/index.haml +11 -17
  116. data/app/views/integral/backend/users/list.haml +18 -0
  117. data/app/views/integral/backend/users/show.haml +5 -11
  118. data/app/views/integral/categories/show.haml +5 -0
  119. data/app/views/integral/posts/_article_footer.haml +17 -0
  120. data/app/views/integral/posts/_card.haml +11 -0
  121. data/app/views/integral/posts/_latest_post.haml +8 -0
  122. data/app/views/integral/posts/_most_read_section.haml +8 -0
  123. data/app/views/integral/posts/_post.haml +11 -0
  124. data/app/views/integral/posts/_similar_posts.haml +5 -0
  125. data/app/views/integral/posts/index.haml +6 -5
  126. data/app/views/integral/posts/templates/default.haml +34 -33
  127. data/app/views/integral/shared/_subscribe_modal.haml +14 -0
  128. data/app/views/integral/shared/blog/_categories.haml +15 -0
  129. data/app/views/integral/shared/blog/_layout.haml +9 -0
  130. data/app/views/integral/shared/blog/_sidebar.haml +10 -0
  131. data/app/views/integral/shared/gallery/_placeholder.haml +1 -1
  132. data/app/views/integral/shared/gallery/_slide.haml +2 -2
  133. data/app/views/integral/shared/gallery/gallery.haml +5 -2
  134. data/app/views/integral/shared/sidebar/_item.haml +8 -0
  135. data/app/views/integral/shared/sidebar/_newsletter_signup.haml +7 -0
  136. data/app/views/integral/shared/sidebar/_popular_posts.haml +7 -0
  137. data/app/views/integral/shared/sidebar/_popular_tags.haml +7 -0
  138. data/app/views/integral/shared/sidebar/_recent_posts.haml +7 -0
  139. data/app/views/integral/tags/index.haml +2 -2
  140. data/app/views/integral/tags/show.haml +3 -6
  141. data/app/views/layouts/integral/backend.html.haml +3 -0
  142. data/app/views/layouts/integral/backend/_main_menu_items.haml +10 -0
  143. data/app/views/layouts/integral/frontend.html.haml +3 -3
  144. data/config/locales/en.yml +52 -49
  145. data/db/migrate/20190414172018_create_webhook_endpoints.rb +10 -0
  146. data/db/migrate/20190929191412_add_integral_post_categories.rb +13 -0
  147. data/db/migrate/20191203090008_add_image_to_integral_categories.rb +6 -0
  148. data/db/migrate/20200401210442_create_category_versions.rb +20 -0
  149. data/db/seeds.rb +3 -1
  150. data/lib/generators/integral/assets_generator.rb +2 -2
  151. data/lib/generators/integral/install_generator.rb +1 -1
  152. data/lib/generators/integral/views_generator.rb +1 -1
  153. data/lib/generators/templates/integral.rb +5 -0
  154. data/lib/integral.rb +3 -30
  155. data/lib/integral/acts_as_listable.rb +2 -2
  156. data/lib/integral/chart_renderer/base.rb +2 -0
  157. data/lib/integral/content_renderer.rb +2 -2
  158. data/lib/integral/engine.rb +2 -2
  159. data/lib/integral/grids/activities_grid.rb +15 -1
  160. data/lib/integral/list_item_renderer.rb +4 -2
  161. data/lib/integral/list_renderer.rb +1 -0
  162. data/lib/integral/middleware/page_router.rb +15 -6
  163. data/lib/integral/router.rb +19 -3
  164. data/lib/integral/version.rb +1 -1
  165. data/lib/integral/widgets/swiper_list.rb +3 -2
  166. data/public/images/integral/demo/continous-integration.png +0 -0
  167. data/public/images/integral/demo/foundation-frontend-framework.jpg +0 -0
  168. data/public/images/integral/demo/heroku.png +0 -0
  169. data/public/images/integral/demo/integral-cms-without-hassle.jpg +0 -0
  170. data/public/images/integral/demo/integral-features-activity-tracking.jpg +0 -0
  171. data/public/images/integral/demo/integral-features-contact-form.png +0 -0
  172. data/public/images/integral/demo/integral-features-design.jpg +0 -0
  173. data/public/images/integral/demo/integral-features-dynamic-pages.jpg +0 -0
  174. data/public/images/integral/demo/integral-features-image-management.jpg +0 -0
  175. data/public/images/integral/demo/integral-features-integrated-blog.jpg +0 -0
  176. data/public/images/integral/demo/integral-features-list-management.jpg +0 -0
  177. data/public/images/integral/demo/integral-features-seo-ready.jpg +0 -0
  178. data/public/images/integral/demo/integral-features-user-management.jpg +0 -0
  179. data/public/images/integral/demo/integral-presentation.png +0 -0
  180. data/spec/factories.rb +15 -7
  181. metadata +110 -98
  182. data/app/assets/javascripts/ckeditor/plugins/integral-card/icons/copywidget.png +0 -0
  183. data/app/assets/javascripts/ckeditor/plugins/integral-card/icons/editwidget.png +0 -0
  184. data/app/assets/javascripts/ckeditor/plugins/integral-card/icons/hidpi/copywidget.png +0 -0
  185. data/app/assets/javascripts/ckeditor/plugins/integral-card/icons/hidpi/editwidget.png +0 -0
  186. data/app/assets/javascripts/ckeditor/plugins/integral-card/icons/hidpi/removewidget.png +0 -0
  187. data/app/assets/javascripts/ckeditor/plugins/integral-card/icons/hidpi/widget.png +0 -0
  188. data/app/assets/javascripts/ckeditor/plugins/integral-card/icons/removewidget.png +0 -0
  189. data/app/assets/javascripts/ckeditor/plugins/integral-card/icons/widget.png +0 -0
  190. data/app/assets/javascripts/ckeditor/plugins/integral-card/plugin.js +0 -86
  191. data/app/assets/javascripts/ckeditor/plugins/integralrecentposts/dialogs/integralrecentposts.js +0 -40
  192. data/app/assets/javascripts/ckeditor/plugins/integralrecentposts/plugin.js +0 -32
  193. data/app/assets/javascripts/ckeditor/plugins/numericinput/LICENSE.md +0 -363
  194. data/app/assets/javascripts/ckeditor/plugins/numericinput/README.md +0 -16
  195. data/app/assets/javascripts/ckeditor/plugins/numericinput/plugin.js +0 -354
  196. data/app/assets/stylesheets/integral/frontend.sass +0 -25
  197. data/app/views/integral/backend/pages/activities.haml +0 -2
  198. data/app/views/integral/backend/pages/activity.haml +0 -1
  199. data/app/views/integral/backend/posts/activities.haml +0 -3
  200. data/app/views/integral/backend/posts/activity.haml +0 -1
  201. data/app/views/integral/posts/_collection.haml +0 -4
  202. data/app/views/integral/posts/_item.haml +0 -16
  203. data/app/views/integral/shared/_blog_layout.haml +0 -15
  204. data/app/views/integral/shared/_blog_sidebar.haml +0 -49
  205. data/lib/integral/slack_bot.rb +0 -45
@@ -1,6 +1,5 @@
1
1
  $facebook-color: #3b5998
2
2
  $twitter-color: #1da1f2
3
- $google-plus-color: #dd4b39
4
3
 
5
4
  #share-modal
6
5
  text-align: center
@@ -19,7 +18,3 @@ $google-plus-color: #dd4b39
19
18
  background-color: $twitter-color
20
19
  &:hover
21
20
  background-color: darken($twitter-color, 10%)
22
- &.google-plus
23
- background-color: $google-plus-color
24
- &:hover
25
- background-color: darken($google-plus-color, 10%)
@@ -1,7 +1,15 @@
1
1
  .modal--gallery
2
2
  padding-top: 3em
3
+ iframe
4
+ height: 100%
5
+ width: 100%
3
6
  .content
4
7
  visibility: hidden
8
+ width: 100%
9
+ height: 100%
10
+ text-align: center
11
+ > img
12
+ max-height: 100%
5
13
  .placeholder
6
14
  margin: 10em 0
7
15
  text-align: center
@@ -3,6 +3,8 @@
3
3
  * Red: Small Screens
4
4
  * Orange: Medium Screens
5
5
  * Green: Large and above
6
+ * Blue: Xlarge Screens
7
+ * Black: XXlarge and above
6
8
  */
7
9
  .query-indicator
8
10
  display: block
@@ -22,4 +24,8 @@
22
24
  background-color: #ffa500
23
25
  @include breakpoint(large)
24
26
  background-color: #008000
27
+ @include breakpoint(xlarge)
28
+ background-color: #1b8ecf
29
+ @include breakpoint(xxlarge)
30
+ background-color: #0c1116
25
31
 
@@ -11,13 +11,19 @@ module Integral
11
11
  # Search Engine Optimization
12
12
  # before_render :load_meta_tags
13
13
 
14
-
15
14
  # Override added as workaround for before_render Rails 5 incompatibility
16
15
  def render(*args, &block)
17
16
  before_render
18
17
  super
19
18
  end
20
19
 
20
+ helper_method :category_path
21
+
22
+ # @return [String] path to category page
23
+ def category_path(category)
24
+ "/#{Integral.blog_namespace}/#{category.slug}"
25
+ end
26
+
21
27
  private
22
28
 
23
29
  # Actions that should be carried out before rendering
@@ -2,9 +2,16 @@ module Integral
2
2
  module Backend
3
3
  # Activity management
4
4
  class ActivitiesController < BaseController
5
- before_action :authorize_with_klass
5
+ before_action :authorize_with_klass, except: [:widget]
6
6
  before_action -> { set_grid }
7
7
 
8
+ def widget
9
+ activities = cast_activities(@grid.assets.limit(10))
10
+ last_created_at = activities.last.created_at.utc if activities.present?
11
+
12
+ render json: { content: render_to_string(partial: 'integral/backend/activities/activity', collection: activities), last_created_at: last_created_at }
13
+ end
14
+
8
15
  # POST /grid
9
16
  # AJAX grid for activities
10
17
  # TODO: Could move this grid action into index action and respond different if json request
@@ -44,8 +51,12 @@ module Integral
44
51
  authorize Version
45
52
  end
46
53
 
54
+ def resource_klass
55
+ Integral::Version
56
+ end
57
+
47
58
  def grid_options
48
- grid_params = params[:grid].present? ? params[:grid].permit(:descending, :order, :page, :user, :action, :object) : {}
59
+ grid_params = params[:grid].present? ? params[:grid].permit(:descending, :order, :page, :user, :action, :object, :created_at, :item_id) : {}
49
60
  grid_params.delete_if { |_k, v| v.empty? }
50
61
  { 'order' => 'date', 'page' => 1, descending: true }.merge(grid_params)
51
62
  end
@@ -26,9 +26,39 @@ module Integral
26
26
  include Pundit
27
27
  rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
28
28
 
29
+ # GET /:id
30
+ # Show resource
31
+ def show
32
+ add_breadcrumb I18n.t('integral.navigation.list'), "list_backend_#{controller_name}_path".to_sym
33
+ add_breadcrumb I18n.t('integral.actions.view'), "backend_#{controller_name.singularize}_path".to_sym
34
+ end
35
+
29
36
  # GET /
30
37
  # Lists all resources
31
38
  def index
39
+ # TODO: This default behaviour will switch to 'list' action
40
+
41
+ respond_to do |format|
42
+ format.html do
43
+ set_grid
44
+ end
45
+
46
+ format.json do
47
+ if params[:gridview].present?
48
+ set_grid
49
+ render json: { content: render_to_string(partial: "integral/backend/#{controller_name}/grid", locals: { grid: @grid }) }
50
+ else
51
+ respond_to_record_selector
52
+ end
53
+ end
54
+ end
55
+ end
56
+
57
+ # GET /list
58
+ # Lists all resources
59
+ def list
60
+ add_breadcrumb I18n.t('integral.navigation.list'), "new_backend_#{controller_name.singularize}_path".to_sym
61
+
32
62
  respond_to do |format|
33
63
  format.html do
34
64
  set_grid
@@ -70,6 +100,7 @@ module Integral
70
100
  # GET /:id/edit
71
101
  # Resource edit screen
72
102
  def edit
103
+ add_breadcrumb I18n.t('integral.actions.view'), "backend_#{controller_name.singularize}_path".to_sym
73
104
  add_breadcrumb I18n.t('integral.navigation.edit'), "edit_backend_#{controller_name.singularize}_path".to_sym
74
105
  end
75
106
 
@@ -86,12 +117,21 @@ module Integral
86
117
  # DELETE /:id
87
118
  def destroy
88
119
  if @resource.destroy
89
- respond_successfully(notification_message('delete_success'), send("backend_#{controller_name}_path"))
120
+ respond_to do |format|
121
+ format.html { respond_successfully(notification_message('delete_success'), send("backend_#{controller_name}_path")) }
122
+ format.js { head :no_content }
123
+ end
90
124
  else
91
- error_message = @resource.errors.full_messages.to_sentence
92
- flash[:error] = "#{notification_message('delete_failure')} - #{error_message}"
125
+ respond_to do |format|
126
+ format.html do
127
+ error_message = @resource.errors.full_messages.to_sentence
128
+ flash[:error] = "#{notification_message('delete_failure')} - #{error_message}"
129
+
130
+ redirect_to send("backend_#{controller_name}_path")
131
+ end
132
+ format.js { head :unprocessable_entity }
133
+ end
93
134
 
94
- redirect_to send("backend_#{controller_name}_path")
95
135
  end
96
136
  end
97
137
 
@@ -121,7 +161,7 @@ module Integral
121
161
  end
122
162
 
123
163
  respond_to do |format|
124
- format.html
164
+ format.html { render template: 'integral/backend/activities/shared/index', locals: { form_url: send("activities_backend_#{controller_name.singularize}_url", @resource.id) } }
125
165
  format.json { render json: { content: render_to_string(partial: 'integral/backend/activities/shared/grid', locals: { grid: @grid }) } }
126
166
  end
127
167
  end
@@ -134,6 +174,8 @@ module Integral
134
174
  add_breadcrumb I18n.t('integral.actions.view')
135
175
 
136
176
  @activity = resource_version_klass.find(params[:activity_id]).decorate
177
+
178
+ render template: 'integral/backend/activities/shared/show', locals: { record: @resource.decorate }
137
179
  end
138
180
 
139
181
  private
@@ -200,7 +242,8 @@ module Integral
200
242
  def notification_message(type_namespace, object_namespace = nil)
201
243
  object_namespace = controller_name if object_namespace.nil?
202
244
 
203
- I18n.t("integral.backend.#{object_namespace}.notification.#{type_namespace}")
245
+ I18n.t("integral.backend.#{object_namespace}.notification.#{type_namespace}",
246
+ default: I18n.t("integral.backend.notifications.#{type_namespace}", type: resource_klass.model_name.human))
204
247
  end
205
248
 
206
249
  def set_grid
@@ -209,10 +252,18 @@ module Integral
209
252
  end
210
253
  end
211
254
 
255
+ helper_method :resource_klass
212
256
  def resource_klass
213
257
  controller_name.classify.constantize
214
258
  end
215
259
 
260
+ helper_method :cast_activities
261
+ def cast_activities(activites)
262
+ activites.map do |version|
263
+ version.becomes(version.item_type.constantize.paper_trail.version_class).decorate
264
+ end
265
+ end
266
+
216
267
  def resource_grid_klass
217
268
  "Integral::Grids::#{controller_name.classify.pluralize}Grid".constantize
218
269
  end
@@ -222,7 +273,9 @@ module Integral
222
273
  end
223
274
 
224
275
  def set_resource
225
- @resource = resource_klass.find(params[:id])
276
+ scope = ['activities', 'activity'].include?(action_name) ? resource_klass.unscoped : resource_klass
277
+
278
+ @resource = scope.find(params[:id])
226
279
  end
227
280
 
228
281
  def grid_options
@@ -0,0 +1,49 @@
1
+ module Integral
2
+ module Backend
3
+ # Categories controller
4
+ class CategoriesController < BaseController
5
+ before_action :authorize_with_klass, except: %i[activities activity]
6
+ before_action :set_resource, except: %i[create new index list]
7
+
8
+ # PUT /:id
9
+ # Updating a resource
10
+ def update
11
+ if @resource.update(resource_params)
12
+ flash.now[:notice] = notification_message('edit_success')
13
+ render json: { redirect_url: request.referrer }, status: :created
14
+ else
15
+ render json: { message: notification_message('edit_failure') }, status: :unprocessable_entity
16
+ end
17
+ end
18
+
19
+ # GET /:id/edit
20
+ # Category update screen
21
+ def edit
22
+ render json: { content: render_to_string(partial: 'integral/backend/categories/modal', locals: { category: @resource, title: 'Edit Category', modal_id: "modal--category-edit-#{@resource.id}" }) }
23
+ end
24
+
25
+ # POST /
26
+ # Category creation
27
+ def create
28
+ @resource = Integral::Category.new(resource_params)
29
+
30
+ if @resource.save
31
+ flash.now[:notice] = notification_message('creation_success')
32
+ render json: { redirect_url: request.referrer }, status: :created
33
+ else
34
+ render json: { message: notification_message('creation_failure') }, status: :unprocessable_entity
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ def resource_params
41
+ params.require(:category).permit(:title, :slug, :description, :image_id)
42
+ end
43
+
44
+ def resource_klass
45
+ Integral::Category
46
+ end
47
+ end
48
+ end
49
+ end
@@ -2,8 +2,8 @@ module Integral
2
2
  module Backend
3
3
  # Pages controller
4
4
  class PagesController < BaseController
5
- before_action :authorize_with_klass, only: %i[index new create edit update destroy]
6
- before_action :set_resource, only: %i[edit update destroy show activities activity duplicate]
5
+ before_action :authorize_with_klass, except: %i[activities activity]
6
+ before_action :set_resource, except: %i[create new index list]
7
7
 
8
8
  # POST /:id/duplicate
9
9
  # Duplicate a resource
@@ -17,10 +17,15 @@ module Integral
17
17
  # @return [BasePolicy] current authorization policy
18
18
  def current_policy
19
19
  return policy(@page) if @page
20
+
20
21
  policy(Integral::Page.new)
21
22
  end
22
23
  helper_method :current_policy
23
24
 
25
+ # GET /
26
+ # Page dashboard screen
27
+ def index; end
28
+
24
29
  private
25
30
 
26
31
  def resource_params
@@ -2,8 +2,8 @@ module Integral
2
2
  module Backend
3
3
  # Post management
4
4
  class PostsController < BaseController
5
- before_action :authorize_with_klass, only: %i[index new create edit update destroy]
6
- before_action :set_resource, only: %i[edit update destroy show activities activity duplicate]
5
+ before_action :authorize_with_klass, except: %i[activities activity]
6
+ before_action :set_resource, except: %i[create new index list]
7
7
 
8
8
  # POST /:id/duplicate
9
9
  # Duplicate a resource
@@ -14,6 +14,7 @@ module Integral
14
14
  cloned_resource.tag_list = @resource.tag_list_on(@resource.tag_context)
15
15
  cloned_resource.slug = @resource.slug
16
16
  cloned_resource.status = :draft
17
+ cloned_resource.published_at = nil
17
18
  end
18
19
  end
19
20
 
@@ -24,10 +25,14 @@ module Integral
24
25
  @resource.user = current_user
25
26
  end
26
27
 
28
+ # GET /
29
+ # Post dashboard screen
30
+ def index; end
31
+
27
32
  private
28
33
 
29
34
  def resource_params
30
- permitted_post_params = %i[title slug body description tag_list image_id preview_image_id status lock_version user_id]
35
+ permitted_post_params = %i[title slug body description tag_list image_id preview_image_id status lock_version user_id category_id]
31
36
 
32
37
  permitted_post_params.concat Integral.additional_post_params
33
38
  params.require(:post).permit(*permitted_post_params)
@@ -6,6 +6,10 @@ module Integral
6
6
  # Dashboard to show website stats and other useful information
7
7
  def dashboard; end
8
8
 
9
+ def resource_klass
10
+ nil
11
+ end
12
+
9
13
  private
10
14
 
11
15
  def set_breadcrumbs; end
@@ -2,9 +2,9 @@ module Integral
2
2
  module Backend
3
3
  # Users controller
4
4
  class UsersController < BaseController
5
- before_action :set_resource, only: %i[edit update destroy show activities activity]
5
+ before_action :set_resource, except: %i[create new index list]
6
+ before_action :authorize_with_klass, except: %i[activities activity show edit update]
6
7
  before_action :authorize_with_instance, only: %i[show edit update]
7
- before_action :authorize_with_klass, only: %i[index new create destroy]
8
8
  before_action -> { set_grid }, only: [:index]
9
9
 
10
10
  # GET /
@@ -48,9 +48,9 @@ module Integral
48
48
  @resource = User.invite!(resource_params, current_user)
49
49
 
50
50
  if @resource.errors.present?
51
- respond_failure I18n.t('integral.backend.users.notification.creation_failure'), 'new'
51
+ respond_failure(notification_message('creation_failure'), 'new')
52
52
  else
53
- respond_successfully I18n.t('integral.backend.users.notification.creation_success'), backend_user_path(@resource)
53
+ respond_successfully(notification_message('creation_success'), backend_user_path(@resource))
54
54
  end
55
55
  end
56
56
 
@@ -61,20 +61,26 @@ module Integral
61
61
  authorized_user_params.delete(:role_ids) unless policy(current_user).manager?
62
62
 
63
63
  if @resource.update(authorized_user_params)
64
- respond_successfully I18n.t('integral.backend.users.notification.edit_success'), backend_user_path(@resource)
64
+ respond_successfully(notification_message('edit_success'), backend_user_path(@resource))
65
65
  else
66
- respond_failure I18n.t('integral.backend.users.notification.edit_failure'), 'edit'
66
+ respond_failure(notification_message('edit_failure'), 'edit')
67
67
  end
68
68
  end
69
69
 
70
70
  private
71
71
 
72
+ def white_listed_grid_params
73
+ %i[descending order page user action object name status]
74
+ end
75
+
72
76
  def resource_klass
73
77
  Integral::User
74
78
  end
75
79
 
76
80
  def resource_params
77
- return params.require(:user).permit(:name, :email, :avatar, :locale, role_ids: []) unless params[:user][:password].present?
81
+ unless params[:user][:password].present?
82
+ return params.require(:user).permit(:name, :email, :avatar, :locale, role_ids: [])
83
+ end
78
84
 
79
85
  params.require(:user).permit(:name, :email, :avatar, :locale, :password, :password_confirmation, role_ids: [])
80
86
  end
@@ -0,0 +1,31 @@
1
+ module Integral
2
+ # Front end categories controller
3
+ class CategoriesController < BlogController
4
+ before_action :find_resource, only: [:show]
5
+
6
+ # GET /:id
7
+ # Presents all posts with particular category
8
+ def show
9
+ add_breadcrumb @resource.title, nil
10
+
11
+ @meta_data = {
12
+ page_title: @resource.title,
13
+ page_description: @resource.description,
14
+ image: @resource&.image&.url
15
+ }
16
+
17
+ @posts = Integral::Post.published.where(category_id: @resource.id).paginate(page: params[:page])
18
+ end
19
+
20
+ private
21
+
22
+ def find_resource
23
+ @resource = Integral::Category.find(params[:id])
24
+ end
25
+
26
+ def set_breadcrumbs
27
+ super
28
+ add_breadcrumb t('integral.breadcrumbs.blog'), :posts_url
29
+ end
30
+ end
31
+ end
@@ -10,7 +10,7 @@ module Integral
10
10
  @meta_data = {
11
11
  page_title: @page.title,
12
12
  page_description: @page.description,
13
- open_graph: {
13
+ open_graph: {
14
14
  image: @page.image&.url(:large)
15
15
  }
16
16
  }