biovision-post 0.2.180325 → 0.21.190513.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +79 -13
- data/app/assets/images/biovision/post/icons/time.svg +6 -0
- data/app/assets/images/biovision/post/publisher_logo.png +0 -0
- data/app/assets/javascripts/biovision/post/biovision-posts.js +258 -0
- data/app/assets/stylesheets/biovision/post/admin/posts.scss +93 -0
- data/app/assets/stylesheets/biovision/post/posts.scss +88 -37
- data/app/controllers/admin/editorial_members_controller.rb +43 -0
- data/app/controllers/admin/featured_posts_controller.rb +23 -0
- data/app/controllers/admin/post_group_categories_controller.rb +19 -0
- data/app/controllers/admin/post_group_tags_controller.rb +19 -0
- data/app/controllers/admin/post_groups_controller.rb +62 -0
- data/app/controllers/admin/post_illustrations_controller.rb +26 -0
- data/app/controllers/admin/post_images_controller.rb +33 -0
- data/app/controllers/admin/post_links_controller.rb +19 -0
- data/app/controllers/admin/post_tags_controller.rb +30 -0
- data/app/controllers/admin/post_types_controller.rb +16 -4
- data/app/controllers/admin/posts_controller.rb +26 -2
- data/app/controllers/articles_controller.rb +23 -11
- data/app/controllers/authors_controller.rb +27 -0
- data/app/controllers/blog_posts_controller.rb +23 -11
- data/app/controllers/editorial_members_controller.rb +65 -0
- data/app/controllers/featured_posts_controller.rb +59 -0
- data/app/controllers/my/posts_controller.rb +124 -0
- data/app/controllers/news_controller.rb +23 -11
- data/app/controllers/post_categories_controller.rb +4 -14
- data/app/controllers/post_groups_controller.rb +76 -0
- data/app/controllers/post_illustrations_controller.rb +22 -0
- data/app/controllers/post_images_controller.rb +62 -0
- data/app/controllers/post_links_controller.rb +37 -0
- data/app/controllers/post_tags_controller.rb +41 -0
- data/app/controllers/posts_controller.rb +119 -14
- data/app/helpers/biovision_posts_helper.rb +114 -5
- data/app/jobs/application_job.rb +7 -0
- data/app/jobs/post_body_parser_job.rb +15 -0
- data/app/models/editorial_member.rb +92 -0
- data/app/models/editorial_member_post_type.rb +15 -0
- data/app/models/featured_post.rb +25 -0
- data/app/models/post.rb +203 -38
- data/app/models/post_category.rb +76 -54
- data/app/models/post_group.rb +84 -0
- data/app/models/post_group_category.rb +36 -0
- data/app/models/post_group_tag.rb +32 -0
- data/app/models/post_illustration.rb +62 -0
- data/app/models/post_image.rb +88 -0
- data/app/models/post_layout.rb +14 -0
- data/app/models/post_link.rb +2 -0
- data/app/models/post_post_category.rb +24 -0
- data/app/models/post_post_tag.rb +21 -0
- data/app/models/post_tag.rb +70 -0
- data/app/models/post_translation.rb +7 -0
- data/app/models/post_type.rb +18 -2
- data/app/models/post_zen_category.rb +6 -0
- data/app/models/zen_category.rb +21 -0
- data/app/services/post_manager.rb +52 -15
- data/app/services/post_parser.rb +80 -0
- data/app/uploaders/post_image_uploader.rb +9 -9
- data/app/views/admin/editorial_members/_nav_item.html.erb +2 -0
- data/app/views/admin/editorial_members/entity/_in_list.html.erb +37 -0
- data/app/views/admin/editorial_members/index.html.erb +15 -0
- data/app/views/admin/editorial_members/show.html.erb +71 -0
- data/app/views/admin/featured_posts/_add.html.erb +140 -0
- data/app/views/admin/featured_posts/_language.html.erb +14 -0
- data/app/views/admin/featured_posts/_nav_item.html.erb +2 -0
- data/app/views/admin/featured_posts/entity/_in_list.html.erb +26 -0
- data/app/views/admin/featured_posts/index.html.erb +18 -0
- data/app/views/admin/index/dashboard/_biovision_post.html.erb +32 -25
- data/app/views/admin/post_categories/entity/_in_list.html.erb +22 -6
- data/app/views/admin/post_categories/show.html.erb +6 -1
- data/app/views/admin/post_group_categories/entity/_in_list.html.erb +18 -0
- data/app/views/admin/post_group_tags/entity/_in_list.html.erb +18 -0
- data/app/views/admin/post_groups/_nav_item.html.erb +6 -0
- data/app/views/admin/post_groups/entity/_categories.html.erb +33 -0
- data/app/views/admin/post_groups/entity/_in_list.html.erb +25 -0
- data/app/views/admin/post_groups/index.html.erb +22 -0
- data/app/views/admin/post_groups/show.html.erb +65 -0
- data/app/views/admin/post_groups/tags.jbuilder +12 -0
- data/app/views/admin/post_illustrations/_nav_item.html.erb +6 -0
- data/app/views/admin/post_illustrations/entity/_in_list.html.erb +19 -0
- data/app/views/admin/post_illustrations/index.html.erb +23 -0
- data/app/views/admin/post_illustrations/show.html.erb +32 -0
- data/app/views/admin/post_images/_nav_item.html.erb +2 -0
- data/app/views/admin/post_images/entity/_in_list.html.erb +30 -0
- data/app/views/admin/post_images/index.html.erb +16 -0
- data/app/views/admin/post_images/show.html.erb +49 -0
- data/app/views/admin/post_links/entity/_in_list.html.erb +43 -0
- data/app/views/admin/post_tags/_nav_item.html.erb +2 -0
- data/app/views/admin/post_tags/entity/_in_list.html.erb +23 -0
- data/app/views/admin/post_tags/index.html.erb +16 -0
- data/app/views/admin/post_tags/posts.html.erb +18 -0
- data/app/views/admin/post_tags/show.html.erb +37 -0
- data/app/views/admin/post_types/authors.html.erb +23 -0
- data/app/views/admin/post_types/post_categories.html.erb +15 -4
- data/app/views/admin/post_types/post_tags.html.erb +18 -0
- data/app/views/admin/post_types/show.html.erb +28 -5
- data/app/views/admin/posts/_filter.html.erb +19 -0
- data/app/views/admin/posts/_nav_item.html.erb +3 -0
- data/app/views/admin/posts/_search_form.html.erb +13 -0
- data/app/views/admin/posts/entity/_in_list.html.erb +31 -7
- data/app/views/admin/posts/entity/_in_search.html.erb +8 -0
- data/app/views/admin/posts/entity/_links.html.erb +125 -0
- data/app/views/admin/posts/images.html.erb +22 -0
- data/app/views/admin/posts/index.html.erb +4 -0
- data/app/views/admin/posts/search.html.erb +21 -0
- data/app/views/admin/posts/search.jbuilder +26 -0
- data/app/views/admin/posts/show.html.erb +118 -18
- data/app/views/articles/category.html.erb +9 -9
- data/app/views/articles/index.html.erb +12 -9
- data/app/views/articles/show.html.erb +2 -4
- data/app/views/articles/tagged.html.erb +14 -0
- data/app/views/authors/_list.html.erb +18 -0
- data/app/views/authors/entity/_in_list.html.erb +9 -0
- data/app/views/authors/index.html.erb +10 -0
- data/app/views/authors/show.html.erb +31 -0
- data/app/views/blog_posts/category.html.erb +9 -9
- data/app/views/blog_posts/index.html.erb +12 -9
- data/app/views/blog_posts/show.html.erb +2 -4
- data/app/views/blog_posts/tagged.html.erb +14 -0
- data/app/views/editorial_members/_form.html.erb +107 -0
- data/app/views/editorial_members/edit.html.erb +17 -0
- data/app/views/editorial_members/new.html.erb +15 -0
- data/app/views/featured_posts/create.jbuilder +10 -0
- data/app/views/index/dashboard/_biovision_post.html.erb +18 -2
- data/app/views/my/index/dashboard/_biovision_post.html.erb +43 -0
- data/app/views/my/posts/_form.html.erb +357 -0
- data/app/views/my/posts/_list.html.erb +9 -0
- data/app/views/my/posts/_post.html.erb +80 -0
- data/app/views/my/posts/_preview.html.erb +35 -0
- data/app/views/my/posts/articles.html.erb +24 -0
- data/app/views/my/posts/blog_posts.html.erb +24 -0
- data/app/views/my/posts/edit.html.erb +19 -0
- data/app/views/my/posts/index.html.erb +14 -0
- data/app/views/my/posts/index/_navigation.html.erb +29 -0
- data/app/views/my/posts/new.html.erb +14 -0
- data/app/views/my/posts/news_index.html.erb +24 -0
- data/app/views/my/posts/show.html.erb +7 -0
- data/app/views/news/category.html.erb +9 -9
- data/app/views/news/index.html.erb +12 -9
- data/app/views/news/show.html.erb +2 -4
- data/app/views/news/tagged.html.erb +14 -0
- data/app/views/post_categories/_form.html.erb +82 -43
- data/app/views/post_groups/_form.html.erb +79 -0
- data/app/views/post_groups/edit.html.erb +17 -0
- data/app/views/post_groups/new.html.erb +15 -0
- data/app/views/post_groups/show.html.erb +10 -0
- data/app/views/post_images/_form.html.erb +121 -0
- data/app/views/post_images/edit.html.erb +19 -0
- data/app/views/post_images/new.html.erb +18 -0
- data/app/views/post_links/create.jbuilder +20 -0
- data/app/views/post_tags/_form.html.erb +26 -0
- data/app/views/post_tags/edit.html.erb +18 -0
- data/app/views/post_tags/new.html.erb +18 -0
- data/app/views/posts/_archive_dates.jbuilder +13 -0
- data/app/views/posts/_breadcrumbs.html.erb +4 -8
- data/app/views/posts/_calendar.html.erb +9 -0
- data/app/views/posts/_collection.html.erb +5 -0
- data/app/views/posts/_form.html.erb +204 -64
- data/app/views/posts/_list.html.erb +1 -1
- data/app/views/{articles/index.jbuilder → posts/_list.jbuilder} +3 -3
- data/app/views/posts/_post.html.erb +43 -16
- data/app/views/posts/_preview.html.erb +32 -21
- data/app/views/posts/_search.html.erb +6 -0
- data/app/views/posts/_wysiwyg.html.erb +25 -0
- data/app/views/posts/archive.jbuilder +3 -0
- data/app/views/posts/archive_day.html.erb +12 -0
- data/app/views/posts/category.html.erb +18 -0
- data/app/views/posts/entity/_gallery.html.erb +54 -0
- data/app/views/posts/entity/_linked_posts.html.erb +7 -0
- data/app/views/posts/entity/_metadata.html.erb +35 -12
- data/app/views/posts/entity/_publisher.html.erb +3 -1
- data/app/views/posts/form/_category_links.html.erb +32 -0
- data/app/views/posts/form/_gallery.html.erb +163 -0
- data/app/views/posts/index.html.erb +13 -0
- data/app/views/posts/index.jbuilder +1 -0
- data/app/views/posts/post_type/_category.html.erb +7 -0
- data/app/views/posts/post_type/_post_page.html.erb +9 -0
- data/app/views/posts/post_type/_posts.html.erb +5 -0
- data/app/views/posts/post_type/_tagged.html.erb +7 -0
- data/app/views/posts/rss.xml.erb +47 -0
- data/app/views/posts/search.html.erb +15 -0
- data/app/views/posts/show.html.erb +5 -3
- data/app/views/posts/tagged.html.erb +10 -0
- data/app/views/posts/tagged.jbuilder +1 -0
- data/app/views/posts/zen.xml.erb +42 -0
- data/config/locales/posts-en.yml +257 -19
- data/config/locales/posts-ru.yml +380 -14
- data/config/locales/posts-sv.yml +416 -0
- data/config/routes.rb +111 -15
- data/db/{migrate → amends}/20180124111113_add_language_to_posts.rb +0 -0
- data/db/{migrate → amends}/20180318215555_add_active_to_post_types.rb +0 -0
- data/db/amends/20180606120000_add_original_title_to_posts.rb +9 -0
- data/db/amends/20180606120001_add_time_required_to_posts.rb +11 -0
- data/db/amends/20180611111111_add_pubdate_and_translator_to_posts.rb +19 -0
- data/db/amends/20180618111111_add_default_category_name_to_post_types.rb +15 -0
- data/db/amends/20180703191919_add_rating_to_posts.rb +14 -0
- data/db/amends/20180810111111_add_explicit_to_posts.rb +11 -0
- data/db/amends/20180825111111_add_meta_description_to_post_categories.rb +11 -0
- data/db/amends/20180927111111_amend_editorial_member_about.rb +13 -0
- data/db/migrate/20170930000001_create_post_types.rb +98 -20
- data/db/migrate/20170930000010_create_posts.rb +194 -0
- data/db/migrate/20180706000000_create_editorial_members.rb +37 -0
- data/db/migrate/20180808000000_create_zen_categories.rb +42 -0
- data/db/migrate/20190202232323_add_spam_to_posts.rb +11 -0
- data/db/migrate/20190224212121_add_data_to_posts.rb +13 -0
- data/db/migrate/20190224212122_rename_post_image_source.rb +26 -0
- data/db/migrate/20190224212123_add_uuid_to_post_images.rb +10 -0
- data/db/migrate/20190313141414_convert_json_post_columns.rb +25 -0
- data/db/migrate/20190401101010_create_post_illustrations.rb +20 -0
- data/db/migrate/20190407101010_create_editorial_member_post_types.rb +18 -0
- data/db/migrate/20190410101010_add_avoid_parsing_to_posts.rb +14 -0
- data/db/migrate/20190410120000_create_post_groups.rb +47 -0
- data/db/migrate/20190412191919_add_nav_text_to_post_categories.rb +14 -0
- data/db/migrate/20190412212121_add_url_part_to_post_types.rb +26 -0
- data/db/migrate/20190420212121_create_post_layouts.rb +27 -0
- data/db/migrate/20190424161616_create_post_post_categories.rb +31 -0
- data/lib/biovision/post/version.rb +3 -1
- data/lib/tasks/posts.rake +6 -0
- metadata +170 -25
- data/app/assets/images/biovision/post/publisher_logo.svg +0 -3
- data/app/services/post_manager/article_handler.rb +0 -10
- data/app/services/post_manager/blog_post_handler.rb +0 -10
- data/app/services/post_manager/news_handler.rb +0 -10
- data/app/views/admin/index/dashboard/biovision_post/_additional_items.html.erb +0 -0
- data/app/views/blog_posts/index.jbuilder +0 -11
- data/app/views/news/index.jbuilder +0 -11
- data/app/views/post_categories/edit.jbuilder +0 -3
- data/app/views/post_categories/edit.js.erb +0 -1
- data/app/views/post_categories/new.jbuilder +0 -3
- data/app/views/post_categories/new.js.erb +0 -1
- data/db/migrate/20170930000002_create_post_categories.rb +0 -29
- data/db/migrate/20170930000003_create_posts.rb +0 -60
- data/db/migrate/20171218111111_add_meta_fields_to_posts.rb +0 -15
- data/db/migrate/20171219111112_add_author_fields_to_posts.rb +0 -11
- data/db/migrate/20180321100000_create_post_references.rb +0 -21
- data/db/migrate/20180321100001_create_post_notes.rb +0 -18
- data/db/migrate/20180321100002_create_post_links.rb +0 -20
@@ -0,0 +1,30 @@
|
|
1
|
+
class Admin::PostTagsController < AdminController
|
2
|
+
before_action :set_entity, except: [:index]
|
3
|
+
|
4
|
+
# get /admin/post_tags
|
5
|
+
def index
|
6
|
+
@collection = PostTag.page_for_administration(current_page)
|
7
|
+
end
|
8
|
+
|
9
|
+
# get /admin/post_tags/:id
|
10
|
+
def show
|
11
|
+
end
|
12
|
+
|
13
|
+
# get /admin/post_tags/:id/posts
|
14
|
+
def posts
|
15
|
+
@collection = @entity.posts.page_for_administration(current_page)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def set_entity
|
21
|
+
@entity = PostTag.find_by(id: params[:id])
|
22
|
+
if @entity.nil?
|
23
|
+
handle_http_404('Cannot find post_tag')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def restrict_access
|
28
|
+
require_privilege_group :editors
|
29
|
+
end
|
30
|
+
end
|
@@ -1,3 +1,6 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Administrative part of post type management
|
1
4
|
class Admin::PostTypesController < AdminController
|
2
5
|
before_action :set_entity, except: [:index]
|
3
6
|
|
@@ -8,20 +11,29 @@ class Admin::PostTypesController < AdminController
|
|
8
11
|
|
9
12
|
# get /admin/post_types/:id
|
10
13
|
def show
|
11
|
-
@
|
14
|
+
@filter = params[:filter] || {}
|
15
|
+
@collection = @entity.posts.page_for_administration(current_page, @filter)
|
12
16
|
end
|
13
17
|
|
14
18
|
# get /admin/post_types/:id/post_categories
|
15
19
|
def post_categories
|
16
20
|
end
|
17
21
|
|
22
|
+
# get /admin/post_types/:id/post_tags
|
23
|
+
def post_tags
|
24
|
+
@collection = @entity.post_tags.page_for_administration(current_page)
|
25
|
+
end
|
26
|
+
|
27
|
+
# get /admin/post_types/:id/authors
|
28
|
+
def authors
|
29
|
+
@collection = @entity.editorial_members.list_for_administration
|
30
|
+
end
|
31
|
+
|
18
32
|
private
|
19
33
|
|
20
34
|
def set_entity
|
21
35
|
@entity = PostType.find_by(id: params[:id])
|
22
|
-
if @entity.nil?
|
23
|
-
handle_http_404('Cannot find post type')
|
24
|
-
end
|
36
|
+
handle_http_404('Cannot find post type') if @entity.nil?
|
25
37
|
end
|
26
38
|
|
27
39
|
def restrict_access
|
@@ -1,17 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Administrative part for posts management
|
1
4
|
class Admin::PostsController < AdminController
|
5
|
+
include LockableEntity
|
2
6
|
include ToggleableEntity
|
3
7
|
|
4
|
-
before_action :set_entity, except: [
|
8
|
+
before_action :set_entity, except: %i[index search]
|
5
9
|
|
6
10
|
# get /admin/posts
|
7
11
|
def index
|
8
|
-
@
|
12
|
+
@filter = params[:filter] || {}
|
13
|
+
@collection = Post.page_for_administration(current_page, @filter)
|
9
14
|
end
|
10
15
|
|
11
16
|
# get /admin/posts/:id
|
12
17
|
def show
|
13
18
|
end
|
14
19
|
|
20
|
+
# get /admin/posts/:id/images
|
21
|
+
def images
|
22
|
+
@collection = @entity.post_images.list_for_administration
|
23
|
+
end
|
24
|
+
|
25
|
+
# get /admin/posts/search?q=
|
26
|
+
def search
|
27
|
+
@collection = params.key?(:q) ? search_posts(param_from_request(:q)) : []
|
28
|
+
end
|
29
|
+
|
15
30
|
private
|
16
31
|
|
17
32
|
def set_entity
|
@@ -24,4 +39,13 @@ class Admin::PostsController < AdminController
|
|
24
39
|
def restrict_access
|
25
40
|
require_privilege_group :editors
|
26
41
|
end
|
42
|
+
|
43
|
+
# @param [String] q
|
44
|
+
def search_posts(q)
|
45
|
+
if Post.respond_to?(:search)
|
46
|
+
Post.search(q).records.page(current_page)
|
47
|
+
else
|
48
|
+
Post.where('title ilike ?', "%#{q}%").page_for_administration(current_page)
|
49
|
+
end
|
50
|
+
end
|
27
51
|
end
|
@@ -1,21 +1,37 @@
|
|
1
1
|
class ArticlesController < ApplicationController
|
2
|
-
before_action :set_category, only:
|
3
|
-
before_action :set_entity, only:
|
2
|
+
before_action :set_category, only: :category
|
3
|
+
before_action :set_entity, only: :show
|
4
4
|
|
5
5
|
# get /articles
|
6
6
|
def index
|
7
7
|
post_type = PostType.find_by(slug: 'article')
|
8
8
|
@collection = post_type.posts.for_language(current_language).page_for_visitors(current_page)
|
9
|
+
respond_to do |format|
|
10
|
+
format.html
|
11
|
+
format.json { render('posts/index') }
|
12
|
+
end
|
9
13
|
end
|
10
14
|
|
11
15
|
# get /articles/:category_slug
|
12
16
|
def category
|
13
|
-
@collection = @category.
|
17
|
+
@collection = Post.in_category_branch(@category).for_language(current_language).page_for_visitors(current_page)
|
18
|
+
respond_to do |format|
|
19
|
+
format.html
|
20
|
+
format.json { render('posts/index') }
|
21
|
+
end
|
14
22
|
end
|
15
23
|
|
16
24
|
# get /articles/:post_id-:post_slug
|
17
25
|
def show
|
18
|
-
@entity.increment
|
26
|
+
@entity.increment :view_count
|
27
|
+
@entity.increment :rating, 0.0025
|
28
|
+
@entity.save
|
29
|
+
end
|
30
|
+
|
31
|
+
# get /articles/tagged/:tag_name
|
32
|
+
def tagged
|
33
|
+
post_type = PostType.find_by(slug: 'article')
|
34
|
+
@collection = post_type.posts.tagged(params[:tag_name]).page_for_visitors(current_page)
|
19
35
|
end
|
20
36
|
|
21
37
|
private
|
@@ -23,15 +39,11 @@ class ArticlesController < ApplicationController
|
|
23
39
|
def set_category
|
24
40
|
type = PostType.find_by(slug: 'article')
|
25
41
|
@category = type.post_categories.find_by(long_slug: params[:category_slug])
|
26
|
-
if @category.nil?
|
27
|
-
handle_http_404('Cannot find post category (article)')
|
28
|
-
end
|
42
|
+
handle_http_404('Cannot find post category (article)') if @category.nil?
|
29
43
|
end
|
30
44
|
|
31
45
|
def set_entity
|
32
|
-
@entity = Post.
|
33
|
-
if @entity.nil?
|
34
|
-
handle_http_404('Cannot find article')
|
35
|
-
end
|
46
|
+
@entity = Post.list_for_visitors.find_by(id: params[:post_id])
|
47
|
+
handle_http_404('Cannot find article') if @entity.nil?
|
36
48
|
end
|
37
49
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class AuthorsController < ApplicationController
|
2
|
+
before_action :set_entity, except: [:index]
|
3
|
+
|
4
|
+
# get /authors
|
5
|
+
def index
|
6
|
+
@collection = EditorialMember.list_for_visitors
|
7
|
+
end
|
8
|
+
|
9
|
+
# get /authors/:slug
|
10
|
+
def show
|
11
|
+
@collection = Post.owned_by(@entity.user).page_for_visitors(current_page)
|
12
|
+
respond_to do |format|
|
13
|
+
format.html
|
14
|
+
format.json { render('posts/index') }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def set_entity
|
21
|
+
user = User.find_by(slug: params[:slug].downcase, deleted: false)
|
22
|
+
@entity = EditorialMember.visible.find_by(user: user)
|
23
|
+
if @entity.nil?
|
24
|
+
handle_http_404('Cannot find user')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -1,21 +1,37 @@
|
|
1
1
|
class BlogPostsController < ApplicationController
|
2
|
-
before_action :set_category, only:
|
3
|
-
before_action :set_entity, only:
|
2
|
+
before_action :set_category, only: :category
|
3
|
+
before_action :set_entity, only: :show
|
4
4
|
|
5
5
|
# get /blog_posts
|
6
6
|
def index
|
7
7
|
post_type = PostType.find_by(slug: 'blog_post')
|
8
8
|
@collection = post_type.posts.for_language(current_language).page_for_visitors(current_page)
|
9
|
+
respond_to do |format|
|
10
|
+
format.html
|
11
|
+
format.json { render('posts/index') }
|
12
|
+
end
|
9
13
|
end
|
10
14
|
|
11
15
|
# get /blog_posts/:category_slug
|
12
16
|
def category
|
13
|
-
@collection = @category.
|
17
|
+
@collection = Post.in_category_branch(@category).for_language(current_language).page_for_visitors(current_page)
|
18
|
+
respond_to do |format|
|
19
|
+
format.html
|
20
|
+
format.json { render('posts/index') }
|
21
|
+
end
|
14
22
|
end
|
15
23
|
|
16
24
|
# get /blog_posts/:post_id-:post_slug
|
17
25
|
def show
|
18
|
-
@entity.increment
|
26
|
+
@entity.increment :view_count
|
27
|
+
@entity.increment :rating, 0.0025
|
28
|
+
@entity.save
|
29
|
+
end
|
30
|
+
|
31
|
+
# get /blog_posts/tagged/:tag_name
|
32
|
+
def tagged
|
33
|
+
post_type = PostType.find_by(slug: 'blog_post')
|
34
|
+
@collection = post_type.posts.tagged(params[:tag_name]).page_for_visitors(current_page)
|
19
35
|
end
|
20
36
|
|
21
37
|
private
|
@@ -23,15 +39,11 @@ class BlogPostsController < ApplicationController
|
|
23
39
|
def set_category
|
24
40
|
type = PostType.find_by(slug: 'blog_post')
|
25
41
|
@category = type.post_categories.find_by(long_slug: params[:category_slug])
|
26
|
-
if @category.nil?
|
27
|
-
handle_http_404('Cannot find post category (blog_post)')
|
28
|
-
end
|
42
|
+
handle_http_404('Cannot find post category (blog_post)') if @category.nil?
|
29
43
|
end
|
30
44
|
|
31
45
|
def set_entity
|
32
|
-
@entity = Post.
|
33
|
-
if @entity.nil?
|
34
|
-
handle_http_404('Cannot find blog_post')
|
35
|
-
end
|
46
|
+
@entity = Post.list_for_visitors.find_by(id: params[:post_id])
|
47
|
+
handle_http_404('Cannot find blog_post') if @entity.nil?
|
36
48
|
end
|
37
49
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
class EditorialMembersController < AdminController
|
2
|
+
before_action :set_entity, only: [:edit, :update, :destroy]
|
3
|
+
|
4
|
+
# get /editorial_members/new
|
5
|
+
def new
|
6
|
+
@entity = EditorialMember.new
|
7
|
+
end
|
8
|
+
|
9
|
+
# post /editorial_members
|
10
|
+
def create
|
11
|
+
@entity = EditorialMember.new(creation_parameters)
|
12
|
+
if @entity.save
|
13
|
+
set_post_type_links
|
14
|
+
form_processed_ok(admin_editorial_member_path(id: @entity.id))
|
15
|
+
else
|
16
|
+
form_processed_with_error(:new)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# get /editorial_members/:id/edit
|
21
|
+
def edit
|
22
|
+
end
|
23
|
+
|
24
|
+
# patch /editorial_members/:id
|
25
|
+
def update
|
26
|
+
if @entity.update(entity_parameters)
|
27
|
+
set_post_type_links
|
28
|
+
form_processed_ok(admin_editorial_member_path(id: @entity.id))
|
29
|
+
else
|
30
|
+
form_processed_with_error(:edit)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# delete /editorial_members/:id
|
35
|
+
def destroy
|
36
|
+
flash[:notice] = t('editorial_members.destroy.success') if @entity.destroy
|
37
|
+
|
38
|
+
redirect_to editorial_members_admin_post_type_path(id: @entity.post_type_id)
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def set_entity
|
44
|
+
@entity = EditorialMember.find_by(id: params[:id])
|
45
|
+
if @entity.nil?
|
46
|
+
handle_http_404('Cannot find editorial_member')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def restrict_access
|
51
|
+
require_privilege :chief_editor
|
52
|
+
end
|
53
|
+
|
54
|
+
def entity_parameters
|
55
|
+
params.require(:editorial_member).permit(EditorialMember.entity_parameters)
|
56
|
+
end
|
57
|
+
|
58
|
+
def creation_parameters
|
59
|
+
params.require(:editorial_member).permit(EditorialMember.creation_parameters)
|
60
|
+
end
|
61
|
+
|
62
|
+
def set_post_type_links
|
63
|
+
@entity.post_type_ids = Array(params[:post_type_ids]).map(&:to_i)
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
class FeaturedPostsController < AdminController
|
2
|
+
before_action :set_entity, only: :destroy
|
3
|
+
|
4
|
+
# post /featured_posts
|
5
|
+
def create
|
6
|
+
@entity = FeaturedPost.new(creation_parameters)
|
7
|
+
bump_priority
|
8
|
+
if @entity.save
|
9
|
+
render status: :created
|
10
|
+
else
|
11
|
+
render json: { errors: @entity.errors }, status: :bad_request
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# delete /featured_posts/:id
|
16
|
+
def destroy
|
17
|
+
@entity.destroy
|
18
|
+
|
19
|
+
head :no_content
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def restrict_access
|
25
|
+
require_privilege :chief_editor
|
26
|
+
end
|
27
|
+
|
28
|
+
def creation_parameters
|
29
|
+
post = Post.find_by(id: params[:post_id])
|
30
|
+
if post.nil?
|
31
|
+
{ post_id: nil, language_id: nil }
|
32
|
+
else
|
33
|
+
{ post_id: post.id, language_id: post.language_id }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def set_entity
|
38
|
+
@entity = FeaturedPost.find_by(id: params[:id])
|
39
|
+
if @entity.nil?
|
40
|
+
handle_http_404('Cannot find featured_post')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def bump_priority
|
45
|
+
@entity.priority = 1
|
46
|
+
|
47
|
+
criteria = {
|
48
|
+
language_id: @entity&.language_id,
|
49
|
+
priority: 1
|
50
|
+
}
|
51
|
+
return unless FeaturedPost.exists?(criteria)
|
52
|
+
|
53
|
+
query = %(update #{FeaturedPost.table_name}
|
54
|
+
set priority = priority + 1
|
55
|
+
where language_id = #{criteria[:language_id]};)
|
56
|
+
|
57
|
+
FeaturedPost.connection.execute(query)
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
class My::PostsController < ProfileController
|
2
|
+
before_action :set_entity, only: [:show, :edit, :update, :destroy]
|
3
|
+
before_action :restrict_editing, only: [:edit, :update, :destroy]
|
4
|
+
|
5
|
+
# get /my/posts
|
6
|
+
def index
|
7
|
+
@collection = Post.page_for_owner(current_user, current_page)
|
8
|
+
end
|
9
|
+
|
10
|
+
# get /my/posts/new
|
11
|
+
def new
|
12
|
+
@entity = Post.new
|
13
|
+
end
|
14
|
+
|
15
|
+
# get /my/articles/new
|
16
|
+
def new_article
|
17
|
+
if current_user_has_privilege?(:editor)
|
18
|
+
@entity = Post.of_type(:article).new
|
19
|
+
render :new
|
20
|
+
else
|
21
|
+
handle_http_401('User has no editor privilege')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# get /my/news/new
|
26
|
+
def new_news
|
27
|
+
if current_user_has_privilege?(:reporter)
|
28
|
+
@entity = Post.of_type(:news).new
|
29
|
+
render :new
|
30
|
+
else
|
31
|
+
handle_http_401('User has no reporter privilege')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# get /my/blog_posts/new
|
36
|
+
def new_blog_post
|
37
|
+
if current_user_has_privilege?(:blogger)
|
38
|
+
@entity = Post.of_type(:blog_post).new
|
39
|
+
render :new
|
40
|
+
else
|
41
|
+
handle_http_401('User has no blogger privilege')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# post /my/posts
|
46
|
+
def create
|
47
|
+
@entity = Post.new(creation_parameters)
|
48
|
+
if @entity.save
|
49
|
+
apply_post_tags
|
50
|
+
form_processed_ok(my_post_path(id: @entity.id))
|
51
|
+
else
|
52
|
+
form_processed_with_error(:new)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# get /my/posts/:id
|
57
|
+
def show
|
58
|
+
end
|
59
|
+
|
60
|
+
# get /my/posts/:id/edit
|
61
|
+
def edit
|
62
|
+
end
|
63
|
+
|
64
|
+
# patch /my/posts/:id
|
65
|
+
def update
|
66
|
+
if @entity.update(entity_parameters)
|
67
|
+
apply_post_tags
|
68
|
+
form_processed_ok(my_post_path(id: @entity.id))
|
69
|
+
else
|
70
|
+
form_processed_with_error(:edit)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# delete /my/posts/:id
|
75
|
+
def destroy
|
76
|
+
if @entity.destroy
|
77
|
+
flash[:notice] = t('posts.destroy.success')
|
78
|
+
end
|
79
|
+
redirect_to my_posts_path
|
80
|
+
end
|
81
|
+
|
82
|
+
# get /my/articles
|
83
|
+
def articles
|
84
|
+
@collection = Post.of_type(:article).page_for_owner(current_user, current_page)
|
85
|
+
end
|
86
|
+
|
87
|
+
# get /my/news
|
88
|
+
def news_index
|
89
|
+
@collection = Post.of_type(:news).page_for_owner(current_user, current_page)
|
90
|
+
end
|
91
|
+
|
92
|
+
# get /my/blog
|
93
|
+
def blog_posts
|
94
|
+
@collection = Post.of_type(:blog_post).page_for_owner(current_user, current_page)
|
95
|
+
end
|
96
|
+
|
97
|
+
private
|
98
|
+
|
99
|
+
def set_entity
|
100
|
+
@entity = Post.owned_by(current_user).find_by(id: params[:id])
|
101
|
+
if @entity.nil?
|
102
|
+
handle_http_404('Cannot find post')
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def restrict_editing
|
107
|
+
if @entity.locked?
|
108
|
+
handle_http_403('Entity is locked')
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def entity_parameters
|
113
|
+
params.require(:post).permit(Post.entity_parameters)
|
114
|
+
end
|
115
|
+
|
116
|
+
def creation_parameters
|
117
|
+
parameters = params.require(:post).permit(Post.creation_parameters)
|
118
|
+
parameters.merge(owner_for_entity(true))
|
119
|
+
end
|
120
|
+
|
121
|
+
def apply_post_tags
|
122
|
+
@entity.tags_string = param_from_request(:tags_string)
|
123
|
+
end
|
124
|
+
end
|