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
@@ -0,0 +1,10 @@
1
+ class CreateWebhookEndpoints < ActiveRecord::Migration[5.1]
2
+ def change
3
+ create_table :integral_webhook_endpoints do |t|
4
+ t.string :target_url, null: false
5
+ t.string :events, null: false, array: true
6
+ t.timestamps
7
+ t.index :events
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ class AddIntegralPostCategories < ActiveRecord::Migration[5.1]
2
+ def change
3
+ create_table :integral_categories do |t|
4
+ t.string :title
5
+ t.string :description
6
+ t.string :slug, unique: true
7
+
8
+ t.timestamps null: false
9
+ end
10
+
11
+ add_reference :integral_posts, :category, index: true
12
+ end
13
+ end
@@ -0,0 +1,6 @@
1
+ class AddImageToIntegralCategories < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_column :integral_categories, :image_id, :bigint
4
+ add_index :integral_categories, :image_id
5
+ end
6
+ end
@@ -0,0 +1,20 @@
1
+ class CreateCategoryVersions < ActiveRecord::Migration[5.2]
2
+ # The largest text column available in all supported RDBMS is
3
+ # 1024^3 - 1 bytes, roughly one gibibyte. We specify a size
4
+ # so that MySQL will use `longtext` instead of `text`. Otherwise,
5
+ # when serializing very large objects, `text` might not be big enough.
6
+ TEXT_BYTES = 1_073_741_823
7
+
8
+ def change
9
+ create_table :integral_category_versions do |t|
10
+ t.string :item_type, {:null=>false}
11
+ t.integer :item_id, null: false
12
+ t.string :event, null: false
13
+ t.string :whodunnit
14
+ t.text :object, limit: TEXT_BYTES
15
+ t.text :object_changes, limit: TEXT_BYTES
16
+ t.datetime :created_at
17
+ end
18
+ add_index :integral_category_versions, %i(item_type item_id)
19
+ end
20
+ end
@@ -34,13 +34,15 @@ Integral::Page.create!(title: 'Integral CMS - Demo Page',
34
34
  status: 1)
35
35
 
36
36
  # Demo Post
37
+ category = Integral::Category.create!(title: 'Uncategorised', description: "Posts which we haven't yet categorized but are sure to grab your attention", slug: 'uncategorized')
37
38
  Integral::Post.create!(title: 'Integral CMS - Demo Post',
38
39
  description:'Integral CMS demo post. Integral is a rails content management system (CMS) which gives developers the ability to create a modern website with all the bells and whistles without the hassle.',
39
40
  body: File.read(File.join(Integral::Engine.root.join('public', 'integral', 'ckeditor_demo_content.html'))),
40
41
  slug: 'integral-demo',
41
42
  user: user,
42
43
  tag_list: 'integral-cms,example-tag',
43
- status: 1)
44
+ status: 1,
45
+ category: category)
44
46
 
45
47
  # Main Menu
