boxroom 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +45 -8
- data/app/concepts/boxroom/search/operations/files_and_folders.rb +1 -1
- data/app/controllers/boxroom/application_controller.rb +1 -1
- data/app/controllers/boxroom/clipboard_controller.rb +1 -1
- data/app/controllers/boxroom/files_controller.rb +2 -1
- data/app/controllers/boxroom/folders_controller.rb +2 -2
- data/app/controllers/boxroom/sessions_controller.rb +3 -3
- data/app/controllers/boxroom/share_links_controller.rb +1 -1
- data/app/controllers/boxroom/users_controller.rb +2 -2
- data/app/controllers/concerns/boxroom/base_controller.rb +19 -12
- data/app/models/boxroom/user_file.rb +1 -0
- data/app/views/boxroom/clipboard/_show.html.erb +4 -4
- data/app/views/boxroom/folders/show.html.erb +13 -11
- data/app/views/boxroom/search/show.html.erb +1 -1
- data/app/views/boxroom/shared/_header.html.erb +3 -3
- data/app/views/boxroom/users/_form.html.erb +2 -2
- data/db/migrate/20180309104530_add_original_id_to_users.rb +5 -0
- data/lib/boxroom/active_record.rb +4 -0
- data/lib/boxroom/configuration.rb +22 -4
- data/lib/boxroom/models.rb +33 -0
- data/lib/boxroom/version.rb +1 -1
- data/lib/boxroom.rb +4 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21e9f11bc948549ad833330da41139124099fa51
|
4
|
+
data.tar.gz: 6fcbc3e5f900ad2c032aa8562cb7ebd2d08a1465
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4c1fd13840b7a5aed4e3c496188fad9e7d0a3302fd853728cc17e13d5292fe2fdf546db8c8b01596059a7d97986e7b0d032c334d395f5999103479fe353fd44
|
7
|
+
data.tar.gz: a1349db39a6ef79da9dce7e9ef0ea125065e8df19b54dea8f27fed7ff661829d5396a2652c139dcf588acfd402cf1ef8a1e8d73225b598ecc4cf92193058ca09
|
data/README.md
CHANGED
@@ -1,20 +1,33 @@
|
|
1
1
|
# Boxroom
|
2
|
+
[](https://badge.fury.io/rb/boxroom)
|
3
|
+
|
2
4
|
This is a Rails engine built based on code of [Boxroom](https://github.com/mischa78/boxroom) project.
|
3
5
|
|
4
6
|
# Features
|
5
7
|
It aims to be a simple interface for managing and
|
6
|
-
sharing files in a web browser. It lets users
|
7
|
-
|
8
|
+
sharing files in a web browser. It lets users
|
9
|
+
- create folders
|
10
|
+
- upload files
|
11
|
+
- download files
|
12
|
+
- share files
|
13
|
+
- search folders and files
|
14
|
+
|
15
|
+
Admins can:
|
16
|
+
- manage users
|
17
|
+
- manage groups
|
18
|
+
- manage access permissions
|
19
|
+
|
20
|
+
Integrates with existing User model amd authentication system.
|
8
21
|
|
9
22
|

|
10
23
|
|
11
24
|
## Install
|
12
|
-
- add to Gemfile `gem 'boxroom'
|
25
|
+
- add to Gemfile `gem 'boxroom'`
|
13
26
|
- run `rails boxroom:install:migrations`
|
14
27
|
- run `rails db:migrate`
|
15
28
|
- mount engine in `config/routes.rb`
|
16
29
|
```ruby
|
17
|
-
mount Boxroom::Engine =>
|
30
|
+
mount Boxroom::Engine => '/boxroom'
|
18
31
|
```
|
19
32
|
|
20
33
|
## Config
|
@@ -29,9 +42,33 @@ Boxroom.configure do |config|
|
|
29
42
|
config.show_groups = true
|
30
43
|
config.show_settings = true
|
31
44
|
config.show_shared_files = true
|
32
|
-
config.
|
45
|
+
config.show_search = true
|
46
|
+
end
|
47
|
+
```
|
48
|
+
|
49
|
+
## Integrate with existing User model and authentication
|
50
|
+
- Create `config/initializers/boxroom.rb`
|
51
|
+
```ruby
|
52
|
+
Boxroom.configure do |config|
|
53
|
+
config.current_user_method = 'current_user' # a method in your application, which returns authenticated User, Boxroom's authentication is disabled
|
54
|
+
config.sign_in_path = '/login' # pass string to redirect unauthenticated user to
|
55
|
+
config.sign_out_path = '/logout' # pass string to redirect to after sign out, '/dashboard' for example. Or it could be sign out page of you main app
|
33
56
|
end
|
34
57
|
```
|
58
|
+
- add `boxroom` to your User model.
|
59
|
+
- Remember you can provide User model methods names instead of fields names too. For example
|
60
|
+
```ruby
|
61
|
+
# app/models/user.rb
|
62
|
+
class User < ActiveRecord::Base
|
63
|
+
# :username and :email are attributes of User model
|
64
|
+
boxroom name: :username, email: :email, is_admin: :is_admin? # all params are required
|
65
|
+
|
66
|
+
def is_admin?
|
67
|
+
email == 'admin@test.com' # Remember only 1 user can be a real admin
|
68
|
+
end
|
69
|
+
end
|
70
|
+
```
|
71
|
+
- if you modify your users without callbacks in any place you should also take care of `boxroom_users` table yourself.
|
35
72
|
|
36
73
|
## Contributing
|
37
74
|
Please feel free to leave an issue or PR.
|
@@ -44,7 +81,7 @@ Please feel free to leave an issue or PR.
|
|
44
81
|
The engine is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
45
82
|
|
46
83
|
## Roadmap:
|
47
|
-
- tests for search
|
48
|
-
- tag files
|
49
|
-
- integrate with existing user model
|
50
84
|
- support s3
|
85
|
+
- batch actions
|
86
|
+
- tag files
|
87
|
+
- integrate with active_admin
|
@@ -12,7 +12,7 @@ module Boxroom::Search
|
|
12
12
|
|
13
13
|
def search_folder(term, folder, options)
|
14
14
|
options['folders'] << folder if folder.name.downcase.include? term.downcase
|
15
|
-
options['files'] += folder.user_files.where(
|
15
|
+
options['files'] += folder.user_files.where('lower(attachment_file_name) LIKE ?', "%#{term.downcase}%").all.to_a
|
16
16
|
folder.children.each do |f|
|
17
17
|
search_folder(term, f, options)
|
18
18
|
end
|
@@ -78,7 +78,7 @@ module Boxroom
|
|
78
78
|
# current folder (identified by params[:folder_id]) if not.
|
79
79
|
%w{read delete}.each do |method|
|
80
80
|
define_method "require_#{method}_permission" do
|
81
|
-
unless
|
81
|
+
unless boxroom_current_user.send("can_#{method}", @folder)
|
82
82
|
redirect_to folder_url(params[:folder_id]), :alert => t(:no_permissions_for_this_type, :method => t(method), :type => t("this_#{params[:type]}"))
|
83
83
|
end
|
84
84
|
end
|
@@ -28,6 +28,7 @@ module Boxroom
|
|
28
28
|
folder_id: params[:target_folder_id]
|
29
29
|
).first
|
30
30
|
|
31
|
+
#TODO: refactor to support S3
|
31
32
|
if existing_file # Resume upload
|
32
33
|
existing_file.update_attribute(:attachment_file_size, existing_file.attachment_file_size + permitted_params.user_file["attachment"].size)
|
33
34
|
File.open("#{Rails.root}/#{Boxroom.configuration.uploads_path}/#{Rails.env}/#{existing_file.id}/original/#{existing_file.id}", "ab") {|f| f.write(permitted_params.user_file["attachment"].read)}
|
@@ -60,7 +61,7 @@ module Boxroom
|
|
60
61
|
def exists
|
61
62
|
@folder = Folder.find(params[:folder])
|
62
63
|
|
63
|
-
if
|
64
|
+
if boxroom_current_user.can_read(@folder) || boxroom_current_user.can_write(@folder)
|
64
65
|
@file = @folder.user_files.build(:attachment_file_name => params[:name].gsub(Boxroom::RESTRICTED_CHARACTERS, '_'))
|
65
66
|
render :json => !@file.valid?
|
66
67
|
end
|
@@ -70,7 +70,7 @@ module Boxroom
|
|
70
70
|
|
71
71
|
# Overrides require_delete_permission in ApplicationController
|
72
72
|
def require_delete_permission
|
73
|
-
unless @folder.is_root? ||
|
73
|
+
unless @folder.is_root? || boxroom_current_user.can_delete(@folder)
|
74
74
|
redirect_to @folder.parent, :alert => t(:no_permissions_for_this_type, :method => t(:delete), :type => t(:this_folder))
|
75
75
|
else
|
76
76
|
require_delete_permissions_for(@folder.children)
|
@@ -79,7 +79,7 @@ module Boxroom
|
|
79
79
|
|
80
80
|
def require_delete_permissions_for(folders)
|
81
81
|
folders.each do |folder|
|
82
|
-
unless
|
82
|
+
unless boxroom_current_user.can_delete(folder)
|
83
83
|
redirect_to @folder.parent, :alert => t(:no_delete_permissions_for_subfolder)
|
84
84
|
else
|
85
85
|
# Recursive...
|
@@ -16,7 +16,7 @@ module Boxroom
|
|
16
16
|
cookies[:auth_token] = {:value => user.remember_token, :expires => 2.weeks.from_now}
|
17
17
|
end
|
18
18
|
|
19
|
-
session[:
|
19
|
+
session[:boxroom_user_id] = user.id
|
20
20
|
redirect_url = session.delete(:return_to) || folders_url
|
21
21
|
redirect_to redirect_url, :only_path => true
|
22
22
|
else
|
@@ -26,10 +26,10 @@ module Boxroom
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def destroy
|
29
|
-
|
29
|
+
boxroom_current_user.forget_me
|
30
30
|
cookies.delete :auth_token
|
31
31
|
reset_session
|
32
|
-
session[:
|
32
|
+
session[:boxroom_user_id] = nil
|
33
33
|
redirect_to Boxroom.configuration.sign_out_path ? Boxroom.configuration.sign_out_path : new_session_url
|
34
34
|
end
|
35
35
|
|
@@ -27,7 +27,7 @@ module Boxroom
|
|
27
27
|
# Note: @file and @folder are set in require_existing_file
|
28
28
|
def create
|
29
29
|
@share_link = @file.share_links.build(permitted_params.share_link)
|
30
|
-
@share_link.user =
|
30
|
+
@share_link.user = boxroom_current_user
|
31
31
|
|
32
32
|
if @share_link.save
|
33
33
|
UserMailer.share_link_email(@share_link).deliver_now
|
@@ -55,12 +55,12 @@ module Boxroom
|
|
55
55
|
private
|
56
56
|
|
57
57
|
def require_existing_user
|
58
|
-
if
|
58
|
+
if boxroom_current_user.member_of_admins? && params[:id] != boxroom_current_user.id.to_s
|
59
59
|
@title = t(:edit_user)
|
60
60
|
@user = User.find(params[:id])
|
61
61
|
else
|
62
62
|
@title = t(:account_settings)
|
63
|
-
@user =
|
63
|
+
@user = boxroom_current_user
|
64
64
|
end
|
65
65
|
rescue ActiveRecord::RecordNotFound
|
66
66
|
redirect_to users_url, :alert => t(:user_already_deleted)
|
@@ -6,11 +6,11 @@ module Boxroom
|
|
6
6
|
before_action :require_admin_in_system
|
7
7
|
before_action :require_login
|
8
8
|
|
9
|
-
helper_method :clipboard, :
|
9
|
+
helper_method :clipboard, :boxroom_current_user, :signed_in?, :permitted_params
|
10
10
|
|
11
11
|
%w{read update delete}.each do |method|
|
12
12
|
define_method "require_#{method}_permission" do
|
13
|
-
unless (method == 'read' && @folder.is_root?) ||
|
13
|
+
unless (method == 'read' && @folder.is_root?) || boxroom_current_user.send("can_#{method}", @folder)
|
14
14
|
redirect_folder = @folder.parent.nil? ? Folder.root : @folder.parent
|
15
15
|
redirect_to redirect_folder, :alert => t(:no_permissions_for_this_type, :method => t(:create), :type => t(:this_folder))
|
16
16
|
end
|
@@ -36,16 +36,23 @@ module Boxroom
|
|
36
36
|
cl
|
37
37
|
end
|
38
38
|
|
39
|
-
def
|
40
|
-
|
39
|
+
def boxroom_current_user
|
40
|
+
# integrate with existing User model
|
41
|
+
if Boxroom.configuration.current_user_method && @current_user.nil?
|
42
|
+
original_user = send(Boxroom.configuration.current_user_method)
|
43
|
+
boxroom_user = User.find_by_original_id(original_user.id)
|
44
|
+
session[:boxroom_user_id] = boxroom_user.id if boxroom_user
|
45
|
+
end
|
46
|
+
|
47
|
+
@current_user ||= User.find_by_id(session[:boxroom_user_id])
|
41
48
|
end
|
42
49
|
|
43
50
|
def signed_in?
|
44
|
-
!!
|
51
|
+
!!boxroom_current_user
|
45
52
|
end
|
46
53
|
|
47
54
|
def permitted_params
|
48
|
-
@permitted_params ||= PermittedParams.new(params,
|
55
|
+
@permitted_params ||= PermittedParams.new(params, boxroom_current_user)
|
49
56
|
end
|
50
57
|
|
51
58
|
def require_admin_in_system
|
@@ -53,21 +60,21 @@ module Boxroom
|
|
53
60
|
end
|
54
61
|
|
55
62
|
def require_admin
|
56
|
-
redirect_to :root unless
|
63
|
+
redirect_to :root unless boxroom_current_user.member_of_admins?
|
57
64
|
end
|
58
65
|
|
59
66
|
def require_login
|
60
|
-
if
|
67
|
+
if boxroom_current_user.nil?
|
61
68
|
user = User.find_by_remember_token(cookies[:auth_token]) unless cookies[:auth_token].blank?
|
62
69
|
|
63
70
|
if user.nil?
|
64
71
|
reset_session
|
65
|
-
session[:
|
72
|
+
session[:boxroom_user_id] = nil
|
66
73
|
session[:return_to] = request.fullpath
|
67
|
-
redirect_to new_session_url
|
74
|
+
redirect_to Boxroom.configuration.sign_in_path ? Boxroom.configuration.sign_in_path : new_session_url
|
68
75
|
else
|
69
76
|
user.refresh_remember_token
|
70
|
-
session[:
|
77
|
+
session[:boxroom_user_id] = user.id
|
71
78
|
cookies[:auth_token] = user.remember_token
|
72
79
|
end
|
73
80
|
end
|
@@ -78,7 +85,7 @@ module Boxroom
|
|
78
85
|
end
|
79
86
|
|
80
87
|
def require_create_permission
|
81
|
-
unless
|
88
|
+
unless boxroom_current_user.can_create(@target_folder)
|
82
89
|
redirect_to @target_folder, :alert => t(:no_permissions_for_this_type, :method => t(:create), :type => t(:this_folder))
|
83
90
|
end
|
84
91
|
end
|
@@ -16,6 +16,7 @@ module Boxroom
|
|
16
16
|
new_file.folder = target_folder
|
17
17
|
new_file.save!
|
18
18
|
|
19
|
+
#TODO: refactor to support S3
|
19
20
|
path = "#{Rails.root}/#{Boxroom.configuration.uploads_path}/#{Rails.env}/#{new_file.id}/original"
|
20
21
|
FileUtils.mkdir_p path
|
21
22
|
FileUtils.cp_r self.attachment.path, "#{path}/#{new_file.id}"
|
@@ -15,13 +15,13 @@
|
|
15
15
|
<td><%= image_tag('boxroom/folder.png') %></td>
|
16
16
|
<td class="clipboard_item"><%= item.name %></td>
|
17
17
|
<td>
|
18
|
-
<% if
|
18
|
+
<% if boxroom_current_user.can_create(@folder) -%>
|
19
19
|
<%= link_to image_tag('boxroom/copy.png', :alt => t(:copy)),
|
20
20
|
{:controller => :clipboard, :action => :copy, :id => item.id, :type => 'folder', :folder_id => @folder, :authenticity_token => form_authenticity_token},
|
21
21
|
:method => :post, :title => t(:copy_folder)
|
22
22
|
%>
|
23
23
|
<% end -%>
|
24
|
-
<% if
|
24
|
+
<% if boxroom_current_user.can_create(@folder) && boxroom_current_user.can_delete(item) -%>
|
25
25
|
<%= link_to image_tag('boxroom/move.png', :alt => t(:move)),
|
26
26
|
{:controller => :clipboard, :action => :move, :id => item.id, :type => 'folder', :folder_id => @folder, :authenticity_token => form_authenticity_token},
|
27
27
|
:method => :post, :title => t(:move_folder), :data => {:confirm => t(:are_you_sure)}
|
@@ -39,13 +39,13 @@
|
|
39
39
|
<td><%= image_tag(file_icon(item.extension)) %></td>
|
40
40
|
<td class="clipboard_item"><%= item.attachment_file_name %></td>
|
41
41
|
<td>
|
42
|
-
<% if
|
42
|
+
<% if boxroom_current_user.can_create(@folder) -%>
|
43
43
|
<%= link_to '<span class="icon is-small"><i class="fa fa-copy"></i></span>'.html_safe,
|
44
44
|
{:controller => :clipboard, :action => :copy, :id => item.id, :type => 'file', :folder_id => @folder, :authenticity_token => form_authenticity_token},
|
45
45
|
:method => :post, :title => t(:copy_file)
|
46
46
|
%>
|
47
47
|
<% end -%>
|
48
|
-
<% if
|
48
|
+
<% if boxroom_current_user.can_create(@folder) && boxroom_current_user.can_delete(item.folder) -%>
|
49
49
|
<%= link_to '<span class="icon is-small"><i class="fa fa-cut"></i></span>'.html_safe,
|
50
50
|
{:controller => :clipboard, :action => :move, :id => item.id, :type => 'file', :folder_id => @folder, :authenticity_token => form_authenticity_token},
|
51
51
|
:method => :post, :title => t(:move_file), :data => {:confirm => t(:are_you_sure)}
|
@@ -12,7 +12,7 @@
|
|
12
12
|
|
13
13
|
<div class="tabs">
|
14
14
|
<ul>
|
15
|
-
<% if
|
15
|
+
<% if boxroom_current_user.can_create(@folder) -%>
|
16
16
|
<li>
|
17
17
|
<a href="<%= new_folder_folder_path(@folder) %>">
|
18
18
|
<span class="icon is-small"><i class="fa fa-folder"></i></span>
|
@@ -26,7 +26,7 @@
|
|
26
26
|
</a>
|
27
27
|
</li>
|
28
28
|
<% end -%>
|
29
|
-
<% if
|
29
|
+
<% if boxroom_current_user.member_of_admins? -%>
|
30
30
|
<li>
|
31
31
|
<a href="#" id="permissions_link" class="permissions_link">
|
32
32
|
<span class="icon is-small"><i class="fa fa-lock"></i></span>
|
@@ -43,23 +43,25 @@
|
|
43
43
|
</ul>
|
44
44
|
</div>
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
46
|
+
<% if Boxroom.configuration.show_search %>
|
47
|
+
<%= form_tag(search_path, method: :get) do %>
|
48
|
+
<div class="field">
|
49
|
+
<div class="control">
|
50
|
+
<%= text_field_tag 'term', nil, placeholder: t(:search), size: 71, class: 'input' %>
|
51
|
+
</div>
|
52
|
+
</div>
|
53
|
+
<%= hidden_field_tag 'folder_id', @folder.id %>
|
54
|
+
<% end %>
|
53
55
|
<% end %>
|
54
56
|
|
55
57
|
<div id="files_and_folders">
|
56
58
|
<%= concept(Boxroom::Folder::Cell::Show, @folder,
|
57
59
|
folders: @folder.children,
|
58
60
|
files: @folder.user_files,
|
59
|
-
current_user:
|
61
|
+
current_user: boxroom_current_user) %>
|
60
62
|
</div>
|
61
63
|
|
62
|
-
<% if
|
64
|
+
<% if boxroom_current_user.member_of_admins? -%>
|
63
65
|
<div id="permissions" style="display:none;">
|
64
66
|
<%= render 'boxroom/permissions/form' %>
|
65
67
|
</div>
|
@@ -13,7 +13,7 @@
|
|
13
13
|
<div class="navbar-start">
|
14
14
|
<% if signed_in? -%>
|
15
15
|
<%= link_to t(:folders), folders_path, class: 'navbar-item' %>
|
16
|
-
<% if
|
16
|
+
<% if boxroom_current_user.member_of_admins? -%>
|
17
17
|
<% if Boxroom.configuration.show_users %>
|
18
18
|
<%= link_to t(:users), users_path, class: 'navbar-item' %>
|
19
19
|
<% end %>
|
@@ -30,10 +30,10 @@
|
|
30
30
|
<div class="navbar-end">
|
31
31
|
<% if signed_in? -%>
|
32
32
|
<div class="navbar-item">
|
33
|
-
<%= t :hello %>, <b><%=
|
33
|
+
<%= t :hello %>, <b><%= boxroom_current_user.name %></b>
|
34
34
|
</div>
|
35
35
|
<% if Boxroom.configuration.show_settings %>
|
36
|
-
<%= link_to t(:settings), edit_user_path(
|
36
|
+
<%= link_to t(:settings), edit_user_path(boxroom_current_user), class: 'navbar-item' %>
|
37
37
|
<% end %>
|
38
38
|
<div class="navbar-item">
|
39
39
|
<%= link_to t(:sign_out), signout_path, method: :delete, class: 'button is-danger' %>
|
@@ -32,7 +32,7 @@
|
|
32
32
|
</div>
|
33
33
|
</div>
|
34
34
|
<% end -%>
|
35
|
-
<% if signed_in? &&
|
35
|
+
<% if signed_in? && boxroom_current_user.member_of_admins? -%>
|
36
36
|
<div class="field">
|
37
37
|
<%= label_tag t(:member_of_these_groups), nil, class: 'label' %>
|
38
38
|
<div class="control">
|
@@ -54,7 +54,7 @@
|
|
54
54
|
<div class="control">
|
55
55
|
<%= f.submit t(:save), class: 'button is-link' %>
|
56
56
|
</div>
|
57
|
-
<% if @user !=
|
57
|
+
<% if @user != boxroom_current_user -%>
|
58
58
|
<div class="control">
|
59
59
|
<%= link_to t(:back), users_url, class: 'button is-text' %>
|
60
60
|
</div>
|
@@ -1,18 +1,36 @@
|
|
1
1
|
module Boxroom
|
2
2
|
class Configuration
|
3
|
-
attr_accessor :site_name,
|
4
|
-
:
|
3
|
+
attr_accessor :site_name,
|
4
|
+
:logo,
|
5
|
+
:show_footer,
|
6
|
+
:show_users,
|
7
|
+
:show_groups,
|
8
|
+
:show_settings,
|
9
|
+
:show_shared_files,
|
10
|
+
:show_search,
|
11
|
+
:uploads_path,
|
12
|
+
:current_user_method,
|
13
|
+
:sign_in_path,
|
14
|
+
:sign_out_path,
|
15
|
+
:parent_controller
|
5
16
|
|
6
17
|
def initialize
|
7
18
|
@site_name = 'Boxroom'
|
8
19
|
@logo = 'boxroom/logo.png'
|
9
|
-
@uploads_path = 'uploads'
|
10
20
|
@show_footer = true
|
11
21
|
@show_users = true
|
12
22
|
@show_groups = true
|
13
23
|
@show_settings = true
|
14
24
|
@show_shared_files = true
|
15
|
-
@
|
25
|
+
@show_search = true
|
26
|
+
@uploads_path = 'uploads'
|
27
|
+
|
28
|
+
# Integrate with existing user model
|
29
|
+
@current_user_method = nil
|
30
|
+
@sign_in_path = nil
|
31
|
+
@sign_out_path = nil
|
32
|
+
|
33
|
+
@parent_controller = 'ApplicationController'
|
16
34
|
end
|
17
35
|
end
|
18
36
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Boxroom
|
2
|
+
module Models
|
3
|
+
module ClassMethods
|
4
|
+
def boxroom(params)
|
5
|
+
throw "Provide 'name:' param for 'boxroom' method in your user model" if params[:name].nil?
|
6
|
+
throw "Provide 'email:' param for 'boxroom' method in your user model" if params[:email].nil?
|
7
|
+
throw "Provide 'is_admin:' param for 'boxroom' method in your user model" if params[:is_admin].nil?
|
8
|
+
|
9
|
+
after_save -> { save_boxroom_user(params) }
|
10
|
+
before_destroy -> { destroy_boxroom_user(params) }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module InstanceMethods
|
15
|
+
def save_boxroom_user(params)
|
16
|
+
bu = Boxroom::User.find_by_original_id(id)
|
17
|
+
bu = Boxroom::User.new if bu.nil?
|
18
|
+
bu.original_id = id
|
19
|
+
bu.name = send(params[:name])
|
20
|
+
bu.email = send(params[:email])
|
21
|
+
bu.is_admin = send(params[:is_admin])
|
22
|
+
bu.save
|
23
|
+
throw "Failed to save Boxroom::User with email=#{bu.email}" unless bu.persisted?
|
24
|
+
end
|
25
|
+
|
26
|
+
def destroy_boxroom_user(params)
|
27
|
+
bu = Boxroom::User.find_by_original_id(id)
|
28
|
+
bu.destroy if bu
|
29
|
+
true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/boxroom/version.rb
CHANGED
data/lib/boxroom.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
require 'boxroom/engine'
|
2
|
+
require 'boxroom/configuration'
|
3
|
+
require 'boxroom/models'
|
4
|
+
require 'boxroom/active_record'
|
5
|
+
|
2
6
|
require 'dynamic_form'
|
3
7
|
require 'jquery-rails'
|
4
8
|
require 'jquery-fileupload-rails'
|
5
9
|
require 'acts_as_tree'
|
6
10
|
require 'paperclip'
|
7
|
-
require 'boxroom/configuration'
|
8
11
|
require 'paperclip/spoof_detector'
|
9
12
|
require 'bulma-rails'
|
10
13
|
require 'font-awesome-rails'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: boxroom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Serge Koba
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -448,9 +448,12 @@ files:
|
|
448
448
|
- db/migrate/20120411081345_boxroom_add_column_signup_token_expires_at_to_users.rb
|
449
449
|
- db/migrate/20130626210927_boxroom_add_columns_message_user_id_to_share_links.rb
|
450
450
|
- db/migrate/20130628082245_boxroom_populate_user_id_in_share_links.rb
|
451
|
+
- db/migrate/20180309104530_add_original_id_to_users.rb
|
451
452
|
- lib/boxroom.rb
|
453
|
+
- lib/boxroom/active_record.rb
|
452
454
|
- lib/boxroom/configuration.rb
|
453
455
|
- lib/boxroom/engine.rb
|
456
|
+
- lib/boxroom/models.rb
|
454
457
|
- lib/boxroom/version.rb
|
455
458
|
- lib/paperclip/spoof_detector.rb
|
456
459
|
- lib/tasks/boxroom_tasks.rake
|