elabs 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +6 -0
- data/CHANGELOG.md +83 -0
- data/Gemfile +3 -1
- data/Gemfile.lock +9 -2
- data/ROADMAP.md +6 -11
- data/app/assets/stylesheets/elabs/_icons.scss +8 -4
- data/app/assets/stylesheets/elabs/app/_badges.scss +11 -0
- data/app/assets/stylesheets/elabs/app/_layout.scss +10 -2
- data/app/assets/stylesheets/elabs/app/_users.scss +7 -0
- data/app/assets/stylesheets/elabs/app/admin-members/_indexes.scss +2 -1
- data/app/assets/stylesheets/elabs/app/mixins/_content-card.scss +4 -0
- data/app/assets/stylesheets/elabs/app/mixins/_content-full.scss +17 -5
- data/app/assets/stylesheets/elabs/lib/knacss/_knacss-variables.scss +16 -15
- data/app/assets/stylesheets/elabs/lib/knacss/_knacss.scss +1 -1
- data/app/assets/stylesheets/elabs/style.scss +1 -0
- data/app/controllers/elabs/acts_controller.rb +1 -1
- data/app/controllers/elabs/admin/admin_content_application_controller.rb +13 -6
- data/app/controllers/elabs/admin/languages_controller.rb +4 -4
- data/app/controllers/elabs/admin/licenses_controller.rb +2 -2
- data/app/controllers/elabs/admin/tags_controller.rb +3 -3
- data/app/controllers/elabs/concerns/elabs_controller.rb +1 -0
- data/app/controllers/elabs/content_application_controller.rb +1 -1
- data/app/controllers/elabs/elabs_application_controller.rb +0 -73
- data/app/controllers/elabs/elabs_public_controller.rb +80 -0
- data/app/controllers/elabs/languages_controller.rb +3 -3
- data/app/controllers/elabs/licenses_controller.rb +3 -3
- data/app/controllers/elabs/member/member_content_application_controller.rb +24 -14
- data/app/controllers/elabs/member/notifications_controller.rb +30 -0
- data/app/controllers/elabs/member/preferences_controller.rb +1 -1
- data/app/controllers/elabs/member/users_controller.rb +8 -5
- data/app/controllers/elabs/reports_controller.rb +2 -2
- data/app/controllers/elabs/tags_controller.rb +2 -2
- data/app/controllers/elabs/users_controller.rb +3 -3
- data/app/helpers/elabs/admin_content_helper.rb +8 -24
- data/app/helpers/elabs/application_helper.rb +1 -1
- data/app/helpers/elabs/content_helper.rb +39 -0
- data/app/helpers/elabs/form_helper.rb +22 -10
- data/app/helpers/elabs/member_content_helper.rb +5 -22
- data/app/helpers/elabs/notification_helper.rb +69 -0
- data/app/helpers/elabs/thumbnails_helper.rb +15 -0
- data/app/helpers/elabs/time_helper.rb +7 -0
- data/app/models/elabs/application_content_record.rb +1 -0
- data/app/models/elabs/application_record.rb +2 -0
- data/app/models/elabs/comment.rb +14 -0
- data/app/models/elabs/concerns/actable_entity.rb +0 -12
- data/app/models/elabs/concerns/content_entity.rb +23 -0
- data/app/models/elabs/concerns/notifiable_entity.rb +46 -0
- data/app/models/elabs/notification.rb +10 -0
- data/app/models/elabs/preference.rb +2 -0
- data/app/models/elabs/report.rb +10 -0
- data/app/models/elabs/user.rb +26 -6
- data/app/views/elabs/acts/_act.json.jbuilder +7 -2
- data/app/views/elabs/acts/index.json.jbuilder +1 -1
- data/app/views/elabs/admin/albums/_album.json.jbuilder +15 -2
- data/app/views/elabs/admin/albums/index.html.haml +1 -1
- data/app/views/elabs/admin/albums/index.json.jbuilder +1 -1
- data/app/views/elabs/admin/articles/_article.json.jbuilder +15 -2
- data/app/views/elabs/admin/articles/index.html.haml +1 -1
- data/app/views/elabs/admin/articles/index.json.jbuilder +1 -1
- data/app/views/elabs/admin/languages/_language.json.jbuilder +9 -2
- data/app/views/elabs/admin/languages/index.html.haml +1 -1
- data/app/views/elabs/admin/languages/index.json.jbuilder +1 -1
- data/app/views/elabs/admin/licenses/_license.json.jbuilder +10 -2
- data/app/views/elabs/admin/licenses/index.html.haml +1 -1
- data/app/views/elabs/admin/licenses/index.json.jbuilder +1 -1
- data/app/views/elabs/admin/notes/_note.json.jbuilder +13 -2
- data/app/views/elabs/admin/notes/index.html.haml +1 -1
- data/app/views/elabs/admin/notes/index.json.jbuilder +1 -1
- data/app/views/elabs/admin/projects/_project.json.jbuilder +20 -2
- data/app/views/elabs/admin/projects/index.html.haml +1 -1
- data/app/views/elabs/admin/projects/index.json.jbuilder +1 -1
- data/app/views/elabs/admin/reports/_report.json.jbuilder +10 -0
- data/app/views/elabs/admin/reports/index.html.haml +1 -1
- data/app/views/elabs/admin/reports/index.json.jbuilder +1 -1
- data/app/views/elabs/admin/tags/_tag.json.jbuilder +8 -2
- data/app/views/elabs/admin/tags/index.html.haml +1 -1
- data/app/views/elabs/admin/tags/index.json.jbuilder +1 -1
- data/app/views/elabs/admin/uploads/_upload.json.jbuilder +17 -2
- data/app/views/elabs/admin/uploads/index.html.haml +1 -1
- data/app/views/elabs/admin/uploads/index.json.jbuilder +1 -1
- data/app/views/elabs/admin/users/_user.json.jbuilder +14 -0
- data/app/views/elabs/admin/users/index.html.haml +6 -2
- data/app/views/elabs/admin/users/index.json.jbuilder +1 -1
- data/app/views/elabs/admin/users/show.html.haml +1 -1
- data/app/views/elabs/admin/users/show.json.jbuilder +1 -1
- data/app/views/elabs/albums/_album.html.haml +2 -2
- data/app/views/elabs/albums/_album.json.jbuilder +12 -2
- data/app/views/elabs/albums/index.json.jbuilder +1 -1
- data/app/views/elabs/albums/show.html.haml +7 -7
- data/app/views/elabs/albums/show.json.jbuilder +1 -1
- data/app/views/elabs/articles/_article.html.haml +2 -2
- data/app/views/elabs/articles/_article.json.jbuilder +12 -2
- data/app/views/elabs/articles/index.json.jbuilder +1 -1
- data/app/views/elabs/articles/show.html.haml +6 -6
- data/app/views/elabs/articles/show.json.jbuilder +1 -1
- data/app/views/elabs/auth/registrations/edit.html.haml +8 -5
- data/app/views/elabs/comments/_comment.json.jbuilder +10 -2
- data/app/views/elabs/comments/_comments.html.haml +2 -2
- data/app/views/elabs/languages/_language.json.jbuilder +9 -2
- data/app/views/elabs/languages/index.json.jbuilder +1 -1
- data/app/views/elabs/languages/show.html.haml +1 -1
- data/app/views/elabs/languages/show.json.jbuilder +1 -1
- data/app/views/elabs/layouts/_menu.html.haml +10 -5
- data/app/views/elabs/licenses/_license.json.jbuilder +10 -2
- data/app/views/elabs/licenses/index.json.jbuilder +1 -1
- data/app/views/elabs/licenses/show.html.haml +2 -6
- data/app/views/elabs/member/albums/_album.json.jbuilder +15 -2
- data/app/views/elabs/member/albums/index.html.haml +1 -1
- data/app/views/elabs/member/albums/index.json.jbuilder +1 -1
- data/app/views/elabs/member/articles/_article.json.jbuilder +15 -2
- data/app/views/elabs/member/articles/index.html.haml +1 -1
- data/app/views/elabs/member/articles/index.json.jbuilder +1 -1
- data/app/views/elabs/member/layouts/_empty.html.haml +3 -2
- data/app/views/elabs/member/notes/_note.json.jbuilder +13 -2
- data/app/views/elabs/member/notes/index.html.haml +1 -1
- data/app/views/elabs/member/notes/index.json.jbuilder +1 -1
- data/app/views/elabs/member/notifications/_notification.json.jbuilder +8 -0
- data/app/views/elabs/member/notifications/index.html.haml +21 -0
- data/app/views/elabs/member/notifications/index.json.jbuilder +1 -0
- data/app/views/elabs/member/preferences/_form.html.haml +6 -0
- data/app/views/elabs/member/preferences/edit.html.haml +2 -1
- data/app/views/elabs/member/projects/_project.json.jbuilder +20 -2
- data/app/views/elabs/member/projects/index.html.haml +1 -1
- data/app/views/elabs/member/projects/index.json.jbuilder +1 -1
- data/app/views/elabs/member/uploads/_upload.json.jbuilder +17 -2
- data/app/views/elabs/member/uploads/index.html.haml +1 -1
- data/app/views/elabs/member/uploads/index.json.jbuilder +1 -1
- data/app/views/elabs/member/users/_form.html.haml +14 -9
- data/app/views/elabs/member/users/edit.html.haml +7 -0
- data/app/views/elabs/notes/_note.html.haml +2 -2
- data/app/views/elabs/notes/_note.json.jbuilder +10 -2
- data/app/views/elabs/notes/index.json.jbuilder +1 -1
- data/app/views/elabs/notes/show.html.haml +5 -5
- data/app/views/elabs/notes/show.json.jbuilder +1 -1
- data/app/views/elabs/projects/_project.html.haml +2 -2
- data/app/views/elabs/projects/_project.json.jbuilder +17 -0
- data/app/views/elabs/projects/index.json.jbuilder +1 -1
- data/app/views/elabs/projects/show.html.haml +14 -11
- data/app/views/elabs/projects/show.json.jbuilder +1 -1
- data/app/views/elabs/tags/_tag.json.jbuilder +8 -2
- data/app/views/elabs/tags/index.json.jbuilder +1 -1
- data/app/views/elabs/tags/show.json.jbuilder +1 -1
- data/app/views/elabs/uploads/_upload.html.haml +1 -1
- data/app/views/elabs/uploads/_upload.json.jbuilder +14 -2
- data/app/views/elabs/uploads/index.json.jbuilder +1 -1
- data/app/views/elabs/uploads/show.html.haml +12 -3
- data/app/views/elabs/uploads/show.json.jbuilder +1 -1
- data/app/views/elabs/users/_user.html.haml +10 -3
- data/app/views/elabs/users/_user.json.jbuilder +14 -2
- data/app/views/elabs/users/index.json.jbuilder +1 -1
- data/app/views/elabs/users/show.html.haml +15 -10
- data/app/views/elabs/users/show.json.jbuilder +1 -1
- data/config/routes.rb +21 -16
- data/db/migrate/20180910000015_remove_license_timestamps.rb +6 -0
- data/db/migrate/20180910175012_create_notifications.rb +13 -0
- data/db/migrate/20180913093027_add_fields_in_preferences.rb +6 -0
- data/docs/migrating.md +14 -0
- data/docs/setup.md +1 -0
- data/lib/elabs.rb +3 -0
- data/lib/elabs/version.rb +1 -1
- data/lib/generators/elabs/required_assets_generator.rb +1 -1
- data/lib/generators/templates/elabs.rb +6 -0
- data/locale/app.pot +73 -14
- data/locale/en/app.edit.po +71 -12
- data/locale/en/app.po +71 -12
- data/locale/fr/app.edit.po +76 -17
- data/locale/fr/app.po +75 -16
- data/package.json +4 -4
- metadata +19 -5
- data/app/assets/images/elabs/preview_placeholder.png +0 -0
- data/app/assets/images/elabs/preview_placeholder_nsfw.png +0 -0
- data/app/views/elabs/admin/users/_admin_user.json.jbuilder +0 -2
@@ -1,5 +1,5 @@
|
|
1
1
|
module Elabs
|
2
|
-
class ReportsController <
|
2
|
+
class ReportsController < ElabsPublicController
|
3
3
|
# POST /reports
|
4
4
|
# POST /reports.json
|
5
5
|
# rubocop:disable Metrics/AbcSize
|
@@ -9,7 +9,7 @@ module Elabs
|
|
9
9
|
respond_to do |format|
|
10
10
|
if report.save
|
11
11
|
format.html { redirect_to request.referer, notice: _('Report was successfully created.') }
|
12
|
-
format.json { render json: { message: 'ok' }, status: :created
|
12
|
+
format.json { render json: { message: 'ok' }, status: :created }
|
13
13
|
else
|
14
14
|
format.html { redirect_to request.referer, notice: { error: report.errors } }
|
15
15
|
format.json { render json: report.errors, status: :unprocessable_entity }
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Elabs
|
2
|
-
class TagsController <
|
2
|
+
class TagsController < ElabsPublicController
|
3
3
|
ALLOWED_ORDER_FROM = %w[name].freeze
|
4
4
|
DEFAULT_ORDER = { name: :desc }.freeze
|
5
5
|
|
@@ -8,7 +8,7 @@ module Elabs
|
|
8
8
|
# GET /tags
|
9
9
|
# GET /tags.json
|
10
10
|
def index
|
11
|
-
@tags = Tag.all
|
11
|
+
@tags = scope_request Tag.all
|
12
12
|
end
|
13
13
|
|
14
14
|
# GET /tags/1
|
@@ -1,14 +1,14 @@
|
|
1
1
|
module Elabs
|
2
|
-
class UsersController <
|
2
|
+
class UsersController < ElabsPublicController
|
3
3
|
ALLOWED_ORDER_FROM = %w[username created_at].freeze
|
4
|
-
DEFAULT_ORDER = { username: :
|
4
|
+
DEFAULT_ORDER = { username: :asc }.freeze
|
5
5
|
|
6
6
|
before_action :set_user, only: %i[show edit update destroy]
|
7
7
|
|
8
8
|
# GET /users
|
9
9
|
# GET /users.json
|
10
10
|
def index
|
11
|
-
@users = User.page(params[:page]).per(self.class::MAX_ITEMS_PER_PAGE)
|
11
|
+
@users = scope_request User.page(params[:page]).per(self.class::MAX_ITEMS_PER_PAGE)
|
12
12
|
end
|
13
13
|
|
14
14
|
# GET /users/1
|
@@ -2,27 +2,20 @@ module Elabs
|
|
2
2
|
module AdminContentHelper
|
3
3
|
def admin_action_links(singular_model, entity)
|
4
4
|
out = []
|
5
|
-
out.push(
|
5
|
+
out.push(show_online_link(entity))
|
6
6
|
out.push(admin_lock_link(singular_model, entity))
|
7
7
|
out.push(admin_destroy_link(singular_model, entity))
|
8
8
|
|
9
9
|
raw out.join('')
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
class: 'btn btn--small btn--show' do
|
16
|
-
icon('eye', ['fw'])
|
17
|
-
end
|
12
|
+
# @deprecated This will be deprecated in 4.0
|
13
|
+
def admin_show_online_link(singular_model, entity)
|
14
|
+
admin_show_link(singular_model, entity)
|
18
15
|
end
|
19
16
|
|
20
|
-
def
|
21
|
-
|
22
|
-
title: _('View online'),
|
23
|
-
class: 'btn btn--small btn--show' do
|
24
|
-
icon('globe', ['fw'])
|
25
|
-
end
|
17
|
+
def admin_show_link(singular_model, entity)
|
18
|
+
namespace_show_link('admin', singular_model, entity)
|
26
19
|
end
|
27
20
|
|
28
21
|
def admin_lock_link(singular_model, entity)
|
@@ -35,20 +28,11 @@ module Elabs
|
|
35
28
|
end
|
36
29
|
|
37
30
|
def admin_destroy_link(singular_model, entity)
|
38
|
-
|
39
|
-
title: _('Destroy'),
|
40
|
-
class: 'btn btn--small btn--destroy',
|
41
|
-
method: :delete, data: { confirm: _('Are you sure?') } do
|
42
|
-
icon('trash', ['fw'])
|
43
|
-
end
|
31
|
+
namespace_destroy_link('admin', singular_model, entity)
|
44
32
|
end
|
45
33
|
|
46
34
|
def admin_edit_link(singular_model, entity)
|
47
|
-
|
48
|
-
title: _('Edit'),
|
49
|
-
class: 'btn btn--small btn--edit' do
|
50
|
-
icon('pencil-alt', ['fw'])
|
51
|
-
end
|
35
|
+
namespace_edit_link('admin', singular_model, entity)
|
52
36
|
end
|
53
37
|
end
|
54
38
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Elabs
|
2
|
+
module ContentHelper
|
3
|
+
def show_online_link(entity)
|
4
|
+
link_to entity,
|
5
|
+
title: _('View online'),
|
6
|
+
class: 'btn btn--small btn--show' do
|
7
|
+
icon('eye', ['fw'])
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def namespace_show_link(namespace, singular_model, entity)
|
12
|
+
link_to send("#{namespace}_#{singular_model}_path", entity),
|
13
|
+
title: _('View online'),
|
14
|
+
class: 'btn btn--small btn--show' do
|
15
|
+
icon('eye', ['fw'])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def namespace_edit_link(namespace, singular_model, entity)
|
20
|
+
link_to send("edit_#{namespace}_#{singular_model}_path", entity),
|
21
|
+
title: _('Edit'),
|
22
|
+
class: 'btn btn--small btn--edit' do
|
23
|
+
icon('pencil-alt', ['fw'])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def namespace_destroy_link(namespace, singular_model, entity, confirm = true)
|
28
|
+
link_params = {
|
29
|
+
title: _('Destroy'),
|
30
|
+
method: :delete,
|
31
|
+
class: 'btn btn--small btn--destroy'
|
32
|
+
}
|
33
|
+
link_params[:data] = { confirm: _('Are you sure?') } if confirm
|
34
|
+
link_to send("#{namespace}_#{singular_model}_path".to_sym, entity), link_params do
|
35
|
+
icon('trash', ['fw'])
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -1,23 +1,35 @@
|
|
1
1
|
module Elabs
|
2
2
|
module FormHelper
|
3
|
-
def album_selector(form)
|
4
|
-
form.select
|
3
|
+
def album_selector(form, field = :album_ids, multiple: true)
|
4
|
+
form.select field, Elabs::Album.by_member(current_user).for_list, {},
|
5
|
+
multiple: multiple, id: selector_id(form, field)
|
5
6
|
end
|
6
7
|
|
7
|
-
def language_selector(form)
|
8
|
-
form.select
|
8
|
+
def language_selector(form, field = :language_id, multiple: false)
|
9
|
+
form.select field, Elabs::Language.for_list, {},
|
10
|
+
multiple: multiple, id: selector_id(form, field)
|
9
11
|
end
|
10
12
|
|
11
|
-
def license_selector(form)
|
12
|
-
form.select
|
13
|
+
def license_selector(form, field = :license_id, multiple: false)
|
14
|
+
form.select field, Elabs::License.for_list, {},
|
15
|
+
multiple: multiple, id: selector_id(form, field)
|
13
16
|
end
|
14
17
|
|
15
|
-
def project_selector(form)
|
16
|
-
form.select
|
18
|
+
def project_selector(form, field = :project_ids, multiple: true)
|
19
|
+
form.select field, Elabs::Project.by_member(current_user).for_list, {},
|
20
|
+
multiple: multiple, id: selector_id(form, field)
|
17
21
|
end
|
18
22
|
|
19
|
-
def uploads_selector(form)
|
20
|
-
form.select
|
23
|
+
def uploads_selector(form, field = :upload_ids, multiple: true)
|
24
|
+
form.select field, Elabs::Upload.by_member(current_user).for_list, {},
|
25
|
+
multiple: multiple, id: selector_id(form, field)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def selector_id(form, field)
|
31
|
+
field_name = field.to_s.sub(/(.*)_id(s?)/, '\1\2')
|
32
|
+
"#{form.object_name}_#{field_name}"
|
21
33
|
end
|
22
34
|
end
|
23
35
|
end
|
@@ -2,7 +2,7 @@ module Elabs
|
|
2
2
|
module MemberContentHelper
|
3
3
|
def member_action_links(singular_model, entity)
|
4
4
|
out = []
|
5
|
-
out.push
|
5
|
+
out.push show_online_link(entity)
|
6
6
|
out.push member_edit_link(singular_model, entity)
|
7
7
|
out.push member_publish_link(singular_model, entity)
|
8
8
|
out.push member_destroy_link(singular_model, entity)
|
@@ -10,20 +10,12 @@ module Elabs
|
|
10
10
|
raw out.join('')
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
14
|
-
|
15
|
-
title: _('View online'),
|
16
|
-
class: 'btn btn--small btn--show' do
|
17
|
-
icon('eye', ['fw'])
|
18
|
-
end
|
13
|
+
def member_edit_link(singular_model, entity)
|
14
|
+
namespace_edit_link('member', singular_model, entity)
|
19
15
|
end
|
20
16
|
|
21
|
-
def
|
22
|
-
|
23
|
-
title: _('Edit'),
|
24
|
-
class: 'btn btn--small btn--edit' do
|
25
|
-
icon('pencil-alt', ['fw'])
|
26
|
-
end
|
17
|
+
def member_destroy_link(singular_model, entity, confirm = true)
|
18
|
+
namespace_destroy_link('member', singular_model, entity, confirm)
|
27
19
|
end
|
28
20
|
|
29
21
|
def member_publish_link(singular_model, entity)
|
@@ -34,14 +26,5 @@ module Elabs
|
|
34
26
|
icon(entity.published? ? 'calendar-times' : 'calendar-check', ['fw'])
|
35
27
|
end
|
36
28
|
end
|
37
|
-
|
38
|
-
def member_destroy_link(singular_model, entity)
|
39
|
-
link_to send("member_#{singular_model}_path".to_sym, entity),
|
40
|
-
title: _('Destroy'),
|
41
|
-
method: :delete, data: { confirm: _('Are you sure?') },
|
42
|
-
class: 'btn btn--small btn--destroy' do
|
43
|
-
icon('trash', ['fw'])
|
44
|
-
end
|
45
|
-
end
|
46
29
|
end
|
47
30
|
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Elabs
|
2
|
+
module NotificationHelper
|
3
|
+
def notification_message(notification)
|
4
|
+
user = notification_user notification.source_user
|
5
|
+
action = notification_action notification.event
|
6
|
+
link = notification_link notification
|
7
|
+
string = notification_string notification
|
8
|
+
format(string, user: user, action: action, link: link).html_safe
|
9
|
+
end
|
10
|
+
|
11
|
+
def notification_icon(event)
|
12
|
+
actions = {
|
13
|
+
comment: 'comment',
|
14
|
+
report: 'flag',
|
15
|
+
lock: 'lock',
|
16
|
+
unlock: 'unlock',
|
17
|
+
delete: 'trash'
|
18
|
+
}.freeze
|
19
|
+
icon (actions[event.to_sym] || 'question'), ['fw']
|
20
|
+
end
|
21
|
+
|
22
|
+
def notification_count
|
23
|
+
Elabs::Notification.for_user(current_user).count
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def notification_action(event)
|
29
|
+
actions = {
|
30
|
+
comment: _('has commented'),
|
31
|
+
report: _('has reported'),
|
32
|
+
lock: _('has locked'),
|
33
|
+
unlock: _('has unlocked'),
|
34
|
+
delete: _('has deleted')
|
35
|
+
}.freeze
|
36
|
+
actions[event.to_sym] || "[missing: #{event}]"
|
37
|
+
end
|
38
|
+
|
39
|
+
def notification_user(user)
|
40
|
+
return link_to user.display_name, user if user
|
41
|
+
|
42
|
+
_('Someone')
|
43
|
+
end
|
44
|
+
|
45
|
+
def notification_link(notification)
|
46
|
+
return "##{notification.content_id}" if notification.event == 'delete'
|
47
|
+
|
48
|
+
link = case notification.content_type
|
49
|
+
when 'Elabs::Report'
|
50
|
+
admin_reports_path
|
51
|
+
else
|
52
|
+
notification.content
|
53
|
+
end
|
54
|
+
link_to("##{notification.content_id}", link).html_safe
|
55
|
+
end
|
56
|
+
|
57
|
+
def notification_string(notification)
|
58
|
+
strings = {
|
59
|
+
'Elabs::Album' => _('%<user>s %<action>s your album %<link>s'),
|
60
|
+
'Elabs::Article' => _('%<user>s %<action>s your article %<link>s'),
|
61
|
+
'Elabs::Note' => _('%<user>s %<action>s your note %<link>s'),
|
62
|
+
'Elabs::Project' => _('%<user>s %<action>s your project %<link>s'),
|
63
|
+
'Elabs::Upload' => _('%<user>s %<action>s your file %<link>s'),
|
64
|
+
'Elabs::Report' => _('%<user>s %<action>s %<link>s')
|
65
|
+
}.freeze
|
66
|
+
strings[notification.content_type] || '%<user> %<action>s something (<%link>)'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -24,5 +24,20 @@ module Elabs
|
|
24
24
|
|
25
25
|
{ resize: dimensions }
|
26
26
|
end
|
27
|
+
|
28
|
+
def avatar_image(avatar, size = :medium)
|
29
|
+
x = avatar.blob.metadata[:width].to_f
|
30
|
+
y = avatar.blob.metadata[:height].to_f
|
31
|
+
bigger_size = x < y ? x : y
|
32
|
+
dimensions = case size
|
33
|
+
when :large
|
34
|
+
'512'
|
35
|
+
when :medium
|
36
|
+
'256'
|
37
|
+
when :small
|
38
|
+
'64'
|
39
|
+
end
|
40
|
+
avatar.variant(combine_options: { gravity: 'center', crop: "#{bigger_size}x#{bigger_size}+0+0", resize: dimensions.to_s }).processed
|
41
|
+
end
|
27
42
|
end
|
28
43
|
end
|
@@ -2,6 +2,7 @@ module Elabs
|
|
2
2
|
module TimeHelper
|
3
3
|
def same_day?(previous_date_time, current_date_time)
|
4
4
|
return false if previous_date_time.nil?
|
5
|
+
|
5
6
|
date1 = Date.parse(previous_date_time.to_s)
|
6
7
|
date2 = Date.parse(current_date_time.to_s)
|
7
8
|
|
@@ -15,5 +16,11 @@ module Elabs
|
|
15
16
|
def date_time_to_time(time)
|
16
17
|
time.strftime(_('%I:%M %p'))
|
17
18
|
end
|
19
|
+
|
20
|
+
def short_date(date)
|
21
|
+
return nil if date.nil?
|
22
|
+
|
23
|
+
I18n.l date, format: :short
|
24
|
+
end
|
18
25
|
end
|
19
26
|
end
|
data/app/models/elabs/comment.rb
CHANGED
@@ -8,5 +8,19 @@ module Elabs
|
|
8
8
|
|
9
9
|
belongs_to :content, polymorphic: true
|
10
10
|
belongs_to :user, optional: true
|
11
|
+
|
12
|
+
after_save :notify_author, if: :notify_author?
|
13
|
+
|
14
|
+
def notify_author?
|
15
|
+
user_id ? content.user_id != user_id : true
|
16
|
+
end
|
17
|
+
|
18
|
+
def notify_author
|
19
|
+
notification = { content: content,
|
20
|
+
event: :comment,
|
21
|
+
user_id: content.user_id }
|
22
|
+
notification[:source_user] = user if user_id
|
23
|
+
Elabs::Notification.create! notification
|
24
|
+
end
|
11
25
|
end
|
12
26
|
end
|
@@ -26,18 +26,6 @@ module Elabs
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
def current_publish_action
|
30
|
-
published? && unlocked? ? :publish : :unpublish
|
31
|
-
end
|
32
|
-
|
33
|
-
def current_lock_action
|
34
|
-
published? && locked? ? :lock : :unlock
|
35
|
-
end
|
36
|
-
|
37
|
-
def current_update_action
|
38
|
-
published? && unlocked? ? :update : :nothing
|
39
|
-
end
|
40
|
-
|
41
29
|
def update_acts
|
42
30
|
acts.destroy_all if %i[lock unpublish].include? @action
|
43
31
|
Act.create content: self, event: @action unless @action == :nothing || hidden_in_history
|
@@ -56,6 +56,29 @@ module Elabs
|
|
56
56
|
self.published_at = nil if changed.include?('published') && !published?
|
57
57
|
end
|
58
58
|
|
59
|
+
# method used by ActableEntity/NotifiableEntity to determine the events.
|
60
|
+
def current_publish_action
|
61
|
+
return :nothing unless unlocked?
|
62
|
+
|
63
|
+
published? ? :publish : :unpublish
|
64
|
+
end
|
65
|
+
|
66
|
+
# method used by ActableEntity/NotifiableEntity to determine the events.
|
67
|
+
def current_lock_action
|
68
|
+
return :nothing unless published?
|
69
|
+
|
70
|
+
locked? ? :lock : :unlock
|
71
|
+
end
|
72
|
+
|
73
|
+
# method used by ActableEntity/NotifiableEntity to determine the events.
|
74
|
+
def current_update_action
|
75
|
+
published? && unlocked? ? :update : :nothing
|
76
|
+
end
|
77
|
+
|
78
|
+
def changed_by_someone_else
|
79
|
+
changed_by.present? && changed_by.id != user.id
|
80
|
+
end
|
81
|
+
|
59
82
|
class_methods do
|
60
83
|
def find_publicly_visible(id)
|
61
84
|
entity = where(id: id).published.first
|