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 +4 -4
- data/VERSION +1 -1
- data/app/views/layouts/rest_framework.html.erb +149 -132
- data/app/views/rest_framework/_head.html.erb +166 -15
- data/app/views/rest_framework/_html_form.html.erb +1 -1
- data/docs/CNAME +1 -0
- data/docs/Gemfile +4 -0
- data/docs/Gemfile.lock +264 -0
- data/docs/_config.yml +17 -0
- data/docs/_guide/1_routers.md +110 -0
- data/docs/_guide/2_controller_mixins.md +293 -0
- data/docs/_guide/3_serializers.md +60 -0
- data/docs/_guide/4_filtering_and_ordering.md +41 -0
- data/docs/_guide/5_pagination.md +21 -0
- data/docs/_includes/anchor_headings.html +144 -0
- data/docs/_includes/head.html +35 -0
- data/docs/_includes/header.html +58 -0
- data/docs/_layouts/default.html +11 -0
- data/docs/assets/css/rest_framework.css +159 -0
- data/docs/assets/images/favicon.ico +0 -0
- data/docs/assets/js/rest_framework.js +132 -0
- data/docs/index.md +133 -0
- data/lib/rest_framework/serializers.rb +1 -1
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b8d9a14de396b6832c13e0f3e1f2627decb432af03c6a2cbb59ce27328cdd7c
|
4
|
+
data.tar.gz: 6d1e675245643d96e2b35aaaadd9118eb441025a1bb7acc303db63d6761dc79c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0ef4d98bec92656d0541f34aebd652d30b90af0bdde8ea91e0b1809b82ee381bdbfef0ea04235b2c24005ec43646ad59b7fce01d3eda1312e48e1a976bd8092
|
7
|
+
data.tar.gz: d64fdd4c884a6173c9df9f87074748290b1093917a053acfa70b5b6579bbe07f7479adf15b226178fb784181edfe28ac3cbce461c13b64372e988d5abbab5966
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
1
|
+
0.8.17
|
@@ -1,174 +1,191 @@
|
|
1
1
|
<!doctype html>
|
2
|
-
<html
|
2
|
+
<html class="rrf-mode">
|
3
3
|
<head>
|
4
4
|
<title><%= @title %></title>
|
5
|
-
<%= render partial:
|
5
|
+
<%= render partial: "rest_framework/head" %>
|
6
6
|
</head>
|
7
7
|
|
8
8
|
<body>
|
9
|
-
<
|
10
|
-
<div class="w-100 m-0 p-0"
|
11
|
-
<nav class="navbar
|
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 ||
|
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
|
-
</
|
34
|
+
</header>
|
21
35
|
<div class="container py-3">
|
22
|
-
<div class="
|
23
|
-
<
|
24
|
-
<
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
44
|
+
last_path = breadcrumbs.last&.first || "/"
|
45
|
+
breadcrumbs << [
|
46
|
+
[last_path, part].join(last_path[-1] == "/" ? "" : "/"),
|
47
|
+
part,
|
48
|
+
]
|
36
49
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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
|
-
|
48
|
-
</
|
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
|
-
<
|
53
|
-
|
54
|
-
|
55
|
-
|
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 @
|
58
|
-
<
|
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
|
-
|
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
|
-
<
|
71
|
-
<
|
72
|
-
<
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
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
|
132
|
-
|
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
|
-
<%
|
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-
|
141
|
-
|
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
|
-
|
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
|
-
|
155
|
-
<div class="tab-pane fade
|
156
|
-
<%= render partial:
|
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
|
-
<%
|
159
|
-
<div class="tab-pane fade" id="tab-
|
160
|
-
<%= render partial:
|
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
|
-
|
185
|
+
<% end %>
|
169
186
|
</div>
|
170
|
-
|
171
|
-
|
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-
|
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
|
-
|
29
|
-
|
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
|
-
/*
|
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: #
|
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
|
-
|
55
|
-
|
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
|
59
|
-
|
60
|
-
|
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
|
-
|
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) => {
|
data/docs/CNAME
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rails-rest-framework.com
|
data/docs/Gemfile
ADDED