rest_framework 0.8.16 → 0.8.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b8523aadeaa24412d0a2ea3d5a0f940864f69f13b4f97859c7b7a072b035a30
4
- data.tar.gz: 3c7a734e85ef542221738030d711b912114712c7e0f0e28115bacfbf43fee032
3
+ metadata.gz: 9b8d9a14de396b6832c13e0f3e1f2627decb432af03c6a2cbb59ce27328cdd7c
4
+ data.tar.gz: 6d1e675245643d96e2b35aaaadd9118eb441025a1bb7acc303db63d6761dc79c
5
5
  SHA512:
6
- metadata.gz: 986584c39f0388eec578bf53f71989f62df6c5eea18001d90023790b2c3fa3781f3b21416215aa58f153265eaf6fdce964ca2dbaf035dd1247b052963ed6d82c
7
- data.tar.gz: 2dc9b1a29e1c7fdd1a6e010d9198a9f761b6eaed1ca37cbaa60dcad8a76ccd8972a6a9e2a5e8b8496b24794d5fe59a0a2ad35ff25ba2f1cd69c463fce572744f
6
+ metadata.gz: a0ef4d98bec92656d0541f34aebd652d30b90af0bdde8ea91e0b1809b82ee381bdbfef0ea04235b2c24005ec43646ad59b7fce01d3eda1312e48e1a976bd8092
7
+ data.tar.gz: d64fdd4c884a6173c9df9f87074748290b1093917a053acfa70b5b6579bbe07f7479adf15b226178fb784181edfe28ac3cbce461c13b64372e988d5abbab5966
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.16
1
+ 0.8.17
@@ -1,174 +1,191 @@
1
1
  <!doctype html>
2
- <html data-bs-theme="dark">
2
+ <html class="rrf-mode">
3
3
  <head>
4
4
  <title><%= @title %></title>
5
- <%= render partial: 'rest_framework/head' %>
5
+ <%= render partial: "rest_framework/head" %>
6
6
  </head>
7
7
 
8
8
  <body>
9
- <div>
10
- <div class="w-100 m-0 p-0" style="height: .3em; background-color: #900;"></div>
11
- <nav class="navbar navbar-dark" style="background-color: #111">
9
+ <header>
10
+ <div class="w-100 m-0 p-0" id="rrfAccentBar"></div>
11
+ <nav class="navbar py-0" data-bs-theme="dark">
12
12
  <div class="container">
13
13
  <span class="navbar-brand p-0">
14
14
  <h1 title="RRF v<%= RESTFramework::VERSION %>" class="text-light font-weight-light m-0 p-0" style="font-size: 1em">
15
- <%= @template_logo_text || 'Rails REST Framework' %>
15
+ <%= @template_logo_text || "Rails REST Framework" %>
16
16
  </h1>
17
17
  </span>
18
+ <div class="dropdown ms-auto" id="rrfModeComponent">
19
+ <button class="btn btn-dark dropdown-toggle rounded-0 bg-black" style="border-color: black" data-bs-toggle="dropdown"></button>
20
+ <div class="rrf-mode dropdown-menu dropdown-menu-end py-0 rounded-0" style="font-size: .8em; min-width: 0">
21
+ <button class="dropdown-item text-end" data-rrf-mode-value="system">
22
+ System<i class="bi bi-circle-half ms-2"></i>
23
+ </button>
24
+ <button class="dropdown-item text-end" data-rrf-mode-value="light">
25
+ Light<i class="bi bi-sun-fill ms-2"></i>
26
+ </button>
27
+ <button class="dropdown-item text-end" data-rrf-mode-value="dark">
28
+ Dark<i class="bi bi-moon-stars-fill ms-2"></i>
29
+ </button>
30
+ </div>
31
+ </div>
18
32
  </div>
19
33
  </nav>
20
- </div>
34
+ </header>
21
35
  <div class="container py-3">
