biovision-post 0.21.190513.0 → 0.26.191013.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/config/biovision_post_manifest.js +1 -0
  3. data/app/assets/images/biovision/post/icons/comment.svg +9 -0
  4. data/app/assets/javascripts/biovision/post/biovision-posts.js +21 -28
  5. data/app/assets/stylesheets/biovision/post/posts.scss +6 -0
  6. data/app/controllers/admin/editorial_members_controller.rb +9 -4
  7. data/app/controllers/admin/featured_posts_controller.rb +9 -4
  8. data/app/controllers/admin/post_categories_controller.rb +12 -6
  9. data/app/controllers/admin/post_group_categories_controller.rb +9 -4
  10. data/app/controllers/admin/post_group_tags_controller.rb +9 -4
  11. data/app/controllers/admin/post_groups_controller.rb +9 -4
  12. data/app/controllers/admin/post_illustrations_controller.rb +9 -4
  13. data/app/controllers/admin/post_images_controller.rb +9 -4
  14. data/app/controllers/admin/post_links_controller.rb +9 -4
  15. data/app/controllers/admin/post_tags_controller.rb +9 -4
  16. data/app/controllers/admin/post_types_controller.rb +13 -4
  17. data/app/controllers/admin/posts_controller.rb +6 -8
  18. data/app/controllers/articles_controller.rb +16 -6
  19. data/app/controllers/authors_controller.rb +9 -4
  20. data/app/controllers/blog_posts_controller.rb +16 -6
  21. data/app/controllers/editorial_members_controller.rb +9 -4
  22. data/app/controllers/featured_posts_controller.rb +6 -1
  23. data/app/controllers/my/posts_controller.rb +35 -38
  24. data/app/controllers/news_controller.rb +16 -6
  25. data/app/controllers/post_attachments_controller.rb +36 -0
  26. data/app/controllers/post_categories_controller.rb +6 -1
  27. data/app/controllers/post_groups_controller.rb +9 -4
  28. data/app/controllers/post_illustrations_controller.rb +6 -1
  29. data/app/controllers/post_images_controller.rb +9 -8
  30. data/app/controllers/post_links_controller.rb +5 -2
  31. data/app/controllers/post_tags_controller.rb +9 -4
  32. data/app/controllers/posts_controller.rb +39 -17
  33. data/app/helpers/biovision_posts_helper.rb +28 -27
  34. data/app/jobs/post_body_parser_job.rb +1 -1
  35. data/app/models/concerns/post_child_with_priority.rb +2 -1
  36. data/app/models/editorial_member.rb +10 -1
  37. data/app/models/post.rb +39 -11
  38. data/app/models/post_attachment.rb +49 -0
  39. data/app/models/post_category.rb +6 -0
  40. data/app/models/post_group_category.rb +1 -1
  41. data/app/models/post_illustration.rb +2 -1
  42. data/app/models/post_image.rb +2 -1
  43. data/app/models/post_type.rb +15 -0
  44. data/app/services/biovision/components/posts_component.rb +65 -0
  45. data/app/views/admin/components/links/_posts.html.erb +33 -0
  46. data/app/views/admin/editorial_members/index.html.erb +2 -1
  47. data/app/views/admin/editorial_members/show.html.erb +1 -0
  48. data/app/views/admin/featured_posts/index.html.erb +1 -0
  49. data/app/views/admin/post_categories/entity/_in_list.html.erb +10 -0
  50. data/app/views/admin/post_categories/show.html.erb +11 -0
  51. data/app/views/admin/post_groups/index.html.erb +2 -1
  52. data/app/views/admin/post_groups/show.html.erb +1 -0
  53. data/app/views/admin/post_illustrations/index.html.erb +1 -0
  54. data/app/views/admin/post_illustrations/show.html.erb +1 -0
  55. data/app/views/admin/post_images/index.html.erb +2 -1
  56. data/app/views/admin/post_images/show.html.erb +1 -0
  57. data/app/views/admin/post_tags/index.html.erb +2 -1
  58. data/app/views/admin/post_tags/posts.html.erb +4 -3
  59. data/app/views/admin/post_tags/show.html.erb +3 -2
  60. data/app/views/admin/post_types/authors.html.erb +1 -0
  61. data/app/views/admin/post_types/index.html.erb +2 -1
  62. data/app/views/admin/post_types/new_post.html.erb +13 -4
  63. data/app/views/admin/post_types/post_categories.html.erb +1 -0
  64. data/app/views/admin/post_types/post_tags.html.erb +4 -3
  65. data/app/views/admin/post_types/show.html.erb +3 -2
  66. data/app/views/admin/posts/entity/_in_list.html.erb +3 -3
  67. data/app/views/admin/posts/images.html.erb +1 -0
  68. data/app/views/admin/posts/index.html.erb +2 -1
  69. data/app/views/admin/posts/search.html.erb +10 -1
  70. data/app/views/admin/posts/show.html.erb +6 -7
  71. data/app/views/authors/show.html.erb +1 -1
  72. data/app/views/blog_posts/index.html.erb +4 -2
  73. data/app/views/editorial_members/edit.html.erb +1 -0
  74. data/app/views/editorial_members/new.html.erb +3 -2
  75. data/app/views/my/index/dashboard/_biovision_post.html.erb +5 -4
  76. data/app/views/my/posts/_form.html.erb +40 -194
  77. data/app/views/my/posts/_post.html.erb +2 -3
  78. data/app/views/my/posts/articles.html.erb +1 -1
  79. data/app/views/my/posts/blog_posts.html.erb +1 -1
  80. data/app/views/my/posts/index/_navigation.html.erb +3 -3
  81. data/app/views/my/posts/new.html.erb +9 -1
  82. data/app/views/my/posts/news_index.html.erb +1 -1
  83. data/app/views/posts/_breadcrumbs.html.erb +1 -6
  84. data/app/views/posts/_form.html.erb +9 -2
  85. data/app/views/posts/_post.html.erb +7 -11
  86. data/app/views/posts/_preview.html.erb +7 -1
  87. data/app/views/posts/edit.html.erb +9 -1
  88. data/app/views/posts/post_type/_category.html.erb +4 -2
  89. data/app/views/posts/post_type/_post_page.html.erb +7 -1
  90. data/app/views/posts/post_type/_posts.html.erb +11 -2
  91. data/app/views/posts/post_type/_tagged.html.erb +4 -4
  92. data/app/views/posts/rss.xml.erb +1 -1
  93. data/app/views/posts/show.html.erb +0 -5
  94. data/app/views/posts/zen.xml.erb +3 -3
  95. data/config/locales/posts-ru.yml +11 -1
  96. data/config/routes.rb +3 -0
  97. data/db/{migrate → amends}/20190202232323_add_spam_to_posts.rb +0 -0
  98. data/db/{migrate → amends}/20190224212121_add_data_to_posts.rb +0 -0
  99. data/db/{migrate → amends}/20190224212122_rename_post_image_source.rb +0 -0
  100. data/db/{migrate → amends}/20190224212123_add_uuid_to_post_images.rb +0 -0
  101. data/db/{migrate → amends}/20190313141414_convert_json_post_columns.rb +0 -0
  102. data/db/amends/20190925181818_add_search_index_to_posts.rb +24 -0
  103. data/db/migrate/20170930000001_create_post_types.rb +4 -13
  104. data/db/migrate/20170930000010_create_posts.rb +26 -3
  105. data/db/migrate/20190715141414_add_data_to_post_categories.rb +14 -0
  106. data/db/migrate/20190801161616_add_posts_component.rb +14 -0
  107. data/db/migrate/20190822121212_create_post_attachments.rb +20 -0
  108. data/db/migrate/20190914212121_convert_post_privileges.rb +56 -0
  109. data/lib/biovision/post/version.rb +1 -1
  110. metadata +18 -13
  111. data/app/services/post_manager.rb +0 -71
  112. data/app/views/admin/index/dashboard/_biovision_post.html.erb +0 -36
  113. data/app/views/articles/show.html.erb +0 -6
  114. data/app/views/blog_posts/show.html.erb +0 -6
  115. data/app/views/news/show.html.erb +0 -6
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Add data column to post_categories
4
+ class AddDataToPostCategories < ActiveRecord::Migration[5.2]
5
+ def up
6
+ return if column_exists? :post_categories, :data
7
+
8
+ add_column :post_categories, :data, :jsonb, default: {}, null: false
9
+ end
10
+
11
+ def down
12
+ # No rollback needed
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Add posts to biovision components
4
+ class AddPostsComponent < ActiveRecord::Migration[5.2]
5
+ def up
6
+ return if BiovisionComponent.where(slug: 'posts').exists?
7
+
8
+ BiovisionComponent.create(slug: 'posts')
9
+ end
10
+
11
+ def down
12
+ # No rollback needed
13
+ end
14
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Create table for post attachment
4
+ class CreatePostAttachments < ActiveRecord::Migration[5.2]
5
+ def up
6
+ return if PostAttachment.table_exists?
7
+
8
+ create_table :post_attachments, comment: 'Attachment for post' do |t|
9
+ t.references :post, foreign_key: { on_update: :cascade, on_delete: :cascade }
10
+ t.uuid :uuid
11
+ t.timestamps
12
+ t.string :name
13
+ t.string :file
14
+ end
15
+ end
16
+
17
+ def down
18
+ # No rollback needed
19
+ end
20
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Convert privilege-based links to component-user links
4
+ class ConvertPostPrivileges < ActiveRecord::Migration[5.2]
5
+ def up
6
+ return unless Privilege.table_exists?
7
+
8
+ @handler = Biovision::Components::BaseComponent.handler('posts')
9
+
10
+ convert_chief_editors
11
+ convert_editors
12
+ end
13
+
14
+ def down
15
+ # No rollback needed
16
+ end
17
+
18
+ private
19
+
20
+ def convert_chief_editors
21
+ privilege = Privilege.find_by(slug: 'chief_editor')
22
+
23
+ return if privilege.nil?
24
+
25
+ data = { chief_editor: true }
26
+
27
+ privilege.users.each do |user|
28
+ @handler.update_privileges(user, data)
29
+ end
30
+ end
31
+
32
+ def convert_editors
33
+ privilege = Privilege.find_by(slug: 'editor')
34
+
35
+ return if privilege.nil?
36
+
37
+ type_ids = PostType.pluck(:id)
38
+
39
+ criteria = {
40
+ biovision_component: @handler.component
41
+ }
42
+
43
+ privilege.users.each do |user|
44
+ criteria[:user] = user
45
+ link = BiovisionComponentUser.find_or_create_by(criteria)
46
+
47
+ link.data['editor'] = true
48
+ link.save!
49
+
50
+ member = EditorialMember.find_or_create_by(user: user)
51
+ type_ids.each do |id|
52
+ EditorialMemberPostType.create(editorial_member: member, post_type_id: id)
53
+ end
54
+ end
55
+ end
56
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Biovision
4
4
  module Post
