biovision-post 0.21.190513.0 → 0.26.191013.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/config/biovision_post_manifest.js +1 -0
- data/app/assets/images/biovision/post/icons/comment.svg +9 -0
- data/app/assets/javascripts/biovision/post/biovision-posts.js +21 -28
- data/app/assets/stylesheets/biovision/post/posts.scss +6 -0
- data/app/controllers/admin/editorial_members_controller.rb +9 -4
- data/app/controllers/admin/featured_posts_controller.rb +9 -4
- data/app/controllers/admin/post_categories_controller.rb +12 -6
- data/app/controllers/admin/post_group_categories_controller.rb +9 -4
- data/app/controllers/admin/post_group_tags_controller.rb +9 -4
- data/app/controllers/admin/post_groups_controller.rb +9 -4
- data/app/controllers/admin/post_illustrations_controller.rb +9 -4
- data/app/controllers/admin/post_images_controller.rb +9 -4
- data/app/controllers/admin/post_links_controller.rb +9 -4
- data/app/controllers/admin/post_tags_controller.rb +9 -4
- data/app/controllers/admin/post_types_controller.rb +13 -4
- data/app/controllers/admin/posts_controller.rb +6 -8
- data/app/controllers/articles_controller.rb +16 -6
- data/app/controllers/authors_controller.rb +9 -4
- data/app/controllers/blog_posts_controller.rb +16 -6
- data/app/controllers/editorial_members_controller.rb +9 -4
- data/app/controllers/featured_posts_controller.rb +6 -1
- data/app/controllers/my/posts_controller.rb +35 -38
- data/app/controllers/news_controller.rb +16 -6
- data/app/controllers/post_attachments_controller.rb +36 -0
- data/app/controllers/post_categories_controller.rb +6 -1
- data/app/controllers/post_groups_controller.rb +9 -4
- data/app/controllers/post_illustrations_controller.rb +6 -1
- data/app/controllers/post_images_controller.rb +9 -8
- data/app/controllers/post_links_controller.rb +5 -2
- data/app/controllers/post_tags_controller.rb +9 -4
- data/app/controllers/posts_controller.rb +39 -17
- data/app/helpers/biovision_posts_helper.rb +28 -27
- data/app/jobs/post_body_parser_job.rb +1 -1
- data/app/models/concerns/post_child_with_priority.rb +2 -1
- data/app/models/editorial_member.rb +10 -1
- data/app/models/post.rb +39 -11
- data/app/models/post_attachment.rb +49 -0
- data/app/models/post_category.rb +6 -0
- data/app/models/post_group_category.rb +1 -1
- data/app/models/post_illustration.rb +2 -1
- data/app/models/post_image.rb +2 -1
- data/app/models/post_type.rb +15 -0
- data/app/services/biovision/components/posts_component.rb +65 -0
- data/app/views/admin/components/links/_posts.html.erb +33 -0
- data/app/views/admin/editorial_members/index.html.erb +2 -1
- data/app/views/admin/editorial_members/show.html.erb +1 -0
- data/app/views/admin/featured_posts/index.html.erb +1 -0
- data/app/views/admin/post_categories/entity/_in_list.html.erb +10 -0
- data/app/views/admin/post_categories/show.html.erb +11 -0
- data/app/views/admin/post_groups/index.html.erb +2 -1
- data/app/views/admin/post_groups/show.html.erb +1 -0
- data/app/views/admin/post_illustrations/index.html.erb +1 -0
- data/app/views/admin/post_illustrations/show.html.erb +1 -0
- data/app/views/admin/post_images/index.html.erb +2 -1
- data/app/views/admin/post_images/show.html.erb +1 -0
- data/app/views/admin/post_tags/index.html.erb +2 -1
- data/app/views/admin/post_tags/posts.html.erb +4 -3
- data/app/views/admin/post_tags/show.html.erb +3 -2
- data/app/views/admin/post_types/authors.html.erb +1 -0
- data/app/views/admin/post_types/index.html.erb +2 -1
- data/app/views/admin/post_types/new_post.html.erb +13 -4
- data/app/views/admin/post_types/post_categories.html.erb +1 -0
- data/app/views/admin/post_types/post_tags.html.erb +4 -3
- data/app/views/admin/post_types/show.html.erb +3 -2
- data/app/views/admin/posts/entity/_in_list.html.erb +3 -3
- data/app/views/admin/posts/images.html.erb +1 -0
- data/app/views/admin/posts/index.html.erb +2 -1
- data/app/views/admin/posts/search.html.erb +10 -1
- data/app/views/admin/posts/show.html.erb +6 -7
- data/app/views/authors/show.html.erb +1 -1
- data/app/views/blog_posts/index.html.erb +4 -2
- data/app/views/editorial_members/edit.html.erb +1 -0
- data/app/views/editorial_members/new.html.erb +3 -2
- data/app/views/my/index/dashboard/_biovision_post.html.erb +5 -4
- data/app/views/my/posts/_form.html.erb +40 -194
- data/app/views/my/posts/_post.html.erb +2 -3
- data/app/views/my/posts/articles.html.erb +1 -1
- data/app/views/my/posts/blog_posts.html.erb +1 -1
- data/app/views/my/posts/index/_navigation.html.erb +3 -3
- data/app/views/my/posts/new.html.erb +9 -1
- data/app/views/my/posts/news_index.html.erb +1 -1
- data/app/views/posts/_breadcrumbs.html.erb +1 -6
- data/app/views/posts/_form.html.erb +9 -2
- data/app/views/posts/_post.html.erb +7 -11
- data/app/views/posts/_preview.html.erb +7 -1
- data/app/views/posts/edit.html.erb +9 -1
- data/app/views/posts/post_type/_category.html.erb +4 -2
- data/app/views/posts/post_type/_post_page.html.erb +7 -1
- data/app/views/posts/post_type/_posts.html.erb +11 -2
- data/app/views/posts/post_type/_tagged.html.erb +4 -4
- data/app/views/posts/rss.xml.erb +1 -1
- data/app/views/posts/show.html.erb +0 -5
- data/app/views/posts/zen.xml.erb +3 -3
- data/config/locales/posts-ru.yml +11 -1
- data/config/routes.rb +3 -0
- data/db/{migrate → amends}/20190202232323_add_spam_to_posts.rb +0 -0
- data/db/{migrate → amends}/20190224212121_add_data_to_posts.rb +0 -0
- data/db/{migrate → amends}/20190224212122_rename_post_image_source.rb +0 -0
- data/db/{migrate → amends}/20190224212123_add_uuid_to_post_images.rb +0 -0
- data/db/{migrate → amends}/20190313141414_convert_json_post_columns.rb +0 -0
- data/db/amends/20190925181818_add_search_index_to_posts.rb +24 -0
- data/db/migrate/20170930000001_create_post_types.rb +4 -13
- data/db/migrate/20170930000010_create_posts.rb +26 -3
- data/db/migrate/20190715141414_add_data_to_post_categories.rb +14 -0
- data/db/migrate/20190801161616_add_posts_component.rb +14 -0
- data/db/migrate/20190822121212_create_post_attachments.rb +20 -0
- data/db/migrate/20190914212121_convert_post_privileges.rb +56 -0
- data/lib/biovision/post/version.rb +1 -1
- metadata +18 -13
- data/app/services/post_manager.rb +0 -71
- data/app/views/admin/index/dashboard/_biovision_post.html.erb +0 -36
- data/app/views/articles/show.html.erb +0 -6
- data/app/views/blog_posts/show.html.erb +0 -6
- data/app/views/news/show.html.erb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0df3d21cefcd77f482394c4b8f72245a2cb543e9963e993e22e9d010e9178228
|
4
|
+
data.tar.gz: a74d55c6455fe9506305cabc57253a02098edf5003b5ee928356d38142b80f2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed8a50e26c8181f9a9f5a1128652cc60bbf4f05d5eed30e5841142ac0f612e8f03d7a1691b3bbf8ea64f6fa636983d8045f6a8766d20db27086989a3518305d7
|
7
|
+
data.tar.gz: 3e71cc4ac3149e09528cab8893407f0a866a7ac3b0762615d9821903671962f2a033f27a093500308770abf316179ccaf9989640f37c9ab8aa8c46264af8614b
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<svg version="1.1" viewBox="0 0 24 24" width="24px" height="24px" xmlns="http://www.w3.org/2000/svg">
|
2
|
+
<title>Comment</title>
|
3
|
+
<defs>
|
4
|
+
<style type="text/css">
|
5
|
+
path { fill: #fff; stroke: #000; stroke-width: 1; stroke-linejoin: round}
|
6
|
+
</style>
|
7
|
+
</defs>
|
8
|
+
<path d="M16,21 v-3 h3 a3,3 0 0,0 3,-3 v-7 a3,3 0 0,0 -3,-3 h-14 a3,3 0 0,0 -3,3 v7 a3,3 0 0,0, 3,3 h8 z"/>
|
9
|
+
</svg>
|
@@ -2,37 +2,34 @@
|
|
2
2
|
|
3
3
|
const Posts = {
|
4
4
|
initialized: false,
|
5
|
-
|
6
|
-
components: {}
|
7
|
-
init: function () {
|
8
|
-
for (let component in this.components) {
|
9
|
-
if (this.components.hasOwnProperty(component)) {
|
10
|
-
if (this.components[component].hasOwnProperty("init")) {
|
11
|
-
this.components[component].init();
|
12
|
-
}
|
13
|
-
}
|
14
|
-
}
|
15
|
-
|
16
|
-
this.initialized = true;
|
17
|
-
}
|
5
|
+
autoInitComponents: true,
|
6
|
+
components: {}
|
18
7
|
};
|
19
8
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
9
|
+
Posts.components.postLoader = {
|
10
|
+
initialized: false,
|
11
|
+
buttons: [],
|
12
|
+
selector: ".posts-loader",
|
13
|
+
init: function () {
|
14
|
+
document.querySelectorAll(this.selector).forEach(this.apply);
|
15
|
+
this.initialized = true;
|
16
|
+
},
|
17
|
+
apply: function (button) {
|
18
|
+
const component = Posts.components.postLoader;
|
19
|
+
component.buttons.push(button);
|
20
|
+
button.addEventListener("click", component.handler);
|
21
|
+
},
|
22
|
+
handler: function (e) {
|
26
23
|
e.preventDefault();
|
27
24
|
|
28
|
-
const button =
|
25
|
+
const button = e.target;
|
29
26
|
const container = document.getElementById(button.getAttribute('data-container'));
|
30
27
|
if (container) {
|
31
|
-
const list = container.querySelector(
|
28
|
+
const list = container.querySelector("div.posts-list");
|
32
29
|
|
33
30
|
if (list && !button.classList.contains('loading')) {
|
34
31
|
const url = button.getAttribute('href');
|
35
|
-
const request = Biovision.
|
32
|
+
const request = Biovision.jsonAjaxRequest("get", url, function () {
|
36
33
|
button.classList.remove('loading');
|
37
34
|
|
38
35
|
const response = JSON.parse(this.responseText);
|
@@ -60,6 +57,8 @@ const BiovisionPosts = {
|
|
60
57
|
button.classList.add('loading');
|
61
58
|
request.send();
|
62
59
|
}
|
60
|
+
} else {
|
61
|
+
console.log("Cannot find container for loaded posts");
|
63
62
|
}
|
64
63
|
}
|
65
64
|
};
|
@@ -250,9 +249,3 @@ Posts.components.groupTagLinker = {
|
|
250
249
|
};
|
251
250
|
|
252
251
|
Biovision.components.posts = Posts;
|
253
|
-
|
254
|
-
document.addEventListener('DOMContentLoaded', function () {
|
255
|
-
document.querySelectorAll('.posts-loader').forEach(function (button) {
|
256
|
-
button.addEventListener('click', BiovisionPosts.loadPosts);
|
257
|
-
});
|
258
|
-
});
|
@@ -132,6 +132,12 @@ $background-post-tag: rgb(248, 248, 248) !default;
|
|
132
132
|
padding-left: 1.8rem;
|
133
133
|
}
|
134
134
|
|
135
|
+
.comment_count {
|
136
|
+
background: image_url('biovision/post/icons/comment.svg') no-repeat center left / 1.6rem auto;
|
137
|
+
display: inline-block;
|
138
|
+
padding-left: 1.8rem;
|
139
|
+
}
|
140
|
+
|
135
141
|
article.post {
|
136
142
|
figure {
|
137
143
|
border-bottom: $border-secondary;
|
@@ -32,12 +32,17 @@ class Admin::EditorialMembersController < AdminController
|
|
32
32
|
|
33
33
|
private
|
34
34
|
|
35
|
-
def
|
36
|
-
|
37
|
-
handle_http_404('Cannot find editorial_member') if @entity.nil?
|
35
|
+
def component_slug
|
36
|
+
Biovision::Components::PostsComponent::SLUG
|
38
37
|
end
|
39
38
|
|
40
39
|
def restrict_access
|
41
|
-
|
40
|
+
error = 'Managing editorial members is not allowed'
|
41
|
+
handle_http_401(error) unless component_handler.allow?('chief_editor')
|
42
|
+
end
|
43
|
+
|
44
|
+
def set_entity
|
45
|
+
@entity = EditorialMember.find_by(id: params[:id])
|
46
|
+
handle_http_404('Cannot find editorial_member') if @entity.nil?
|
42
47
|
end
|
43
48
|
end
|
@@ -10,14 +10,19 @@ class Admin::FeaturedPostsController < AdminController
|
|
10
10
|
|
11
11
|
private
|
12
12
|
|
13
|
+
def component_slug
|
14
|
+
Biovision::Components::PostsComponent::SLUG
|
15
|
+
end
|
16
|
+
|
17
|
+
def restrict_access
|
18
|
+
error = 'Managing post groups is not allowed'
|
19
|
+
handle_http_401(error) unless component_handler.allow?('chief_editor', 'deputy_chief_editor')
|
20
|
+
end
|
21
|
+
|
13
22
|
def set_entity
|
14
23
|
@entity = FeaturedPost.find_by(id: params[:id])
|
15
24
|
if @entity.nil?
|
16
25
|
handle_http_404('Cannot find post_link')
|
17
26
|
end
|
18
27
|
end
|
19
|
-
|
20
|
-
def restrict_access
|
21
|
-
require_privilege :chief_editor
|
22
|
-
end
|
23
28
|
end
|
@@ -1,3 +1,6 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Handling post categories
|
1
4
|
class Admin::PostCategoriesController < AdminController
|
2
5
|
include LockableEntity
|
3
6
|
include ToggleableEntity
|
@@ -12,14 +15,17 @@ class Admin::PostCategoriesController < AdminController
|
|
12
15
|
|
13
16
|
private
|
14
17
|
|
15
|
-
def
|
16
|
-
|
17
|
-
if @entity.nil?
|
18
|
-
handle_http_404('Cannot find post category')
|
19
|
-
end
|
18
|
+
def component_slug
|
19
|
+
Biovision::Components::PostsComponent::SLUG
|
20
20
|
end
|
21
21
|
|
22
22
|
def restrict_access
|
23
|
-
|
23
|
+
error = 'Managing post categories is not allowed'
|
24
|
+
handle_http_401(error) unless component_handler.allow?('chief_editor')
|
25
|
+
end
|
26
|
+
|
27
|
+
def set_entity
|
28
|
+
@entity = PostCategory.find_by(id: params[:id])
|
29
|
+
handle_http_404('Cannot find post category') if @entity.nil?
|
24
30
|
end
|
25
31
|
end
|
@@ -8,12 +8,17 @@ class Admin::PostGroupCategoriesController < AdminController
|
|
8
8
|
|
9
9
|
private
|
10
10
|
|
11
|
-
def
|
12
|
-
|
13
|
-
handle_http_404('Cannot find post_group_category') if @entity.nil?
|
11
|
+
def component_slug
|
12
|
+
Biovision::Components::PostsComponent::SLUG
|
14
13
|
end
|
15
14
|
|
16
15
|
def restrict_access
|
17
|
-
|
16
|
+
error = 'Managing post group categories is not allowed'
|
17
|
+
handle_http_401(error) unless component_handler.allow?('chief_editor')
|
18
|
+
end
|
19
|
+
|
20
|
+
def set_entity
|
21
|
+
@entity = PostGroupCategory.find_by(id: params[:id])
|
22
|
+
handle_http_404('Cannot find post_group_category') if @entity.nil?
|
18
23
|
end
|
19
24
|
end
|
@@ -8,12 +8,17 @@ class Admin::PostGroupTagsController < AdminController
|
|
8
8
|
|
9
9
|
private
|
10
10
|
|
11
|
-
def
|
12
|
-
|
13
|
-
handle_http_404('Cannot find post_group_tag') if @entity.nil?
|
11
|
+
def component_slug
|
12
|
+
Biovision::Components::PostsComponent::SLUG
|
14
13
|
end
|
15
14
|
|
16
15
|
def restrict_access
|
17
|
-
|
16
|
+
error = 'Managing post tags is not allowed'
|
17
|
+
handle_http_401(error) unless component_handler.allow?('chief_editor')
|
18
|
+
end
|
19
|
+
|
20
|
+
def set_entity
|
21
|
+
@entity = PostGroupTag.find_by(id: params[:id])
|
22
|
+
handle_http_404('Cannot find post_group_tag') if @entity.nil?
|
18
23
|
end
|
19
24
|
end
|
@@ -51,12 +51,17 @@ class Admin::PostGroupsController < AdminController
|
|
51
51
|
|
52
52
|
private
|
53
53
|
|
54
|
-
def
|
55
|
-
|
56
|
-
handle_http_404('Cannot find post_group') if @entity.nil?
|
54
|
+
def component_slug
|
55
|
+
Biovision::Components::PostsComponent::SLUG
|
57
56
|
end
|
58
57
|
|
59
58
|
def restrict_access
|
60
|
-
|
59
|
+
error = 'Managing post groups is not allowed'
|
60
|
+
handle_http_401(error) unless component_handler.allow?('chief_editor')
|
61
|
+
end
|
62
|
+
|
63
|
+
def set_entity
|
64
|
+
@entity = PostGroup.find_by(id: params[:id])
|
65
|
+
handle_http_404('Cannot find post_group') if @entity.nil?
|
61
66
|
end
|
62
67
|
end
|
@@ -15,12 +15,17 @@ class Admin::PostIllustrationsController < AdminController
|
|
15
15
|
|
16
16
|
private
|
17
17
|
|
18
|
-
def
|
19
|
-
|
20
|
-
handle_http_404('Cannot find post_illustration') if @entity.nil?
|
18
|
+
def component_slug
|
19
|
+
Biovision::Components::PostsComponent::SLUG
|
21
20
|
end
|
22
21
|
|
23
22
|
def restrict_access
|
24
|
-
|
23
|
+
error = 'Viewing post illustrations is not allowed'
|
24
|
+
handle_http_401(error) unless component_handler.allow?
|
25
|
+
end
|
26
|
+
|
27
|
+
def set_entity
|
28
|
+
@entity = PostIllustration.find_by(id: params[:id])
|
29
|
+
handle_http_404('Cannot find post_illustration') if @entity.nil?
|
25
30
|
end
|
26
31
|
end
|
@@ -20,14 +20,19 @@ class Admin::PostImagesController < AdminController
|
|
20
20
|
|
21
21
|
private
|
22
22
|
|
23
|
+
def component_slug
|
24
|
+
Biovision::Components::PostsComponent::SLUG
|
25
|
+
end
|
26
|
+
|
27
|
+
def restrict_access
|
28
|
+
error = 'Viewing post images is not allowed'
|
29
|
+
handle_http_401(error) unless component_handler.allow?
|
30
|
+
end
|
31
|
+
|
23
32
|
def set_entity
|
24
33
|
@entity = PostImage.find_by(id: params[:id])
|
25
34
|
if @entity.nil?
|
26
35
|
handle_http_404('Cannot find post_image')
|
27
36
|
end
|
28
37
|
end
|
29
|
-
|
30
|
-
def restrict_access
|
31
|
-
require_privilege_group :editors
|
32
|
-
end
|
33
38
|
end
|
@@ -6,14 +6,19 @@ class Admin::PostLinksController < AdminController
|
|
6
6
|
|
7
7
|
private
|
8
8
|
|
9
|
+
def component_slug
|
10
|
+
Biovision::Components::PostsComponent::SLUG
|
11
|
+
end
|
12
|
+
|
13
|
+
def restrict_access
|
14
|
+
error = 'Managing post links is not allowed'
|
15
|
+
handle_http_401(error) unless component_handler.allow?
|
16
|
+
end
|
17
|
+
|
9
18
|
def set_entity
|
10
19
|
@entity = PostLink.find_by(id: params[:id])
|
11
20
|
if @entity.nil?
|
12
21
|
handle_http_404('Cannot find post_link')
|
13
22
|
end
|
14
23
|
end
|
15
|
-
|
16
|
-
def restrict_access
|
17
|
-
require_privilege_group :editors
|
18
|
-
end
|
19
24
|
end
|
@@ -17,14 +17,19 @@ class Admin::PostTagsController < AdminController
|
|
17
17
|
|
18
18
|
private
|
19
19
|
|
20
|
+
def component_slug
|
21
|
+
Biovision::Components::PostsComponent::SLUG
|
22
|
+
end
|
23
|
+
|
24
|
+
def restrict_access
|
25
|
+
error = 'Managing post tags is not allowed'
|
26
|
+
handle_http_401(error) unless component_handler.allow?('chief_editor')
|
27
|
+
end
|
28
|
+
|
20
29
|
def set_entity
|
21
30
|
@entity = PostTag.find_by(id: params[:id])
|
22
31
|
if @entity.nil?
|
23
32
|
handle_http_404('Cannot find post_tag')
|
24
33
|
end
|
25
34
|
end
|
26
|
-
|
27
|
-
def restrict_access
|
28
|
-
require_privilege_group :editors
|
29
|
-
end
|
30
35
|
end
|
@@ -29,14 +29,23 @@ class Admin::PostTypesController < AdminController
|
|
29
29
|
@collection = @entity.editorial_members.list_for_administration
|
30
30
|
end
|
31
31
|
|
32
|
+
# get /admin/post_types/:id/new_post
|
33
|
+
def new_post
|
34
|
+
end
|
35
|
+
|
32
36
|
private
|
33
37
|
|
34
|
-
def
|
35
|
-
|
36
|
-
handle_http_404('Cannot find post type') if @entity.nil?
|
38
|
+
def component_slug
|
39
|
+
Biovision::Components::PostsComponent::SLUG
|
37
40
|
end
|
38
41
|
|
39
42
|
def restrict_access
|
40
|
-
|
43
|
+
error = 'Viewing post types is not allowed'
|
44
|
+
handle_http_401(error) unless component_handler.allow?
|
45
|
+
end
|
46
|
+
|
47
|
+
def set_entity
|
48
|
+
@entity = PostType.find_by(id: params[:id])
|
49
|
+
handle_http_404('Cannot find post type') if @entity.nil?
|
41
50
|
end
|
42
51
|
end
|
@@ -29,15 +29,13 @@ class Admin::PostsController < AdminController
|
|
29
29
|
|
30
30
|
private
|
31
31
|
|
32
|
-
def
|
33
|
-
|
34
|
-
if @entity.nil?
|
35
|
-
handle_http_404('Cannot find post')
|
36
|
-
end
|
32
|
+
def component_slug
|
33
|
+
Biovision::Components::PostsComponent::SLUG
|
37
34
|
end
|
38
35
|
|
39
|
-
def
|
40
|
-
|
36
|
+
def set_entity
|
37
|
+
@entity = Post.find_by(id: params[:id])
|
38
|
+
handle_http_404('Cannot find post') if @entity.nil?
|
41
39
|
end
|
42
40
|
|
43
41
|
# @param [String] q
|
@@ -45,7 +43,7 @@ class Admin::PostsController < AdminController
|
|
45
43
|
if Post.respond_to?(:search)
|
46
44
|
Post.search(q).records.page(current_page)
|
47
45
|
else
|
48
|
-
Post.
|
46
|
+
Post.pg_search(q).page_for_administration(current_page)
|
49
47
|
end
|
50
48
|
end
|
51
49
|
end
|
@@ -1,11 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Articles for visitors
|
1
4
|
class ArticlesController < ApplicationController
|
2
5
|
before_action :set_category, only: :category
|
3
6
|
before_action :set_entity, only: :show
|
4
7
|
|
5
8
|
# get /articles
|
6
9
|
def index
|
7
|
-
|
8
|
-
@collection =
|
10
|
+
posts = PostType['article'].posts.for_language(current_language)
|
11
|
+
@collection = posts.page_for_visitors(current_page)
|
9
12
|
respond_to do |format|
|
10
13
|
format.html
|
11
14
|
format.json { render('posts/index') }
|
@@ -14,7 +17,8 @@ class ArticlesController < ApplicationController
|
|
14
17
|
|
15
18
|
# get /articles/:category_slug
|
16
19
|
def category
|
17
|
-
|
20
|
+
posts = Post.in_category_branch(@category).for_language(current_language)
|
21
|
+
@collection = posts.page_for_visitors(current_page)
|
18
22
|
respond_to do |format|
|
19
23
|
format.html
|
20
24
|
format.json { render('posts/index') }
|
@@ -26,18 +30,24 @@ class ArticlesController < ApplicationController
|
|
26
30
|
@entity.increment :view_count
|
27
31
|
@entity.increment :rating, 0.0025
|
28
32
|
@entity.save
|
33
|
+
|
34
|
+
render 'posts/show'
|
29
35
|
end
|
30
36
|
|
31
37
|
# get /articles/tagged/:tag_name
|
32
38
|
def tagged
|
33
|
-
|
34
|
-
@collection =
|
39
|
+
posts = PostType['article'].posts.tagged(params[:tag_name])
|
40
|
+
@collection = posts.page_for_visitors(current_page)
|
35
41
|
end
|
36
42
|
|
37
43
|
private
|
38
44
|
|
45
|
+
def component_slug
|
46
|
+
Biovision::Components::PostsComponent::SLUG
|
47
|
+
end
|
48
|
+
|
39
49
|
def set_category
|
40
|
-
type
|
50
|
+
type = PostType['article']
|
41
51
|
@category = type.post_categories.find_by(long_slug: params[:category_slug])
|
42
52
|
handle_http_404('Cannot find post category (article)') if @category.nil?
|
43
53
|
end
|