22
- <div class="container">
23
- <div class="row">
24
- <nav>
25
- <ol class="breadcrumb">
26
- <%
27
- breadcrumbs = request.path.split("/").inject([]) { |breadcrumbs, part|
28
- # Ignore blank parts of the path (leading slash or double-slashes).
29
- next breadcrumbs if part.blank?
36
+ <div class="row">
37
+ <nav>
38
+ <ol class="breadcrumb">
39
+ <%
40
+ breadcrumbs = request.path.split("/").inject([]) { |breadcrumbs, part|
41
+ # Ignore blank parts of the path (leading slash or double-slashes).
42
+ next breadcrumbs if part.blank?
30
43
 
31
- last_path = breadcrumbs.last&.first || "/"
32
- breadcrumbs << [
33
- [last_path, part].join(last_path[-1] == "/" ? "" : "/"),
34
- part,
35
- ]
44
+ last_path = breadcrumbs.last&.first || "/"
45
+ breadcrumbs << [
46
+ [last_path, part].join(last_path[-1] == "/" ? "" : "/"),
47
+ part,
48
+ ]
36
49
 
37
- next breadcrumbs
38
- }
39
- %>
40
- <% breadcrumbs.each_with_index do |(path, label), i| %>
41
- <% if i != breadcrumbs.size - 1 %>
42
- <li class="breadcrumb-item"><a href="<%= path %>"><%= label %></a></li>
43
- <% else %>
44
- <li class="breadcrumb-item active"><%= label %></li>
45
- <% end %>
50
+ next breadcrumbs
51
+ }
52
+ %>
53
+ <% breadcrumbs.each_with_index do |(path, label), i| %>
54
+ <% if i != breadcrumbs.size - 1 %>
55
+ <li class="breadcrumb-item"><a href="<%= path %>"><%= label %></a></li>
56
+ <% else %>
57
+ <li class="breadcrumb-item active"><%= label %></li>
46
58
  <% end %>
47
- </ol>
48
- </nav>
59
+ <% end %>
60
+ </ol>
61
+ </nav>
62
+ </div>
63
+ <div class="row">
64
+ <div>
65
+ <h1 class="m-0"><%= (@header_text if defined? @header_text) || @title %></h1>
66
+ <div style="float: right">
67
+ <% if @route_groups.values[0].any? { |r| r[:matches_path] && r[:verb] == "DELETE" } %>
68
+ <button type="button" class="btn btn-danger" onclick="rrfDelete(this)">DELETE</button>
69
+ <% end %>
70
+ <% if @route_groups.values[0].any? { |r| r[:matches_path] && r[:verb] == "OPTIONS" } %>
71
+ <button type="button" class="btn btn-primary" onclick="rrfOptions(this)">OPTIONS</button>
72
+ <% end %>
73
+ <button type="button" class="btn btn-primary" onclick="rrfGet(this)">GET</button>
74
+ </div>
75
+ <% if @description.present? %>
76
+ <br><br><p style="display: inline-block; margin-bottom: 0"><%= @description %></p>
77
+ <% end %>
49
78
  </div>
79
+ </div>
80
+ <hr/>
81
+ <div class="row">
82
+ <div>
83
+ <pre style="white-space: normal">
84
+ <code>
85
+ <strong>
86
+ <%= request.request_method %>
87
+ <% if request.method != request.request_method %>
88
+ (via <%= request.method %>)
89
+ <% end %>
90
+ </strong> <%= request.path %><br>
91
+ </code>
92
+ </pre>
93
+ <pre style="white-space: normal">
94
+ <code>
95
+ <strong>HTTP <%= response.status %> <%= response.message %></strong><br>
96
+ <strong>Content-Type:</strong> <%= response.content_type %>
97
+ </code>
98
+ </pre>
99
+ </div>
100
+ </div>
101
+ <% if @json_payload.present? || @xml_payload.present? %>
50
102
  <div class="row">
51
103
  <div>
