rest_framework 0.8.17 → 0.9.0

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: 9b8d9a14de396b6832c13e0f3e1f2627decb432af03c6a2cbb59ce27328cdd7c
4
- data.tar.gz: 6d1e675245643d96e2b35aaaadd9118eb441025a1bb7acc303db63d6761dc79c
3
+ metadata.gz: e2e028b70ec7cad48ee82a18f8e7b68b6c5d2c3d79bf058ab9a9dfc9f1b428b6
4
+ data.tar.gz: 70f703c74d2e2d7228f0bf09c8510958a6860bf9a7cc2d7e6f586a8975e0374a
5
5
  SHA512:
6
- metadata.gz: a0ef4d98bec92656d0541f34aebd652d30b90af0bdde8ea91e0b1809b82ee381bdbfef0ea04235b2c24005ec43646ad59b7fce01d3eda1312e48e1a976bd8092
7
- data.tar.gz: d64fdd4c884a6173c9df9f87074748290b1093917a053acfa70b5b6579bbe07f7479adf15b226178fb784181edfe28ac3cbce461c13b64372e988d5abbab5966
6
+ metadata.gz: 659e40f0cd59dfc249a3799baca4c9a6b0109302904d4874d998c4d656c1ffdd1e0d11f4e463d92cc9006bcb174b7fe72f61bc01e914ed57428616aa56e662bd
7
+ data.tar.gz: a172ab0072d67e52280f058ea38694ffd22d543697bcae1a73fc5fc9ec595101d606b4ff681e1f11ba27beca86d3376eda40907b95ae8bf213a6a86c2eb6e3ae
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.17
1
+ 0.9.0
@@ -135,11 +135,15 @@ html[data-bs-theme="dark"] .rrf-routes .rrf-route-group-header:hover {
135
135
  }
136
136
  .rrf-copy .rrf-copy-link {
137
137
  position: absolute;
138
- top: .5em;
139
- right: .5em;
138
+ top: .25em;
139
+ right: .4em;
140
140
  transition: 0.3s ease;
141
+ font-size: 1.5em;
141
142
  }
