biovision-base 0.34.190331.1 → 0.36.190526.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/javascripts/biovision/base/biovision.js +52 -7
- data/app/assets/javascripts/biovision/base/components/carousel.js +127 -17
- data/app/assets/javascripts/biovision/base/components/video-stretcher.js +51 -0
- data/app/assets/stylesheets/biovision/base/biovision.scss +18 -2
- data/app/controllers/admin/settings_controller.rb +7 -12
- data/app/controllers/admin_controller.rb +4 -0
- data/app/controllers/concerns/authentication.rb +3 -0
- data/app/controllers/editable_pages_controller.rb +2 -0
- data/app/controllers/my/profiles_controller.rb +1 -1
- data/app/helpers/biovision_users_helper.rb +1 -1
- data/app/jobs/editable_page_body_parser_job.rb +16 -0
- data/app/models/biovision_component.rb +18 -11
- data/app/models/editable_page.rb +21 -16
- data/app/models/foreign_site.rb +9 -3
- data/app/services/biovision/components/base_component.rb +17 -40
- data/app/services/canonizer.rb +21 -14
- data/app/services/oembed_receiver.rb +92 -0
- data/app/services/user_bouncer.rb +3 -4
- data/app/uploaders/simple_file_uploader.rb +15 -0
- data/app/views/admin/editable_pages/entity/_in_list.html.erb +1 -1
- data/app/views/admin/editable_pages/show.html.erb +2 -2
- data/app/views/admin/index/_biovision_base.html.erb +2 -2
- data/app/views/admin/settings/component/_new_parameter.html.erb +5 -13
- data/app/views/admin/settings/component/_parameters.html.erb +6 -6
- data/app/views/admin/settings/show.html.erb +1 -1
- data/app/views/admin/users/entity/_in_list.html.erb +3 -0
- data/app/views/admin/users/show.html.erb +1 -1
- data/app/views/editable_pages/_editable_page.html.erb +1 -1
- data/app/views/editable_pages/_form.html.erb +2 -2
- data/app/views/editable_pages/entity/_content.html.erb +1 -1
- data/app/views/editable_pages/entity/_metadata.html.erb +12 -10
- data/app/views/index/index/_default_dashboard.html.erb +3 -1
- data/app/views/my/index/index/_dashboard.html.erb +16 -0
- data/app/views/shared/_breadcrumbs.html.erb +4 -2
- data/app/views/shared/_track.html.erb +8 -8
- data/app/views/shared/admin/_breadcrumbs.html.erb +4 -2
- data/app/views/shared/editable_pages/_body.html.erb +2 -2
- data/app/views/shared/entity/_metadata.html.erb +13 -0
- data/app/views/shared/forms/_toggle_wysiwyg.html.erb +24 -0
- data/app/views/shared/forms/_wysiwyg.html.erb +1 -1
- data/app/views/simple_blocks/_form.html.erb +12 -0
- data/app/views/users/_form.html.erb +22 -22
- data/config/locales/components-ru.yml +2 -3
- data/config/routes.rb +41 -90
- data/db/migrate/20181217000000_create_biovision_components.rb +16 -39
- data/db/migrate/20181217000110_create_editable_pages.rb +11 -40
- data/db/migrate/20190326120000_create_simple_blocks.rb +7 -1
- data/db/migrate/20190423101010_add_parameters_to_biovision_components.rb +29 -0
- data/db/migrate/20190429111111_add_parsed_body_to_editable_pages.rb +18 -0
- data/lib/biovision/base/base_methods.rb +10 -0
- data/lib/biovision/base/privilege_methods.rb +5 -0
- data/lib/biovision/base/version.rb +1 -1
- metadata +9 -3
- data/app/views/layouts/profile.html.erb +0 -30
@@ -6,9 +6,6 @@ ru:
|
|
6
6
|
attributes:
|
7
7
|
biovision_component:
|
8
8
|
slug: "Идентификатор"
|
9
|
-
biovision_parameter:
|
10
|
-
slug: "Идентификатор"
|
11
|
-
value: "Значение"
|
12
9
|
admin:
|
13
10
|
settings:
|
14
11
|
index:
|
@@ -27,6 +24,8 @@ ru:
|
|
27
24
|
guidelines:
|
28
25
|
slug: "Только латинские буквы, цифры, дефис и подчёркивание (кроме начала и конца)."
|
29
26
|
value: "Произвольная строка"
|
27
|
+
slug: "Параметр"
|
28
|
+
value: "Значение"
|
30
29
|
update:
|
31
30
|
success: "Настройки компонента обновлены"
|
32
31
|
biovision:
|
data/config/routes.rb
CHANGED
@@ -1,6 +1,29 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
Rails.application.routes.draw do
|
4
|
+
concern :check do
|
5
|
+
post :check, on: :collection, defaults: { format: :json }
|
6
|
+
end
|
7
|
+
|
8
|
+
concern :toggle do
|
9
|
+
post :toggle, on: :member, defaults: { format: :json }
|
10
|
+
end
|
11
|
+
|
12
|
+
concern :priority do
|
13
|
+
post :priority, on: :member, defaults: { format: :json }
|
14
|
+
end
|
15
|
+
|
16
|
+
concern :removable_image do
|
17
|
+
delete :image, action: :destroy_image, on: :member, defaults: { format: :json }
|
18
|
+
end
|
19
|
+
|
20
|
+
concern :lock do
|
21
|
+
member do
|
22
|
+
put :lock, defaults: { format: :json }
|
23
|
+
delete :lock, action: :unlock, defaults: { format: :json }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
4
27
|
resources :agents, :browsers, only: %i[update destroy]
|
5
28
|
|
6
29
|
resources :editable_blocks, only: %i[update destroy]
|
@@ -62,35 +85,14 @@ Rails.application.routes.draw do
|
|
62
85
|
delete ':slug/:parameter_slug' => :delete_parameter, as: :parameter
|
63
86
|
end
|
64
87
|
|
65
|
-
resources :agents, :browsers, only: %i[index show]
|
66
|
-
member do
|
67
|
-
post 'toggle', defaults: { format: :json }
|
68
|
-
put 'lock', defaults: { format: :json }
|
69
|
-
delete 'lock', action: :unlock, defaults: { format: :json }
|
70
|
-
end
|
71
|
-
end
|
88
|
+
resources :agents, :browsers, only: %i[index show], concerns: %i[lock toggle]
|
72
89
|
|
73
90
|
resources :codes, only: %i[index show]
|
74
|
-
resources :tokens, only: %i[index show]
|
75
|
-
member do
|
76
|
-
post 'toggle', defaults: { format: :json }
|
77
|
-
end
|
78
|
-
end
|
91
|
+
resources :tokens, only: %i[index show], concerns: :toggle
|
79
92
|
|
80
|
-
resources :editable_pages, only: %i[index show]
|
81
|
-
|
82
|
-
|
83
|
-
post 'toggle', defaults: { format: :json }
|
84
|
-
end
|
85
|
-
end
|
86
|
-
resources :simple_blocks, only: %i[index show] do
|
87
|
-
post 'toggle', on: :member, defaults: { format: :json }
|
88
|
-
end
|
89
|
-
resources :editable_blocks, only: %i[index show] do
|
90
|
-
member do
|
91
|
-
post 'toggle', defaults: { format: :json }
|
92
|
-
end
|
93
|
-
end
|
93
|
+
resources :editable_pages, only: %i[index show], concerns: %i[priority toggle]
|
94
|
+
resources :simple_blocks, only: %i[index show], concerns: :toggle
|
95
|
+
resources :editable_blocks, only: %i[index show], concerns: :toggle
|
94
96
|
resources :stored_values, only: %i[index show]
|
95
97
|
|
96
98
|
resources :metrics, only: %i[index show] do
|
@@ -99,28 +101,20 @@ Rails.application.routes.draw do
|
|
99
101
|
end
|
100
102
|
end
|
101
103
|
|
102
|
-
resources :privileges, only: %i[index show] do
|
103
|
-
collection do
|
104
|
-
post 'check'
|
105
|
-
end
|
104
|
+
resources :privileges, only: %i[index show], concerns: %i[priority toggle] do
|
106
105
|
member do
|
107
|
-
post 'priority', defaults: { format: :json }
|
108
|
-
post 'toggle', defaults: { format: :json }
|
109
106
|
get 'users'
|
110
107
|
get 'regions', defaults: { format: :json }
|
111
108
|
end
|
112
109
|
end
|
113
110
|
resources :privilege_groups, only: %i[index show] do
|
114
|
-
collection do
|
115
|
-
post 'check'
|
116
|
-
end
|
117
111
|
member do
|
118
112
|
put 'privileges/:privilege_id' => :add_privilege, as: :privilege, defaults: { format: :json }
|
119
113
|
delete 'privileges/:privilege_id' => :remove_privilege, defaults: { format: :json }
|
120
114
|
end
|
121
115
|
end
|
122
116
|
|
123
|
-
resources :users, only: %i[index show] do
|
117
|
+
resources :users, only: %i[index show], concerns: :toggle do
|
124
118
|
collection do
|
125
119
|
get 'search', defaults: { format: :json }
|
126
120
|
end
|
@@ -130,7 +124,6 @@ Rails.application.routes.draw do
|
|
130
124
|
get 'privileges'
|
131
125
|
put 'privileges/:privilege_id' => :grant_privilege, as: :privilege
|
132
126
|
delete 'privileges/:privilege_id' => :revoke_privilege
|
133
|
-
post 'toggle', defaults: { format: :json }
|
134
127
|
post 'authenticate'
|
135
128
|
end
|
136
129
|
end
|
@@ -144,75 +137,33 @@ Rails.application.routes.draw do
|
|
144
137
|
get 'files'
|
145
138
|
end
|
146
139
|
end
|
147
|
-
resources :media_files, only: %i[index show]
|
148
|
-
member do
|
149
|
-
put 'lock', defaults: { format: :json }
|
150
|
-
delete 'lock', action: :unlock, defaults: { format: :json }
|
151
|
-
end
|
152
|
-
end
|
140
|
+
resources :media_files, only: %i[index show], concerns: :lock
|
153
141
|
|
154
|
-
resources :feedback_requests, only: :index
|
155
|
-
member do
|
156
|
-
post 'toggle', defaults: { format: :json }
|
157
|
-
end
|
158
|
-
end
|
142
|
+
resources :feedback_requests, only: :index, concerns: :toggle
|
159
143
|
|
160
|
-
resources :link_blocks, only: %i[index show]
|
161
|
-
|
162
|
-
post 'toggle', defaults: { format: :json }
|
163
|
-
end
|
164
|
-
end
|
165
|
-
resources :link_block_items, only: :show do
|
166
|
-
member do
|
167
|
-
post 'toggle', defaults: { format: :json }
|
168
|
-
post 'priority', defaults: { format: :json }
|
169
|
-
end
|
170
|
-
end
|
144
|
+
resources :link_blocks, only: %i[index show], concerns: :toggle
|
145
|
+
resources :link_block_items, only: :show, concerns: %i[priority toggle]
|
171
146
|
end
|
172
147
|
|
173
148
|
namespace :my do
|
174
149
|
get '/' => 'index#index'
|
175
150
|
|
176
|
-
resource :profile, except: :destroy
|
177
|
-
post 'check'
|
178
|
-
end
|
151
|
+
resource :profile, except: :destroy, concerns: :check
|
179
152
|
resource :confirmation, :recovery, only: %i[show create update]
|
180
|
-
resources :tokens, only: :index
|
181
|
-
member do
|
182
|
-
post 'toggle', defaults: { format: :json }
|
183
|
-
end
|
184
|
-
end
|
153
|
+
resources :tokens, only: :index, concerns: :toggle
|
185
154
|
resources :login_attempts, only: :index
|
186
155
|
end
|
187
156
|
|
188
157
|
resources :agents, :browsers, except: %i[index show update destroy]
|
189
158
|
|
190
|
-
resources :editable_pages, except: %i[index show update destroy]
|
191
|
-
|
192
|
-
|
193
|
-
end
|
194
|
-
end
|
195
|
-
resources :editable_blocks, except: %i[index show update destroy] do
|
196
|
-
collection do
|
197
|
-
post 'check', defaults: { format: :json }
|
198
|
-
end
|
199
|
-
end
|
200
|
-
resources :simple_blocks, only: %i[new create edit] do
|
201
|
-
post 'check', on: :collection, defaults: { format: :json }
|
202
|
-
end
|
159
|
+
resources :editable_pages, except: %i[index show update destroy], concerns: :check
|
160
|
+
resources :editable_blocks, except: %i[index show update destroy], concerns: :check
|
161
|
+
resources :simple_blocks, only: %i[new create edit], concerns: :check
|
203
162
|
resources :stored_values, except: %i[index show update destroy]
|
204
163
|
|
205
|
-
resources :link_blocks, :link_block_items, except: %i[index show update destroy]
|
206
|
-
collection do
|
207
|
-
post 'check', defaults: { format: :json }
|
208
|
-
end
|
209
|
-
end
|
164
|
+
resources :link_blocks, :link_block_items, except: %i[index show update destroy], concerns: :check
|
210
165
|
|
211
|
-
resources :users, except: %i[index show update destroy]
|
212
|
-
collection do
|
213
|
-
post 'check', defaults: { format: :json }
|
214
|
-
end
|
215
|
-
end
|
166
|
+
resources :users, except: %i[index show update destroy], concerns: :check
|
216
167
|
resources :tokens, :codes, except: %i[index show update destroy]
|
217
168
|
|
218
169
|
resources :metrics, only: :edit
|
@@ -1,16 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#
|
3
|
+
# Table and default items for Biovision components
|
4
4
|
class CreateBiovisionComponents < ActiveRecord::Migration[5.2]
|
5
5
|
def up
|
6
6
|
create_components_table unless BiovisionComponent.table_exists?
|
7
|
-
create_parameters_table unless BiovisionParameter.table_exists?
|
8
7
|
|
9
8
|
seed_items
|
10
9
|
end
|
11
10
|
|
12
11
|
def down
|
13
|
-
drop_table :biovision_parameters if BiovisionParameter.table_exists?
|
14
12
|
drop_table :biovision_components if BiovisionComponent.table_exists?
|
15
13
|
end
|
16
14
|
|
@@ -21,60 +19,39 @@ class CreateBiovisionComponents < ActiveRecord::Migration[5.2]
|
|
21
19
|
t.timestamps
|
22
20
|
t.string :slug, null: false
|
23
21
|
t.jsonb :settings, null: false, default: {}
|
22
|
+
t.jsonb :parameters, null: false, default: {}
|
24
23
|
end
|
25
24
|
|
26
25
|
add_index :biovision_components, :slug, unique: true
|
27
26
|
end
|
28
27
|
|
29
|
-
def create_parameters_table
|
30
|
-
create_table :biovision_parameters, comment: 'Biovision component parameter' do |t|
|
31
|
-
t.timestamps
|
32
|
-
t.references :biovision_component, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
33
|
-
t.boolean :deletable, default: true, null: false
|
34
|
-
t.string :slug, null: false
|
35
|
-
t.text :value
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
28
|
def seed_items
|
40
29
|
create_registration_component
|
30
|
+
create_contact_component
|
41
31
|
|
42
|
-
component = BiovisionComponent.create!(slug: 'contact')
|
43
|
-
collection = {
|
44
|
-
feedback_receiver: 'info@example.com',
|
45
|
-
email: 'info@example.com',
|
46
|
-
phone: '',
|
47
|
-
address: ''
|
48
|
-
}
|
49
|
-
create_parameters(component, collection)
|
50
32
|
end
|
51
33
|
|
52
34
|
def create_registration_component
|
53
|
-
slug = 'registration'
|
54
35
|
settings = {
|
55
|
-
open:
|
56
|
-
invite_only:
|
36
|
+
open: true,
|
37
|
+
invite_only: false,
|
57
38
|
confirm_email: false,
|
58
|
-
use_invites:
|
39
|
+
use_invites: false,
|
59
40
|
require_email: false,
|
60
|
-
invite_count:
|
41
|
+
invite_count: 5
|
61
42
|
}
|
62
43
|
|
63
|
-
BiovisionComponent.create!(slug:
|
44
|
+
BiovisionComponent.create!(slug: 'registration', settings: settings)
|
64
45
|
end
|
65
46
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
deletable: false,
|
74
|
-
value: value,
|
75
|
-
}
|
47
|
+
def create_contact_component
|
48
|
+
parameters = {
|
49
|
+
feedback_receiver: 'info@example.com',
|
50
|
+
email: 'info@example.com',
|
51
|
+
phone: '',
|
52
|
+
address: ''
|
53
|
+
}
|
76
54
|
|
77
|
-
|
78
|
-
end
|
55
|
+
BiovisionComponent.create!(slug: 'contact', parameters: parameters)
|
79
56
|
end
|
80
57
|
end
|
@@ -4,13 +4,9 @@
|
|
4
4
|
class CreateEditablePages < ActiveRecord::Migration[5.1]
|
5
5
|
def up
|
6
6
|
create_editable_pages unless EditablePage.table_exists?
|
7
|
-
create_link_blocks unless LinkBlock.table_exists?
|
8
|
-
create_link_block_items unless LinkBlockItem.table_exists?
|
9
7
|
end
|
10
8
|
|
11
9
|
def down
|
12
|
-
drop_table :link_block_items if LinkBlockItem.table_exists?
|
13
|
-
drop_table :link_blocks if LinkBlock.table_exists?
|
14
10
|
drop_table :editable_pages if EditablePage.table_exists?
|
15
11
|
end
|
16
12
|
|
@@ -32,57 +28,32 @@ class CreateEditablePages < ActiveRecord::Migration[5.1]
|
|
32
28
|
t.string :meta_keywords, default: '', null: false
|
33
29
|
t.string :meta_description, default: '', null: false
|
34
30
|
t.text :body, default: '', null: false
|
31
|
+
t.text :parsed_body
|
35
32
|
end
|
36
33
|
|
37
34
|
seed_pages
|
38
35
|
end
|
39
36
|
|
40
|
-
def create_link_blocks
|
41
|
-
create_table :link_blocks, comment: 'Editable block of links' do |t|
|
42
|
-
t.timestamps
|
43
|
-
t.references :language, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
44
|
-
t.boolean :visible, default: true, null: false
|
45
|
-
t.string :slug, null: false
|
46
|
-
t.string :title
|
47
|
-
t.text :lead
|
48
|
-
t.text :footer_text
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def create_link_block_items
|
53
|
-
create_table :link_block_items, comment: 'Link in editable links block' do |t|
|
54
|
-
t.timestamps
|
55
|
-
t.references :link_block, null: false, foreign_key: { on_update: :cascade, on_delete: :cascade }
|
56
|
-
t.boolean :visible, default: true, null: false
|
57
|
-
t.integer :priority, limit: 2, default: 1, null: false
|
58
|
-
t.string :slug
|
59
|
-
t.string :image
|
60
|
-
t.string :image_alt_text
|
61
|
-
t.string :title
|
62
|
-
t.string :button_text
|
63
|
-
t.string :button_url
|
64
|
-
t.text :body
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
37
|
def seed_pages
|
69
38
|
pages = {
|
70
|
-
index:
|
71
|
-
about:
|
72
|
-
tos:
|
39
|
+
index: ['', { ru: 'Главная страница', en: 'Main page' }],
|
40
|
+
about: ['about', { ru: 'О проекте', en: 'About' }],
|
41
|
+
tos: ['tos', { ru: 'Пользовательское соглашение', en: 'Terms of service' }],
|
73
42
|
privacy: ['privacy', { ru: 'Политика конфиденциальности', en: 'Privacy' }],
|
74
43
|
contact: ['contact', { ru: 'Контакты', en: 'Contact' }]
|
75
44
|
}
|
76
45
|
|
77
46
|
pages.each do |slug, data|
|
78
|
-
url
|
47
|
+
url = data[0]
|
79
48
|
names = data[1]
|
80
|
-
Language.
|
49
|
+
Language.where(active: true).each do |language|
|
50
|
+
code = language.code
|
51
|
+
prefix = code.to_sym == I18n.default_locale ? '' : "/#{code}"
|
81
52
|
EditablePage.create(
|
82
|
-
slug:
|
83
|
-
name:
|
53
|
+
slug: slug,
|
54
|
+
name: names[code.to_sym],
|
84
55
|
language: language,
|
85
|
-
url:
|
56
|
+
url: "#{prefix}/#{url}"
|
86
57
|
)
|
87
58
|
end
|
88
59
|
end
|
@@ -26,6 +26,12 @@ class CreateSimpleBlocks < ActiveRecord::Migration[5.2]
|
|
26
26
|
private
|
27
27
|
|
28
28
|
def seed_default_blocks
|
29
|
-
|
29
|
+
data = [
|
30
|
+
['counters', 'Счётчики для сайта']
|
31
|
+
]
|
32
|
+
|
33
|
+
data.each do |row|
|
34
|
+
SimpleBlock.create(slug: row[0], name: row[1])
|
35
|
+
end
|
30
36
|
end
|
31
37
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Convert BiovisionParameter records to JSONB data in BiovisionComponent
|
4
|
+
class AddParametersToBiovisionComponents < ActiveRecord::Migration[5.2]
|
5
|
+
def up
|
6
|
+
return if column_exists?(:biovision_components, :parameters)
|
7
|
+
|
8
|
+
add_column :biovision_components, :parameters, :jsonb, default: {}, null: false
|
9
|
+
|
10
|
+
move_data
|
11
|
+
end
|
12
|
+
|
13
|
+
def down
|
14
|
+
# No rollback needed
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def move_data
|
20
|
+
BiovisionComponent.order('id asc').each do |component|
|
21
|
+
data = {}
|
22
|
+
BiovisionParameter.where(biovision_component: component).each do |parameter|
|
23
|
+
data[parameter.slug] = parameter.value
|
24
|
+
end
|
25
|
+
|
26
|
+
component.update! parameters: data
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Add parsed body column to editable pages
|
4
|
+
class AddParsedBodyToEditablePages < ActiveRecord::Migration[5.2]
|
5
|
+
def up
|
6
|
+
return if column_exists?(:editable_pages, :parsed_body)
|
7
|
+
|
8
|
+
add_column :editable_pages, :parsed_body, :text
|
9
|
+
|
10
|
+
EditablePage.pluck(:id).each do |id|
|
11
|
+
EditablePageBodyParserJob.perform_now(id)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def down
|
16
|
+
# No rollback needed
|
17
|
+
end
|
18
|
+
end
|