52
- <h1><%= (@header_text if defined? @header_text) || @title %></h1>
53
- <div style="float: right">
54
- <% if @route_groups.values[0].any? { |r| r[:matches_path] && r[:verb] == "DELETE" } %>
55
- <button type="button" class="btn btn-danger" onclick="rrfDelete(this)">DELETE</button>
104
+ <ul class="nav nav-tabs">
105
+ <% if @json_payload.present? %>
106
+ <li class="nav-item">
107
+ <a class="nav-link active" href="#tab-json" data-bs-toggle="tab" role="tab">
108
+ .json
109
+ </a>
110
+ </li>
56
111
  <% end %>
57
- <% if @route_groups.values[0].any? { |r| r[:matches_path] && r[:verb] == "OPTIONS" } %>
58
- <button type="button" class="btn btn-primary" onclick="rrfOptions(this)">OPTIONS</button>
112
+ <% if @xml_payload.present? %>
113
+ <li class="nav-item">
114
+ <a class="nav-link" href="#tab-xml" data-bs-toggle="tab" role="tab">
115
+ .xml
116
+ </a>
117
+ </li>
118
+ <% end %>
119
+ </ul>
120
+ </div>
121
+ <div class="tab-content pt-2">
122
+ <div class="tab-pane fade show active" id="tab-json" role="tabpanel">
123
+ <% if @json_payload.present? %>
124
+ <div><pre class="rrf-copy"><code class="auto-hljs language-json"><%=
125
+ JSON.pretty_generate(
126
+ JSON.parse(@json_payload)
127
+ ) unless @json_payload == ''
128
+ %></code></pre></div>
129
+ <% end %>
130
+ </div>
131
+ <div class="tab-pane fade" id="tab-xml" role="tabpanel">
132
+ <% if @xml_payload.present? %>
133
+ <div><pre class="rrf-copy"><code class="auto-hljs language-xml"><%=
134
+ CGI.unescapeHTML(@xml_payload)
135
+ %></code></pre></div>
59
136
  <% end %>
60
- <button type="button" class="btn btn-primary" onclick="rrfGet(this)">GET</button>
61
137
  </div>
62
- <% if @description.present? %>
63
- <br><br><p style="display: inline-block; margin-bottom: 0"><%= @description %></p>
64
- <% end %>
65
138
  </div>
66
139
  </div>
67
- <hr/>
140
+ <% end %>
141
+ <% if @route_groups.present? %>
142
+ <%
143
+ @is_model_controller = controller.class.included_modules.include?(RESTFramework::ModelControllerMixin)
144
+ %>
68
145
  <div class="row">
69
146
  <div>
70
- <pre style="white-space: normal">
71
- <code>
72
- <strong><%= request.method %></strong> <%= request.path %><br>
73
- </code>
74
- </pre>
75
- <pre style="white-space: normal">
76
- <code>
77
- <strong>HTTP <%= response.status %> <%= response.message %></strong><br>
78
- <strong>Content-Type:</strong> <%= response.content_type %>
79
- </code>
80
- </pre>
81
- </div>
82
- </div>
83
- <% if @json_payload.present? || @xml_payload.present? %>
84
- <div class="row">
85
- <div>
86
- <ul class="nav nav-tabs">
87
- <% if @json_payload.present? %>
88
- <li class="nav-item">
89
- <a class="nav-link active" href="#tab-json" data-bs-toggle="tab" role="tab">
90
- .json
91
- </a>
92
- </li>
93
- <% end %>
94
- <% if @xml_payload.present? %>
95
- <li class="nav-item">
96
- <a class="nav-link" href="#tab-xml" data-bs-toggle="tab" role="tab">
97
- .xml
98
- </a>
99
- </li>
100
- <% end %>
101
- </ul>
102
- </div>
103
- <div class="tab-content pt-2">
104
- <div class="tab-pane fade show active" id="tab-json" role="tabpanel">
105
- <% if @json_payload.present? %>
106
- <div><pre class="rrf-copy"><code class="auto-hljs language-json"><%=
107
- JSON.pretty_generate(
108
- JSON.parse(@json_payload)
109
- ) unless @json_payload == ''
110
- %></code></pre></div>
111
- <% end %>
112
- </div>
113
- <div class="tab-pane fade" id="tab-xml" role="tabpanel">
114
- <% if @xml_payload.present? %>
115
- <div><pre class="rrf-copy"><code class="auto-hljs language-xml"><%=
116
- CGI.unescapeHTML(@xml_payload)
117
- %></code></pre></div>
118
- <% end %>
119
- </div>
120
- </div>
121
- </div>
122
- <% end %>
123
- <% if @route_groups.present? %>
124
- <%
125
- @is_model_controller = controller.class.included_modules.include?(RESTFramework::ModelControllerMixin)
126
- %>
127
- <div class="row">
128
- <div>
129
- <ul class="nav nav-tabs">
147
+ <ul class="nav nav-tabs">
148
+ <li class="nav-item">
149
+ <a class="nav-link active" href="#tab-routes" data-bs-toggle="tab" role="tab">
150
+ Routes
151
+ </a>
152
+ </li>
153
+ <% @_rrf_form_routes = @route_groups.values[0].select { |r|
154
+ r[:matches_params] && r[:verb].in?(["POST", "PUT", "PATCH"])
155
+ } %>
156
+ <% unless @_rrf_form_routes.empty? %>
130
157
  <li class="nav-item">
