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
@@ -9,6 +9,7 @@ class UserBouncer
|
|
9
9
|
# @param [String] password
|
10
10
|
def let_user_in?(password)
|
11
11
|
return false unless @user&.allow_login?
|
12
|
+
|
12
13
|
@password = password
|
13
14
|
too_many_attempts? ? (log_attempt && false) : try_password
|
14
15
|
end
|
@@ -16,7 +17,7 @@ class UserBouncer
|
|
16
17
|
private
|
17
18
|
|
18
19
|
def too_many_attempts?
|
19
|
-
LoginAttempt.owned_by(@user).since(15.minutes.ago).count >
|
20
|
+
LoginAttempt.owned_by(@user).since(15.minutes.ago).count > 10
|
20
21
|
end
|
21
22
|
|
22
23
|
def log_attempt
|
@@ -30,8 +31,6 @@ class UserBouncer
|
|
30
31
|
|
31
32
|
def count_attempt
|
32
33
|
log_attempt
|
33
|
-
if too_many_attempts?
|
34
|
-
UserMailer.login_attempt(@user.id).deliver_later
|
35
|
-
end
|
34
|
+
UserMailer.login_attempt(@user.id).deliver_later if too_many_attempts?
|
36
35
|
end
|
37
36
|
end
|
@@ -9,4 +9,19 @@ class SimpleFileUploader < CarrierWave::Uploader::Base
|
|
9
9
|
|
10
10
|
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{slug}"
|
11
11
|
end
|
12
|
+
|
13
|
+
def extension_blacklist
|
14
|
+
%w[
|
15
|
+
htm html action apk app bat bin cmd com command cpl csh exe gadget inf ins
|
16
|
+
inx ipa isu job jse ksh lnk msc msi msp mst osx out paf pif prg ps1 reg
|
17
|
+
rgs run scr sct shb shs u3p vb vbe vbs vbscript workflow ws wsf wsh 0xe
|
18
|
+
73k 89k a6p ac acc acr actm ahk air app arscript as asb awk azw2 beam btm
|
19
|
+
cel celx chm cof crt dek dld dmc docm dotm dxl ear ebm ebs ebs2 ecf eham
|
20
|
+
elf es ex4 exopc ezs fas fky fpi frs fxp gs ham hms hpf hta iim ipf isp
|
21
|
+
jar js jsx kix lo ls mam mcr mel mpx mrc ms ms mxe nexe obs ore otm pex
|
22
|
+
plx potm ppam ppsm pptm prc pvd pwc pyc pyo qpx rbx rox rpj s2a sbs sca
|
23
|
+
scar scb script smm spr tcp thm tlb tms udf upx url vlx vpm wcm widget wiz
|
24
|
+
wpk wpm xap xbap xlam xlm xlsm xltm xqt xys zl9 dmg pkg php rb
|
25
|
+
]
|
26
|
+
end
|
12
27
|
end
|
@@ -25,7 +25,7 @@
|
|
25
25
|
<dt><%= t('activerecord.attributes.editable_page.image') %></dt>
|
26
26
|
<dd>
|
27
27
|
<figure role="group" class="preview">
|
28
|
-
<%=
|
28
|
+
<%= simple_image_medium(@entity) %>
|
29
29
|
<figcaption><%= @entity.image_alt_text %></figcaption>
|
30
30
|
</figure>
|
31
31
|
</dd>
|
@@ -47,7 +47,7 @@
|
|
47
47
|
<dt><%= t('activerecord.attributes.editable_page.body') %></dt>
|
48
48
|
<dd>
|
49
49
|
<div class="text">
|
50
|
-
<%= raw
|
50
|
+
<%= raw @entity.text %>
|
51
51
|
</div>
|
52
52
|
</dd>
|
53
53
|
|
@@ -2,8 +2,8 @@
|
|
2
2
|
<%#= render 'admin/index/dashboard/biovision_track' %>
|
3
3
|
<%= render 'admin/index/dashboard/biovision_user' %>
|
4
4
|
<%= render 'admin/index/dashboard/editorial' %>
|
5
|
-
<%= render 'admin/index/dashboard/biovision_links' if LinkBlock.any? %>
|
5
|
+
<%= render 'admin/index/dashboard/biovision_links' if LinkBlock.table_exists? && LinkBlock.any? %>
|
6
6
|
<%= render 'admin/index/dashboard/biovision_feedback' %>
|
7
|
-
<% %w[
|
7
|
+
<% %w[partners post vote poll comment].each do |part| %>
|
8
8
|
<%= render "admin/index/dashboard/biovision_#{part}" if Gem.loaded_specs.key?("biovision-#{part}") %>
|
9
9
|
<% end %>
|
@@ -11,21 +11,17 @@
|
|
11
11
|
) do |f|
|
12
12
|
%>
|
13
13
|
<dl>
|
14
|
-
<dt>
|
15
|
-
<%=
|
16
|
-
f.label(:slug, t('activerecord.attributes.biovision_parameter.slug'))
|
17
|
-
%>
|
18
|
-
</dt>
|
14
|
+
<dt><%= f.label(:slug, t('.slug')) %></dt>
|
19
15
|
<dd>
|
20
16
|
<%=
|
21
17
|
f.text_field(
|
22
18
|
:slug,
|
23
19
|
value: '',
|
24
20
|
required: true,
|
25
|
-
pattern:
|
21
|
+
pattern: BiovisionComponent::SLUG_PATTERN_HTML,
|
26
22
|
title: t('.guidelines.slug'),
|
27
23
|
size: nil,
|
28
|
-
maxlength:
|
24
|
+
maxlength: BiovisionComponent::SLUG_LIMIT,
|
29
25
|
data: {
|
30
26
|
field: :slug
|
31
27
|
}
|
@@ -34,11 +30,7 @@
|
|
34
30
|
<div class="guideline"><%= t('.guidelines.slug') %></div>
|
35
31
|
</dd>
|
36
32
|
|
37
|
-
<dt>
|
38
|
-
<%=
|
39
|
-
f.label(:value, t('activerecord.attributes.biovision_parameter.value'))
|
40
|
-
%>
|
41
|
-
</dt>
|
33
|
+
<dt><%= f.label(:value, t('.value')) %></dt>
|
42
34
|
<dd>
|
43
35
|
<%=
|
44
36
|
f.text_field(
|
@@ -46,7 +38,7 @@
|
|
46
38
|
value: '',
|
47
39
|
required: true,
|
48
40
|
size: nil,
|
49
|
-
maxlength:
|
41
|
+
maxlength: BiovisionComponent::VALUE_LIMIT,
|
50
42
|
data: {
|
51
43
|
field: :value
|
52
44
|
}
|
@@ -2,17 +2,17 @@
|
|
2
2
|
<h2><%= t('.heading') %></h2>
|
3
3
|
|
4
4
|
<ul id="biovision-component-parameters" data-url="<%= admin_set_parameter_path(slug: handler.slug) %>">
|
5
|
-
<% parameters.each do |parameter| %>
|
5
|
+
<% parameters.each do |parameter, value| %>
|
6
6
|
<%
|
7
|
-
element_id = "parameter-#{parameter
|
8
|
-
description = t("biovision.components.#{
|
7
|
+
element_id = "parameter-#{parameter}"
|
8
|
+
description = t("biovision.components.#{handler.component.slug}.parameters.#{parameter}.description", default: '')
|
9
9
|
%>
|
10
10
|
<li>
|
11
11
|
<div class="name">
|
12
|
-
<%= label_tag(element_id, parameter
|
12
|
+
<%= label_tag(element_id, parameter) %>
|
13
13
|
</div>
|
14
14
|
<div class="value">
|
15
|
-
<%= text_field_tag(:value,
|
15
|
+
<%= text_field_tag(:value, value, id: element_id) %>
|
16
16
|
<%=
|
17
17
|
button_tag(
|
18
18
|
'',
|
@@ -21,7 +21,7 @@
|
|
21
21
|
class: 'apply',
|
22
22
|
disabled: true,
|
23
23
|
data: {
|
24
|
-
slug: parameter
|
24
|
+
slug: parameter
|
25
25
|
}
|
26
26
|
)
|
27
27
|
%>
|
@@ -12,7 +12,7 @@
|
|
12
12
|
<ul class="actions">
|
13
13
|
<li><%= back_icon(admin_users_path) %></li>
|
14
14
|
<% unless @entity.deleted? %>
|
15
|
-
<li><%= world_icon(user_profile_path(slug: @entity.
|
15
|
+
<li><%= world_icon(user_profile_path(slug: @entity.slug)) %></li>
|
16
16
|
<li><%= edit_icon(edit_user_path(id: @entity.id)) %></li>
|
17
17
|
<% end %>
|
18
18
|
</ul>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= render partial: '
|
1
|
+
<%= render partial: 'shared/entity/metadata', locals: { entity: entity } %>
|
2
2
|
|
3
3
|
<article class="editable-page">
|
4
4
|
<%= render partial: 'editable_pages/entity/content', locals: { entity: entity } %>
|
@@ -76,14 +76,14 @@
|
|
76
76
|
<% if entity.image.blank? %>
|
77
77
|
<%= f.label :image, image_tag('biovision/base/placeholders/16x9.svg', alt: '') %>
|
78
78
|
<% else %>
|
79
|
-
<%= f.label :image, image_tag(entity.image.
|
79
|
+
<%= f.label :image, image_tag(entity.image.medium_url, alt: '') %>
|
80
80
|
<% end %>
|
81
81
|
<figcaption>
|
82
82
|
<%=
|
83
83
|
f.file_field(
|
84
84
|
:image,
|
85
85
|
id: "#{model_name}_image",
|
86
|
-
accept: 'image/jpeg,image/png',
|
86
|
+
accept: 'image/jpeg,image/png,image/svg+xml',
|
87
87
|
data: { image: "#{model_name}-image" }
|
88
88
|
)
|
89
89
|
%>
|
@@ -1,11 +1,13 @@
|
|
1
|
-
<%
|
2
|
-
<% content_for(:
|
3
|
-
<% content_for(:
|
4
|
-
<% unless entity.
|
5
|
-
<%
|
6
|
-
|
7
|
-
<%
|
8
|
-
<%
|
9
|
-
|
10
|
-
|
1
|
+
<% unless entity.nil? %>
|
2
|
+
<% content_for(:meta_title, entity.meta_title) unless entity.meta_title.blank? %>
|
3
|
+
<% content_for(:meta_keywords, entity.meta_keywords) unless entity.meta_keywords.blank? %>
|
4
|
+
<% content_for(:meta_description, entity.meta_description) unless entity.meta_description.blank? %>
|
5
|
+
<% unless entity.image.blank? %>
|
6
|
+
<% content_for :meta_image, (request.protocol + request.host_with_port + entity.image.url) %>
|
7
|
+
<% content_for :meta_image_alt, entity.image_alt_text %>
|
8
|
+
<% end %>
|
9
|
+
<% content_for :meta_twitter do %>
|
10
|
+
<meta name="twitter:card" content="summary_large_image"/>
|
11
|
+
<meta name="twitter:description" content="<%= entity.meta_description %>"/>
|
12
|
+
<% end %>
|
11
13
|
<% end %>
|
@@ -1,2 +1,4 @@
|
|
1
1
|
<%= render 'index/index/custom_dashboard' %>
|
2
|
-
|
2
|
+
<% %w[post partners].each do |component| %>
|
3
|
+
<%= render "index/dashboard/biovision_#{component}" if Gem.loaded_specs.key?("biovision-#{component}") %>
|
4
|
+
<% end %>
|
@@ -6,5 +6,21 @@
|
|
6
6
|
<figcaption><%= current_user.profile_name %></figcaption>
|
7
7
|
</figure>
|
8
8
|
|
9
|
+
<div class="sidebar">
|
10
|
+
<nav>
|
11
|
+
<ul>
|
12
|
+
<li><%= render 'my/profiles/nav_item' %></li>
|
13
|
+
<li><%= render 'my/tokens/nav_item' %></li>
|
14
|
+
<li><%= render 'my/login_attempts/nav_item' %></li>
|
15
|
+
<%= render 'my/index/sidebar/biovision_courses' if Gem.loaded_specs.key?('biovision-courses') %>
|
16
|
+
<%= render 'my/index/index/custom_sidebar' %>
|
17
|
+
<% if UserPrivilege.user_has_any_privilege?(current_user) %>
|
18
|
+
<li><%= link_to t('admin.index.index.heading'), admin_path %></li>
|
19
|
+
<% end %>
|
20
|
+
<li><%= link_to t(:logout), logout_path, method: :delete %></li>
|
21
|
+
</ul>
|
22
|
+
</nav>
|
23
|
+
</div>
|
24
|
+
|
9
25
|
<%= render 'my/index/dashboard/biovision_post' if Gem.loaded_specs.key?('biovision-post') %>
|
10
26
|
</section>
|
@@ -1,10 +1,10 @@
|
|
1
1
|
<% if current_user_has_privilege?(:administrator) %>
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
2
|
+
<div class="track">
|
3
|
+
<% if item.respond_to?(:agent) && !item.agent.nil? %>
|
4
|
+
<div class="agent"><%= item.agent.name %></div>
|
5
|
+
<% end %>
|
6
|
+
<% if item.respond_to?(:ip) && !item.ip.nil? %>
|
7
|
+
<div class="ip"><%= item.ip %></div>
|
8
|
+
<% end %>
|
9
|
+
</div>
|
10
10
|
<% end %>
|
@@ -1,3 +1,3 @@
|
|
1
|
-
<%= render partial: '
|
1
|
+
<%= render partial: 'shared/entity/metadata', locals: { entity: entity } %>
|
2
2
|
|
3
|
-
<%= raw entity.
|
3
|
+
<%= raw entity.parsed_body %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<% unless entity.nil? %>
|
2
|
+
<% content_for(:meta_title, entity.meta_title) unless entity.meta_title.blank? %>
|
3
|
+
<% content_for(:meta_keywords, entity.meta_keywords) unless entity.meta_keywords.blank? %>
|
4
|
+
<% content_for(:meta_description, entity.meta_description) unless entity.meta_description.blank? %>
|
5
|
+
<% unless entity.image.blank? %>
|
6
|
+
<% content_for :meta_image, (request.protocol + request.host_with_port + entity.image.url) %>
|
7
|
+
<% content_for :meta_image_alt, entity.image_alt_text if entity.respond_to?(:image_alt_text) %>
|
8
|
+
<% end %>
|
9
|
+
<% content_for :meta_twitter do %>
|
10
|
+
<meta name="twitter:card" content="summary_large_image"/>
|
11
|
+
<meta name="twitter:description" content="<%= entity.meta_description %>"/>
|
12
|
+
<% end %>
|
13
|
+
<% end %>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<script src="https://cdn.ckeditor.com/ckeditor5/12.0.0/classic/ckeditor.js"></script>
|
2
|
+
<script>
|
3
|
+
"use strict";
|
4
|
+
document.addEventListener("DOMContentLoaded", function () {
|
5
|
+
document.querySelectorAll("button.js-wysiwyg-toggle").forEach(function (button) {
|
6
|
+
button.addEventListener("click", function (event) {
|
7
|
+
const button = event.target;
|
8
|
+
button.classList.add("hidden");
|
9
|
+
const editor = document.getElementById(button.getAttribute("data-element"));
|
10
|
+
editor.required = false;
|
11
|
+
ClassicEditor
|
12
|
+
.create(editor, {
|
13
|
+
image: {
|
14
|
+
toolbar: ['imageTextAlternative']
|
15
|
+
},
|
16
|
+
ckfinder: {
|
17
|
+
uploadUrl: editor.getAttribute('data-upload-url')
|
18
|
+
}
|
19
|
+
})
|
20
|
+
.catch(error => console.error(error));
|
21
|
+
});
|
22
|
+
});
|
23
|
+
});
|
24
|
+
</script>
|
@@ -51,6 +51,16 @@
|
|
51
51
|
|
52
52
|
<dt><%= f.label :body %></dt>
|
53
53
|
<dd>
|
54
|
+
<div class="wysiwyg-button-container">
|
55
|
+
<button
|
56
|
+
type="button"
|
57
|
+
class="js-wysiwyg-toggle button-action"
|
58
|
+
data-element="<%= model_name %>_body"
|
59
|
+
data-upload-url="/media_files/ckeditor"
|
60
|
+
>
|
61
|
+
WYSIWYG
|
62
|
+
</button>
|
63
|
+
</div>
|
54
64
|
<%=
|
55
65
|
f.text_area(
|
56
66
|
:body,
|
@@ -118,3 +128,5 @@
|
|
118
128
|
<%= f.button t(:save), type: :submit, class: 'button-save' %>
|
119
129
|
</div>
|
120
130
|
<% end %>
|
131
|
+
|
132
|
+
<%= render 'shared/forms/toggle_wysiwyg' %>
|
@@ -11,9 +11,9 @@
|
|
11
11
|
<%=
|
12
12
|
f.file_field(
|
13
13
|
:image,
|
14
|
-
id:
|
14
|
+
id: "#{model_name}_image",
|
15
15
|
accept: 'image/jpeg,image/png',
|
16
|
-
data:
|
16
|
+
data: { image: "#{model_name}-image" }
|
17
17
|
)
|
18
18
|
%>
|
19
19
|
</figcaption>
|
@@ -25,14 +25,14 @@
|
|
25
25
|
<%=
|
26
26
|
f.text_field(
|
27
27
|
:screen_name,
|
28
|
-
id:
|
28
|
+
id: "#{model_name}_screen_name",
|
29
29
|
maxlength: User::SCREEN_NAME_LIMIT,
|
30
|
-
|
31
|
-
title: t('.guidelines.screen_name'),
|
32
|
-
required: true
|
30
|
+
required: true
|
33
31
|
)
|
34
32
|
%>
|
35
|
-
|
33
|
+
<% unless entity.foreign_slug? %>
|
34
|
+
<div class="guideline"><%= t('.guidelines.screen_name') %></div>
|
35
|
+
<% end %>
|
36
36
|
</dd>
|
37
37
|
|
38
38
|
<dt><%= f.label :email %></dt>
|
@@ -40,10 +40,10 @@
|
|
40
40
|
<%=
|
41
41
|
f.email_field(
|
42
42
|
:email,
|
43
|
-
id:
|
44
|
-
size:
|
43
|
+
id: "#{model_name}_email",
|
44
|
+
size: nil,
|
45
45
|
maxlength: User::EMAIL_LIMIT,
|
46
|
-
readonly:
|
46
|
+
readonly: entity.super_user?
|
47
47
|
)
|
48
48
|
%>
|
49
49
|
</dd>
|
@@ -53,10 +53,10 @@
|
|
53
53
|
<%=
|
54
54
|
f.phone_field(
|
55
55
|
:phone,
|
56
|
-
id:
|
57
|
-
size:
|
56
|
+
id: "#{model_name}_phone",
|
57
|
+
size: 15,
|
58
58
|
maxlength: User::PHONE_LIMIT,
|
59
|
-
readonly:
|
59
|
+
readonly: entity.super_user?
|
60
60
|
)
|
61
61
|
%>
|
62
62
|
</dd>
|
@@ -77,7 +77,7 @@
|
|
77
77
|
<%=
|
78
78
|
f.date_field(
|
79
79
|
:birthday,
|
80
|
-
id:
|
80
|
+
id: "#{model_name}_birthday",
|
81
81
|
size: 10
|
82
82
|
)
|
83
83
|
%>
|
@@ -89,10 +89,10 @@
|
|
89
89
|
<%=
|
90
90
|
f.text_field(
|
91
91
|
:password,
|
92
|
-
id:
|
93
|
-
size:
|
92
|
+
id: "#{model_name}_password",
|
93
|
+
size: nil,
|
94
94
|
maxlength: 70,
|
95
|
-
required:
|
95
|
+
required: entity.id.nil?
|
96
96
|
)
|
97
97
|
%>
|
98
98
|
</dd>
|
@@ -102,10 +102,10 @@
|
|
102
102
|
<%=
|
103
103
|
f.text_field(
|
104
104
|
:password_confirmation,
|
105
|
-
id:
|
106
|
-
size:
|
105
|
+
id: "#{model_name}_password_confirmation",
|
106
|
+
size: nil,
|
107
107
|
maxlength: 70,
|
108
|
-
required:
|
108
|
+
required: entity.id.nil?
|
109
109
|
)
|
110
110
|
%>
|
111
111
|
</dd>
|
@@ -118,8 +118,8 @@
|
|
118
118
|
<%=
|
119
119
|
f.text_field(
|
120
120
|
:notice,
|
121
|
-
id:
|
122
|
-
size:
|
121
|
+
id: "#{model_name}_notice",
|
122
|
+
size: nil,
|
123
123
|
maxlength: User::NOTICE_LIMIT
|
124
124
|
)
|
125
125
|
%>
|