5
- VERSION = '0.21.190513.0'
5
+ VERSION = '0.26.191013.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: biovision-post
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.190513.0
4
+ version: 0.26.191013.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxim Khan-Magomedov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-15 00:00:00.000000000 Z
11
+ date: 2019-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -119,6 +119,7 @@ files:
119
119
  - README.md
120
120
  - Rakefile
121
121
  - app/assets/config/biovision_post_manifest.js
122
+ - app/assets/images/biovision/post/icons/comment.svg
122
123
  - app/assets/images/biovision/post/icons/time.svg
123
124
  - app/assets/images/biovision/post/icons/view.svg
124
125
  - app/assets/images/biovision/post/publisher_logo.png
@@ -146,6 +147,7 @@ files:
146
147
  - app/controllers/featured_posts_controller.rb
147
148
  - app/controllers/my/posts_controller.rb
148
149
  - app/controllers/news_controller.rb
150
+ - app/controllers/post_attachments_controller.rb
149
151
  - app/controllers/post_categories_controller.rb
150
152
  - app/controllers/post_groups_controller.rb
151
153
  - app/controllers/post_illustrations_controller.rb
@@ -166,6 +168,7 @@ files:
166
168
  - app/models/editorial_member_post_type.rb
167
169
  - app/models/featured_post.rb