131
- <a class="nav-link active" href="#tab-routes" data-bs-toggle="tab" role="tab">
132
- Routes
158
+ <a class="nav-link" href="#tab-raw-form" data-bs-toggle="tab" role="tab">
159
+ Raw Form
133
160
  </a>
134
161
  </li>
135
- <% @_rrf_form_routes = @route_groups.values[0].select { |r|
136
- r[:matches_params] && r[:verb].in?(["POST", "PUT", "PATCH"])
137
- } %>
138
- <% unless @_rrf_form_routes.empty? %>
162
+ <% if @is_model_controller %>
139
163
  <li class="nav-item">
140
- <a class="nav-link" href="#tab-raw-form" data-bs-toggle="tab" role="tab">
141
- Raw Form
164
+ <a class="nav-link" href="#tab-html-form" data-bs-toggle="tab" role="tab">
165
+ HTML Form
142
166
  </a>
143
167
  </li>
144
- <% if @is_model_controller %>
145
- <li class="nav-item">
146
- <a class="nav-link" href="#tab-html-form" data-bs-toggle="tab" role="tab">
147
- HTML Form
148
- </a>
149
- </li>
150
- <% end %>
151
168
  <% end %>
152
- </ul>
169
+ <% end %>
170
+ </ul>
171
+ </div>
172
+ <div class="tab-content pt-2">
173
+ <div class="tab-pane fade show active" id="tab-routes" role="tabpanel">
174
+ <%= render partial: "rest_framework/routes" %>
153
175
  </div>
154
- <div class="tab-content pt-2">
155
- <div class="tab-pane fade show active" id="tab-routes" role="tabpanel">
156
- <%= render partial: 'rest_framework/routes' %>
176
+ <% unless @_rrf_form_routes.empty? %>
177
+ <div class="tab-pane fade" id="tab-raw-form" role="tabpanel">
178
+ <%= render partial: "rest_framework/raw_form" %>
157
179
  </div>
158
- <% unless @_rrf_form_routes.empty? %>
159
- <div class="tab-pane fade" id="tab-raw-form" role="tabpanel">
160
- <%= render partial: 'rest_framework/raw_form' %>
180
+ <% if @is_model_controller %>
181
+ <div class="tab-pane fade" id="tab-html-form" role="tabpanel">
182
+ <%= render partial: "rest_framework/html_form" %>
161
183
  </div>
162
- <% if @is_model_controller %>
163
- <div class="tab-pane fade" id="tab-html-form" role="tabpanel">
164
- <%= render partial: 'rest_framework/html_form' %>
165
- </div>
166
- <% end %>
167
184
  <% end %>
168
- </div>
185
+ <% end %>
169
186
  </div>
170
- <% end %>
171
- </div>
187
+ </div>
188
+ <% end %>
172
189
  </div>
