hotsheet 0.2.0 → 0.2.1
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 +26 -6
- data/app/controllers/hotsheet/application_controller.rb +6 -0
- data/app/controllers/hotsheet/home_controller.rb +9 -0
- data/app/controllers/hotsheet/sheets_controller.rb +5 -7
- data/app/views/hotsheet/home/error.html.erb +1 -0
- data/app/views/hotsheet/shared/_nav.html.erb +1 -1
- data/config/locales/en.yml +5 -0
- data/config/routes.rb +4 -5
- data/lib/generators/templates/hotsheet.rb +10 -3
- data/lib/hotsheet/version.rb +1 -1
- data/lib/hotsheet.rb +5 -5
- metadata +5 -4
- data/app/helpers/hotsheet/application_helper.rb +0 -7
- data/app/views/hotsheet/sheets/error.html.erb +0 -1
- /data/app/views/hotsheet/{sheets/root.html.erb → home/show.html.erb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b1074112914dc017affebb383fba9eaa3bbab56e59b40355510d94ddf0f21f9
|
4
|
+
data.tar.gz: 54d77d78f488cd563ee2377c3c5585580fa6d692d4c90de9126de82233ddfc3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 400ea189cbefc49907da08f1d22c3f3f40f9f28a7e7c0ad92a8469b4b18014f2f3767a2a57c03dbc81ff369366c107ab2252dad2c3c3e43a1deec3ac95b5bf4b
|
7
|
+
data.tar.gz: 64b2a5ca09604b2adacaa2da16e43bf95429d233c728e3f8175009b71fef00f0ac217a193711d1be4823bdc8870c56929d52316facc38b3130e68129fc2653a7
|
data/README.md
CHANGED
@@ -16,25 +16,45 @@
|
|
16
16
|
|
17
17
|
## Usage
|
18
18
|
|
19
|
-
After
|
19
|
+
After the installation, you can start the Rails server and visit
|
20
|
+
[/hotsheet](http://localhost:3000/hotsheet) to view the spreadsheet.
|
20
21
|
|
21
22
|
### Configuration
|
22
23
|
|
23
24
|
You can configure which models ('sheets') this gem should manage, and specify which
|
24
25
|
database columns should be editable or viewable in the spreadsheet. This can be
|
25
|
-
done by
|
26
|
+
done by editing the [config/initializers/hotsheet.rb](https://github.com/renuo/hotsheet/blob/main/lib/generators/templates/hotsheet.rb)
|
27
|
+
file created by the install command:
|
26
28
|
|
27
29
|
```rb
|
28
|
-
# config/initializers/hotsheet.rb
|
29
|
-
|
30
30
|
Hotsheet.configure do
|
31
|
+
# Configure the visible and editable columns for each model.
|
32
|
+
# The ID is included as the first column by default.
|
31
33
|
sheet :User do
|
32
34
|
column :name
|
33
|
-
column :
|
35
|
+
column :email, editable: false
|
36
|
+
column :birthdate, editable: -> { rand > 0.5 }
|
34
37
|
end
|
38
|
+
|
39
|
+
# Leave the block out to include all database columns.
|
40
|
+
sheet :Post
|
35
41
|
end
|
36
42
|
```
|
37
43
|
|
44
|
+
### Basic Authentication
|
45
|
+
|
46
|
+
If you don't want everyone to have access to Hotsheet, you can set a
|
47
|
+
basic auth environment variable:
|
48
|
+
|
49
|
+
```sh
|
50
|
+
HOTSHEET_BASIC_AUTH="admin:password"
|
51
|
+
```
|
52
|
+
|
53
|
+
### Internationalization
|
54
|
+
|
55
|
+
You can create custom translations by overwriting the default locales defined in
|
56
|
+
[config/locales/en.yml](https://github.com/renuo/hotsheet/blob/main/config/locales/en.yml).
|
57
|
+
|
38
58
|
## Contributing
|
39
59
|
|
40
60
|
See [Contributing Guide](https://github.com/renuo/hotsheet/blob/main/CONTRIBUTING.md) and please
|
@@ -48,7 +68,7 @@ This is a newly created gem, and we will firstly focus on:
|
|
48
68
|
1. Configuration and access permissions
|
49
69
|
1. Concurrent users (broadcasting, conflict resolution)
|
50
70
|
|
51
|
-
Feel free to look at our [planned enhancements](https://github.com/renuo/hotsheet/issues?q=is
|
71
|
+
Feel free to look at our [planned enhancements](https://github.com/renuo/hotsheet/issues?q=is:open+is:issue+label:feature)
|
52
72
|
or add your own.
|
53
73
|
|
54
74
|
## License
|
@@ -18,27 +18,25 @@ class Hotsheet::SheetsController < Hotsheet::ApplicationController
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
def error
|
22
|
-
render "error", status: :not_found
|
23
|
-
end
|
24
|
-
|
25
21
|
private
|
26
22
|
|
27
23
|
def set_sheet
|
28
24
|
@sheet = Hotsheet.sheets[params[:sheet_name]]
|
25
|
+
|
26
|
+
render "hotsheet/home/error", status: :not_found if @sheet.nil?
|
29
27
|
end
|
30
28
|
|
31
29
|
def set_column
|
32
30
|
@column = @sheet.columns[params[:column_name]]
|
33
|
-
return respond Hotsheet.t "
|
31
|
+
return respond Hotsheet.t "error_not_found" if @column.nil?
|
34
32
|
|
35
|
-
respond Hotsheet.t "
|
33
|
+
respond Hotsheet.t "error_forbidden" unless @column.editable?
|
36
34
|
end
|
37
35
|
|
38
36
|
def set_resource
|
39
37
|
@resource = @sheet.model.find_by id: params[:id]
|
40
38
|
|
41
|
-
respond Hotsheet.t "
|
39
|
+
respond Hotsheet.t "error_not_found" if @resource.nil?
|
42
40
|
end
|
43
41
|
|
44
42
|
def respond(message = "")
|
@@ -0,0 +1 @@
|
|
1
|
+
<h1><%= Hotsheet.t "error_not_found" %></h1>
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<% Hotsheet.sheets.each_with_index do |entry, index| %>
|
7
7
|
<li>
|
8
8
|
<% sheet_name, sheet = entry %>
|
9
|
-
<%= link_to sheet.model.model_name.human(count: 2),
|
9
|
+
<%= link_to sheet.model.model_name.human(count: 2), sheets_path(sheet_name),
|
10
10
|
class: ("active" if params[:sheet_name] == sheet_name), data: { x: index } %>
|
11
11
|
</li>
|
12
12
|
<% end %>
|
data/config/routes.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
Hotsheet::Engine.routes.draw do
|
4
|
-
|
4
|
+
root "home#show"
|
5
5
|
|
6
|
-
|
7
|
-
resources
|
6
|
+
scope ":sheet_name" do
|
7
|
+
resources controller: :sheets, only: %i[index update], as: :sheets
|
8
8
|
end
|
9
9
|
|
10
|
-
|
11
|
-
match "*path", to: "sheets#error", via: :all
|
10
|
+
match "*path", to: "home#error", via: :all
|
12
11
|
end
|
@@ -1,12 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Configure the models to be used by Hotsheet.
|
4
|
-
# See https://github.com/renuo/hotsheet
|
5
|
-
# The ID is included by default. It is always the first column.
|
4
|
+
# See https://github.com/renuo/hotsheet/blob/main/README.md#usage.
|
6
5
|
|
7
6
|
Hotsheet.configure do
|
7
|
+
# Configure the visible and editable columns for each model.
|
8
|
+
# The ID is included as the first column by default.
|
9
|
+
|
8
10
|
# sheet :User do
|
9
11
|
# column :name
|
10
|
-
# column :
|
12
|
+
# column :email, editable: false
|
13
|
+
# column :birthdate, editable: -> { rand > 0.5 }
|
11
14
|
# end
|
15
|
+
|
16
|
+
# Leave the block out to include all database columns.
|
17
|
+
|
18
|
+
# sheet :Post
|
12
19
|
end
|
data/lib/hotsheet/version.rb
CHANGED
data/lib/hotsheet.rb
CHANGED
@@ -12,10 +12,10 @@ module Hotsheet
|
|
12
12
|
class << self
|
13
13
|
include Config
|
14
14
|
|
15
|
-
CONFIG = {}.freeze
|
16
|
-
|
17
15
|
attr_reader :config
|
18
16
|
|
17
|
+
CONFIG = {}.freeze
|
18
|
+
|
19
19
|
def configure(config = {}, &sheets)
|
20
20
|
@config = [merge_config!(CONFIG, config), sheets]
|
21
21
|
self
|
@@ -29,10 +29,10 @@ module Hotsheet
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
I18N = Psych.load_file(Hotsheet::Engine.root.join("config/locales/en.yml"))["en"]["hotsheet"].freeze
|
33
|
+
|
32
34
|
def t(key)
|
33
|
-
I18n.t key,
|
34
|
-
rescue I18n::MissingTranslationData
|
35
|
-
I18n.with_locale(:en) { I18n.t key, scope: "hotsheet" }
|
35
|
+
I18n.t "hotsheet.#{key}", default: I18N[key]
|
36
36
|
end
|
37
37
|
|
38
38
|
private
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hotsheet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Renuo AG
|
@@ -38,13 +38,14 @@ files:
|
|
38
38
|
- app/assets/hotsheet.css
|
39
39
|
- app/assets/hotsheet.js
|
40
40
|
- app/controllers/hotsheet/application_controller.rb
|
41
|
+
- app/controllers/hotsheet/home_controller.rb
|
41
42
|
- app/controllers/hotsheet/sheets_controller.rb
|
42
|
-
- app/
|
43
|
+
- app/views/hotsheet/home/error.html.erb
|
44
|
+
- app/views/hotsheet/home/show.html.erb
|
43
45
|
- app/views/hotsheet/shared/_nav.html.erb
|
44
|
-
- app/views/hotsheet/sheets/error.html.erb
|
45
46
|
- app/views/hotsheet/sheets/index.html.erb
|
46
|
-
- app/views/hotsheet/sheets/root.html.erb
|
47
47
|
- app/views/layouts/hotsheet/application.html.erb
|
48
|
+
- config/locales/en.yml
|
48
49
|
- config/routes.rb
|
49
50
|
- lib/generators/hotsheet/install_generator.rb
|
50
51
|
- lib/generators/templates/hotsheet.rb
|
@@ -1 +0,0 @@
|
|
1
|
-
<h1><%= Hotsheet.t "errors.not_found" %></h1>
|
File without changes
|