mensa 0.1.13 → 0.1.14
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/.devcontainer/Dockerfile +3 -0
- data/.devcontainer/compose.yaml +49 -0
- data/.devcontainer/devcontainer.json +36 -0
- data/.gitignore +2 -1
- data/Gemfile.lock +19 -17
- data/app/jobs/mensa/export_job.rb +25 -5
- data/app/tables/mensa/base.rb +2 -0
- data/app/tables/mensa/config/table_dsl.rb +3 -0
- data/bin/setup +61 -0
- data/lib/mensa/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da50e030f24e6c7e64770478ffd598ca0b8be05620336d3b9bf8771f2b21d421
|
4
|
+
data.tar.gz: 79b64d284100efce11449c1901d5d1451095255eb9eb77c2e187fb20d1ce1f6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 641ad2ec79f5248734a44d7ead99431a9ebf688772dc3a0e7b7e2ba384af9801da4759dc533e8bebe7303445ec438360735fefd91aeaf011b1e6408d65388300
|
7
|
+
data.tar.gz: '0977c07090e1ced8802e9acc874db2e58a68987891375cfa5887154e67bf73ea298566a5254505b8bc6687c4031a0a1ac49d83d69b6b396b51b9eedb39f6cf7d'
|
@@ -0,0 +1,49 @@
|
|
1
|
+
name: "mensa"
|
2
|
+
|
3
|
+
services:
|
4
|
+
rails-app:
|
5
|
+
cpu_count: 2
|
6
|
+
build:
|
7
|
+
context: ..
|
8
|
+
dockerfile: .devcontainer/Dockerfile
|
9
|
+
|
10
|
+
volumes:
|
11
|
+
- ../..:/workspaces:cached
|
12
|
+
# Overrides default command so things don't shut down after the process ends.
|
13
|
+
command: sleep infinity
|
14
|
+
|
15
|
+
# Uncomment the next line to use a non-root user for all processes.
|
16
|
+
# user: vscode
|
17
|
+
|
18
|
+
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
|
19
|
+
# (Adding the "ports" property to this file will not forward from a Codespace.)
|
20
|
+
depends_on:
|
21
|
+
- selenium
|
22
|
+
- postgres
|
23
|
+
- redis
|
24
|
+
|
25
|
+
environment:
|
26
|
+
- DATABASE_URL=postgres://postgres:postgres@postgres:5432
|
27
|
+
- RUBY_YJIT_ENABLE=1
|
28
|
+
|
29
|
+
selenium:
|
30
|
+
image: selenium/standalone-chromium
|
31
|
+
restart: unless-stopped
|
32
|
+
|
33
|
+
redis:
|
34
|
+
image: redis:6.2
|
35
|
+
restart: unless-stopped
|
36
|
+
|
37
|
+
postgres:
|
38
|
+
image: postgres:17.0
|
39
|
+
restart: unless-stopped
|
40
|
+
networks:
|
41
|
+
- default
|
42
|
+
volumes:
|
43
|
+
- postgres-data:/var/lib/postgresql/data
|
44
|
+
environment:
|
45
|
+
POSTGRES_USER: postgres
|
46
|
+
POSTGRES_PASSWORD: postgres
|
47
|
+
|
48
|
+
volumes:
|
49
|
+
postgres-data:
|
@@ -0,0 +1,36 @@
|
|
1
|
+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
|
2
|
+
// README at: https://github.com/devcontainers/templates/tree/main/src/ruby
|
3
|
+
{
|
4
|
+
"name": "mensa",
|
5
|
+
"dockerComposeFile": "compose.yaml",
|
6
|
+
"service": "rails-app",
|
7
|
+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
|
8
|
+
// Features to add to the dev container. More info: https://containers.dev/features.
|
9
|
+
"features": {
|
10
|
+
"ghcr.io/devcontainers/features/github-cli:1": {},
|
11
|
+
"ghcr.io/rails/devcontainer/features/activestorage": {},
|
12
|
+
"ghcr.io/rails/devcontainer/features/postgres-client": {
|
13
|
+
"version": "17"
|
14
|
+
},
|
15
|
+
"ghcr.io/devcontainers/features/node:1": {},
|
16
|
+
"ghcr.io/duduribeiro/devcontainer-features/tmux:1": {},
|
17
|
+
"ghcr.io/devcontainers-extra/features/mkcert:1": {}
|
18
|
+
},
|
19
|
+
"containerEnv": {
|
20
|
+
"CAPYBARA_SERVER_PORT": "45678",
|
21
|
+
"SELENIUM_HOST": "selenium",
|
22
|
+
"DB_HOST": "postgres"
|
23
|
+
},
|
24
|
+
"forwardPorts": [
|
25
|
+
3000,
|
26
|
+
5432
|
27
|
+
],
|
28
|
+
"customizations": {
|
29
|
+
"vscode": {
|
30
|
+
"extensions": [
|
31
|
+
"Shopify.ruby-lsp"
|
32
|
+
]
|
33
|
+
}
|
34
|
+
},
|
35
|
+
"postCreateCommand": "bin/setup"
|
36
|
+
}
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -13,7 +13,7 @@ GIT
|
|
13
13
|
PATH
|
14
14
|
remote: .
|
15
15
|
specs:
|
16
|
-
mensa (0.1.
|
16
|
+
mensa (0.1.12)
|
17
17
|
caxlsx_rails (~> 0)
|
18
18
|
importmap-rails
|
19
19
|
pagy (>= 6)
|
@@ -119,12 +119,12 @@ GEM
|
|
119
119
|
rack-test (>= 0.6.3)
|
120
120
|
regexp_parser (>= 1.5, < 3.0)
|
121
121
|
xpath (~> 3.2)
|
122
|
-
caxlsx (
|
122
|
+
caxlsx (4.2.0)
|
123
123
|
htmlentities (~> 4.3, >= 4.3.4)
|
124
124
|
marcel (~> 1.0)
|
125
125
|
nokogiri (~> 1.10, >= 1.10.4)
|
126
126
|
rubyzip (>= 1.3.0, < 3)
|
127
|
-
caxlsx_rails (0.6.
|
127
|
+
caxlsx_rails (0.6.4)
|
128
128
|
actionpack (>= 3.1)
|
129
129
|
caxlsx (>= 3.0)
|
130
130
|
coderay (1.1.3)
|
@@ -141,7 +141,7 @@ GEM
|
|
141
141
|
htmlentities (4.3.4)
|
142
142
|
i18n (1.14.1)
|
143
143
|
concurrent-ruby (~> 1.0)
|
144
|
-
importmap-rails (2.0
|
144
|
+
importmap-rails (2.1.0)
|
145
145
|
actionpack (>= 6.0.0)
|
146
146
|
activesupport (>= 6.0.0)
|
147
147
|
railties (>= 6.0.0)
|
@@ -161,6 +161,7 @@ GEM
|
|
161
161
|
matrix (0.4.2)
|
162
162
|
method_source (1.0.0)
|
163
163
|
mini_mime (1.1.5)
|
164
|
+
mini_portile2 (2.8.8)
|
164
165
|
minitest (5.21.1)
|
165
166
|
mutex_m (0.2.0)
|
166
167
|
net-imap (0.4.9.1)
|
@@ -173,11 +174,10 @@ GEM
|
|
173
174
|
net-smtp (0.4.0.1)
|
174
175
|
net-protocol
|
175
176
|
nio4r (2.7.0)
|
176
|
-
nokogiri (1.16.0
|
177
|
+
nokogiri (1.16.0)
|
178
|
+
mini_portile2 (~> 2.8.2)
|
177
179
|
racc (~> 1.4)
|
178
|
-
|
179
|
-
racc (~> 1.4)
|
180
|
-
pagy (7.0.4)
|
180
|
+
pagy (9.3.3)
|
181
181
|
pg (1.5.4)
|
182
182
|
pry (0.14.2)
|
183
183
|
coderay (~> 1.1)
|
@@ -249,22 +249,23 @@ GEM
|
|
249
249
|
actionpack (>= 5.2)
|
250
250
|
activesupport (>= 5.2)
|
251
251
|
sprockets (>= 3.0.0)
|
252
|
-
stimulus-rails (1.3.
|
252
|
+
stimulus-rails (1.3.4)
|
253
253
|
railties (>= 6.0.0)
|
254
254
|
stringio (3.1.0)
|
255
|
-
tailwindcss-rails (
|
256
|
-
railties (>=
|
257
|
-
|
258
|
-
|
255
|
+
tailwindcss-rails (4.0.0)
|
256
|
+
railties (>= 7.0.0)
|
257
|
+
tailwindcss-ruby (~> 4.0)
|
258
|
+
tailwindcss-ruby (4.0.4-aarch64-linux-gnu)
|
259
|
+
tailwindcss-ruby (4.0.4-arm64-darwin)
|
260
|
+
tailwindcss-ruby (4.0.4-x86_64-linux-gnu)
|
259
261
|
temple (0.10.3)
|
260
|
-
textacular (5.
|
261
|
-
activerecord (>= 5.0
|
262
|
+
textacular (5.7.0)
|
263
|
+
activerecord (>= 5.0)
|
262
264
|
thor (1.3.0)
|
263
265
|
tilt (2.3.0)
|
264
266
|
timeout (0.4.1)
|
265
|
-
turbo-rails (2.0.
|
267
|
+
turbo-rails (2.0.11)
|
266
268
|
actionpack (>= 6.0.0)
|
267
|
-
activejob (>= 6.0.0)
|
268
269
|
railties (>= 6.0.0)
|
269
270
|
tzinfo (2.0.6)
|
270
271
|
concurrent-ruby (~> 1.0)
|
@@ -282,6 +283,7 @@ GEM
|
|
282
283
|
zeitwerk (2.6.12)
|
283
284
|
|
284
285
|
PLATFORMS
|
286
|
+
aarch64-linux
|
285
287
|
arm64-darwin-22
|
286
288
|
x86_64-linux
|
287
289
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "securerandom"
|
2
|
+
|
1
3
|
module Mensa
|
2
4
|
class ExportJob < ApplicationJob
|
3
5
|
queue_as :default
|
@@ -7,9 +9,11 @@ module Mensa
|
|
7
9
|
# export_complete: lambda do |user_id, table_name, attachment|
|
8
10
|
# end
|
9
11
|
|
10
|
-
def perform(
|
12
|
+
def perform(user, table_name)
|
11
13
|
table = Mensa.for_name(table_name)
|
12
|
-
|
14
|
+
return unless table.exportable?
|
15
|
+
|
16
|
+
context = Mensa.config.callbacks[:export_started].call(user, table_name)
|
13
17
|
|
14
18
|
styles = []
|
15
19
|
default_style = { b: true, bg_color: '3B82F6', fg_color: 'FFFFFF', border: { style: :thin, color: '000000' }, sz: 8,
|
@@ -82,10 +86,26 @@ module Mensa
|
|
82
86
|
sheet.auto_filter = Axlsx.cell_range([first_cell, last_cell], false)
|
83
87
|
end
|
84
88
|
|
85
|
-
|
86
|
-
|
89
|
+
base_filename = "#{table_name}_export_#{Time.current.strftime("%Y-%m-%d-%H:%M:%S")}"
|
90
|
+
enc = nil
|
91
|
+
password = nil
|
92
|
+
if table.export_with_password?
|
93
|
+
password = SecureRandom.hex(6)
|
94
|
+
enc = Zip::TraditionalEncrypter.new(password)
|
95
|
+
end
|
96
|
+
stringio = Zip::OutputStream.write_buffer(encrypter: enc) do |zio|
|
97
|
+
zio.put_next_entry("#{base_filename}.xlsx")
|
98
|
+
zio.write p.to_stream.read
|
99
|
+
end
|
100
|
+
stringio.rewind
|
101
|
+
|
102
|
+
attachment = { io: stringio,
|
103
|
+
content_type: 'application/zip', filename: "#{base_filename}.zip" }
|
104
|
+
if password.present?
|
105
|
+
attachment[:password] = password
|
106
|
+
end
|
87
107
|
|
88
|
-
Mensa.config.callbacks[:export_completed].call(
|
108
|
+
Mensa.config.callbacks[:export_completed].call(user, table_name, context, attachment)
|
89
109
|
end
|
90
110
|
end
|
91
111
|
end
|
data/app/tables/mensa/base.rb
CHANGED
@@ -17,6 +17,8 @@ module Mensa
|
|
17
17
|
config_reader :view_condensed_toggle?
|
18
18
|
config_reader :view_columns_sorting?
|
19
19
|
config_reader :show_header?
|
20
|
+
config_reader :exportable?
|
21
|
+
config_reader :export_with_password?
|
20
22
|
|
21
23
|
def initialize(config = {})
|
22
24
|
@params = config.to_h.deep_symbolize_keys
|
@@ -52,6 +52,9 @@ module Mensa::Config
|
|
52
52
|
option :column, dsl_hash: Mensa::Config::ColumnDsl
|
53
53
|
option :link
|
54
54
|
|
55
|
+
option :exportable, default: true
|
56
|
+
option :export_with_password, default: false
|
57
|
+
|
55
58
|
# Default sort order {column: direction, column: direction}
|
56
59
|
option :order, default: {}
|
57
60
|
|
data/bin/setup
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
#!/usr/bin/env ruby
|
4
|
+
require "fileutils"
|
5
|
+
|
6
|
+
# path to your application root.
|
7
|
+
GEM_ROOT = File.expand_path("..", __dir__)
|
8
|
+
APP_ROOT = File.expand_path("../test/dummy", __dir__)
|
9
|
+
|
10
|
+
def system!(*args)
|
11
|
+
system(*args, exception: true)
|
12
|
+
end
|
13
|
+
|
14
|
+
def copy_sample(file)
|
15
|
+
return if File.exist?(file)
|
16
|
+
|
17
|
+
copy_sample!(file)
|
18
|
+
end
|
19
|
+
|
20
|
+
def copy_sample!(file)
|
21
|
+
FileUtils.cp "#{file}.sample", file
|
22
|
+
end
|
23
|
+
|
24
|
+
FileUtils.chdir GEM_ROOT do
|
25
|
+
# This script is a way to set up or update your development environment automatically.
|
26
|
+
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
|
27
|
+
# Add necessary setup steps to this file.
|
28
|
+
|
29
|
+
puts "== Installing dependencies =="
|
30
|
+
system! "gem install bundler --conservative"
|
31
|
+
system("bundle config set --local path 'vendor/bundle'")
|
32
|
+
system("bundle check") || system!("bundle install")
|
33
|
+
|
34
|
+
system!("yarn install")
|
35
|
+
end
|
36
|
+
|
37
|
+
FileUtils.chdir APP_ROOT do
|
38
|
+
puts "\n== Copying sample files =="
|
39
|
+
copy_sample "config/database.yml"
|
40
|
+
copy_sample! "config/tailwind.config.js"
|
41
|
+
copy_sample! "app/assets/stylesheets/application.tailwind.css"
|
42
|
+
copy_sample "config/puma.rb"
|
43
|
+
unless File.exist?(".ssl/localhost.crt")
|
44
|
+
FileUtils.mkdir_p ".ssl"
|
45
|
+
FileUtils.chdir "#{APP_ROOT}/.ssl" do
|
46
|
+
system!("mkcert localhost")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
puts "\n== Caching mode =="
|
51
|
+
FileUtils.touch "tmp/caching-dev.txt"
|
52
|
+
|
53
|
+
puts "\n== Preparing database =="
|
54
|
+
system! "bin/rails db:prepare"
|
55
|
+
|
56
|
+
puts "\n== Removing old logs and tempfiles =="
|
57
|
+
system! "bin/rails log:clear tmp:clear"
|
58
|
+
|
59
|
+
puts "\n== Done, welcome to Soverin Core =="
|
60
|
+
puts "To start the application, run 'cd test/dummy; bin/rails s'"
|
61
|
+
end
|
data/lib/mensa/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mensa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom de Grunt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-02-
|
11
|
+
date: 2025-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: caxlsx_rails
|
@@ -144,6 +144,9 @@ executables: []
|
|
144
144
|
extensions: []
|
145
145
|
extra_rdoc_files: []
|
146
146
|
files:
|
147
|
+
- ".devcontainer/Dockerfile"
|
148
|
+
- ".devcontainer/compose.yaml"
|
149
|
+
- ".devcontainer/devcontainer.json"
|
147
150
|
- ".github/workflows/gem-push.yml"
|
148
151
|
- ".gitignore"
|
149
152
|
- Gemfile
|
@@ -231,6 +234,7 @@ files:
|
|
231
234
|
- app/views/mensa/tables/show.turbo_stream.slim
|
232
235
|
- bin/importmap
|
233
236
|
- bin/rails
|
237
|
+
- bin/setup
|
234
238
|
- config/importmap.rb
|
235
239
|
- config/locales/en.yml
|
236
240
|
- config/locales/nl.yml
|