173
190
  </body>
174
191
  </html>
@@ -3,15 +3,14 @@
3
3
  <%= csrf_meta_tags %>
4
4
  <%= csp_meta_tag rescue nil %>
5
5
 
6
- <!-- ActiveStorage -->
7
- <script src="https://cdn.jsdelivr.net/npm/activestorage@5.2.8-1/app/assets/javascripts/activestorage.min.js"></script>
8
-
9
6
  <!-- Bootstrap -->
10
7
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-aFq/bzH65dt+w6FI2ooMVUpc+21e0SRygnTpmBvdBgSdnuTN7QbdgL+OapgHtvPp" crossorigin="anonymous">
11
8
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha2/dist/js/bootstrap.bundle.min.js" integrity="sha384-qKXV1j0HvMUeCBQ+QVp7JcfGl760yU08IQ+GpUo5hlbpg51QRiuqHAJz8+BrxE/N" crossorigin="anonymous"></script>
9
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.4/font/bootstrap-icons.css">
12
10
 
13
11
  <!-- Highlight.js -->
14
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/a11y-dark.min.css" integrity="sha512-Vj6gPCk8EZlqnoveEyuGyYaWZ1+jyjMPg8g4shwyyNlRQl6d3L9At02ZHQr5K6s5duZl/+YKMnM3/8pDhoUphg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
12
+ <link rel="stylesheet" class="rrf-light-mode" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/a11y-light.min.css" integrity="sha512-WDk6RzwygsN9KecRHAfm9HTN87LQjqdygDmkHSJxVkVI7ErCZ8ZWxP6T8RvBujY1n2/E4Ac+bn2ChXnp5rnnHA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
13
+ <link rel="stylesheet" class="rrf-dark-mode" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/a11y-dark.min.css" integrity="sha512-Vj6gPCk8EZlqnoveEyuGyYaWZ1+jyjMPg8g4shwyyNlRQl6d3L9At02ZHQr5K6s5duZl/+YKMnM3/8pDhoUphg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
15
14
  <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js" integrity="sha512-bgHRAiTjGrzHzLyKOnpFvaEpGzJet3z4tZnXGjpsCcqOnAH6VGUx9frc5bcIhKTVLEiCO6vEhNAgx5jtLUYrfA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
16
15
  <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/languages/json.min.js" integrity="sha512-0xYvyncS9OLE7GOpNBZFnwyh9+bq4HVgk4yVVYI678xRvE22ASicF1v6fZ1UiST+M6pn17MzFZdvVCI3jTHSyw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
17
16
  <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/languages/xml.min.js" integrity="sha512-5zBcw+OKRkaNyvUEPlTSfYylVzgpi7KpncY36b0gRudfxIYIH0q0kl2j26uCUB3YBRM6ytQQEZSgRg+ZlBTmdA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
@@ -25,43 +24,98 @@
25
24
 
26
25
  <!-- Custom Style -->
27
26
  <style>
28
- /* Adjust headers to always take up their entire row, and tweak the sizing. */
29
- h1,h2,h3,h4,h5,h6 { display: inline-block; font-weight: normal; margin-bottom: 0; }
27
+ /********************************
28
+ * START OF LIB/DOCS COMMON CSS *
29
+ ********************************/
30
+
31
+ :root {
32
+ --rrf-red: #900;
33
+ --rrf-red-hover: #5f0c0c;
34
+ --rrf-light-red: #db2525;
35
+ --rrf-light-red-hover: #b80404;
36
+ }
37
+ #rrfAccentBar {
38
+ background-color: var(--rrf-red);
39
+ height: .3em;
40
+ }
41
+ header nav { background-color: black; }
42
+
43
+ /* Header adjustments. */
30
44
  h1 { font-size: 2rem; }
31
45
  h2 { font-size: 1.7rem; }
32
46
  h3 { font-size: 1.5rem; }
33
47
  h4 { font-size: 1.3rem; }
34
48
  h5 { font-size: 1.1rem; }
35
49
  h6 { font-size: 1rem; }
