rails-realtime-erd 0.1.0
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 +7 -0
- data/MIT-LICENSE +21 -0
- data/README.md +76 -0
- data/Rakefile +9 -0
- data/app/assets/stylesheets/rails_realtime_erd/erd.css +214 -0
- data/app/controllers/rails_realtime_erd/application_controller.rb +5 -0
- data/app/controllers/rails_realtime_erd/assets_controller.rb +23 -0
- data/app/controllers/rails_realtime_erd/erd_controller.rb +18 -0
- data/app/helpers/rails_realtime_erd/erd_helper.rb +25 -0
- data/app/javascript/rails_realtime_erd/application.js +640 -0
- data/app/javascript/rails_realtime_erd/vendor/mermaid.js +2029 -0
- data/app/javascript/rails_realtime_erd/vendor/stimulus.js +2588 -0
- data/app/views/layouts/rails_realtime_erd/application.html.erb +18 -0
- data/app/views/rails_realtime_erd/erd/_main.html.erb +40 -0
- data/app/views/rails_realtime_erd/erd/_sidebar.html.erb +106 -0
- data/app/views/rails_realtime_erd/erd/show.html.erb +44 -0
- data/config/routes.rb +4 -0
- data/lib/rails-realtime-erd/builder.rb +167 -0
- data/lib/rails-realtime-erd/configuration.rb +11 -0
- data/lib/rails-realtime-erd/engine.rb +18 -0
- data/lib/rails-realtime-erd/version.rb +3 -0
- data/lib/rails-realtime-erd.rb +20 -0
- metadata +138 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: efe3b4e2ea8f20ac758e39b19f90494e08dc462d6582e8581555eebf69f2baa6
|
|
4
|
+
data.tar.gz: 053f0a83cd28180b2a95895d27e69e13d73299495effbaadc3dc5a97f6806521
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 17ef9d429795bc8100e029edadbb3e78f548cdd8d687f910b019eb1e0e894a0a550fcc5e60d8e848129895dcd03bde37b5e3950bbf08e414a045128bfdbb71f1
|
|
7
|
+
data.tar.gz: 71e1b2f091c753a558d1daf47f837fb95328b516f52d36491c368d8468a70657036883f8aeab84defccc855996f487fdbd80fa4781948ac72f7e8009ce7dfd22
|
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jackson Pires
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Rails Realtime ERD
|
|
2
|
+
|
|
3
|
+
Live Mermaid ERD viewer for any Rails app, mounted as a real-time route, powered by Hotwire.
|
|
4
|
+
|
|
5
|
+
Inspired by [`rails-mermaid_erd`](https://github.com/koedame/rails-mermaid_erd) — but instead of generating a static HTML file you check into your repo, this gem mounts `GET /rails/erd` in your Rails app and renders the ERD **on every request** by introspecting your current `ActiveRecord` models and live schema. Run a migration, refresh the page, see the new diagram.
|
|
6
|
+
|
|
7
|
+
The frontend is plain Hotwire (Stimulus) — **no Vue**, no build step, no asset pipeline required in the host app.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- Mounts `/rails/erd` automatically in `development` and `test` environments
|
|
12
|
+
- On-the-fly introspection: no pre-generated HTML to keep in sync with `schema.rb`
|
|
13
|
+
- Mermaid ERD rendered client-side, with filters / options / zoom / pan
|
|
14
|
+
- Copy Mermaid code, Copy Markdown, Copy shareable URL (state in `location.hash`)
|
|
15
|
+
- Download SVG / PNG of the rendered diagram
|
|
16
|
+
- Sidebar filter to scope the diagram to a subset of models
|
|
17
|
+
- Works with any host asset pipeline (Sprockets, Propshaft, importmap, or none) — all CSS/JS is inlined by the engine layout
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
Add to your `Gemfile`:
|
|
22
|
+
|
|
23
|
+
```ruby
|
|
24
|
+
gem "rails-realtime-erd", group: :development
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Then:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
$ bundle install
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
That's it. Boot your Rails dev server and visit:
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
http://localhost:3000/rails/erd
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Configuration
|
|
40
|
+
|
|
41
|
+
Optional. Create `config/initializers/rails_realtime_erd.rb`:
|
|
42
|
+
|
|
43
|
+
```ruby
|
|
44
|
+
RailsRealtimeErd.configure do |c|
|
|
45
|
+
c.mount_path = "/rails/erd" # default
|
|
46
|
+
c.auto_mount = true # default
|
|
47
|
+
c.enabled_environments = %w[development test] # default
|
|
48
|
+
end
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
If you set `auto_mount = false`, mount the engine yourself in `config/routes.rb`:
|
|
52
|
+
|
|
53
|
+
```ruby
|
|
54
|
+
mount RailsRealtimeErd::Engine => "/rails/erd"
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Why use it instead of `rails-mermaid_erd`?
|
|
58
|
+
|
|
59
|
+
- No rake step. No `mermaid_erd/index.html` to regenerate, share, or `.gitignore`.
|
|
60
|
+
- The diagram is always in sync with your live schema and models.
|
|
61
|
+
- No JS framework dependency in your host app — only standard Hotwire.
|
|
62
|
+
|
|
63
|
+
If you want a shareable static file (for documentation, CI artifacts, public demos), use [`rails-mermaid_erd`](https://github.com/koedame/rails-mermaid_erd). The two gems target different use cases.
|
|
64
|
+
|
|
65
|
+
## Development
|
|
66
|
+
|
|
67
|
+
Specs run against a SQLite-backed dummy Rails app in `spec/dummy`. SQLite does not preserve column/table comments, so the Builder spec asserts `nil`/`""` for those fields even though the schema declares comments — the Builder forwards whatever the connection returns, so on Postgres/MySQL those values round-trip correctly.
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
$ bundle install
|
|
71
|
+
$ bundle exec rspec
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
76
|
+
MIT. See `MIT-LICENSE`.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/* =========================================================================
|
|
2
|
+
* Rails Realtime ERD — self-contained stylesheet.
|
|
3
|
+
*
|
|
4
|
+
* Implements only the utility classes referenced by this gem's ERB views,
|
|
5
|
+
* plus a small reset. Intentionally avoids a CDN so the engine renders
|
|
6
|
+
* correctly inside hosts with strict Content Security Policy.
|
|
7
|
+
* ========================================================================= */
|
|
8
|
+
|
|
9
|
+
/* ------- Reset / Preflight ------- */
|
|
10
|
+
*, *::before, *::after { box-sizing: border-box; border: 0 solid #e5e7eb; }
|
|
11
|
+
html, body { margin: 0; padding: 0; }
|
|
12
|
+
body {
|
|
13
|
+
font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
14
|
+
font-size: 14px;
|
|
15
|
+
line-height: 1.4;
|
|
16
|
+
color: #111827;
|
|
17
|
+
background: #ffffff;
|
|
18
|
+
}
|
|
19
|
+
h1, h2, h3, h4, p { margin: 0; font-size: inherit; font-weight: inherit; }
|
|
20
|
+
button {
|
|
21
|
+
background: transparent;
|
|
22
|
+
cursor: pointer;
|
|
23
|
+
font-family: inherit;
|
|
24
|
+
font-size: 100%;
|
|
25
|
+
padding: 0;
|
|
26
|
+
border: 0;
|
|
27
|
+
color: inherit;
|
|
28
|
+
-webkit-appearance: button;
|
|
29
|
+
}
|
|
30
|
+
input, textarea, select {
|
|
31
|
+
font-family: inherit;
|
|
32
|
+
font-size: 100%;
|
|
33
|
+
line-height: inherit;
|
|
34
|
+
color: inherit;
|
|
35
|
+
margin: 0;
|
|
36
|
+
padding: 0;
|
|
37
|
+
}
|
|
38
|
+
textarea { resize: vertical; }
|
|
39
|
+
input[type="search"] { -webkit-appearance: textfield; outline-offset: -2px; }
|
|
40
|
+
input[type="checkbox"] {
|
|
41
|
+
appearance: auto;
|
|
42
|
+
width: 1rem;
|
|
43
|
+
height: 1rem;
|
|
44
|
+
vertical-align: middle;
|
|
45
|
+
accent-color: #dc2626;
|
|
46
|
+
}
|
|
47
|
+
svg { display: inline-block; vertical-align: middle; flex-shrink: 0; }
|
|
48
|
+
a { color: inherit; text-decoration: inherit; }
|
|
49
|
+
|
|
50
|
+
/* ------- Display / Layout ------- */
|
|
51
|
+
.flex { display: flex; }
|
|
52
|
+
.inline-flex { display: inline-flex; }
|
|
53
|
+
.block { display: block; }
|
|
54
|
+
.flex-1 { flex: 1 1 0%; }
|
|
55
|
+
.flex-none { flex: none; }
|
|
56
|
+
.flex-col { flex-direction: column; }
|
|
57
|
+
.items-center { align-items: center; }
|
|
58
|
+
.items-start { align-items: flex-start; }
|
|
59
|
+
.justify-between { justify-content: space-between; }
|
|
60
|
+
.justify-center { justify-content: center; }
|
|
61
|
+
.min-w-0 { min-width: 0; }
|
|
62
|
+
|
|
63
|
+
/* ------- Position ------- */
|
|
64
|
+
.relative { position: relative; }
|
|
65
|
+
.absolute { position: absolute; }
|
|
66
|
+
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
|
|
67
|
+
.bottom-0 { bottom: 0; }
|
|
68
|
+
.right-0 { right: 0; }
|
|
69
|
+
.left-1\/2 { left: 50%; }
|
|
70
|
+
.-translate-x-1\/2 { transform: translateX(-50%); }
|
|
71
|
+
.pointer-events-none { pointer-events: none; }
|
|
72
|
+
|
|
73
|
+
/* ------- Spacing — margin ------- */
|
|
74
|
+
.mx-auto { margin-left: auto; margin-right: auto; }
|
|
75
|
+
.mr-1 { margin-right: 0.25rem; }
|
|
76
|
+
.mr-2 { margin-right: 0.5rem; }
|
|
77
|
+
.ml-1 { margin-left: 0.25rem; }
|
|
78
|
+
.mb-1 { margin-bottom: 0.25rem; }
|
|
79
|
+
.my-1 { margin-top: 0.25rem; margin-bottom: 0.25rem; }
|
|
80
|
+
|
|
81
|
+
/* ------- Spacing — padding ------- */
|
|
82
|
+
.p-1 { padding: 0.25rem; }
|
|
83
|
+
.p-2 { padding: 0.5rem; }
|
|
84
|
+
.p-4 { padding: 1rem; }
|
|
85
|
+
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
|
|
86
|
+
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
|
|
87
|
+
.px-4 { padding-left: 1rem; padding-right: 1rem; }
|
|
88
|
+
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
|
|
89
|
+
.py-1\.5 { padding-top: 0.375rem; padding-bottom: 0.375rem; }
|
|
90
|
+
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
|
|
91
|
+
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
|
|
92
|
+
|
|
93
|
+
/* ------- Space-between children ------- */
|
|
94
|
+
.space-x-1 > * + * { margin-left: 0.25rem; }
|
|
95
|
+
.space-x-2 > * + * { margin-left: 0.5rem; }
|
|
96
|
+
.space-x-4 > * + * { margin-left: 1rem; }
|
|
97
|
+
.space-x-6 > * + * { margin-left: 1.5rem; }
|
|
98
|
+
.space-y-1 > * + * { margin-top: 0.25rem; }
|
|
99
|
+
.space-y-2 > * + * { margin-top: 0.5rem; }
|
|
100
|
+
.space-y-8 > * + * { margin-top: 2rem; }
|
|
101
|
+
|
|
102
|
+
/* ------- Sizing ------- */
|
|
103
|
+
.w-full { width: 100%; }
|
|
104
|
+
.w-\[250px\] { width: 250px; }
|
|
105
|
+
.w-3 { width: 0.75rem; }
|
|
106
|
+
.w-4 { width: 1rem; }
|
|
107
|
+
.w-6 { width: 1.5rem; }
|
|
108
|
+
.h-3 { height: 0.75rem; }
|
|
109
|
+
.h-4 { height: 1rem; }
|
|
110
|
+
.h-6 { height: 1.5rem; }
|
|
111
|
+
.h-full { height: 100%; }
|
|
112
|
+
.min-h-\[calc\(100vh-56px-32px\)\] { min-height: calc(100vh - 56px - 32px); }
|
|
113
|
+
.min-h-\[calc\(100vh-56px-32px-56px\)\] { min-height: calc(100vh - 56px - 32px - 56px); }
|
|
114
|
+
|
|
115
|
+
/* ------- Borders ------- */
|
|
116
|
+
.border { border-width: 1px; }
|
|
117
|
+
.border-0 { border-width: 0; }
|
|
118
|
+
.border-r { border-right-width: 1px; }
|
|
119
|
+
.border-gray-300 { border-color: #d1d5db; }
|
|
120
|
+
.rounded { border-radius: 0.25rem; }
|
|
121
|
+
|
|
122
|
+
/* ------- Background colors ------- */
|
|
123
|
+
.bg-red-600 { background-color: #dc2626; }
|
|
124
|
+
.bg-gray-100 { background-color: #f3f4f6; }
|
|
125
|
+
.bg-gray-300 { background-color: #d1d5db; }
|
|
126
|
+
.bg-gray-400 { background-color: #9ca3af; }
|
|
127
|
+
.bg-gray-800 { background-color: #1f2937; }
|
|
128
|
+
.bg-gray-900 { background-color: #111827; }
|
|
129
|
+
.bg-white { background-color: #ffffff; }
|
|
130
|
+
|
|
131
|
+
/* ------- Text colors ------- */
|
|
132
|
+
.text-white { color: #ffffff; }
|
|
133
|
+
.text-white\/60 { color: rgba(255, 255, 255, 0.6); }
|
|
134
|
+
.text-white\/80 { color: rgba(255, 255, 255, 0.8); }
|
|
135
|
+
.text-gray-300 { color: #d1d5db; }
|
|
136
|
+
.text-gray-600 { color: #4b5563; }
|
|
137
|
+
.text-gray-700 { color: #374151; }
|
|
138
|
+
.text-gray-900 { color: #111827; }
|
|
139
|
+
.text-red-200 { color: #fecaca; }
|
|
140
|
+
.text-red-600 { color: #dc2626; }
|
|
141
|
+
.text-red-900 { color: #7f1d1d; }
|
|
142
|
+
.text-orange-900 { color: #7c2d12; }
|
|
143
|
+
|
|
144
|
+
/* ------- Typography ------- */
|
|
145
|
+
.text-xs { font-size: 0.75rem; line-height: 1rem; }
|
|
146
|
+
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
|
|
147
|
+
.text-\[10px\] { font-size: 10px; line-height: 1.2; }
|
|
148
|
+
.font-bold { font-weight: 700; }
|
|
149
|
+
.font-medium { font-weight: 500; }
|
|
150
|
+
.font-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }
|
|
151
|
+
.text-center { text-align: center; }
|
|
152
|
+
|
|
153
|
+
/* ------- Hover ------- */
|
|
154
|
+
.hover\:bg-white:hover { background-color: #ffffff; }
|
|
155
|
+
.hover\:bg-gray-100:hover { background-color: #f3f4f6; }
|
|
156
|
+
.hover\:text-gray-400:hover { color: #9ca3af; }
|
|
157
|
+
.hover\:text-red-200:hover { color: #fecaca; }
|
|
158
|
+
.hover\:text-red-900:hover { color: #7f1d1d; }
|
|
159
|
+
|
|
160
|
+
/* ------- Cursors / state ------- */
|
|
161
|
+
.cursor-pointer { cursor: pointer; }
|
|
162
|
+
.cursor-not-allowed { cursor: not-allowed; }
|
|
163
|
+
.cursor-grab { cursor: grab; }
|
|
164
|
+
.cursor-grabbing { cursor: grabbing; }
|
|
165
|
+
.opacity-60 { opacity: 0.6; }
|
|
166
|
+
|
|
167
|
+
/* ------- Focus rings (simplified) ------- */
|
|
168
|
+
.focus\:ring:focus,
|
|
169
|
+
.focus\:ring-2:focus { outline: 2px solid #dc2626; outline-offset: 2px; }
|
|
170
|
+
.focus\:ring-red-600:focus { outline-color: #dc2626; }
|
|
171
|
+
.focus\:ring-white:focus { outline-color: #ffffff; }
|
|
172
|
+
.focus\:ring-0:focus { outline: 0; }
|
|
173
|
+
.focus\:ring-offset-1:focus { outline-offset: 1px; }
|
|
174
|
+
.focus\:ring-offset-2:focus { outline-offset: 2px; }
|
|
175
|
+
.focus\:border-red-600:focus { border-color: #dc2626; }
|
|
176
|
+
|
|
177
|
+
/* ------- Misc ------- */
|
|
178
|
+
.overflow-hidden { overflow: hidden; }
|
|
179
|
+
|
|
180
|
+
/* ------- Mermaid override ------- */
|
|
181
|
+
#mermaid-erd { fill: #9c9c9c !important; }
|
|
182
|
+
|
|
183
|
+
/* ------- Engine-specific ------- */
|
|
184
|
+
[data-rre-hidden] { display: none !important; }
|
|
185
|
+
|
|
186
|
+
[data-zoom-pan-target="area"] {
|
|
187
|
+
transform-origin: top left;
|
|
188
|
+
will-change: transform;
|
|
189
|
+
position: absolute;
|
|
190
|
+
inset: 0;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
[data-zoom-pan-dragging="true"],
|
|
194
|
+
[data-zoom-pan-dragging="true"] * {
|
|
195
|
+
user-select: none;
|
|
196
|
+
cursor: grabbing !important;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
[data-zoom-pan-space-pressed="true"] [data-zoom-pan-target="canvas"] {
|
|
200
|
+
cursor: grab;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
#rre-preview {
|
|
204
|
+
width: 100%;
|
|
205
|
+
height: 100%;
|
|
206
|
+
display: flex;
|
|
207
|
+
align-items: center;
|
|
208
|
+
justify-content: center;
|
|
209
|
+
padding: 1rem;
|
|
210
|
+
}
|
|
211
|
+
#rre-preview svg {
|
|
212
|
+
max-width: 100%;
|
|
213
|
+
height: auto;
|
|
214
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module RailsRealtimeErd
|
|
2
|
+
class AssetsController < ApplicationController
|
|
3
|
+
ASSETS = {
|
|
4
|
+
"stimulus.js" => "app/javascript/rails_realtime_erd/vendor/stimulus.js",
|
|
5
|
+
"mermaid.js" => "app/javascript/rails_realtime_erd/vendor/mermaid.js",
|
|
6
|
+
"application.js" => "app/javascript/rails_realtime_erd/application.js"
|
|
7
|
+
}.freeze
|
|
8
|
+
|
|
9
|
+
skip_forgery_protection if respond_to?(:skip_forgery_protection)
|
|
10
|
+
|
|
11
|
+
def show
|
|
12
|
+
relative_path = ASSETS[params[:name]]
|
|
13
|
+
return head :not_found unless relative_path
|
|
14
|
+
|
|
15
|
+
path = Engine.root.join(relative_path)
|
|
16
|
+
return head :not_found unless File.exist?(path)
|
|
17
|
+
|
|
18
|
+
response.headers["Cache-Control"] = "private, max-age=300"
|
|
19
|
+
response.headers["X-Content-Type-Options"] = "nosniff"
|
|
20
|
+
send_file path, type: "text/javascript; charset=utf-8", disposition: "inline"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module RailsRealtimeErd
|
|
2
|
+
class ErdController < ApplicationController
|
|
3
|
+
layout "rails_realtime_erd/application"
|
|
4
|
+
|
|
5
|
+
def show
|
|
6
|
+
::Rails.application.eager_load!
|
|
7
|
+
|
|
8
|
+
if ::Rails.env.development?
|
|
9
|
+
connection = ::ActiveRecord::Base.connection
|
|
10
|
+
connection.schema_cache.clear! if connection.respond_to?(:schema_cache)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
@schema = Builder.model_data
|
|
14
|
+
@app_name = ::Rails.application.class.try(:module_parent_name) || ::Rails.application.class.try(:parent_name) || "Application"
|
|
15
|
+
@version = RailsRealtimeErd::VERSION
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module RailsRealtimeErd
|
|
2
|
+
module ErdHelper
|
|
3
|
+
def inline_asset(relative_path)
|
|
4
|
+
path = Engine.root.join(relative_path)
|
|
5
|
+
File.read(path)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def inline_stylesheet(relative_path)
|
|
9
|
+
content_tag(:style, inline_asset(relative_path).html_safe)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def inline_javascript(relative_path, type: "module")
|
|
13
|
+
content_tag(:script, inline_asset(relative_path).html_safe, type: type)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def schema_data_tag(schema)
|
|
17
|
+
content_tag(
|
|
18
|
+
:script,
|
|
19
|
+
schema.to_json.html_safe,
|
|
20
|
+
type: "application/json",
|
|
21
|
+
id: "rre-schema-data"
|
|
22
|
+
)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|