46
48
  Integral::List.create!({ title: 'Main Menu', list_items: [
@@ -6,7 +6,7 @@ module Integral
6
6
  # @example Generate all Integral assets
7
7
  # rails g integral:assets --assets 'backend frontend email'
8
8
  class AssetsGenerator < Rails::Generators::Base
9
- source_root File.expand_path('../../../../app/assets', __FILE__)
9
+ source_root File.expand_path('../../../app/assets', __dir__)
10
10
  class_option :asset_list, aliases: '-a', type: :array, default: 'frontend'
11
11
  desc 'Copies Integral assets to your application'
12
12
 
@@ -24,7 +24,7 @@ module Integral
24
24
  return unless options['asset_list'].include?('frontend')
25
25
 
26
26
  file 'javascripts/integral/frontend.js'
27
- file 'stylesheets/integral/frontend.sass'
27
+ file 'stylesheets/integral/frontend.scss'
28
28
  directory 'stylesheets/integral/frontend'
29
29
  end
30
30
 
@@ -3,7 +3,7 @@ module Integral
3
3
  module Generators
4
4
  # Runs setup for an Integral Application
5
5
  class InstallGenerator < Rails::Generators::Base
6
- source_root File.expand_path('../../templates', __FILE__)
6
+ source_root File.expand_path('../templates', __dir__)
7
7
  desc 'Creates Integral, Carrierwave, CarrierwaveBackgrounder & Sitemap initializers'
8
8
 
9
9
  # Copies over necessary initialiser files
@@ -6,7 +6,7 @@ module Integral
6
6
  # @example Generate all Integral views
7
7
  # rails g integral:views --views 'backend frontend devise mailer'
8
8
  class ViewsGenerator < Rails::Generators::Base
9
- source_root File.expand_path('../../../../app/views', __FILE__)
9
+ source_root File.expand_path('../../../app/views', __dir__)
10
10
  class_option :views, aliases: '-v', type: :array, default: 'frontend'
11
11
  desc 'Copies Integral views to your application'
12
12
 
@@ -61,6 +61,11 @@ Integral.configure do |config|
61
61
  #
62
62
  # config.additional_page_templates = [:full_width]
63
63
 
64
+ # Add additional tracked classes to include within activity tracking
65
+ # Default is []
66
+ #
67
+ # config.additional_tracked_classes = [MyCustomClass]
68
+
64
69
  # Configure what page paths are protected from user entry to prevent accidentally overriding
65
70
  # config.black_listed_paths = [
66
71
  # '/admin/',
@@ -5,7 +5,6 @@ require 'integral/version'
5
5
  require 'integral/router'
6
6
  require 'integral/middleware/page_router'
7
7
  require 'integral/engine'
8
- require 'integral/slack_bot'
9
8
  require 'integral/button_link_renderer'
10
9
  require 'integral/google_tag_manager'
11
10
  require 'integral/foundation_builder'
@@ -34,107 +33,81 @@ module Integral
34
33
  yield(self)
35
34
  end
36
35
 
37
- #
38
36
  mattr_accessor :backend_namespace
39
37
  @@backend_namespace = 'admin'
40
38
 
41
- #
42
39
  mattr_accessor :backend_locales
43
40
  @@backend_locales = [:en]
44
41
 
45
- #
46
42
  mattr_accessor :additional_settings_params
47
43
  @@additional_settings_params = []
48
44
 
49
- #
50
45
  mattr_accessor :additional_widgets
51
46
  @@additional_widgets = []
52
47
 
53
- #
54
48
  mattr_accessor :additional_post_params
55
49
  @@additional_post_params = []
56
50
 
57
- #
58
51
  mattr_accessor :additional_page_params
59
52
  @@additional_page_params = []
60
53
 
61
- #
62
54
  mattr_accessor :gtm_container_id
63
55
  @@gtm_container_id = ''
64
56
 
65
- #
66
57
  mattr_accessor :blog_enabled
67
58
  @@blog_enabled = true
68
59
 
69
- #
70
60
  mattr_accessor :blog_namespace
71
61
  @@blog_namespace = 'blog'
72
62
 
73
- #
74
63
  mattr_accessor :black_listed_paths
75
64
  @@black_listed_paths = ['/admin']
76
65
 
77
- #
78
66
  mattr_accessor :root_path
79
67
  @@root_path = nil
80
68
 
81
- #
82
69
  mattr_accessor :frontend_parent_controller
83
70
  @@frontend_parent_controller = 'Integral::ApplicationController'
84
71
 
85
- #
86
72
  mattr_accessor :editor_image_size_limit
87
73
  @@editor_image_size_limit = [1600, 1600]
88
74
 
89
- #
90
75
  mattr_accessor :image_thumbnail_size
91
76
  @@image_thumbnail_size = [50, 50]
92
77
 
93
- #
94
78
  mattr_accessor :image_small_size
95
79
  @@image_small_size = [500, 500]
96
80
 
97
- #
98
81
  mattr_accessor :image_medium_size
99
82
  @@image_medium_size = [800, 800]
100
83
 
101
- #
102
84
  mattr_accessor :image_large_size
103
85
  @@image_large_size = [1600, 1600]
104
86
 
105
- #
106
87
  mattr_accessor :additional_page_templates
107
88
  @@additional_page_templates = []
108
89
 
109
- #
90
+ mattr_accessor :additional_tracked_classes
91
+ @@additional_tracked_classes = []
92
+
110
93
  mattr_accessor :compression_enabled
111
94
  @@compression_enabled = true
112
95
 
113
- #
114
96
  mattr_accessor :image_compression_quality
115
97
  @@image_compression_quality = 85
116
98
 
117
- #
118
99
  mattr_accessor :editable_persisted_images
119
100
  @@editable_persisted_images = false
120
101
 
121
- #
122
- mattr_accessor :slack_web_hook_url
123
- @@slack_web_hook_url = nil
124
-
125
- #
126
102
  mattr_accessor :description_length_maximum
127
103
  @@description_length_maximum = 300
128
104
 
129
- #
130
105
  mattr_accessor :description_length_minimum
131
106
  @@description_length_minimum = 50
132
107
 
133
- #
134
108
  mattr_accessor :title_length_maximum
135
109
  @@title_length_maximum = 60
136
110
 
137
- #
138
111
  mattr_accessor :title_length_minimum
139
112
  @@title_length_minimum = 4
140
113
 
@@ -2,8 +2,8 @@ module Integral
2
2
  # Handles listable behaviour
3
3
  module ActsAsListable
4
4
  class << self
5
- # Keeps a track of listable objects
6
- attr_writer :objects
5
+ # Keeps a track of listable objects
6
+ attr_writer :objects
7
7
  end
8
8
 
9
9
  # Accessor for listable objects
@@ -24,6 +24,7 @@ module Integral
24
24
  data = process_data
25
25
 
26
26
  return respond_with_chart(data) if data_available?(data)
27
+
27
28
  respond_with_no_data_available
28
29
  end
29
30
 
@@ -64,6 +65,7 @@ module Integral
64
65
  data = data.map(&:uniq).uniq
65
66
 
66
67
  return true if data.length > 1
68
+
67
69
  data = data.first
68
70
  end
69
71
 
@@ -59,8 +59,8 @@ module Integral
59
59
  return widget_not_available_message unless widget.present?
60
60
 
61
61
  widget[1].constantize.render(options)
62
- rescue StandardError => error
63
- respond_with_widget_error(error)
62
+ rescue StandardError => e
63
+ respond_with_widget_error(e)
64
64
  end
65
65
 
66
66
  # Handles widget errors
@@ -35,7 +35,6 @@ module Integral
35
35
  # require 'before_render'
36
36
  require 'friendly_id'
37
37
  require 'acts-as-taggable-on'
38
- require 'slack-notifier'
39
38
  require 'paranoia'
40
39
  require 'inky'
41
40
  require 'premailer/rails'
@@ -43,6 +42,7 @@ module Integral
43
42
  require 'will_paginate-foundation'
44
43
  require 'rails-settings-cached'
45
44
  require 'gaffe'
45
+ require 'fast_jsonapi'
46
46
 
47
47
  isolate_namespace Integral
48
48
 
@@ -73,7 +73,7 @@ module Integral
73
73
  # Allows engine factories to be reused by application
74
74
  initializer 'model_core.factories', after: 'factory_bot.set_factory_paths' do
75
75
  if defined?(FactoryBot)
76
- FactoryBot.definition_file_paths << File.expand_path('../../../spec/factories', __FILE__)
76
+ FactoryBot.definition_file_paths << File.expand_path('../../spec/factories', __dir__)
77
77
  end
78
78
  end
79
79
 
@@ -6,7 +6,17 @@ module Integral
6
6
  include Datagrid
7
7
 
8
8
  scope do
9
- Integral::UserVersion.all.union(Integral::PageVersion.all).union(Integral::PostVersion.all).union(Integral::ListVersion.all).union(Integral::ImageVersion.all).order('created_at DESC')
9
+ fields = [:id, :item_type, :item_id, :event, :whodunnit, :created_at]
10
+ scope = Integral::PageVersion.select(fields).all
11
+
12
+ [Integral::PostVersion,
13
+ Integral::CategoryVersion,
14
+ Integral::ListVersion,
15
+ Integral::ImageVersion,
16
+ Integral::UserVersion].concat(Integral.additional_tracked_classes.map { |klass| klass.version_class_name.constantize }).each do |version|
17
+ scope = scope.union(version.select(fields).all)
18
+ end
19
+ scope = scope.order('created_at DESC')
10
20
  end
11
21
 
12
22
  filter(:user, multiple: true) do |value|
@@ -25,6 +35,10 @@ module Integral
25
35
  where(item_id: value)
26
36
  end
27
37
 
38
+ filter(:created_at) do |value|
39
+ where("created_at < ?", value)
40
+ end
41
+
28
42
  column(:date, order: :created_at)
29
43
  column(:user, order: :whodunnit)
30
44
  column(:action, order: :event)
@@ -76,6 +76,7 @@ module Integral
76
76
  # TODO: Move this onto the model level
77
77
  def type_for_dropdown
78
78
  return list_item.type unless list_item.object?
79
+
79
80
  list_item.object_type.to_s
80
81
  end
81
82
 
@@ -97,12 +98,13 @@ module Integral
97
98
  # @return [String] URL of list item
98
99
  def url
99
100
  return if list_item.basic?
101
+
100
102
  url = provide_attr(:url)
101
103
 
102
104
  return url if url.nil? || url.empty?
103
- return url if url.match?(URI::DEFAULT_PARSER.make_regexp)
105
+ return CGI.unescape(url) if url.match?(URI::DEFAULT_PARSER.make_regexp)
104
106
 
105
- "#{Rails.application.routes.default_url_options[:host]}#{url}"
107
+ CGI.unescape("#{Rails.application.routes.default_url_options[:host]}#{url}")
106
108
  end
107
109
 
108
110
  # @return [String] subtitle of list item
@@ -79,6 +79,7 @@ module Integral
79
79
  def html_id
80
80
  return list.html_id if list.html_id.present?
81
81
  return opts[:html_id] if opts[:html_id].present?
82
+
82
83
  ''
83
84
  end
84
85
 
@@ -39,7 +39,13 @@ module Integral
39
39
  return dynamic_homepage if path == '/' && Integral.dynamic_homepage_enabled?
40
40
 
41
41
  # TODO: Speed this up by adding an index & unique constraint on path attribute
42
- Integral::Page.find_by_path(path)&.id
42
+ Integral::Page.not_archived.find_by_path(path)&.id
43
+ end
44
+
45
+ def category_identifier(path)
46
+ return nil unless path.starts_with?("/#{Integral.blog_namespace}")
47
+
48
+ Integral::Category.select(:id, :slug).all.map { |category| [category.id, "/#{Integral.blog_namespace}/#{category.slug}"] }.find { |category| category[1] == path }&.first
43
49
  end
44
50
 
45
51
  # Converts the request path from human readable into something Rails router understands
@@ -51,12 +57,15 @@ module Integral
51
57
  # @return [String] Path Rails needs to link the request to the correct Integral::Page record
52
58
  def rewrite_path(env, path)
53
59
  page_id = page_identifier(path)
54
- return if page_id.nil?
60
+ if page_id
61
+ env['PATH_INFO'] = "/pages/#{page_id}"
62
+ else
63
+ category_id = category_identifier(path)
55
64
 
56
- rewritten_path = "/pages/#{page_id}"
57
- env['PATH_INFO'] = rewritten_path
58
- rescue StandardError => error
59
- handle_rewrite_error(error)
65
+ env['PATH_INFO'] = "/#{Integral.blog_namespace}/categories/#{category_id}" if category_id
66
+ end
67
+ rescue StandardError => e
68
+ handle_rewrite_error(e)
60
69
  end
61
70
 
62
71
  # Homepage ID as defined by User within backend settings
@@ -33,6 +33,7 @@ module Integral
33
33
  if Integral.blog_enabled?
34
34
  scope Integral.blog_namespace do
35
35
  resources :tags, only: %i[index show]
36
+ resources :categories, only: %i[show]
36
37
  end
37
38
  # Post Routing must go after tags otherwise it will override
38
39
  resources Integral.blog_namespace, only: %i[show index], as: :posts, controller: 'posts'
@@ -59,13 +60,20 @@ module Integral
59
60
  get 'account', to: 'users#account'
60
61
 
61
62
  # User Management
62
- resources :users
63
+ resources :users do
64
+ get 'list', on: :collection
65
+ member do
66
+ get 'activities', controller: 'users'
67
+ get 'activities/:activity_id', to: 'users#activity', as: :activity
68
+ end
69
+ end
63
70
 
64
71
  # Image Management
65
72
  resources :images, as: :img
66
73
 
67
74
  # Page Management
68
- resources :pages, except: [:show] do
75
+ resources :pages do
76
+ get 'list', on: :collection
69
77
  member do
70
78
  post 'duplicate'
71
79
  get 'activities', controller: 'pages'
@@ -76,13 +84,15 @@ module Integral
76
84
  # Activity Management
77
85
  resources :activities, only: %i[index show] do
78
86
  collection do
87
+ post 'widget'
79
88
  post 'grid'
80
89
  end
81
90
  end
82
91
 
83
92
  # Post Management
84
93
  if Integral.blog_enabled?
85
- resources :posts, except: [:show] do
94
+ resources :posts do
95
+ get 'list', on: :collection
86
96
  member do
87
97
  post 'duplicate'
88
98
  get 'activities', controller: 'posts'
@@ -90,6 +100,12 @@ module Integral
90
100
  end
91
101
  # resources :comments, only: [:create, :destroy]
92
102
  end
103
+ resources :categories, only: %i[create edit update destroy] do
104
+ member do
105
+ get 'activities', controller: 'categories'
106
+ get 'activities/:activity_id', to: 'categories#activity', as: :activity
107
+ end
108
+ end
93
109
  end
94
110
 
95
111
  # List Management