50
+ h1, h2, h3, h4, h5, h6 {
51
+ color: var(--rrf-red);
52
+ }
53
+ html[data-bs-theme="dark"] h1,
54
+ html[data-bs-theme="dark"] h2,
55
+ html[data-bs-theme="dark"] h3,
56
+ html[data-bs-theme="dark"] h4,
57
+ html[data-bs-theme="dark"] h5,
58
+ html[data-bs-theme="dark"] h6 {
59
+ color: var(--rrf-light-red);
60
+ }
36
61
 
37
- /* Make code and code blocks a little nicer looking. */
62
+ /* Improve code and code blocks. */
38
63
  pre code {
39
64
  display: block;
40
65
  overflow-x: auto;
41
66
  }
42
- code {
67
+ code, .trix-content pre {
43
68
  padding: .5em !important;
44
- background-color: #2b2b2b !important;
69
+ background-color: #eee !important;
45
70
  border: 1px solid #aaa;
46
71
  border-radius: 3px;
47
72
  }
73
+ p code {
74
+ padding: .1em .3em !important;
75
+ }
76
+ html[data-bs-theme="dark"] code, html[data-bs-theme="dark"] .trix-content pre {
77
+ background-color: #2b2b2b !important;
78
+ }
79
+
80
+ /* Anchors */
81
+ a:not(.nav-link) {
82
+ text-decoration: none;
83
+ color: var(--rrf-red);
84
+ }
85
+ a:hover:not(.nav-link) {
86
+ text-decoration: underline;
87
+ color: var(--rrf-red-hover);
88
+ }
89
+ html[data-bs-theme="dark"] a:not(.nav-link) { color: var(--rrf-light-red); }
90
+ html[data-bs-theme="dark"] a:hover:not(.nav-link) { color: var(--rrf-light-red-hover); }
91
+
92
+ /******************************
93
+ * END OF LIB/DOCS COMMON CSS *
94
+ ******************************/
95
+
96
+ /* Header adjustments. */
97
+ h1,h2,h3,h4,h5,h6 { display: inline-block; font-weight: normal; margin-bottom: 0; }
48
98
 
49
99
  /* Reduce label font size. */
50
100
  label.form-label {
51
101
  font-size: .8em;
52
102
  }
53
103
 
54
- trix-editor:empty:not(:focus)::before {
55
- pointer-events: none;
104
+ /* Make Trix buttons visible even in dark mode. */
105
+ trix-toolbar .trix-button-group {
106
+ background-color: #eee;
56
107
  }
57
108
 
58
- /* Make Trix buttons visible in the dark mode. */
59
- trix-toolbar .trix-button-group {
60
- background-color: #f8f8f8;
109
+ /* Make Trix dialog URL input visible in dark mode. */
110
+ input.trix-input--dialog {
111
+ color: black;
61
112
  }
62
113
 
63
114
  /* Make route group expansion obvious to the user. */
64
115
  .rrf-routes .rrf-route-group-header:hover {
116
+ background-color: #ddd;
117
+ }
118
+ html[data-bs-theme="dark"] .rrf-routes .rrf-route-group-header:hover {
65
119
  background-color: #333;
66
120
  }
67
121
  .rrf-routes .rrf-route-group-header td {
@@ -92,7 +146,104 @@ trix-toolbar .trix-button-group {
92
146
 
93
147
  <!-- Custom JavaScript -->
94
148
  <script>
95
- // What to do when document loads.
149
+ /*******************************
150
+ * START OF LIB/DOCS COMMON JS *
151
+ *******************************/
152
+
153
+ ;(() => {
154
+ // Get the real mode from a selected mode. Anything other than "light" or "dark" is treated as
155
+ // "system" mode.
156
+ const rrfGetRealMode = (selectedMode) => {
157
+ if (selectedMode === "light" || selectedMode === "dark") {
158
+ return selectedMode
159
+ }
160
+
161
+ if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
162
+ return "dark"
163
+ }
164
+
165
+ return "light"
166
+ }
167
+
168
+ // Set the mode, given a "selected" mode.
169
+ const rrfSetSelectedMode = (selectedMode) => {
170
+ const modeComponent = document.getElementById("rrfModeComponent")
171
+
172
+ // Anything except "light" or "dark" is casted to "system".
173
+ if (selectedMode !== "light" && selectedMode !== "dark") {
174
+ selectedMode = "system"
175
+ }
176
+
177
+ // Store selected mode in `localStorage`.
178
+ localStorage.setItem("rrfMode", selectedMode)
179
+
180
+ // Set the mode selector to the selected mode.
181
+ let labelHTML
182
+ modeComponent.querySelectorAll("button[data-rrf-mode-value]").forEach((el) => {
183
+ if (el.getAttribute("data-rrf-mode-value") === selectedMode) {
184
+ el.classList.add("active")
185
+ labelHTML = el.querySelector("i").outerHTML.replace("ms-2", "me-1")
186
+ } else {
187
+ el.classList.remove("active")
188
+ }
189
+ })
190
+ modeComponent.querySelector("button[data-bs-toggle]").innerHTML = labelHTML
191
+
192
+ // Get the real mode to use.
193
+ realMode = rrfGetRealMode(selectedMode)
194
+
195
+ // Set the `realMode` effects.
196
+ if (realMode === "light") {
197
+ document.querySelectorAll(".rrf-light-mode").forEach((el) => {
198
+ el.disabled = false
199
+ })
200
+ document.querySelectorAll(".rrf-dark-mode").forEach((el) => {
201
+ el.disabled = true
202
+ })
203
+ document.querySelectorAll(".rrf-mode").forEach((el) => {
204
+ el.setAttribute("data-bs-theme", "light")
205
+ })
206
+ } else if (realMode === "dark") {
207
+ document.querySelectorAll(".rrf-light-mode").forEach((el) => {
208
+ el.disabled = true
209
+ })
210
+ document.querySelectorAll(".rrf-dark-mode").forEach((el) => {
211
+ el.disabled = false
212
+ })
213
+ document.querySelectorAll(".rrf-mode").forEach((el) => {
214
+ el.setAttribute("data-bs-theme", "dark")
215
+ })
216
+ } else {
217
+ console.log(`RRF: Unknown mode: ${mode}`)
218
+ }
219
+ }
220
+
221
+ // Initialize dark/light mode.
222
+ document.addEventListener("DOMContentLoaded", (event) => {
223
+ const selectedMode = localStorage.getItem("rrfMode")
224
+ rrfSetSelectedMode(selectedMode)
225
+ document.querySelectorAll("#rrfModeComponent button[data-rrf-mode-value]").forEach((el) => {
226
+ el.addEventListener("click", (event) => {
227
+ rrfSetSelectedMode(event.target.getAttribute("data-rrf-mode-value"))
228
+ })
229
+ })
230
+ })
231
+
232
+ // Handle case where user changes system theme.
233
+ if (window.matchMedia) {
234
+ window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", () => {
235
+ const selectedMode = localStorage.getItem("rrfMode")
236
+ if (selectedMode !== "light" && selectedMode !== "dark") {
237
+ rrfSetSelectedMode("system")
238
+ }
239
+ })
240
+ }
241
+ })()
242
+
243
+ /*****************************
244
+ * END OF LIB/DOCS COMMON JS *
245
+ *****************************/
246
+
96
247
  document.addEventListener("DOMContentLoaded", (event) => {
97
248
  // Pretty-print JSON.
98
249
  document.querySelectorAll(".language-json").forEach((el, index) => {
@@ -13,7 +13,7 @@
13
13
  <%= form_with(
14
14
  model: @record,
15
15
  url: "",
16
- method: "PATCH",
16
+ method: :patch,
17
17
  id: "htmlForm",
18
18
  scope: "",
19
19
  ) do |form| %>
data/docs/CNAME ADDED
@@ -0,0 +1 @@
1
+ rails-rest-framework.com
data/docs/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "github-pages"
4
+ gem "yard"