142
- .rrf-copy .rrf-copy-link.rrf-clicked{
143
+ .rrf-copy .rrf-copy-link.rrf-clicked {
144
+ color: green;
145
+ }
146
+ .rrf-copy .rrf-copy-link.rrf-clicked:hover {
143
147
  color: green;
144
148
  }
145
149
  </style>
@@ -167,8 +171,6 @@ html[data-bs-theme="dark"] .rrf-routes .rrf-route-group-header:hover {
167
171
 
168
172
  // Set the mode, given a "selected" mode.
169
173
  const rrfSetSelectedMode = (selectedMode) => {
170
- const modeComponent = document.getElementById("rrfModeComponent")
171
-
172
174
  // Anything except "light" or "dark" is casted to "system".
173
175
  if (selectedMode !== "light" && selectedMode !== "dark") {
174
176
  selectedMode = "system"
@@ -178,16 +180,19 @@ html[data-bs-theme="dark"] .rrf-routes .rrf-route-group-header:hover {
178
180
  localStorage.setItem("rrfMode", selectedMode)
179
181
 
180
182
  // 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
183
+ const modeComponent = document.getElementById("rrfModeComponent")
184
+ if (modeComponent) {
185
+ let labelHTML
186
+ modeComponent.querySelectorAll("button[data-rrf-mode-value]").forEach((el) => {
187
+ if (el.getAttribute("data-rrf-mode-value") === selectedMode) {
188
+ el.classList.add("active")
189
+ labelHTML = el.querySelector("i").outerHTML.replace("ms-2", "me-1")
190
+ } else {
191
+ el.classList.remove("active")
192
+ }
193
+ })
194
+ modeComponent.querySelector("button[data-bs-toggle]").innerHTML = labelHTML
195
+ }
191
196
 
192
197
  // Get the real mode to use.
193
198
  realMode = rrfGetRealMode(selectedMode)
@@ -218,10 +223,14 @@ html[data-bs-theme="dark"] .rrf-routes .rrf-route-group-header:hover {
218
223
  }
219
224
  }
220
225
 
221
- // Initialize dark/light mode.
226
+ // Initialize dark/light mode before page fully loads to prevent flash.
227
+ rrfSetSelectedMode(localStorage.getItem("rrfMode"))
228
+
229
+ // Initialize dark/light mode after page load (mostly so mode component is updated).
222
230
  document.addEventListener("DOMContentLoaded", (event) => {
223
- const selectedMode = localStorage.getItem("rrfMode")
224
- rrfSetSelectedMode(selectedMode)
231
+ rrfSetSelectedMode(localStorage.getItem("rrfMode"))
232
+
233
+ // Also set up mode selector.
225
234
  document.querySelectorAll("#rrfModeComponent button[data-rrf-mode-value]").forEach((el) => {
226
235
  el.addEventListener("click", (event) => {
227
236
  rrfSetSelectedMode(event.target.getAttribute("data-rrf-mode-value"))
@@ -246,7 +255,7 @@ html[data-bs-theme="dark"] .rrf-routes .rrf-route-group-header:hover {
246
255
 
247
256
  document.addEventListener("DOMContentLoaded", (event) => {
248
257
  // Pretty-print JSON.
249
- document.querySelectorAll(".language-json").forEach((el, index) => {
258
+ document.querySelectorAll(".language-json").forEach((el) => {
250
259
  el.innerHTML = neatJSON(JSON.parse(el.innerText), {
251
260
  wrap: 80,
252
261
  afterComma: 1,
@@ -263,17 +272,37 @@ document.addEventListener("DOMContentLoaded", (event) => {
263
272
  hljs.highlightAll()
264
273
 
265
274
  // Replace text node links with anchor tag links.
266
- document.querySelectorAll(".rrf-copy code").forEach((el, index) => {
275
+ document.querySelectorAll(".rrf-copy code").forEach((el) => {
267
276
  el.innerHTML = rrfLinkify(el.innerHTML)
268
277
  })
269
278
 
270
- // Insert copy link and callback to copy contents of `<code>` element.
271
- document.querySelectorAll("rrf-copy").forEach((el, index) => {
279
+ // Insert copy links.
280
+ document.querySelectorAll(".rrf-copy").forEach((el) => {
272
281
  el.insertAdjacentHTML(
273
282
  "afterbegin",
274
- "<a class=\"rrf-copy-link\" onclick=\"return rrfCopyToClipboard(this)\" href=\"#\">Copy to Clipboard</a>",
283
+ '<a class="rrf-copy-link" title="Copy to Clipboard" href="#"><i class="bi bi-clipboard-fill"></i></a>',
275
284
  )
276
285
  })
286
+
287
+ // Copy link implementation.
288
+ document.querySelectorAll(".rrf-copy-link").forEach((el) => {
289
+ el.addEventListener("click", (event) => {
290
+ const range = document.createRange()
291
+ range.selectNode(el.nextSibling)
292
+ window.getSelection().removeAllRanges()
293
+ window.getSelection().addRange(range)
294
+ if (document.execCommand("copy")) {
295
+ // Trigger clicked animation.
296
+ el.classList.add("rrf-clicked")
297
+ el.innerHTML = '<i class="bi bi-clipboard-check-fill">'
298
+ setTimeout(() => {
299
+ el.classList.remove("rrf-clicked")
300
+ el.innerHTML = '<i class="bi bi-clipboard-fill">'
301
+ }, 1000)
302
+ }
303
+ event.preventDefault()
304
+ })
305
+ })
277
306
  })
278
307
 
279
308
  // Convert plain-text links to anchor tag links.
@@ -292,26 +321,6 @@ function rrfReplaceDocument(content) {
292
321
  document.dispatchEvent(new Event("DOMContentLoaded", {bubbles: true, cancelable: true}))
293
322
  }
294
323
 
295
- // Copy the element's next `<code>` sibling's content to the clipboard.
296
- function rrfCopyToClipboard(element) {
297
- let range = document.createRange()
298
- range.selectNode(element.nextSibling)
299
- window.getSelection().removeAllRanges()
300
- window.getSelection().addRange(range)
301
- if (document.execCommand("copy")) {
302
- // Trigger clicked animation.
303
- element.classList.add("rrf-clicked")
304
- element.innerText = "Copied!"
305
- setTimeout(() => {
306
- element.classList.remove("rrf-clicked")
307
- element.innerText = "Copy to Clipboard"
308
- }, 700)
309
- }
310
-
311
- // Return false to prevent normal link behavior.
312
- return false
313
- }
314
-
315
324
  // Refresh the window as a `GET` request.
316
325
  function rrfGet(button) {
317
326
  button.disabled = true
@@ -352,7 +361,7 @@ function rrfSubmitRawForm(button) {
352
361
  // Add file(s) to `formData`.
353
362
  const rawFilesForm = document.getElementById("rawFilesForm")
354
363
  if (rawFilesForm) {
355
- rawFilesForm.querySelectorAll("input[type=file]").forEach((el, index) => {
364
+ rawFilesForm.querySelectorAll("input[type=file]").forEach((el) => {
356
365
  const files = el.files
357
366
  for (let i = 0; i < files.length; i++) {
358
367
  formData.append(el.name, files[i])
@@ -19,8 +19,6 @@
19
19
 
20
20
  // Set the mode, given a "selected" mode.
21
21
  const rrfSetSelectedMode = (selectedMode) => {
22
- const modeComponent = document.getElementById("rrfModeComponent")
23
-
24
22
  // Anything except "light" or "dark" is casted to "system".
25
23
  if (selectedMode !== "light" && selectedMode !== "dark") {
26
24
  selectedMode = "system"
@@ -30,16 +28,19 @@
30
28
  localStorage.setItem("rrfMode", selectedMode)
31
29
 
32
30
  // Set the mode selector to the selected mode.
33
- let labelHTML
34
- modeComponent.querySelectorAll("button[data-rrf-mode-value]").forEach((el) => {
35
- if (el.getAttribute("data-rrf-mode-value") === selectedMode) {
36
- el.classList.add("active")
37
- labelHTML = el.querySelector("i").outerHTML.replace("ms-2", "me-1")
38
- } else {
39
- el.classList.remove("active")
40
- }
41
- })
42
- modeComponent.querySelector("button[data-bs-toggle]").innerHTML = labelHTML
31
+ const modeComponent = document.getElementById("rrfModeComponent")
32
+ if (modeComponent) {
33
+ let labelHTML
34
+ modeComponent.querySelectorAll("button[data-rrf-mode-value]").forEach((el) => {
35
+ if (el.getAttribute("data-rrf-mode-value") === selectedMode) {
36
+ el.classList.add("active")
37
+ labelHTML = el.querySelector("i").outerHTML.replace("ms-2", "me-1")
38
+ } else {
39
+ el.classList.remove("active")
40
+ }
41
+ })
42
+ modeComponent.querySelector("button[data-bs-toggle]").innerHTML = labelHTML
43
+ }
43
44
 
44
45
  // Get the real mode to use.
45
46
  realMode = rrfGetRealMode(selectedMode)
@@ -70,10 +71,14 @@
70
71
  }
71
72
  }
72
73
 
73
- // Initialize dark/light mode.
74
+ // Initialize dark/light mode before page fully loads to prevent flash.
75
+ rrfSetSelectedMode(localStorage.getItem("rrfMode"))
76
+
77
+ // Initialize dark/light mode after page load (mostly so mode component is updated).
74
78
  document.addEventListener("DOMContentLoaded", (event) => {
75
- const selectedMode = localStorage.getItem("rrfMode")
76
- rrfSetSelectedMode(selectedMode)
79
+ rrfSetSelectedMode(localStorage.getItem("rrfMode"))
80
+
81
+ // Also set up mode selector.
77
82
  document.querySelectorAll("#rrfModeComponent button[data-rrf-mode-value]").forEach((el) => {
78
83
  el.addEventListener("click", (event) => {
79
84
  rrfSetSelectedMode(event.target.getAttribute("data-rrf-mode-value"))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest_framework
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.17
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregory N. Schmit