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
File without changes
|
File without changes
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class AddPubdateAndTranslatorToPosts < ActiveRecord::Migration[5.2]
|
2
|
+
def up
|
3
|
+
unless column_exists? :posts, :publication_time
|
4
|
+
add_column :posts, :publication_time, :datetime
|
5
|
+
end
|
6
|
+
|
7
|
+
unless column_exists? :posts, :translator_name
|
8
|
+
add_column :posts, :translator_name, :string
|
9
|
+
end
|
10
|
+
|
11
|
+
Post.where(publication_time: nil).order('id asc').each do |post|
|
12
|
+
post.update! publication_time: post.created_at
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def down
|
17
|
+
# no rollback needed
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class AddDefaultCategoryNameToPostTypes < ActiveRecord::Migration[5.2]
|
2
|
+
def up
|
3
|
+
unless column_exists?(:post_types, :default_category_name)
|
4
|
+
add_column :post_types, :default_category_name, :string
|
5
|
+
|
6
|
+
PostType.find_by(slug: 'news')&.update(default_category_name: 'Новости')
|
7
|
+
PostType.find_by(slug: 'article')&.update(default_category_name: 'Статьи')
|
8
|
+
PostType.find_by(slug: 'blog_post')&.update(default_category_name: 'Блог')
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def down
|
13
|
+
# no rollback needed
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class AddRatingToPosts < ActiveRecord::Migration[5.2]
|
2
|
+
def up
|
3
|
+
unless column_exists?(:posts, :allow_votes)
|
4
|
+
add_column :posts, :allow_votes, :boolean, default: true, null: false
|
5
|
+
end
|
6
|
+
unless column_exists?(:posts, :rating)
|
7
|
+
add_column :posts, :rating, :float, default: 0.0, null: false
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def down
|
12
|
+
# no rollback needed
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class AddMetaDescriptionToPostCategories < ActiveRecord::Migration[5.2]
|
2
|
+
def up
|
3
|
+
unless column_exists?(:post_categories, :meta_description)
|
4
|
+
add_column :post_categories, :meta_description, :string
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
def down
|
9
|
+
# No need to rollback
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class AmendEditorialMemberAbout < ActiveRecord::Migration[5.2]
|
2
|
+
def up
|
3
|
+
EditorialMember.order('id asc').each do |entity|
|
4
|
+
next if entity.about[0] == '<'
|
5
|
+
|
6
|
+
entity.update! about: "<p>#{entity.about.gsub(/\r?\n/, '</p><p>')}</p>"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def down
|
11
|
+
# No rollback needed
|
12
|
+
end
|
13
|
+
end
|
@@ -1,27 +1,105 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Tables for post types, categories and tags
|
4
|
+
class CreatePostTypes < ActiveRecord::Migration[5.2]
|
2
5
|
def up
|
3
|
-
unless PostType.table_exists?
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
t.integer :posts_count, default: 0, null: false
|
8
|
-
t.integer :category_depth, limit: 2, default: 0
|
9
|
-
t.string :name, null: false
|
10
|
-
t.string :slug, null: false
|
11
|
-
end
|
12
|
-
|
13
|
-
add_index :post_types, :slug, unique: true
|
14
|
-
add_index :post_types, :name, unique: true
|
15
|
-
|
16
|
-
PostType.create(slug: 'blog_post', name: 'Запись в блоге')
|
17
|
-
PostType.create(slug: 'article', name: 'Статья')
|
18
|
-
PostType.create(slug: 'news', name: 'Новость')
|
19
|
-
end
|
6
|
+
create_post_types unless PostType.table_exists?
|
7
|
+
create_post_categories unless PostCategory.table_exists?
|
8
|
+
create_post_tags unless PostTag.table_exists?
|
9
|
+
create_post_layouts unless PostLayout.table_exists?
|
20
10
|
end
|
21
11
|
|
22
12
|
def down
|
23
|
-
if
|
24
|
-
|
13
|
+
drop_table :post_layouts if PostLayout.table_exists?
|
14
|
+
drop_table :post_tags if PostTag.table_exists?
|
15
|
+
drop_table :post_categories if PostCategory.table_exists?
|
16
|
+
drop_table :post_types if PostType.table_exists?
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def create_post_types
|
22
|
+
create_table :post_types, comment: 'Post type' do |t|
|
23
|
+
t.timestamps
|
24
|
+
t.boolean :active, default: true, null: false
|
25
|
+
t.integer :posts_count, default: 0, null: false
|
26
|
+
t.integer :category_depth, limit: 2, default: 0
|
27
|
+
t.string :name, null: false
|
28
|
+
t.string :slug, null: false
|
29
|
+
t.string :url_part, null: false
|
30
|
+
t.string :default_category_name
|
31
|
+
end
|
32
|
+
|
33
|
+
add_index :post_types, :slug, unique: true
|
34
|
+
add_index :post_types, :name, unique: true
|
35
|
+
|
36
|
+
create_default_types
|
37
|
+
create_privileges
|
38
|
+
end
|
39
|
+
|
40
|
+
def create_post_categories
|
41
|
+
create_table :post_categories, comment: 'Post category' do |t|
|
42
|
+
t.references :post_type, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
43
|
+
t.integer :parent_id
|
44
|
+
t.timestamps
|
45
|
+
t.integer :priority, limit: 2, default: 1, null: false
|
46
|
+
t.integer :posts_count, default: 0, null: false
|
47
|
+
t.boolean :locked, default: false, null: false
|
48
|
+
t.boolean :visible, default: true, null: false
|
49
|
+
t.boolean :deleted, default: false, null: false
|
50
|
+
t.string :name, null: false
|
51
|
+
t.string :nav_text
|
52
|
+
t.string :slug, null: false
|
53
|
+
t.string :long_slug, null: false
|
54
|
+
t.string :meta_description
|
55
|
+
t.string :parents_cache, default: '', null: false
|
56
|
+
t.integer :children_cache, default: [], array: true, null: false
|
57
|
+
end
|
58
|
+
|
59
|
+
add_foreign_key :post_categories, :post_categories, column: :parent_id, on_update: :cascade, on_delete: :cascade
|
60
|
+
end
|
61
|
+
|
62
|
+
def create_post_tags
|
63
|
+
create_table :post_tags, comment: 'Post tag' do |t|
|
64
|
+
t.timestamps
|
65
|
+
t.references :post_type, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
66
|
+
t.integer :posts_count, default: 0, null: false
|
67
|
+
t.string :name
|
68
|
+
t.string :slug, index: true
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def create_post_layouts
|
73
|
+
create_table :post_layouts, comment: 'Post layout' do |t|
|
74
|
+
t.integer :posts_count, default: 0, null: false
|
75
|
+
t.string :slug
|
76
|
+
t.string :name
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def create_default_types
|
81
|
+
items = {
|
82
|
+
blog_post: ['Запись в блоге', 'blog_posts', 'Блог'],
|
83
|
+
article: %w[Статья articles Статьи],
|
84
|
+
news: %w[Новость news Новости]
|
85
|
+
}
|
86
|
+
|
87
|
+
items.each do |slug, data|
|
88
|
+
PostType.create(slug: slug, name: data[0], url_part: data[1], default_category_name: data[2])
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def create_privileges
|
93
|
+
group = PrivilegeGroup.find_by(slug: 'editors') || PrivilegeGroup.create!(slug: 'editors', name: 'Редакторы')
|
94
|
+
chief_editor = Privilege.find_by(slug: 'chief_editor') || Privilege.create(slug: 'chief_editor', name: 'Главный редактор')
|
95
|
+
children = {
|
96
|
+
editor: 'Редактор'
|
97
|
+
}
|
98
|
+
|
99
|
+
children.each do |slug, name|
|
100
|
+
child = Privilege.new(parent: chief_editor, slug: slug, name: name, administrative: false)
|
101
|
+
|
102
|
+
group.add_privilege(child) if child.save
|
25
103
|
end
|
26
104
|
end
|
27
105
|
end
|
@@ -0,0 +1,194 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Create tables for posts and post-related items
|
4
|
+
class CreatePosts < ActiveRecord::Migration[5.2]
|
5
|
+
def up
|
6
|
+
create_posts unless Post.table_exists?
|
7
|
+
create_post_post_tags unless PostPostTag.table_exists?
|
8
|
+
create_post_post_categories unless PostPostCategory.table_exists?
|
9
|
+
create_post_images unless PostImage.table_exists?
|
10
|
+
create_post_links unless PostLink.table_exists?
|
11
|
+
create_post_translations unless PostTranslation.table_exists?
|
12
|
+
create_post_references unless PostReference.table_exists?
|
13
|
+
create_post_notes unless PostNote.table_exists?
|
14
|
+
create_featured_posts unless FeaturedPost.table_exists?
|
15
|
+
create_post_illustrations unless PostIllustration.table_exists?
|
16
|
+
end
|
17
|
+
|
18
|
+
def down
|
19
|
+
drop_table :post_illustrations if PostIllustration.table_exists?
|
20
|
+
drop_table :featured_posts if FeaturedPost.table_exists?
|
21
|
+
drop_table :post_notes if PostNote.table_exists?
|
22
|
+
drop_table :post_references if PostReference.table_exists?
|
23
|
+
drop_table :post_translations if PostTranslation.table_exists?
|
24
|
+
drop_table :post_links if PostLink.table_exists?
|
25
|
+
drop_table :post_images if PostImage.table_exists?
|
26
|
+
drop_table :post_post_categories if PostPostCategory.table_exists?
|
27
|
+
drop_table :post_post_tags if PostPostTag.table_exists?
|
28
|
+
drop_table :posts if Post.table_exists?
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def create_posts
|
34
|
+
create_table :posts, comment: 'Post' do |t|
|
35
|
+
t.references :user, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
36
|
+
t.references :post_type, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
37
|
+
t.references :language, foreign_key: { on_update: :cascade, on_delete: :nullify }
|
38
|
+
t.integer :region_id
|
39
|
+
t.integer :original_post_id
|
40
|
+
t.references :agent, foreign_key: { on_update: :cascade, on_delete: :nullify }
|
41
|
+
t.inet :ip
|
42
|
+
t.timestamps
|
43
|
+
t.boolean :visible, default: true, null: false
|
44
|
+
t.boolean :locked, default: false, null: false
|
45
|
+
t.boolean :deleted, default: false, null: false
|
46
|
+
t.boolean :approved, default: true, null: false
|
47
|
+
t.boolean :show_owner, default: true, null: false
|
48
|
+
t.boolean :allow_comments, default: true, null: false
|
49
|
+
t.boolean :allow_votes, default: true, null: false
|
50
|
+
t.boolean :translation, default: false, null: false
|
51
|
+
t.boolean :explicit, default: false, null: false
|
52
|
+
t.boolean :spam, default: false, null: false
|
53
|
+
t.boolean :avoid_parsing, default: false, null: false
|
54
|
+
t.float :rating, default: 0.0, null: false
|
55
|
+
t.integer :privacy, limit: 2, default: 0
|
56
|
+
t.integer :comments_count, default: 0, null: false
|
57
|
+
t.integer :view_count, default: 0, null: false
|
58
|
+
t.integer :upvote_count, default: 0, null: false
|
59
|
+
t.integer :downvote_count, default: 0, null: false
|
60
|
+
t.integer :vote_result, default: 0, null: false
|
61
|
+
t.integer :time_required, limit: 2
|
62
|
+
t.datetime :publication_time
|
63
|
+
t.uuid :uuid, null: false
|
64
|
+
t.string :title, null: false
|
65
|
+
t.string :slug, null: false, index: true
|
66
|
+
t.string :image
|
67
|
+
t.string :image_alt_text
|
68
|
+
t.string :image_name
|
69
|
+
t.string :image_source_name
|
70
|
+
t.string :image_source_link
|
71
|
+
t.string :original_title
|
72
|
+
t.string :source_name
|
73
|
+
t.string :source_link
|
74
|
+
t.string :meta_title
|
75
|
+
t.string :meta_keywords
|
76
|
+
t.string :meta_description
|
77
|
+
t.string :author_name
|
78
|
+
t.string :author_title
|
79
|
+
t.string :author_url
|
80
|
+
t.string :translator_name
|
81
|
+
t.text :lead
|
82
|
+
t.text :body, null: false
|
83
|
+
t.text :parsed_body
|
84
|
+
t.string :tags_cache, array: true, default: [], null: false
|
85
|
+
t.jsonb :data, default: {}, null: false
|
86
|
+
end
|
87
|
+
|
88
|
+
execute "create index posts_created_at_month_idx on posts using btree (date_trunc('month', created_at), post_type_id, user_id);"
|
89
|
+
execute "create index posts_pubdate_month_idx on posts using btree (date_trunc('month', publication_time), post_type_id, user_id);"
|
90
|
+
|
91
|
+
add_foreign_key :posts, :posts, column: :original_post_id, on_update: :cascade, on_delete: :nullify
|
92
|
+
|
93
|
+
add_index :posts, :created_at
|
94
|
+
add_index :posts, :data, using: :gin
|
95
|
+
|
96
|
+
if Gem.loaded_specs.key?('elasticsearch-model')
|
97
|
+
Post.__elasticsearch__.create_index!
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def create_post_post_tags
|
102
|
+
create_table :post_post_tags, comment: 'Link between post and tag' do |t|
|
103
|
+
t.references :post, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
104
|
+
t.references :post_tag, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
105
|
+
t.timestamps
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def create_post_post_categories
|
110
|
+
create_table :post_post_categories, comment: 'Post in post category' do |t|
|
111
|
+
t.references :post, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
112
|
+
t.references :post_category, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
113
|
+
t.timestamps
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def create_post_links
|
118
|
+
create_table :post_links, comment: 'Link between posts' do |t|
|
119
|
+
t.references :post, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
120
|
+
t.integer :other_post_id, null: false
|
121
|
+
t.timestamps
|
122
|
+
t.integer :priority, limit: 2, default: 1, null: false
|
123
|
+
end
|
124
|
+
|
125
|
+
add_foreign_key :post_links, :posts, column: :other_post_id, on_update: :cascade, on_delete: :cascade
|
126
|
+
end
|
127
|
+
|
128
|
+
def create_post_images
|
129
|
+
create_table :post_images, comment: 'Image in post gallery' do |t|
|
130
|
+
t.references :post, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
131
|
+
t.timestamps
|
132
|
+
t.boolean :visible, default: true, null: false
|
133
|
+
t.integer :priority, limit: 2, default: 1, null: false
|
134
|
+
t.uuid :uuid
|
135
|
+
t.string :image
|
136
|
+
t.string :image_alt_text
|
137
|
+
t.string :caption
|
138
|
+
t.string :source_name
|
139
|
+
t.string :source_link
|
140
|
+
t.text :description
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def create_post_translations
|
145
|
+
create_table :post_translations, comment: 'Post translation' do |t|
|
146
|
+
t.references :post, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
147
|
+
t.references :language, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
148
|
+
t.integer :translated_post_id, null: false
|
149
|
+
t.timestamps
|
150
|
+
end
|
151
|
+
|
152
|
+
add_foreign_key :post_translations, :posts, column: :translated_post_id, on_update: :cascade, on_delete: :cascade
|
153
|
+
end
|
154
|
+
|
155
|
+
def create_post_references
|
156
|
+
create_table :post_references, comment: 'Reference in post body' do |t|
|
157
|
+
t.references :post, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
158
|
+
t.timestamps
|
159
|
+
t.integer :priority, limit: 2, default: 1, null: false
|
160
|
+
t.string :authors
|
161
|
+
t.string :title, null: false
|
162
|
+
t.string :url
|
163
|
+
t.string :publishing_info
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def create_post_notes
|
168
|
+
create_table :post_notes, comment: 'Footnote for post' do |t|
|
169
|
+
t.references :post, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
170
|
+
t.timestamps
|
171
|
+
t.integer :priority, limit: 2, default: 1, null: false
|
172
|
+
t.text :text, null: false
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def create_featured_posts
|
177
|
+
create_table :featured_posts do |t|
|
178
|
+
t.references :language, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
179
|
+
t.references :post, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
180
|
+
t.timestamps
|
181
|
+
t.integer :priority, limit: 2, null: false, default: 1
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
def create_post_illustrations
|
186
|
+
create_table :post_illustrations, comment: 'Inline post illustration' do |t|
|
187
|
+
t.references :user, foreign_key: { on_update: :cascade, on_delete: :nullify }
|
188
|
+
t.references :agent, foreign_key: { on_update: :cascade, on_delete: :nullify }
|
189
|
+
t.inet :ip
|
190
|
+
t.timestamps
|
191
|
+
t.string :image
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Table for editorial members
|
4
|
+
class CreateEditorialMembers < ActiveRecord::Migration[5.2]
|
5
|
+
def up
|
6
|
+
create_editorial_members unless EditorialMember.table_exists?
|
7
|
+
create_member_post_types unless EditorialMemberPostType.table_exists?
|
8
|
+
end
|
9
|
+
|
10
|
+
def down
|
11
|
+
drop_table :editorial_member_post_types if EditorialMemberPostType.table_exists?
|
12
|
+
drop_table :editorial_members if EditorialMember.table_exists?
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def create_editorial_members
|
18
|
+
create_table :editorial_members, comment: 'Editorial member' do |t|
|
19
|
+
t.references :user, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
20
|
+
t.timestamps
|
21
|
+
t.boolean :visible, default: true, null: false
|
22
|
+
t.integer :priority, limit: 2, default: 1, null: false
|
23
|
+
t.string :title
|
24
|
+
t.text :lead
|
25
|
+
t.text :about
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
def create_member_post_types
|
31
|
+
create_table :editorial_member_post_types, comment: 'Available post type for editorial member' do |t|
|
32
|
+
t.references :editorial_member, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
33
|
+
t.references :post_type, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
34
|
+
t.timestamps
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|