168
170
  - app/models/post.rb
171
+ - app/models/post_attachment.rb
169
172
  - app/models/post_category.rb
170
173
  - app/models/post_group.rb
171
174
  - app/models/post_group_category.rb
@@ -183,9 +186,10 @@ files:
183
186
  - app/models/post_type.rb
184
187
  - app/models/post_zen_category.rb
185
188
  - app/models/zen_category.rb
186
- - app/services/post_manager.rb
189
+ - app/services/biovision/components/posts_component.rb
187
190
  - app/services/post_parser.rb
188
191
  - app/uploaders/post_image_uploader.rb
192
+ - app/views/admin/components/links/_posts.html.erb
189
193
  - app/views/admin/editorial_members/_nav_item.html.erb
190
194
  - app/views/admin/editorial_members/entity/_in_list.html.erb
191
195
  - app/views/admin/editorial_members/index.html.erb
@@ -195,7 +199,6 @@ files:
195
199
  - app/views/admin/featured_posts/_nav_item.html.erb
196
200
  - app/views/admin/featured_posts/entity/_in_list.html.erb
197
201
  - app/views/admin/featured_posts/index.html.erb
198
- - app/views/admin/index/dashboard/_biovision_post.html.erb
199
202
  - app/views/admin/post_categories/entity/_in_list.html.erb
200
203
  - app/views/admin/post_categories/show.html.erb
201
204
  - app/views/admin/post_group_categories/entity/_in_list.html.erb
@@ -241,7 +244,6 @@ files:
241
244
  - app/views/admin/posts/show.html.erb
242
245
  - app/views/articles/category.html.erb
243
246
  - app/views/articles/index.html.erb
244
- - app/views/articles/show.html.erb
245
247
  - app/views/articles/tagged.html.erb
246
248
  - app/views/authors/_list.html.erb
247
249
  - app/views/authors/entity/_in_list.html.erb
@@ -249,7 +251,6 @@ files:
249
251
  - app/views/authors/show.html.erb
250
252
  - app/views/blog_posts/category.html.erb
251
253
  - app/views/blog_posts/index.html.erb
252
- - app/views/blog_posts/show.html.erb
253
254
  - app/views/blog_posts/tagged.html.erb
254
255
  - app/views/editorial_members/_form.html.erb
255
256
  - app/views/editorial_members/edit.html.erb
@@ -272,7 +273,6 @@ files:
272
273
  - app/views/my/posts/show.html.erb
273
274
  - app/views/news/category.html.erb
274
275
  - app/views/news/index.html.erb
275
- - app/views/news/show.html.erb
276
276
  - app/views/news/tagged.html.erb
277
277
  - app/views/post_categories/_form.html.erb
278
278
  - app/views/post_categories/edit.html.erb
@@ -335,15 +335,16 @@ files:
335
335
  - db/amends/20180810111111_add_explicit_to_posts.rb
336
336
  - db/amends/20180825111111_add_meta_description_to_post_categories.rb
337
337
  - db/amends/20180927111111_amend_editorial_member_about.rb
338
+ - db/amends/20190202232323_add_spam_to_posts.rb
339
+ - db/amends/20190224212121_add_data_to_posts.rb
340
+ - db/amends/20190224212122_rename_post_image_source.rb
341
+ - db/amends/20190224212123_add_uuid_to_post_images.rb
342
+ - db/amends/20190313141414_convert_json_post_columns.rb
343
+ - db/amends/20190925181818_add_search_index_to_posts.rb
338
344
  - db/migrate/20170930000001_create_post_types.rb
339
345
  - db/migrate/20170930000010_create_posts.rb
340
346
  - db/migrate/20180706000000_create_editorial_members.rb
341
347
  - db/migrate/20180808000000_create_zen_categories.rb
342
- - db/migrate/20190202232323_add_spam_to_posts.rb
343
- - db/migrate/20190224212121_add_data_to_posts.rb
344
- - db/migrate/20190224212122_rename_post_image_source.rb
345
- - db/migrate/20190224212123_add_uuid_to_post_images.rb
346
- - db/migrate/20190313141414_convert_json_post_columns.rb
347
348
  - db/migrate/20190401101010_create_post_illustrations.rb
348
349
  - db/migrate/20190407101010_create_editorial_member_post_types.rb
349
350
  - db/migrate/20190410101010_add_avoid_parsing_to_posts.rb
@@ -352,6 +353,10 @@ files:
352
353
  - db/migrate/20190412212121_add_url_part_to_post_types.rb
353
354
  - db/migrate/20190420212121_create_post_layouts.rb
354
355
  - db/migrate/20190424161616_create_post_post_categories.rb
356
+ - db/migrate/20190715141414_add_data_to_post_categories.rb
357
+ - db/migrate/20190801161616_add_posts_component.rb
358
+ - db/migrate/20190822121212_create_post_attachments.rb
359
+ - db/migrate/20190914212121_convert_post_privileges.rb
355
360
  - lib/biovision/post.rb
356
361
  - lib/biovision/post/engine.rb
357
362
  - lib/biovision/post/version.rb
@@ -376,7 +381,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
376
381
  - !ruby/object:Gem::Version
377
382
  version: '0'
378
383
  requirements: []
379
- rubygems_version: 3.0.4
384
+ rubygems_version: 3.0.6
380
385
  signing_key:
381
386
  specification_version: 4
382
387
  summary: Posts for biovision-based applications
@@ -1,71 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Manager for handling post-related cases
4
- class PostManager
5
- # @param [Post|PostCategory] entity
6
- # @param [Symbol|String] locale
7
- def initialize(entity, locale = I18n.locale)
8
- @entity = entity
9
- @body = entity.body.to_s if @entity.is_a?(Post)
10
- @prefix = locale.nil? || locale == I18n.default_locale ? '' : "/#{locale}"
11
- @url_part = entity.post_type.url_part
12
- end
13
-
14
- # @param [User] user
15
- # @param [String|PostType] type
16
- def self.editor?(user, type)
17
- return true if UserPrivilege.user_has_privilege?(user, :chief_editor)
18
-
19
- type = PostType.find_by(slug: type) unless type.is_a?(PostType)
20
-
21
- EditorialMember.find_by(user: user)&.post_type?(type)
22
- end
23
-
24
- # @param [Post] post
25
- def self.enclosures(post)
26
- post.parsed_body.scan(/<img[^>]+>/).map do |image|
27
- image.scan(/src="([^"]+)"/)[0][0]
28
- end
29
- end
30
-
31
- def parsed_body
32
- PostParser.new(@entity).parsed_body if @entity.is_a?(Post)
33
- end
34
-
35
- def post_path
36
- "#{@prefix}/#{@url_part}/#{@entity.id}-#{@entity.slug}" if @entity.is_a?(Post)
37
- end
38
-
39
- def edit_path
40
- "#{@prefix}/posts/#{@entity.id}/edit" if @entity.is_a?(Post)
41
- end
42
-
43
- # @param [String] tag_name
44
- def tagged_path(tag_name)
45
- "#{@prefix}/#{@url_part}/tagged/#{CGI.escape(tag_name)}"
46
- end
47
-
48
- def category_path
49
- postfix = ''
50
- suffix = @entity.is_a?(Post) ? @entity.post_category : @entity
51
- postfix += "/#{suffix.long_slug}" unless suffix.nil?
52
-
53
- empty_category_path + postfix
54
- end
55
-
56
- def category_name
57
- if @entity.is_a?(Post)
58
- if @entity.post_category.nil?
59
- @entity.post_type.default_category_name
60
- else
61
- @entity.post_categories.map(&:text_for_link)
62
- end
63
- else
64
- @entity.text_for_link
65
- end
66
- end
67
-
68
- def empty_category_path
69
- "#{@prefix}/#{@url_part}"
70
- end
71
- end
@@ -1,36 +0,0 @@
1
- <% if current_user_in_group?(:editors) %>
2
- <nav>
3
- <h3><%= t('.heading') %></h3>
4
- <ul>
5
- <li>
6
- <%= render 'admin/post_types/nav_item' %>
7
- <ul>
8
- <% PostType.list_for_administration.each do |post_type| %>
9
- <li>
10
- <div><%= admin_post_type_link(post_type) %></div>
11
- <div class="description">
12
- <%= t(:post_count, count: post_type.posts_count) %>
13
- </div>
14
- <ul class="actions">
15
- <li>
16
- <%= create_icon(new_post_admin_post_type_path(id: post_type.id)) %>
17
- </li>
18
- </ul>
19
- </li>
20
- <% end %>
21
- </ul>
22
- </li>
23
- <li><%= render 'admin/posts/nav_item' %></li>
24
- <% if current_user_has_privilege?(:chief_editor) %>
25
- <li><%= render 'admin/featured_posts/nav_item' %></li>
26
- <li><%= render 'admin/post_groups/nav_item' %></li>
27
- <% end %>
28
- <li><%= render 'admin/post_tags/nav_item' %></li>
29
- <li><%= render 'admin/post_illustrations/nav_item' %></li>
30
- <li><%= render 'admin/post_images/nav_item' %></li>
31
- <% if current_user_has_privilege?(:chief_editor) %>
32
- <li><%= render 'admin/editorial_members/nav_item' %></li>
33
- <% end %>
34
- </ul>
35
- </nav>
36
- <% end %>
@@ -1,6 +0,0 @@
1
- <% content_for :breadcrumbs do %>
2
- <%= link_to(t('articles.index.nav_text'), articles_path) %>
3
- <%= render partial: 'posts/breadcrumbs', locals: { entity: @entity } %>
4
- <% end %>
5
-
6
- <%= render partial: 'posts/post_type/post_page', locals: { entity: @entity } %>
@@ -1,6 +0,0 @@
1
- <% content_for :breadcrumbs do %>
2
- <%= link_to(t('blog_posts.index.nav_text'), blog_posts_path) %>
3
- <%= render partial: 'posts/breadcrumbs', locals: { entity: @entity } %>
4
- <% end %>
5
-
6
- <%= render partial: 'posts/post_type/post_page', locals: { entity: @entity } %>
@@ -1,6 +0,0 @@
1
- <% content_for :breadcrumbs do %>
2
- <%= link_to(t('news.index.nav_text'), news_index_path) %>
3
- <%= render partial: 'posts/breadcrumbs', locals: { entity: @entity } %>
4
- <% end %>
5
-
6
- <%= render partial: 'posts/post_type/post_page', locals: { entity: @entity } %>