From b95a2de1de44976bb6b6235e84d9b3dc8b20d10c Mon Sep 17 00:00:00 2001 From: Konstantin Gredeskoul Date: Thu, 26 Nov 2026 12:25:41 -0800 Subject: [PATCH 1/5] Preview a box whose front slopes back slopedProfile mirrors laser-cutter's Sloped::Profile (kigster/laser-cutter#25): the side outline, top strip depth and panel lengths from depth, height, front height and slope. isoSlopedBox draws it in the same isometric view as isoBox: side wall, front strip, tilted panel, top strip, finger joints, dimensions and the slope angle; a plain lid lifts the tilted panel off. Library modules import nothing, so the caller passes in the profile and tabCount. Not wired into the form yet: that needs the gem release with --slope. --- app/assets/stylesheets/generator.css | 1 + app/javascript/lib/iso_sloped_box.js | 125 +++++++++++++++++++++++++++ app/javascript/lib/sloped_profile.js | 48 ++++++++++ cypress/e2e/lib.cy.js | 71 +++++++++++++++ 4 files changed, 245 insertions(+) create mode 100644 app/javascript/lib/iso_sloped_box.js create mode 100644 app/javascript/lib/sloped_profile.js diff --git a/app/assets/stylesheets/generator.css b/app/assets/stylesheets/generator.css index 7f52439..2054d76 100644 --- a/app/assets/stylesheets/generator.css +++ b/app/assets/stylesheets/generator.css @@ -29,6 +29,7 @@ .stage .top { fill: var(--birch-light); } .stage .left { fill: var(--birch); } .stage .right { fill: var(--birch-dark); } +.stage .tilted { fill: color-mix(in oklab, var(--birch-light) 55%, var(--birch)); } .stage .inside { stroke: #2a1a0c; stroke-width: 1; } .stage .floor { fill: #6b5231; } .stage .far { fill: #a98a57; } diff --git a/app/javascript/lib/iso_sloped_box.js b/app/javascript/lib/iso_sloped_box.js new file mode 100644 index 0000000..0e81b02 --- /dev/null +++ b/app/javascript/lib/iso_sloped_box.js @@ -0,0 +1,125 @@ +// Draws the isometric preview of a box whose front slopes back: the right +// side wall, the front strip, the tilted panel and the top strip, with finger +// joints and the dimensions. For a lid that lifts off, the tilted panel floats +// up off the box. Pure geometry, no state. +// +// Library modules here import nothing (importmap pins them by bare name, which +// the test bundler cannot resolve), so the caller passes in the profile from +// slopedProfile() and tabCount from iso_box.js. The projection matches +// iso_box.js, so both boxes draw at the same scale. + +const COS30 = Math.cos(Math.PI / 6) +const SCALE = 100 + +const project = (x, y, z) => [(x - y) * COS30 * SCALE, ((x + y) * 0.5 - z) * SCALE] +const pair = (point) => point.map((n) => n.toFixed(1)).join(",") + +// box: { width, height, depth, frontHeight, slope, thickness, notch, units, lid, hot } +// profile: slopedProfile() of the same box, in the same units +// Returns { viewBox, markup } for an . Every interpolated value is a number +// or one of a fixed set of words, so the markup is safe to assign as innerHTML. +export function isoSlopedBox(box, profile, tabCount) { + // Drawn in inches whatever the units, as iso_box.js does. + const inch = box.units === "mm" ? 25.4 : 1 + const [W, H, D, Hf, t] = [box.width, box.height, box.depth, box.frontHeight, box.thickness].map((value) => value / inch) + const notch = (box.notch || 3 * box.thickness) / inch + const [Dt, S] = [profile.topDepth / inch, profile.slopeLength / inch] + const tilted = profile.lengths.tilted / inch + const start = Math.hypot(...profile.span[0].map((c, i) => c - [0, box.frontHeight][i])) / inch // where the tilted panel begins on the slope + const [cos, sin] = [Math.cos(profile.angle), Math.sin(profile.angle)] + const open = box.lid === "plain" + const unit = Math.max(W, H, D) + const points = [] + let markup = "" + + // A face maps its own (p, q) onto the box: o + u·p + v·q. + const face = (o, u, v) => ({ o, u, v }) + const at = (f, p, q) => { + const point = project(...[0, 1, 2].map((i) => f.o[i] + f.u[i] * p + f.v[i] * q)) + points.push(point) + return point + } + const shape = (cls, f, corners) => { markup += `` } + const rect = (cls, f, a, b) => shape(cls, f, [[0, 0], [a, 0], [a, b], [0, b]]) + + // A finger is the end grain of the neighbouring panel showing through an + // edge: every other notch along it, one thickness deep. + const fingers = (f, from, dir, inward, length, phase) => { + if (length <= 0) return + const count = tabCount(length, notch) + const point = (s, d) => [from[0] + dir[0] * s + inward[0] * d, from[1] + dir[1] * s + inward[1] * d] + for (let i = phase; i < count; i += 2) { + const a = (i * length) / count, b = ((i + 1) * length) / count + shape("finger", f, [point(a, 0), point(b, 0), point(b, t), point(a, t)]) + } + } + + // Seen from the right, the side's own p runs from the front to the back. + const side = face([W, D, 0], [0, -1, 0], [0, 0, 1]) + const front = face([0, D, 0], [1, 0, 0], [0, 0, 1]) + const slope = face([0, D, Hf], [1, 0, 0], [0, -cos, sin]) + const top = face([0, Dt, H], [1, 0, 0], [0, -1, 0]) + const outline = profile.outline.map(([p, q]) => [p / inch, q / inch]) + + const shadow = [project(-0.04 * unit, D, 0), project(W, D + 0.1 * unit, 0), project(W + 0.22 * unit, D * 0.4, 0), project(W + 0.16 * unit, -0.1 * unit, 0)] + markup += `` + + shape("face right", side, outline) + fingers(side, [0, 0], [1, 0], [0, 1], D, 1) + fingers(side, [D, 0], [0, 1], [-1, 0], H, 1) + fingers(side, [0, 0], [0, 1], [1, 0], Hf, 1) + fingers(side, [D - Dt, H], [1, 0], [0, -1], Dt, 1) + + if (Hf > 0) { + rect("face left", front, W, Hf) + fingers(front, [0, 0], [1, 0], [0, 1], W, 1) + fingers(front, [W, 0], [0, 1], [-1, 0], Hf, 0) + } + if (Dt > 0) { + rect("face top", top, W, Dt) + fingers(top, [0, Dt], [1, 0], [0, -1], W, 0) + fingers(top, [W, 0], [0, 1], [-1, 0], Dt, 0) + } + + if (open) { + // The opening the tilted panel leaves, then the panel, lifted along its + // own normal, a slab one thickness deep. + shape("inside floor", slope, [[0, 0], [W, 0], [W, S], [0, S]]) + const lift = Math.max(0.35 * H, 0.18 * unit) + const up = [0, sin * lift, cos * lift] + const lifted = face(slope.o.map((c, i) => c + up[i]), slope.u, slope.v) + const edge = lifted.o.map((c, i) => c + slope.v[i] * start) // the low edge of the lifted panel + rect("face left", face(edge, [1, 0, 0], [0, -sin, -cos]), W, t) + shape("face tilted", lifted, [[0, start], [W, start], [W, start + tilted], [0, start + tilted]]) + fingers(lifted, [W, start], [0, 1], [-1, 0], tilted, 0) + } else { + rect("face tilted", slope, W, S) + fingers(slope, [W, start], [0, 1], [-1, 0], tilted, 0) + // The side's sloped edge, under the tilted panel's fingers. + const [low] = profile.span + fingers(side, [low[0] / inch, low[1] / inch], [cos, sin], [sin, -cos], tilted, 1) + } + + const offset = 0.1 * unit, size = unit * SCALE * 0.052 + const label = (key, at, text) => { + points.push([at[0] - size * 2.4, at[1] - size], [at[0] + size * 2.4, at[1] + size]) + markup += `${text}` + } + const dimension = (key, a, b, away, value) => { + const a1 = project(a[0] + away[0] * offset, a[1] + away[1] * offset, a[2]) + const b1 = project(b[0] + away[0] * offset, b[1] + away[1] * offset, b[2]) + points.push(a1, b1) + markup += `` + label(key, [(a1[0] + b1[0]) / 2, (a1[1] + b1[1]) / 2], `${Number(value)} ${box.units === "mm" ? "mm" : "in"}`) + } + dimension("width", [0, D, 0], [W, D, 0], [0, 1.6], box.width) + dimension("depth", [W, 0, 0], [W, D, 0], [1.6, 0], box.depth) + dimension("height", [W, 0, 0], [W, 0, H], [1.6, -1.2], box.height) + if (Hf > 0) dimension("frontHeight", [0, D, 0], [0, D, Hf], [-1.2, 0], box.frontHeight) + label("slope", project(W + offset, D - (S / 2) * cos, Hf + (S / 2) * sin + offset), `${Number(Number(box.slope).toFixed(1))}°`) + + const xs = points.map((p) => p[0]), ys = points.map((p) => p[1]), pad = unit * 6 + const x0 = Math.min(...xs) - pad, y0 = Math.min(...ys) - pad + const viewBox = [x0, y0, Math.max(...xs) + pad - x0, Math.max(...ys) + pad - y0].map((n) => n.toFixed(1)).join(" ") + return { viewBox, markup } +} diff --git a/app/javascript/lib/sloped_profile.js b/app/javascript/lib/sloped_profile.js new file mode 100644 index 0000000..89af235 --- /dev/null +++ b/app/javascript/lib/sloped_profile.js @@ -0,0 +1,48 @@ +// The side view of a box whose front slopes back, the same numbers +// laser-cutter's Sloped::Profile computes. Pure geometry, no state. +// +// Seen from the left, front to the left: a front strip Hf high, a tilted +// panel rising at the slope, a top strip Dt deep, the back H high, and the +// bottom D deep. Every length is of the inside outline. +// +// Where the tilted panel meets a strip the corner is obtuse: the strip runs +// past the corner over the end of the tilted panel, which stops short, so the +// outside faces meet. A strip of zero size is dropped. + +const PRECISION = 1e-6 + +// { depth, height, frontHeight, slope (degrees), thickness } +// Returns null when the numbers do not make this shape, otherwise +// { angle, topDepth, slopeLength, outline, span, lengths }. +export function slopedProfile({ depth: D, height: H, frontHeight: Hf, slope, thickness: t }) { + if (!(D > 0 && H > 0 && t > 0 && slope > 0 && slope < 90 && Hf >= 0 && Hf < H)) return null + const angle = (slope * Math.PI) / 180 + const run = (H - Hf) / Math.tan(angle) + if (run > D + PRECISION) return null + + const topDepth = D - run < PRECISION ? 0 : D - run + const top = topDepth > 0, front = Hf > 0 + const topCut = top ? t / Math.tan(angle) : 0 + const frontCut = front ? t * Math.tan(angle) : 0 + const slopeLength = Math.hypot(run, H - Hf) + const [cos, sin] = [Math.cos(angle), Math.sin(angle)] + + // [depth from the front, height], counter-clockwise from the front of the bottom. + const outline = [[0, 0], [D, 0], [D, H]] + if (top) outline.push([D - topDepth, H]) + if (front) outline.push([0, Hf]) + + return { + angle, + topDepth, + slopeLength, + outline, + // The stretch of the slope the tilted panel covers, low end first. + span: [[frontCut * cos, Hf + frontCut * sin], [run - topCut * cos, H - topCut * sin]], + lengths: { + tilted: slopeLength - frontCut - topCut, + top: top ? topDepth + t / sin : 0, + front: front ? Hf + t / cos : 0 + } + } +} diff --git a/cypress/e2e/lib.cy.js b/cypress/e2e/lib.cy.js index 44b91d6..aeb72d2 100644 --- a/cypress/e2e/lib.cy.js +++ b/cypress/e2e/lib.cy.js @@ -1,6 +1,8 @@ // The pure modules behind the preview and the trace, tested without a page. import { tabCount, isoBox } from "../../app/javascript/lib/iso_box" import { chain } from "../../app/javascript/lib/laser_trace" +import { slopedProfile } from "../../app/javascript/lib/sloped_profile" +import { isoSlopedBox } from "../../app/javascript/lib/iso_sloped_box" describe("tabCount", () => { it("is odd and at least three, counted the way laser-cutter counts", () => { @@ -66,3 +68,72 @@ describe("chain", () => { expect(chain(lines, 2)).to.eq(lines) }) }) + +describe("slopedProfile", () => { + const box = { depth: 6, height: 4, frontHeight: 1, slope: 45, thickness: 0.25 } + const close = (a, b) => expect(a).to.be.closeTo(b, 1e-9) + + it("computes the numbers laser-cutter's Sloped::Profile computes", () => { + const p = slopedProfile(box) + close(p.topDepth, 3) + close(p.slopeLength, 3 * Math.SQRT2) + expect(p.outline.map((point) => point.map((c) => Number(c.toFixed(9))))).to.deep.eq([[0, 0], [6, 0], [6, 4], [3, 4], [0, 1]]) + close(p.lengths.top, 3 + 0.25 * Math.SQRT2) + close(p.lengths.front, 1 + 0.25 * Math.SQRT2) + close(p.lengths.tilted, 3 * Math.SQRT2 - 0.5) + }) + + it("meets each strip on the outside, with no gap and no overlap", () => { + const p = slopedProfile(box) + const out = ([x, y]) => [x - 0.25 * Math.sin(p.angle), y + 0.25 * Math.cos(p.angle)] + const [low, high] = p.span.map(out) + close(high[0], 6 - p.lengths.top); close(high[1], 4) + close(low[0], 0); close(low[1], p.lengths.front) + }) + + it("drops a strip of zero size", () => { + const wedge = slopedProfile({ ...box, frontHeight: 0, slope: (Math.atan(4 / 6) * 180) / Math.PI }) + expect(wedge.outline).to.have.length(3) + expect([wedge.lengths.top, wedge.lengths.front]).to.deep.eq([0, 0]) + }) + + it("refuses what cannot be built", () => { + for (const bad of [{ slope: 0 }, { slope: 90 }, { slope: 20 }, { frontHeight: 4 }, { frontHeight: -1 }, { thickness: 0 }]) { + expect(slopedProfile({ ...box, ...bad }), JSON.stringify(bad)).to.eq(null) + } + }) +}) + +describe("isoSlopedBox", () => { + const box = { width: 5, height: 4, depth: 6, frontHeight: 1, slope: 45, thickness: 0.25, notch: 0, units: "in", hot: null } + const draw = (extra = {}) => { const b = { ...box, ...extra }; return isoSlopedBox(b, slopedProfile(b), tabCount) } + const count = (markup, cls) => markup.split(`class="${cls}"`).length - 1 + + it("draws the side, the front strip, the tilted panel and the top strip, with fingers", () => { + const { viewBox, markup } = draw({ lid: "full" }) + expect(count(markup, "face right") + count(markup, "face left") + count(markup, "face tilted") + count(markup, "face top")).to.eq(4) + expect(count(markup, "finger")).to.be.greaterThan(20) + expect(markup).to.contain(">5 in<").and.contain(">4 in<").and.contain(">6 in<").and.contain(">1 in<").and.contain(">45°<") + expect(viewBox.split(" ").map(Number).every(Number.isFinite)).to.eq(true) + }) + + it("lifts the tilted panel off for a plain lid", () => { + expect(draw({ lid: "plain" }).markup).to.contain('class="inside floor"') + expect(draw({ lid: "full" }).markup).not.to.contain('class="inside floor"') + }) + + it("leaves out a strip of zero size", () => { + const { markup } = draw({ lid: "full", frontHeight: 0, slope: (Math.atan(4 / 6) * 180) / Math.PI }) + expect(count(markup, "face left") + count(markup, "face top")).to.eq(0) + expect(markup).to.contain(">33.7°<") + }) + + it("draws a box in millimetres at the same size as in inches", () => { + const mm = { width: 127, height: 101.6, depth: 152.4, frontHeight: 25.4, thickness: 6.35, units: "mm" } + expect(draw({ ...mm, lid: "full" }).viewBox).to.eq(draw({ lid: "full" }).viewBox) + }) + + it("marks the dimension being edited", () => { + expect(count(draw({ lid: "full", hot: "slope" }).markup, "dim hot")).to.eq(1) + }) +}) From 6f741e5e6617937cc85e668c2ef9ad9dcb4e6df5 Mon Sep 17 00:00:00 2001 From: Konstantin Gredeskoul Date: Wed, 2 Dec 2026 01:04:19 -0800 Subject: [PATCH 2/5] Update laser-cutter to 3.0 and Puma to 7 --- Gemfile | 6 +- Gemfile.lock | 429 ++++++++++++++++++++++++++------------------------- 2 files changed, 225 insertions(+), 210 deletions(-) diff --git a/Gemfile b/Gemfile index d6d01fa..7325bfb 100644 --- a/Gemfile +++ b/Gemfile @@ -13,13 +13,13 @@ group :default do gem 'haml' gem 'importmap-rails' gem 'redis' - # Lids are merged but not on RubyGems yet; once 2.0.1 is released, go back to '~> 2.0', '>= 2.0.1'. - gem 'laser-cutter' + # 3.0 draws the sloped box (slope, front_height) and every lid. + gem 'laser-cutter', '~> 3.0' gem 'lograge' gem 'matrix' gem 'newrelic_rpm' gem 'propshaft' - gem 'puma', '~> 6' + gem 'puma', '~> 7' gem 'rack-timeout', require: 'rack/timeout/base' gem 'rails', '~> 8.1' gem 'sdoc', group: :doc diff --git a/Gemfile.lock b/Gemfile.lock index ad8783c..fd543bf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,29 +3,29 @@ GEM specs: action_text-trix (2.1.19) railties - actioncable (8.1.4) - actionpack (= 8.1.4) - activesupport (= 8.1.4) + actioncable (8.1.4.1) + actionpack (= 8.1.4.1) + activesupport (= 8.1.4.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (8.1.4) - actionpack (= 8.1.4) - activejob (= 8.1.4) - activerecord (= 8.1.4) - activestorage (= 8.1.4) - activesupport (= 8.1.4) + actionmailbox (8.1.4.1) + actionpack (= 8.1.4.1) + activejob (= 8.1.4.1) + activerecord (= 8.1.4.1) + activestorage (= 8.1.4.1) + activesupport (= 8.1.4.1) mail (>= 2.8.0) - actionmailer (8.1.4) - actionpack (= 8.1.4) - actionview (= 8.1.4) - activejob (= 8.1.4) - activesupport (= 8.1.4) + actionmailer (8.1.4.1) + actionpack (= 8.1.4.1) + actionview (= 8.1.4.1) + activejob (= 8.1.4.1) + activesupport (= 8.1.4.1) mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (8.1.4) - actionview (= 8.1.4) - activesupport (= 8.1.4) + actionpack (8.1.4.1) + actionview (= 8.1.4.1) + activesupport (= 8.1.4.1) nokogiri (>= 1.8.5) rack (>= 2.2.4) rack-session (>= 1.0.1) @@ -33,36 +33,36 @@ GEM rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) useragent (~> 0.16) - actiontext (8.1.4) + actiontext (8.1.4.1) action_text-trix (~> 2.1.15) - actionpack (= 8.1.4) - activerecord (= 8.1.4) - activestorage (= 8.1.4) - activesupport (= 8.1.4) + actionpack (= 8.1.4.1) + activerecord (= 8.1.4.1) + activestorage (= 8.1.4.1) + activesupport (= 8.1.4.1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (8.1.4) - activesupport (= 8.1.4) + actionview (8.1.4.1) + activesupport (= 8.1.4.1) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) - rails-html-sanitizer (~> 1.6) - activejob (8.1.4) - activesupport (= 8.1.4) + rails-html-sanitizer (~> 1.6, >= 1.7.2) + activejob (8.1.4.1) + activesupport (= 8.1.4.1) globalid (>= 0.3.6) - activemodel (8.1.4) - activesupport (= 8.1.4) - activerecord (8.1.4) - activemodel (= 8.1.4) - activesupport (= 8.1.4) + activemodel (8.1.4.1) + activesupport (= 8.1.4.1) + activerecord (8.1.4.1) + activemodel (= 8.1.4.1) + activesupport (= 8.1.4.1) timeout (>= 0.4.0) - activestorage (8.1.4) - actionpack (= 8.1.4) - activejob (= 8.1.4) - activerecord (= 8.1.4) - activesupport (= 8.1.4) + activestorage (8.1.4.1) + actionpack (= 8.1.4.1) + activejob (= 8.1.4.1) + activerecord (= 8.1.4.1) + activesupport (= 8.1.4.1) marcel (~> 1.0) - activesupport (8.1.4) + activesupport (8.1.4.1) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.3.1) @@ -87,7 +87,7 @@ GEM bigdecimal (3.3.1) binding_of_caller (2.0.0) debug_inspector (>= 1.2.0) - bootsnap (1.26.0) + bootsnap (1.26.2) msgpack (~> 1.5) builder (3.3.0) capistrano (3.20.1) @@ -118,10 +118,10 @@ GEM commander (5.0.0) highline (~> 3.0.0) concurrent-ruby (1.3.8) - connection_pool (3.0.2) + connection_pool (3.0.3) coverage-badge (0.1.1) - crass (1.0.7) - dalli (5.2.2) + crass (1.0.9) + dalli (5.4.0) logger date (3.6.0) debug_inspector (1.2.0) @@ -154,7 +154,7 @@ GEM logger zeitwerk (~> 2.6) dry-inflector (1.3.1) - dry-logic (1.6.0) + dry-logic (1.6.1) bigdecimal concurrent-ruby (~> 1.0) dry-core (~> 1.1) @@ -164,7 +164,7 @@ GEM dry-types (~> 1.8, >= 1.8.2) ice_nine (~> 0.11) zeitwerk (~> 2.6) - dry-types (1.9.1) + dry-types (1.9.2) bigdecimal (>= 3.0) concurrent-ruby (~> 1.0) dry-core (~> 1.0) @@ -176,12 +176,12 @@ GEM erubi (1.13.1) globalid (1.4.0) activesupport (>= 6.1) - haml (7.5.1) + haml (7.5.2) prism (>= 1.1.0) temple (>= 0.8.2) thor tilt - hashie (5.1.0) + hashie (6.0.0) logger highline (3.0.1) i18n (1.15.2) @@ -191,22 +191,22 @@ GEM actionpack (>= 6.0.0) activesupport (>= 6.0.0) railties (>= 6.0.0) - io-console (0.9.4) - irb (1.18.0) + io-console (0.9.5) + irb (1.19.0) pp (>= 0.6.0) prism (>= 1.3.0) rdoc (>= 4.0.0) reline (>= 0.4.2) - jaro_winkler (1.7.0) - json (3.0.2) - kramdown (2.5.2) + jaro_winkler (1.7.1) + json (3.2.0) + kramdown (2.6.1) rexml (>= 3.4.4) kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) language_server-protocol (3.17.0.6) - laser-cutter (2.0.1) + laser-cutter (3.0.0) dry-cli (~> 1.4.1) - dry-cli-autocomplete + dry-cli-autocomplete (~> 0.6) dry-cli-help dry-cli-ui dry-struct (~> 1.6) @@ -224,15 +224,15 @@ GEM zeitwerk lint_roller (1.1.0) logger (1.7.0) - lograge (0.15.1) + lograge (0.16.0) actionpack (>= 4) activesupport (>= 4) logger railties (>= 4) request_store (~> 1.0) - loofah (2.25.2) + loofah (2.25.3) crass (~> 1.0.2) - nokogiri (>= 1.12.0) + nokogiri (>= 1.19.5) mail (2.9.1) logger mini_mime (>= 0.1.1) @@ -243,48 +243,51 @@ GEM matrix (0.4.3) mini_mime (1.1.5) mini_portile2 (2.8.9) - minitest (6.0.6) + minitest (6.1.0) drb (~> 2.0) - prism (~> 1.5) + prism (>= 1.5, < 3) mry (0.78.0.0) rubocop (>= 0.41.0) - msgpack (1.8.5) - net-imap (0.6.7) + msgpack (1.8.7) + net-imap (0.6.8) date net-protocol net-pop (0.1.2) net-protocol net-protocol (0.4.0) timeout - net-scp (4.1.0) - net-ssh (>= 2.6.5, < 8.0.0) - net-sftp (4.0.0) - net-ssh (>= 5.0.0, < 8.0.0) + net-scp (4.2.2) + net-ssh (>= 2.6.5, < 9.0.0) + net-sftp (4.2.0) + net-ssh (>= 5.0.0, < 9.0.0) net-smtp (0.5.2) net-protocol - net-ssh (7.3.6) + net-ssh (8.2.0) + logger + openssl (>= 3.2.0) newrelic_rpm (10.9.1) logger nio4r (2.7.5) - nokogiri (1.19.4) + nokogiri (1.19.7) mini_portile2 (~> 2.8.2) racc (~> 1.4) - nokogiri (1.19.4-aarch64-linux-gnu) + nokogiri (1.19.7-aarch64-linux-gnu) racc (~> 1.4) - nokogiri (1.19.4-aarch64-linux-musl) + nokogiri (1.19.7-aarch64-linux-musl) racc (~> 1.4) - nokogiri (1.19.4-arm-linux-gnu) + nokogiri (1.19.7-arm-linux-gnu) racc (~> 1.4) - nokogiri (1.19.4-arm-linux-musl) + nokogiri (1.19.7-arm-linux-musl) racc (~> 1.4) - nokogiri (1.19.4-arm64-darwin) + nokogiri (1.19.7-arm64-darwin) racc (~> 1.4) - nokogiri (1.19.4-x86_64-linux-gnu) + nokogiri (1.19.7-x86_64-linux-gnu) racc (~> 1.4) - nokogiri (1.19.4-x86_64-linux-musl) + nokogiri (1.19.7-x86_64-linux-musl) racc (~> 1.4) observer (0.1.2) open3 (0.2.1) + openssl (4.0.2) ostruct (0.6.3) parallel (2.3.0) parlour (9.1.2) @@ -292,7 +295,7 @@ GEM parser rainbow (~> 3.0) sorbet-runtime (>= 0.5) - parser (3.3.12.0) + parser (3.3.14.0) ast (~> 2.4.1) racc pastel (0.8.0) @@ -305,50 +308,54 @@ GEM pdf-core (~> 0.10.0) ttfunk (~> 1.8) prettyprint (0.2.1) - prism (1.9.0) + prism (2.1.0) + prism (2.1.0-aarch64-linux-gnu) + prism (2.1.0-aarch64-linux-musl) + prism (2.1.0-arm-linux-gnu) + prism (2.1.0-arm-linux-musl) + prism (2.1.0-arm64-darwin) + prism (2.1.0-x86_64-linux-gnu) + prism (2.1.0-x86_64-linux-musl) propshaft (1.3.2) actionpack (>= 7.0.0) activesupport (>= 7.0.0) rack - psych (5.5.0) - date - stringio - puma (6.6.1) + puma (7.2.4) nio4r (~> 2.0) racc (1.8.1) - rack (3.2.7) + rack (3.2.9) rack-session (2.1.2) base64 (>= 0.1.0) rack (>= 3.0.0) - rack-test (2.2.0) + rack-test (2.3.0) rack (>= 1.3) rack-timeout (0.7.0) rackup (2.3.1) rack (>= 3) - rails (8.1.4) - actioncable (= 8.1.4) - actionmailbox (= 8.1.4) - actionmailer (= 8.1.4) - actionpack (= 8.1.4) - actiontext (= 8.1.4) - actionview (= 8.1.4) - activejob (= 8.1.4) - activemodel (= 8.1.4) - activerecord (= 8.1.4) - activestorage (= 8.1.4) - activesupport (= 8.1.4) + rails (8.1.4.1) + actioncable (= 8.1.4.1) + actionmailbox (= 8.1.4.1) + actionmailer (= 8.1.4.1) + actionpack (= 8.1.4.1) + actiontext (= 8.1.4.1) + actionview (= 8.1.4.1) + activejob (= 8.1.4.1) + activemodel (= 8.1.4.1) + activerecord (= 8.1.4.1) + activestorage (= 8.1.4.1) + activesupport (= 8.1.4.1) bundler (>= 1.15.0) - railties (= 8.1.4) + railties (= 8.1.4.1) rails-dom-testing (2.3.0) activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.7.1) - loofah (~> 2.25, >= 2.25.2) + rails-html-sanitizer (1.7.2) + loofah (~> 2.25, >= 2.25.3) nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) - railties (8.1.4) - actionpack (= 8.1.4) - activesupport (= 8.1.4) + railties (8.1.4.1) + actionpack (= 8.1.4.1) + activesupport (= 8.1.4.1) irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) @@ -361,39 +368,40 @@ GEM logger prism (>= 1.6.0) tsort - rdoc (7.2.0) + rdoc (8.1.0) erb - psych (>= 4.0.0) + prism (>= 1.6.0) + rbs (>= 4.0.0) tsort - redis (6.0.0) - redis-client (= 0.30.1) - redis-client (0.30.1) + redis (6.1.1) + redis-client (= 0.31.0) + redis-client (0.31.0) connection_pool - regexp_parser (2.13.1) + regexp_parser (2.13.4) relaxed-rubocop (2.5) reline (0.7.0) io-console (~> 0.5) request_store (1.7.0) rack (>= 1.4) - reverse_markdown (3.0.2) + reverse_markdown (3.1.0) nokogiri rexml (3.4.4) rspec (3.13.2) rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) rspec-mocks (~> 3.13.0) - rspec-core (3.13.6) + rspec-core (3.13.7) rspec-support (~> 3.13.0) - rspec-expectations (3.13.5) + rspec-expectations (3.13.6) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-its (2.0.0) rspec-core (>= 3.13.0) rspec-expectations (>= 3.13.0) - rspec-mocks (3.13.8) + rspec-mocks (3.13.9) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-rails (8.0.4) + rspec-rails (8.1.0) actionpack (>= 7.2) activesupport (>= 7.2) railties (>= 7.2) @@ -404,21 +412,23 @@ GEM rspec-rake (0.0.4) rake rspec-core - rspec-support (3.13.7) - rubocop (1.91.0) + rspec-support (3.13.8) + rubocop (1.93.0) json (>= 2.3) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.1.0) parallel (>= 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 2.9.3, < 3.0) - rubocop-ast (>= 1.49.0, < 2.0) + regexp_parser (>= 2.11.3, < 3.0) + rubocop-ast (>= 1.54.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 4.0) - rubocop-ast (1.50.0) + rubocop-ast (1.54.0) + ast (~> 2.4) parser (>= 3.3.7.2) - prism (~> 1.7) + prism (>= 1.7) + racc rubocop-rails (2.38.0) activesupport (>= 4.2.0) lint_roller (~> 1.1) @@ -428,18 +438,18 @@ GEM rubocop-rake (0.7.1) lint_roller (~> 1.1) rubocop (>= 1.72.1) - rubocop-rspec (3.10.2) + rubocop-rspec (3.11.0) lint_roller (~> 1.1) - regexp_parser (>= 2.0) - rubocop (~> 1.86, >= 1.86.2) + rubocop (~> 1.92) ruby-progressbar (1.13.0) rufo (0.18.2) sdoc (2.6.5) rdoc (>= 5.0) securerandom (0.4.1) - semantic_logger (5.1.0) + semantic_logger (5.4.0) concurrent-ruby (~> 1.0) - sidekiq (8.1.7) + logger (~> 1.5) + sidekiq (8.1.8) connection_pool (>= 3.0.0) json (>= 2.16.0) logger (>= 1.7.0) @@ -447,7 +457,7 @@ GEM redis-client (>= 0.29.0) simplecov (1.3.2) slop (4.10.1) - solargraph (0.61.0) + solargraph (0.62.2) ast (~> 2.4.3) backport (~> 1.2) benchmark (~> 0.4) @@ -461,9 +471,9 @@ GEM open3 (~> 0.2.1) ostruct (~> 0.6) parser (~> 3.0) - prism (~> 1.4) + prism (~> 2.1) rbs (>= 3.10.4) - rdoc (~> 7.0) + rdoc (>= 7.2) reverse_markdown (~> 3.0) rubocop (~> 1.76) sord (~> 7.0) @@ -472,7 +482,7 @@ GEM yard (~> 0.9, >= 0.9.24) yard-activesupport-concern (~> 0.0) yard-solargraph (~> 0.1) - sorbet-runtime (0.6.13544) + sorbet-runtime (0.6.13737) sord (7.1.0) commander (~> 5.0) parlour (~> 9.1) @@ -489,7 +499,6 @@ GEM ostruct stimulus-rails (1.3.4) railties (>= 6.0.0) - stringio (3.2.0) strings (0.2.1) strings-ansi (~> 0.2) unicode-display_width (>= 1.5, < 3.0) @@ -503,7 +512,7 @@ GEM slop (~> 4.3) temple (0.10.7) thor (1.5.0) - tilt (2.9.0) + tilt (2.10.0) timeout (0.6.1) tsort (0.2.0) ttfunk (1.8.0) @@ -535,19 +544,19 @@ GEM tty-screen (~> 0.8) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - tzinfo-data (1.2026.5) + tzinfo-data (1.2026.6) tzinfo (>= 1.0.0) unicode-display_width (2.6.0) unicode_utils (1.4.0) uri (1.1.2) useragent (0.16.11) victor (0.5.0) - websocket-driver (0.8.2) + websocket-driver (0.9.2) base64 - websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.5) + websocket-extensions (>= 0.2.0) + websocket-extensions (0.3.0) wisper (2.0.1) - yard (0.9.45) + yard (0.9.46) yard-activesupport-concern (0.0.1) yard (>= 0.8) yard-rspec (0.1) @@ -585,13 +594,13 @@ DEPENDENCIES ed25519 haml importmap-rails - laser-cutter + laser-cutter (~> 3.0) lograge matrix mry newrelic_rpm propshaft - puma (~> 6) + puma (~> 7) rack-timeout rails (~> 8.1) redis @@ -617,17 +626,17 @@ DEPENDENCIES CHECKSUMS action_text-trix (2.1.19) sha256=7012f59421009cf284aa651294896414d653a61a2417c9b8714c8476d2f74009 - actioncable (8.1.4) sha256=cfcd72f8c861e01ccdc96d772ad8c5ad6ed0ea7c571aef81a794b6027eaa7f11 - actionmailbox (8.1.4) sha256=9c4525e577ebb671ce558f3ea78b8a634f64e56a0e6e8d105b28b873793a06eb - actionmailer (8.1.4) sha256=f82d95d6762ae46ea38f221d3363639266af4f8e56d50e2bd367558674baf093 - actionpack (8.1.4) sha256=245493cc51be195a7645e6fc184880fa7e5b32ff1a08e053ee31f58c76e30ea4 - actiontext (8.1.4) sha256=33ee99bea7da6af911fc7d98b17013a8e1ec62aa01b20b20e9a5366f40dbf644 - actionview (8.1.4) sha256=eff1efd07c4d969abad288322b423bcb67fdbab5e324c91ca37352b80f226076 - activejob (8.1.4) sha256=4ed5b2ed8d4cc5c8f5f09becfef8346f202a4884eee0c8c73cae5ac378824099 - activemodel (8.1.4) sha256=9a0906c127bd118aa5f06157db12b8f750da83dccee72db2f658547a0ae7a0e8 - activerecord (8.1.4) sha256=3b4957ea7f246c9231bd7faa909312eac03a9101aaf87977b6c52733ff00b04f - activestorage (8.1.4) sha256=f4956f3ec9ee63e5e0b332b57c877cb627f82b56f4cc902279310d2aa285c7a8 - activesupport (8.1.4) sha256=891dd3fe43c4fc8391934b237b1189bb1f661c932a84a840043db9d46a4e80df + actioncable (8.1.4.1) sha256=007670f7297973e94809e9f32a56624a7aa60b6e9d6696cd078064ce86d1c7fc + actionmailbox (8.1.4.1) sha256=18b43dd842bf3a3e31b8e38b7917c21e48c128fc8b263c893481cc66ee1a8f78 + actionmailer (8.1.4.1) sha256=a7b71dedf744e48dd6751e97350634edce9a2f7beeceac332dcccb91729ad066 + actionpack (8.1.4.1) sha256=8c6f2e7cbd2653ef0539bde1ff20eb3e2e264e366affe56f0ba7f06d3670cb4b + actiontext (8.1.4.1) sha256=fb59611dc16e2b6bbfcec66793acfae6cdd64b1e35ef3f9175424f31e62c38da + actionview (8.1.4.1) sha256=d25b4d9cf8d0c0195ffcfe8b2cf3fcbe6fea54fd7c17f1a9cb8182881463f12b + activejob (8.1.4.1) sha256=82c4c9311ea1016d5f7f134a0c5f9b6527cad5a6237f5f3f60aa17984ef36229 + activemodel (8.1.4.1) sha256=063caf105372fbc98b2d789e4be23de63ac5c043f7d9330f04e2caddb7012805 + activerecord (8.1.4.1) sha256=bd65599ca0b5d210937f835d42c7aff69d271741c75aab022730be6cbce67e87 + activestorage (8.1.4.1) sha256=0f4e2f114f3584723a80a2c089aacc6170e765a0b2c385c9782e26ed78f05c66 + activesupport (8.1.4.1) sha256=16ac4f341ca65c85a1fcdb8ac73f68891aae9e3c4a6f9c3a27daed8b00017ed7 airbrussh (1.6.2) sha256=3278655b2d957d774589a17e01496149288cbd8f1158b377581d82db006401cc asciidoctor (2.0.26) sha256=16e3accf1fc206bbd6335848649d7fd65f31d2daa60d85af13d47a8ee4b071c1 ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383 @@ -638,7 +647,7 @@ CHECKSUMS benchmark (0.5.0) sha256=465df122341aedcb81a2a24b4d3bd19b6c67c1530713fd533f3ff034e419236c bigdecimal (3.3.1) sha256=eaa01e228be54c4f9f53bf3cc34fe3d5e845c31963e7fcc5bedb05a4e7d52218 binding_of_caller (2.0.0) sha256=e53eebf8428a85587aede7b43a83e7419eb85b8b690938a96aa330d03052d517 - bootsnap (1.26.0) sha256=ca96237015e6cd74a02963d5821cf00ac5ea134653b323e8cd6d702a7718bf1b + bootsnap (1.26.2) sha256=f0d749dcda6bf5e3d324bc7e126009b2127d2b83db74273d8ded3b4c8e322bb7 builder (3.3.0) sha256=497918d2f9dca528fdca4b88d84e4ef4387256d984b8154e9d5d3fe5a9c8835f bundler (4.1.0.beta1) sha256=8a2dac8ca276ff4eff5efc2c6457b0044080fc1e431534ad7c5cc6187232b800 capistrano (3.20.1) sha256=b0d54ba5cf49bb194998bf6b427e889aa36ed05f545ecf7cc37acb9d529e9ae9 @@ -652,10 +661,10 @@ CHECKSUMS colored2 (3.1.2) sha256=b13c2bd7eeae2cf7356a62501d398e72fde78780bd26aec6a979578293c28b4a commander (5.0.0) sha256=22ca42866ce5ed1a7f3e9a9c831a23d03b75b3743c7ad0302c3cbcd9eb5f257d concurrent-ruby (1.3.8) sha256=b2f1be836e968ccc78ccfce277ea79c72a88633f22306782c16ff23fb415d1e1 - connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a + connection_pool (3.0.3) sha256=e0f8ee3ee0039396753e06e8a2dde0ef028e40f7df29e97f57da7577c489cb5e coverage-badge (0.1.1) sha256=f4ada4edadfa98cd99a50ab49f04ffc1af926e9f00513a063b774bd683eda131 - crass (1.0.7) sha256=94868719948664c89ddcaf0a37c65048413dfcb1c869470a5f7a7ceb5390b295 - dalli (5.2.2) sha256=23ad7dd2891525b720be39a550eba144bebebfe807d3d51b4582be2997d63f73 + crass (1.0.9) sha256=5d39d4246b0b2d42abf3af08dde783c0d1015d3e7dbec0e764bbf0c61baa215c + dalli (5.4.0) sha256=8b014bc2557d8868d0362144329bc060d32925e0e7a999430d6f8bb7e57d54f7 date (3.6.0) sha256=18ac945c4e24ebd93534f8eab8c2fd8c5604b3e977105b3798d62a1e8d27b580 debug_inspector (1.2.0) sha256=9bdfa02eebc3da163833e6a89b154084232f5766087e59573b70521c77ea68a2 diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962 @@ -666,126 +675,132 @@ CHECKSUMS dry-cli-ui (0.7.0) sha256=2efc8570a0dbe8c0c6e31f2767ce18ca14d7ca639301206ef100adc69282c51d dry-core (1.2.0) sha256=0cc5a7da88df397f153947eeeae42e876e999c1e30900f3c536fb173854e96a1 dry-inflector (1.3.1) sha256=7fb0c2bb04f67638f25c52e7ba39ab435d922a3a5c3cd196120f63accb682dcc - dry-logic (1.6.0) sha256=da6fedbc0f90fc41f9b0cc7e6f05f5d529d1efaef6c8dcc8e0733f685745cea2 + dry-logic (1.6.1) sha256=3cea14d2108b62f1a99d20b993dff3a5c365136a3995202fd33d9a163baedd31 dry-struct (1.8.1) sha256=033868594c45241540172bf1ebbc8bb76b72b4f0717072325deba38ac13e80f1 - dry-types (1.9.1) sha256=baebeecdb9f8395d6c9d227b62011279440943e3ef2468fe8ccc1ba11467f178 + dry-types (1.9.2) sha256=c52d3d6bdb0269fc299c44a7d9d5fcd736a63b393e2459b38728d9736b7df164 ed25519 (1.4.0) sha256=16e97f5198689a154247169f3453ef4cfd3f7a47481fde0ae33206cdfdcac506 erb (6.0.7) sha256=c5ca6dc25b0ef974a44dc8f59fe847577122483b1968a38dec305c60bf91ee92 erubi (1.13.1) sha256=a082103b0885dbc5ecf1172fede897f9ebdb745a4b97a5e8dc63953db1ee4ad9 globalid (1.4.0) sha256=037f12fbf1d9d7a014d501c2d5c77356fd4ddd96d7a7991d6700bba96706f427 - haml (7.5.1) sha256=91c5843dd85d32042cc6218d2df8c81282403459958aa53caa58fda238adc287 - hashie (5.1.0) sha256=c266471896f323c446ea8207f8ffac985d2718df0a0ba98651a3057096ca3870 + haml (7.5.2) sha256=fcef494c3c5f173f5b38338b1ade7e65b1de37194919b901f047cac76f370d42 + hashie (6.0.0) sha256=0896391e9fc7a259bfe02abbb1a026b3e142e2f464e10255261d50a0eda18e3e highline (3.0.1) sha256=ca18b218fd581b1fae832f89bfeaf2b34d3a93429c44fd4411042ffce286f009 i18n (1.15.2) sha256=00f9eb62412fe593b2a65a97daa75300d37abb8f7202ec748e94b6d46a9dd1b5 ice_nine (0.11.2) sha256=5d506a7d2723d5592dc121b9928e4931742730131f22a1a37649df1c1e2e63db importmap-rails (2.2.3) sha256=7101be2a4dc97cf1558fb8f573a718404c5f6bcfe94f304bf1f39e444feeb16a - io-console (0.9.4) sha256=a403304f32928ee85e56d457b4612ca43f2703b561a3258844992bd24085fbb1 - irb (1.18.0) sha256=de9454a0703a54704b9811a5ef31a60c86949fbf4013fcf244fabc7c775248e3 - jaro_winkler (1.7.0) sha256=8daa05a5cd05bf7d27c1c65caa8ab0d47c05419d80210feaa17126db24044ada - json (3.0.2) sha256=8e6d7e7b11384c21230430cef90b71f14849a34a1f4452796670f7c981bd19df - kramdown (2.5.2) sha256=1ba542204c66b6f9111ff00dcc26075b95b220b07f2905d8261740c82f7f02fa + io-console (0.9.5) sha256=83dd9bbf4c4680416629245b39cd4212eb5f4d9a4ea91804870c1f6b846414d5 + irb (1.19.0) sha256=55ee56acbdd6c9fe06a2e6909f46a24e5c41f45f16906bab04e8049cf46f1d27 + jaro_winkler (1.7.1) sha256=190a7da5ebb001e1a7726dc939bfae59260d61162bd44f256fb48892533fec49 + json (3.2.0) sha256=4a4e222a9ee6ffb296ab3171b6b39d85fec83afc4e7b57eee17edf68c74aec87 + kramdown (2.6.1) sha256=fbef3479b69c875aacb118dde77a40d6cc3a91e2c1d505a4c3f3f9e92d142641 kramdown-parser-gfm (1.1.0) sha256=fb39745516427d2988543bf01fc4cf0ab1149476382393e0e9c48592f6581729 language_server-protocol (3.17.0.6) sha256=5ef2c0c138f8267e1bc631d3328347d354f96724b0af22f2c79516120443b7f0 - laser-cutter (2.0.1) sha256=207eace851339edaaf11b435c1ca8abb9fd316aef1b852d6370d9f9a54af5529 + laser-cutter (3.0.0) sha256=5efc9901b4966e3fa863afe6886b04de6c5b3bf021e964f6668c8f5e26dfe50b lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87 logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203 - lograge (0.15.1) sha256=b8a6b3d45f15855f3b038ce01019317e783fa9ddf774eb20818c751438c5c761 - loofah (2.25.2) sha256=2007f746959ac65552456e04b433e83deb22759ab38c838b4445c70e43425918 + lograge (0.16.0) sha256=32d5ed2352a356a765243cf37125a2f924f4c5b6363ee4e808a9ec0f84d06a91 + loofah (2.25.3) sha256=545f14eef0cc2a7de80df560530d593232b7c07e515c5c4e37532d9cb5b0185c mail (2.9.1) sha256=06574eca475253d6c18145dd70af80d0eb970182d55053497c5f4d797ea160e8 marcel (1.2.1) sha256=1678e9360e32f9eafa917c80029e2f6d10b2715c66a4b87b6d0da9b9cd1f859f matrix (0.4.3) sha256=a0d5ab7ddcc1973ff690ab361b67f359acbb16958d1dc072b8b956a286564c5b mini_mime (1.1.5) sha256=8681b7e2e4215f2a159f9400b5816d85e9d8c6c6b491e96a12797e798f8bccef mini_portile2 (2.8.9) sha256=0cd7c7f824e010c072e33f68bc02d85a00aeb6fce05bb4819c03dfd3c140c289 - minitest (6.0.6) sha256=153ea36d1d987a62942382b61075745042a2b3123b1cd48f4c3675af9cc7d6f1 + minitest (6.1.0) sha256=ff373595aa8888631e8a5463986a76b3845346ae6d7fa46e139c1633d418076e mry (0.78.0.0) sha256=9dd56c8342902f9078e8ce98e912af7f086405e04860744bdba7af1ea1537aba - msgpack (1.8.5) sha256=97419eaa7b35dfe3e462c0e6c1a3dfdcbfc8756605c09e46e4c6daef127517ba - net-imap (0.6.7) sha256=b5c9573be975d856de252ee851871724da66aa2d449b2482d5690bd12bc23660 + msgpack (1.8.7) sha256=dfefec761b5f9047e6e8d95d2c7f8af4b3725d984a01942adc533aa819a2df33 + net-imap (0.6.8) sha256=eb30bb62227b64a3af6b518b04b2375113d69f68f15de59b0193b07d98acf6d9 net-pop (0.1.2) sha256=848b4e982013c15b2f0382792268763b748cce91c9e91e36b0f27ed26420dff3 net-protocol (0.4.0) sha256=f9f90c8c6f64794a45160bf422177a336db12809de3beeeaa26b88fcd2e8c853 - net-scp (4.1.0) sha256=a99b0b92a1e5d360b0de4ffbf2dc0c91531502d3d4f56c28b0139a7c093d1a5d - net-sftp (4.0.0) sha256=65bb91c859c2f93b09826757af11b69af931a3a9155050f50d1b06d384526364 + net-scp (4.2.2) sha256=af26fa536fb1fe5a3e77e0095d00685eca58fa49c28968f4fabc52fea21d35a2 + net-sftp (4.2.0) sha256=e0499eee81bd098cb84e735c597e8fb04f5638b727b67211b2b747354567b77a net-smtp (0.5.2) sha256=35103cc04d6b2d94632f9928ede07483c24b70b9c0db1f231fea43909b678f3c - net-ssh (7.3.6) sha256=3364dedce752b9f5221e12ae970880d871a8e733e4730e4b9bd89e0b6808ce4b + net-ssh (8.2.0) sha256=9ccb5e49b007a7d0050980c708e3f178769edfe710379a5d92d32fa97eda31c3 newrelic_rpm (10.9.1) sha256=7a2c8f0bd6c3407f7d981999d46e0d5c39c53bee9ca737f0e083d3b6dcc8f0c3 nio4r (2.7.5) sha256=6c90168e48fb5f8e768419c93abb94ba2b892a1d0602cb06eef16d8b7df1dca1 - nokogiri (1.19.4) sha256=50c951611c92bca05c51411aef45f1cbc50f2821c4802758c5c6d34696533ab5 - nokogiri (1.19.4-aarch64-linux-gnu) sha256=1269fb644a6de405057a53dd5c762b1209b43ca7424f839454d3dbc677c31a8f - nokogiri (1.19.4-aarch64-linux-musl) sha256=35c65b9ce72b3bb03207bdbe7067915019dc18c1b9b59139684bd6690fdd01af - nokogiri (1.19.4-arm-linux-gnu) sha256=a301313e38bb065d68239e79734bcd6f56fb6efaacebde29e9abf2a4735340ca - nokogiri (1.19.4-arm-linux-musl) sha256=588923c101bcfa78869734d247d25b598674323e7f22474fc468f6e5647311eb - nokogiri (1.19.4-arm64-darwin) sha256=a46db9853286e6597b36ebc6953817d15acf3a299583eb3f89fdc6f91dd63527 - nokogiri (1.19.4-x86_64-linux-gnu) sha256=379fae440b28915e3f19d752ce2dcf8465ed2b2fbefd2a7ca0dd497bc981a06a - nokogiri (1.19.4-x86_64-linux-musl) sha256=17dfb7c1fa194ae02fbf7c51a7afc8d278045ab3fdacfd86f91d02d7b274470b + nokogiri (1.19.7) sha256=abe94507c54cb18f872777b16bdca4aad32b1abdc4c52fe843f1c80fbdf992b8 + nokogiri (1.19.7-aarch64-linux-gnu) sha256=8f5e15d299602456406e1f03a9f3456cceb33a0722811e818d2ee2214eb4c84a + nokogiri (1.19.7-aarch64-linux-musl) sha256=efe0c3602e6e54521bc21c681930ce5568e2d11203de17400710b2b3ca2e4cb4 + nokogiri (1.19.7-arm-linux-gnu) sha256=7fd1907125691aa89e838cc91161761c758b4e17bb32f0dd9b5515a82cc759af + nokogiri (1.19.7-arm-linux-musl) sha256=28d0ff0c87b6bb2e56580323a6fb049d5d4a02b94f0958fdd47e9ac146991c77 + nokogiri (1.19.7-arm64-darwin) sha256=f27d7f25f4873fbc3aa35a2cc2fb680c98555fec1925348da439d0869d541142 + nokogiri (1.19.7-x86_64-linux-gnu) sha256=25865ccb462f714e712fdf8906fde07849cb6704a808e3d629d75baa5af5dd3b + nokogiri (1.19.7-x86_64-linux-musl) sha256=464d1f3dfb0d53cf54c0c6a7e23e8e91cf68ec3cafc2b27dc4a7682f2d9bf546 observer (0.1.2) sha256=d8a3107131ba661138d748e7be3dbafc0d82e732fffba9fccb3d7829880950ac open3 (0.2.1) sha256=8e2d7d2113526351201438c1aa35c8139f0141c9e8913baa007c898973bf3952 + openssl (4.0.2) sha256=1037ad2868ae58df9ad917891c0c0f9815a1172f6846d4bcdd508e4c2ee747c2 ostruct (0.6.3) sha256=95a2ed4a4bd1d190784e666b47b2d3f078e4a9efda2fccf18f84ddc6538ed912 parallel (2.3.0) sha256=f75a3e904101ce6a1ccb6b8dc800cbafd42166d83330192438dcf29395167a6f parlour (9.1.2) sha256=446ce24243e125f0e8c4f9b5722c3b86063d42d8b106c847a7d73a8cc693c382 - parser (3.3.12.0) sha256=21a6d7f755d5a24dfbdc6e6b772e4e879a52e7631a88bc5a3a134606052c9828 + parser (3.3.14.0) sha256=62f8f76af7b919425ee2d811880e9dcb8011ab40bfd59970dfb583141697e58f pastel (0.8.0) sha256=481da9fb7d2f6e6b1a08faf11fa10363172dc40fd47848f096ae21209f805a75 pdf-core (0.10.0) sha256=0a5d101e2063c01e3f941e1ee47cbb97f1adfc1395b58372f4f65f1300f3ce91 pp (0.6.4) sha256=dfcb0fce700c41456265922884f9fe195d7fbb0674a3578e6c0f69588e82b570 prawn (2.5.0) sha256=f4e20e3b4f30bf5b9ae37dad15eb421831594553aa930b2391b0fa0a99c43cb6 prettyprint (0.2.1) sha256=d555d57ea6d7cf001d4774b693546a6bd88bec1e778ddffb5c60b68ceec4b7d4 - prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85 + prism (2.1.0) sha256=1c0a7c6dea0e93183390fb123f007564dbe663198e2f86ad87204151147601f3 + prism (2.1.0-aarch64-linux-gnu) sha256=808dddc72def68e1a0463689414c97e0ba211938eddbab05387a4844aa2b3ec2 + prism (2.1.0-aarch64-linux-musl) sha256=dd1a0732620c1e575dabb07a297a62911fabd72f8e20ce850b522a866f877930 + prism (2.1.0-arm-linux-gnu) sha256=96b2426b9dbab05448c4add735619929042be3cd7e871ff186468121b62bcfa8 + prism (2.1.0-arm-linux-musl) sha256=00ef918e42a3dc98f11a461bf473586a3424b0f78bee8a4e43b5a65a5f5e2cd0 + prism (2.1.0-arm64-darwin) sha256=2d0c2e3e011cfd89c041940907d3ff3def379d7b0f2ba158d1d42238e8ad8afc + prism (2.1.0-x86_64-linux-gnu) sha256=b2b647afce09551e650b8bb3e2fc91d7d73d392a09534ca307ec0d619c33bfd4 + prism (2.1.0-x86_64-linux-musl) sha256=249f45981726923e259b927902246219fa25ad10a76f43849c9aee1a3d3ec5b8 propshaft (1.3.2) sha256=1d56a3e56a92c21bfc29caf07406b5386b00d4c47ddf357cf989a5a234b1389e - psych (5.5.0) sha256=4b245bbbd0f3238df8ccee766ebc1a6b062b10e4ee1d3284eb588739ba156a0a - puma (6.6.1) sha256=b9b56e4a4ea75d1bfa6d9e1972ee2c9f43d0883f011826d914e8e37b3694ea1e + puma (7.2.4) sha256=abba6fb5d44354bb8dd904b34eb8f4071c23fffe3a9983dc49fd601a8e680ca3 racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f - rack (3.2.7) sha256=93e13e1c24f93556671d85d2d79fa228c3485815c50d7e2f265b5330c6528fb7 + rack (3.2.9) sha256=8235c1d08f0c461bedcff4413bbeba888173e5b09e1332ae951c98f0ee460dcc rack-session (2.1.2) sha256=595434f8c0c3473ae7d7ac56ecda6cc6dfd9d37c0b2b5255330aa1576967ffe8 - rack-test (2.2.0) sha256=005a36692c306ac0b4a9350355ee080fd09ddef1148a5f8b2ac636c720f5c463 + rack-test (2.3.0) sha256=b118d177cc002c572fc1b6fd8d19c9ed5881a36e8d6f689f9e618f9f861241e8 rack-timeout (0.7.0) sha256=757337e9793cca999bb73a61fe2a7d4280aa9eefbaf787ce3b98d860749c87d9 rackup (2.3.1) sha256=6c79c26753778e90983761d677a48937ee3192b3ffef6bc963c0950f94688868 - rails (8.1.4) sha256=5f3ecdf9a2a3b79b2e31b8fee3b64a00f7284d76e5631f87d0e58e665911a33b + rails (8.1.4.1) sha256=365c3a0ad2713bd6e60628e5e826622d4ca8dee60b5a7e560e9b20844e9650bc rails-dom-testing (2.3.0) sha256=8acc7953a7b911ca44588bf08737bc16719f431a1cc3091a292bca7317925c1d - rails-html-sanitizer (1.7.1) sha256=e797a7c9b01e567307e317c576b49ab4168017e63eea4dba9ce3cb587e2f22c2 - railties (8.1.4) sha256=b5e7a8e8984e33114d68af62227971960aae1e6c02bd7c9d826ffad97fff583c + rails-html-sanitizer (1.7.2) sha256=a21ef45b7a6639fc8e2282473c547514cb86ae271616162a946bf89148fa2424 + railties (8.1.4.1) sha256=ff2ef4b5a62cbc89811f88be11c776e2ed71b14dd012eae6a494d37994aa9782 rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a rake (13.4.2) sha256=cb825b2bd5f1f8e91ca37bddb4b9aaf345551b4731da62949be002fa89283701 rbs (4.2.0) sha256=51f7b886dcc05bc09e10b901daa6a81829f6adc03101d6ca9ea4aac6103e0674 - rdoc (7.2.0) sha256=8650f76cd4009c3b54955eb5d7e3a075c60a57276766ebf36f9085e8c9f23192 - redis (6.0.0) sha256=de71c10edd106986b759ec7ecdd08b63b9c0ee7414a0d0c1da73d31ba2bccda6 - redis-client (0.30.1) sha256=5151bc5c7bbfe48623732cdae3b900d8a22dc691cc7cdfacfb351ac55116522d - regexp_parser (2.13.1) sha256=5aedb6b7c35688f51e86eef17a15374dfd287c83f4ca644b2c5f3ec50a33b44b + rdoc (8.1.0) sha256=befc37880a5cfd36dcb176c748b5fd5ee39dd3536a75e81824e4972ce230f60a + redis (6.1.1) sha256=dd9c591a518c21ba42aa8d275dc7068d25dc4a352911280a644ec2abd0ebe573 + redis-client (0.31.0) sha256=6820cb2a21e6795a823141f50fd25e655de2b8dc8ff833b43509a27b0263fd75 + regexp_parser (2.13.4) sha256=1d0547814f57e6f00946957bd0ca201bc42f42cfb08eee89df60998aedcd8a3b relaxed-rubocop (2.5) sha256=70f4b95d7260a2e98df30d1519d81ca6eb2e315347bda103b43d34e450d12f50 reline (0.7.0) sha256=5b012d8e55dbf9d450f12bde2cf7d15ff546ae80b3f8f3b30e570d431815583d request_store (1.7.0) sha256=e1b75d5346a315f452242a68c937ef8e48b215b9453a77a6c0acdca2934c88cb - reverse_markdown (3.0.2) sha256=818ebb92ce39dbb1a291690dd1ec9a6d62530d4725296b17e9c8f668f9a5b8af + reverse_markdown (3.1.0) sha256=7fc569f3708a90ca3d6661e419d9d1233d57eef5a5b59eb1347c24e6a6b988a4 rexml (3.4.4) sha256=19e0a2c3425dfbf2d4fc1189747bdb2f849b6c5e74180401b15734bc97b5d142 rspec (3.13.2) sha256=206284a08ad798e61f86d7ca3e376718d52c0bc944626b2349266f239f820587 - rspec-core (3.13.6) sha256=a8823c6411667b60a8bca135364351dda34cd55e44ff94c4be4633b37d828b2d - rspec-expectations (3.13.5) sha256=33a4d3a1d95060aea4c94e9f237030a8f9eae5615e9bd85718fe3a09e4b58836 + rspec-core (3.13.7) sha256=c64ff16d9788119805cbc6a3f4b6d87cc22417c2d25976a3330de136896b5469 + rspec-expectations (3.13.6) sha256=bf538ca6d367ff5b0d85a87fdb5c0c6038f2cd1308a0eeba07476caa02d22f35 rspec-its (2.0.0) sha256=a88e8bc38149f2835e93533591ec4f5c829aacbfd41269a2e6f9f5b82f5260df - rspec-mocks (3.13.8) sha256=086ad3d3d17533f4237643de0b5c42f04b66348c28bf6b9c2d3f4a3b01af1d47 - rspec-rails (8.0.4) sha256=06235692fc0892683d3d34977e081db867434b3a24ae0dd0c6f3516bad4e22df + rspec-mocks (3.13.9) sha256=ea5c7ff3054a6098ca6039aacef80aec69d5a8a3ef80be8fc88337359b672a30 + rspec-rails (8.1.0) sha256=5e6c6a4e7f7d644b56e412d410824f6480c1e5a9c61b8448998236b4a4dbf3be rspec-rake (0.0.4) sha256=0a3f7e7685cd2f98f9c65c1c69c67b8ba3d737c6cb8cc3968670731aae86ab2f - rspec-support (3.13.7) sha256=0640e5570872aafefd79867901deeeeb40b0c9875a36b983d85f54fb7381c47c - rubocop (1.91.0) sha256=9c82b7bf391c5d7e3798c5b9996e22a1fe3bd7468e351dfdeb96140c058296d0 - rubocop-ast (1.50.0) sha256=b9ca88300da0803ee222ad20cdb30494c0a784eed06fdc35d254b06d662788db + rspec-support (3.13.8) sha256=e4160030309b7e3e9d9863dfe720a35dfcc577162f5402cd68fc8c5258a0ffd6 + rubocop (1.93.0) sha256=cb675628d17fe21dfab42f84848040ca2785c22ee4df41c888bfc404f3e74684 + rubocop-ast (1.54.0) sha256=11f7cadec54e593e905b1bb78f2b28bdd4b8e13b34cb82fe49c876e3dd5008c1 rubocop-rails (2.38.0) sha256=6e2b7c532efa95e3050371bec20b8f5b025662acead8bc70ee31f0e3e6fa2f06 rubocop-rake (0.7.1) sha256=3797f2b6810c3e9df7376c26d5f44f3475eda59eb1adc38e6f62ecf027cbae4d - rubocop-rspec (3.10.2) sha256=0b3e2ecc592cd10ecbf0095bb58d1e357905276e069643523cc19eb7495f65e2 + rubocop-rspec (3.11.0) sha256=3be37ecf0330634f4e53e0491ed71424daf004e33120bb6c7c5e17d67267c091 ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33 rufo (0.18.2) sha256=f279bea838aae7cd51149413a2dfa3383044b1c93f1469ceaddd1ca3824fc46f sdoc (2.6.5) sha256=7998b61c10775ee3179ccb0253774332d139e2c0649c251091f5868107a09b86 securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1 - semantic_logger (5.1.0) sha256=9a8170fc0212ad47ef29e0760219cf416cb5b9973061981733234f7148b6d6ea - sidekiq (8.1.7) sha256=91ad48c7e6c32e1846bf1d5b74c27948758049b93fed0cb539f8d586c7de3415 + semantic_logger (5.4.0) sha256=93039395bee1b7c39fccaf0290084a4293cb1fea174ca0b41c5c2cc3d0af1a29 + sidekiq (8.1.8) sha256=27cde03db00d3b683b75225733a37f9b6537ef8067e7b377e216e553d21f9104 simplecov (1.3.2) sha256=2a22ec1759f1b8db60881a2e038758956fc69ef93ed669be0bde0678de6d0e85 slop (4.10.1) sha256=844322b5ffcf17ed4815fdb173b04a20dd82b4fd93e3744c88c8fafea696d9c7 - solargraph (0.61.0) sha256=7fcc98d75bf5483b09ea07c86ba695486b9859c557574f7a6d26ec3009c9f138 - sorbet-runtime (0.6.13544) sha256=30c6d716f5771da7fe81d5c51b90fc027756de32fa8c9c75cd2c4a8103792f30 + solargraph (0.62.2) sha256=ef8e89ebadd5ad1f60ae31a04020e69a5faaeeded493d870f3af47e5802a03a7 + sorbet-runtime (0.6.13737) sha256=ee3fe1df7309068f5b1fb87947a0fd42c06e5289233a464c033a8ee0ce23dbc3 sord (7.1.0) sha256=e02fd59294da520e50cea80a07fb9bc93db709c552d055871379ae8d8e87601f sshkit (1.25.1) sha256=be3f10b9d6eb0b44d5eaba3f7cbe41bc6bb894bce4339688ac20124391455b78 stimulus-rails (1.3.4) sha256=765676ffa1f33af64ce026d26b48e8ffb2e0b94e0f50e9119e11d6107d67cb06 - stringio (3.2.0) sha256=c37cb2e58b4ffbd33fe5cd948c05934af997b36e0b6ca6fdf43afa234cf222e1 strings (0.2.1) sha256=933293b3c95cf85b81eb44b3cf673e3087661ba739bbadfeadf442083158d6fb strings-ansi (0.2.0) sha256=90262d760ea4a94cc2ae8d58205277a343409c288cbe7c29416b1826bd511c88 sym (3.0.2) sha256=1c4bfbab59297f75dcb85df1b9d389b41e73bf69903831718da0504313ff5231 temple (0.10.7) sha256=369fe560adb6534674ce232899c2232df614bcb29c5359b05efedff7a57ed9c0 thor (1.5.0) sha256=e3a9e55fe857e44859ce104a84675ab6e8cd59c650a49106a05f55f136425e73 - tilt (2.9.0) sha256=da5735d0280bba96e9a91041bb14aee435ccad5c17b0fa519249ae543d9aa3a5 + tilt (2.10.0) sha256=b8c832e193e7e1c70a05d1c7154702499982d383c510c89d53127be468bba4f7 timeout (0.6.1) sha256=78f57368a7e7bbadec56971f78a3f5ecbcfb59b7fcbb0a3ed6ddc08a5094accb tsort (0.2.0) sha256=9650a793f6859a43b6641671278f79cfead60ac714148aabe4e3f0060480089f ttfunk (1.8.0) sha256=a7cbc7e489cc46e979dde04d34b5b9e4f5c8f1ee5fc6b1a7be39b829919d20ca @@ -799,16 +814,16 @@ CHECKSUMS tty-spinner (0.9.3) sha256=0e036f047b4ffb61f2aa45f5a770ec00b4d04130531558a94bfc5b192b570542 tty-table (0.12.0) sha256=fdc27a4750835c1a16efe19a0b857e3ced3652cc7aceafe6dca94908965b9939 tzinfo (2.0.6) sha256=8daf828cc77bcf7d63b0e3bdb6caa47e2272dcfaf4fbfe46f8c3a9df087a829b - tzinfo-data (1.2026.5) sha256=0bdc3c5a540b1704f73a7b5c9be5c90bd0a5866c8e9e8e8a7885977d23a81645 + tzinfo-data (1.2026.6) sha256=fefda3d5a0f26730d7464f2853ceb021cb2eb1f1f504da2108ea1ce5d5309670 unicode-display_width (2.6.0) sha256=12279874bba6d5e4d2728cef814b19197dbb10d7a7837a869bab65da943b7f5a unicode_utils (1.4.0) sha256=b922d0cf2313b6b7136ada6645ce7154ffc86418ca07d53b058efe9eb72f2a40 uri (1.1.2) sha256=89292e98eabbef6248b0a0ed5e7e398e152f83f17560023a6d94a7f492b169fb useragent (0.16.11) sha256=700e6413ad4bb954bb63547fa098dddf7b0ebe75b40cc6f93b8d54255b173844 victor (0.5.0) sha256=de1a0dbe46683f95a332f13b83ec0790946bf906f55a2702d791ae3415dae83b - websocket-driver (0.8.2) sha256=97c556b019bf3410b4961002ac501621e9322d3f8a7bc02161a09301cc4c4146 - websocket-extensions (0.1.5) sha256=1c6ba63092cda343eb53fc657110c71c754c56484aad42578495227d717a8241 + websocket-driver (0.9.2) sha256=e209b7fc987347ece48aec8ef724f6281ae8d3c540bf018f2cfb84923339f576 + websocket-extensions (0.3.0) sha256=1492aabd79218294b564e67e9ee6a90abdac1a2981d35a49848bbc39754f0752 wisper (2.0.1) sha256=ce17bc5c3a166f241a2e6613848b025c8146fce2defba505920c1d1f3f88fae6 - yard (0.9.45) sha256=52e211493f7cb8a3ebf7e104a25a1e73937a3103092545d34cb88fafebb3dc51 + yard (0.9.46) sha256=9b1ee37b5da942811dc584d8bb2dfd0efca0a72c44be30bf8282c34955902855 yard-activesupport-concern (0.0.1) sha256=be790cb0efc23e2e87677063598ac8b743586154657bbd9655a7f03ce78390ef yard-rspec (0.1) sha256=f59e3070cdca303fa460f43ad7adbbffa0a6c5d6b79651b6d03fb87778815db5 yard-solargraph (0.1.0) sha256=a19a4619c942181a618fb9458970a9d2534cf7fda69fc43949629a7948a5930e From 7d3c9186a310a6b7e66ec126f4e180b29efabf66 Mon Sep 17 00:00:00 2001 From: Konstantin Gredeskoul Date: Wed, 2 Dec 2026 01:04:19 -0800 Subject: [PATCH 3/5] Draw a sloped box, ask before reset, fix panel layout --- .rubocop_todo.yml | 4 +- app/assets/stylesheets/generator.css | 75 +++++++-- app/assets/stylesheets/tokens.css | 1 + app/controllers/boxes_controller.rb | 2 +- app/controllers/home_controller.rb | 5 +- .../controllers/generator_controller.js | 117 ++++++++++++-- app/javascript/lib/iso_sloped_box.js | 4 +- app/javascript/lib/sloped_profile.js | 14 ++ app/models/box_request.rb | 44 ++++-- app/views/home/_generator.html.haml | 75 ++++++--- cypress/e2e/generator.cy.js | 144 +++++++++++++++++- cypress/e2e/lib.cy.js | 29 +++- docs/badges/coverage_badge.svg | 4 +- lib/makeabox/svg_renderer.rb | 2 +- spec/models/box_request_sloped_spec.rb | 64 ++++++++ spec/models/box_request_spec.rb | 28 +--- spec/requests/boxes_spec.rb | 14 ++ spec/requests/home_spec.rb | 13 -- 18 files changed, 524 insertions(+), 115 deletions(-) create mode 100644 spec/models/box_request_sloped_spec.rb diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ece75ea..f5e7cdb 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2026-10-10 00:10:32 UTC using RuboCop version 1.91.0. +# on 2026-12-02 05:27:22 UTC using RuboCop version 1.91.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -43,7 +43,7 @@ RSpec/ExampleLength: RSpec/MessageSpies: EnforcedStyle: receive -# Offense count: 42 +# Offense count: 47 RSpec/MultipleExpectations: Max: 4 diff --git a/app/assets/stylesheets/generator.css b/app/assets/stylesheets/generator.css index 2054d76..7945dad 100644 --- a/app/assets/stylesheets/generator.css +++ b/app/assets/stylesheets/generator.css @@ -45,12 +45,19 @@ .panel { position: relative; margin: 0; background: var(--panel); border-top: 3px solid var(--amber); border-bottom: 1px solid var(--rule); - display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.35fr) minmax(0, 1.2fr) minmax(0, 1.3fr) minmax(140px, 1.1fr); + /* The choices, the three sides, thickness, notch, Generate. */ + display: grid; grid-template-columns: minmax(max-content, 1.3fr) repeat(3, minmax(0, 1fr)) minmax(0, 1.35fr) minmax(0, 1.2fr) minmax(140px, 1.1fr); } -.hint { position: absolute; left: var(--gutter); bottom: calc(100% + 10px); margin: 0; font-size: 14px; color: var(--alarm); } +/* Why the box cannot be made: a bright red pill above the strip. */ +.hint { + position: absolute; left: var(--gutter); bottom: calc(100% + 10px); margin: 0; max-width: calc(100% - 2 * var(--gutter)); + padding: 6px 16px; border-radius: 99px; background: var(--error); color: #fff; font-size: 14px; font-weight: 700; line-height: 1.35; + box-shadow: 0 2px 10px rgb(0 0 0 / 0.35); +} +.hint:empty { display: none; } .field { position: relative; padding: 16px clamp(12px, 1.5vw, 22px) 14px; border-right: 1px solid var(--rule); display: grid; gap: 10px; align-content: start; } -.field > label { font-size: 13px; color: var(--mute); font-stretch: 110%; cursor: ew-resize; user-select: none; touch-action: none; display: flex; justify-content: space-between; gap: 8px; white-space: nowrap; overflow: hidden; } +.field > label { font-size: 13px; color: var(--mute); font-stretch: 110%; cursor: move; user-select: none; touch-action: none; display: flex; justify-content: space-between; gap: 8px; white-space: nowrap; overflow: hidden; } .field > label i { font-style: normal; opacity: 0; transition: opacity 0.15s; white-space: nowrap; } .field:hover > label i, .field:focus-within > label i { opacity: 0.7; } .num { display: flex; align-items: baseline; gap: 6px; } @@ -74,7 +81,24 @@ font-size: 13px; color: var(--soft); cursor: pointer; } .chips button:hover, .more:hover, .pick select:hover { border-color: var(--soft); } -.field .restart { justify-self: start; white-space: nowrap; } +/* Wraps to "Reset to / defaults" when the Width cell is too narrow for one line. */ +.field .restart { text-align: left; border-radius: 14px; } +.reset { position: relative; justify-self: start; } +/* Reset, and the Yes that carries it out, warn in red. */ +.field .restart:hover, .field .restart[aria-expanded="true"], .reset .yes:hover { color: var(--error); border-color: var(--error); } +/* The popup sits to the right of Reset, over the next cell, with a point towards the button. */ +.reset .confirm { + position: absolute; z-index: 5; left: calc(100% + 10px); top: 50%; transform: translateY(-50%); + display: flex; align-items: center; gap: 6px; white-space: nowrap; + padding: 6px 8px 6px 12px; border: 1px solid var(--edge); border-radius: 12px; + background: var(--sheet); box-shadow: 0 4px 16px rgb(0 0 0 / 0.45); font-size: 13px; color: var(--soft); +} +.reset .confirm[hidden] { display: none; } +.reset .confirm::before { + content: ""; position: absolute; left: -6px; top: 50%; width: 10px; height: 10px; + background: var(--sheet); border-left: 1px solid var(--edge); border-bottom: 1px solid var(--edge); + transform: translateY(-50%) rotate(45deg); +} .chips button[aria-pressed="true"] { background: var(--ink); color: var(--panel); border-color: var(--ink); } .side { padding: 14px clamp(12px, 1.5vw, 22px); border-right: 1px solid var(--rule); display: grid; gap: 8px; align-content: center; justify-items: start; } @@ -84,8 +108,17 @@ .seg input:checked + span { background: var(--ink); color: var(--panel); } .seg input:focus-visible + span { outline: 2px solid var(--amber); outline-offset: 2px; } .pick select { padding: 4px 10px; max-width: 100%; } +/* The column is as wide as its longest option; both dropdowns fill it, so they line up. */ +.side .pick { justify-self: stretch; } +.side .pick select { width: 100%; } .pick select option { background: var(--panel); color: var(--ink); } -.soon { color: var(--mute); font-size: 12.5px; line-height: 1.3; } + +/* The slope and front height of a sloped box: a row of its own under the strip, after Generate. */ +.sloped { grid-column: 1 / -1; order: 1; display: grid; grid-template-columns: subgrid; border-top: 1px solid var(--rule); } +.sloped[hidden] { display: none; } +/* A text input is twenty characters wide unless told otherwise; without this the Slope input would widen the choices column. */ +.sloped > .field { contain: inline-size; } +.sloped .note { grid-column: 3 / -1; margin: 0; padding: 16px clamp(12px, 1.5vw, 22px); align-self: center; max-width: 72ch; font-size: 13px; line-height: 1.4; color: var(--mute); } .go { background: var(--beam); color: #160a04; border: 0; cursor: pointer; @@ -102,14 +135,28 @@ /* As tall as the drawing needs and no taller, so no empty band above and below it. */ .stage { height: auto; min-height: 0; margin-top: 8px; } .stage svg { height: auto; max-height: 50vh; } - .panel { grid-template-columns: repeat(3, 1fr); } - .field.thickness { grid-column: span 2; } - .side, .go { grid-column: span 3; } - .field.thickness, .field.notch, .side, .go { border-top: 1px solid var(--rule); } - .side { grid-auto-flow: column; justify-content: start; align-items: center; gap: 10px 14px; grid-auto-flow: row; } + /* Twelve columns: three sides in fourths, then thickness and notch, with slope and front height between them. */ + .panel { grid-template-columns: repeat(12, minmax(0, 1fr)); } + .panel > .field { grid-column: span 4; } + .field.thickness { grid-column: span 8; } + .side, .go, .sloped .note { grid-column: 1 / -1; } + .sloped { display: contents; } + .sloped[hidden] { display: none; } + .sloped:not([hidden]) > .field, + .panel:has(.sloped:not([hidden])) .field.thickness, + .panel:has(.sloped:not([hidden])) .field.notch { grid-column: span 3; } + /* Every control comes before Generate. */ + .field.notch { order: 1; } + .sloped .note { order: 2; } + .go { order: 3; } + /* The choices come first, so every row under them gets a rule. */ + .panel > .field, .sloped > .field, .go { border-top: 1px solid var(--rule); } + /* Above the measurements, the choices sit in one line beside the units pill, wrapping only when there is no room. */ + .side { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; } + .side .pick select { width: auto; } .go { padding: 18px; } - .hint { position: static; grid-column: span 3; padding: 8px var(--gutter) 0; } - .hint:empty { display: none; } + .hint { position: static; grid-column: 1 / -1; justify-self: start; margin: 10px var(--gutter) 0; max-width: none; border-radius: 18px; } + .sloped .note { grid-column: 1 / -1; padding-top: 0; } } /* A phone-width Width cell only has room for "Reset". */ @@ -117,8 +164,8 @@ .field .restart .wide { display: none; } } -/* On a phone, a slim Generate bar sits above the controls instead of below them. */ +/* On a phone, Generate is a slim bar under the controls. */ @media (max-width: 640px) { - .go { order: -1; padding: 9px 14px; font-size: 18px; border-top: 0; } + .go { padding: 9px 14px; font-size: 18px; } .go small { display: none; } } diff --git a/app/assets/stylesheets/tokens.css b/app/assets/stylesheets/tokens.css index be64bab..a519fb7 100644 --- a/app/assets/stylesheets/tokens.css +++ b/app/assets/stylesheets/tokens.css @@ -37,6 +37,7 @@ --beam: #ff5a2b; /* the laser */ --amber: #ffb53d; /* the accent: headings, edges, whatever is being edited */ --alarm: #ff7a6b; + --error: #ff2020; /* the error pill */ --birch: #e2c48f; /* plywood */ --birch-light: #efd9aa; --birch-dark: #c4a269; diff --git a/app/controllers/boxes_controller.rb b/app/controllers/boxes_controller.rb index 96cf90d..be8d450 100644 --- a/app/controllers/boxes_controller.rb +++ b/app/controllers/boxes_controller.rb @@ -12,7 +12,7 @@ class BoxesController < ApplicationController # ActionController::Live's own thread, which Rack::Timeout never interrupts. RENDER_SECONDS = 20 - PERMITTED = (BoxRequest::DIMENSIONS + BoxRequest::OPTIONAL + %i[units page_size page_layout metadata lid]).freeze + PERMITTED = (BoxRequest::DIMENSIONS + BoxRequest::OPTIONAL + BoxRequest::SLOPED + %i[units page_size page_layout metadata lid]).freeze # Draws the SVG, reporting progress as it goes and sending the drawing last. def stream diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 6885f0d..ebea567 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -3,9 +3,8 @@ class HomeController < ApplicationController def index @settings = { - defaults: BoxRequest.defaults, - pageSizes: BoxRequest.page_sizes, - lidsSupported: BoxRequest.lids_supported? + defaults: BoxRequest.defaults, + pageSizes: BoxRequest.page_sizes } end end diff --git a/app/javascript/controllers/generator_controller.js b/app/javascript/controllers/generator_controller.js index 6e2133c..1a17ee1 100644 --- a/app/javascript/controllers/generator_controller.js +++ b/app/javascript/controllers/generator_controller.js @@ -1,5 +1,7 @@ import { Controller } from "@hotwired/stimulus" import { isoBox, tabCount } from "lib/iso_box" +import { isoSlopedBox } from "lib/iso_sloped_box" +import { slopedProfile, slopeProblem } from "lib/sloped_profile" import { load, trace } from "lib/laser_trace" const STORAGE_KEY = "makeabox:settings:v1" @@ -10,7 +12,10 @@ const STOCK = { in: [["1/8″", 0.125], ["3/16″", 0.1875], ["1/4″", 0.25]], mm: [["3 mm", 3], ["4.5 mm", 4.5], ["6 mm", 6]] } -const STEP = { in: { side: 0.25, thickness: 0.005, notch: 0.05 }, mm: { side: 5, thickness: 0.1, notch: 1 } } +const STEP = { in: { side: 0.25, thickness: 0.005, notch: 0.05, slope: 1 }, mm: { side: 5, thickness: 0.1, notch: 1, slope: 1 } } +// A sloped box starts at 45° from a front this share of the height. A sloped +// box has no lid with tabs along the back (BoxRequest::SLOPED_LIDS). +const SLOPE_START = { slope: 45, front: 0.4 } // The narrowest notch worth cutting. The widest is a third of the shortest // side; on a box too small for both, the narrowest is half the widest. Both // ends are rounded down to NOTCH_SCALE, exactly as BoxRequest does. @@ -27,8 +32,8 @@ const KERF_FIT = { green: ["About just right", "About just right"] } const KERF_STEP = { in: 0.0005, mm: 0.01 } -// What "Reset to defaults" under Width puts back, in inches. -const STARTING_BOX = { width: 5, height: 4, depth: 3, thickness: 0.125, kerf: 0.026 } +// What "Reset to defaults" under Width puts back, in inches, with a closed upright box. +const STARTING_BOX = { width: 5, height: 4, depth: 3, thickness: 0.25, kerf: 0.026 } const TRACE_MS = 1500 const clean = (number) => Number(number.toFixed(4)) @@ -49,7 +54,8 @@ const label = (key) => (key === "thickness" ? "Thickness" : key[0].toUpperCase() export default class extends Controller { static targets = ["preview", "form", "hint", "number", "unit", "chips", "range", "units", "lid", "settings", "optional", "pageSize", "go", "cut", "cutTitle", "cutMaterial", "drawing", "specs", "phase", "count", "bar", "download", - "kerfSlider", "kerfFit", "metadata"] + "kerfSlider", "kerfFit", "metadata", "shape", "sloped", "slope", "frontHeight", + "restart", "confirm"] static values = { settings: Object, streamUrl: String, downloadUrl: String, countUrl: String } connect() { @@ -88,15 +94,32 @@ export default class extends Controller { return query.toString() } + get sloped() { + return this.shapeTarget.value === "sloped" + } + problem() { for (const key of [...SIDES, "thickness"]) if (!(this.number(key) > 0)) return `${label(key)} needs a number above zero.` if (this.number("thickness") >= Math.min(...SIDES.map((key) => this.number(key)))) return "Thickness has to be smaller than the shortest side of the box." + const slope = this.slopeProblem() + if (slope) return slope if (this.notchProblem()) return `Notch length has to be between ${this.notchRange().join(" and ")} ${this.unit}, or blank to let makeabox choose.` const notches = tabCount(Math.max(...SIDES.map((key) => this.number(key))), this.number("notch") || 3 * this.number("thickness")) if (notches > MAX_NOTCHES) return `That is ${notches} notches along the longest side, and ${MAX_NOTCHES} is the most we draw. Use thicker material or a longer notch.` return "" } + slopeProblem() { + if (!this.sloped) return "" + return slopeProblem({ height: this.number("height"), depth: this.number("depth"), slope: parse(this.fields.slope), + frontHeight: parse(this.fields.front_height), lid: this.lidTarget.value, unit: this.unit }) + } + + get profile() { + return slopedProfile({ depth: this.number("depth"), height: this.number("height"), frontHeight: parse(this.fields.front_height), + slope: parse(this.fields.slope), thickness: this.number("thickness") }) + } + // [narrowest, widest] notch, the same numbers as BoxRequest#notch_range. notchRange() { const scale = NOTCH_SCALE[this.unit], down = (value) => Math.floor(value * scale + 1e-6) / scale @@ -116,7 +139,8 @@ export default class extends Controller { } clamp(key, value) { - const [low, high] = key === "notch" ? this.notchRange() : [this.step(key), Infinity] + const bounds = { notch: () => this.notchRange(), slope: () => [1, 89], front_height: () => [0, Math.max(0, this.number("height") - this.step(key))] } + const [low, high] = bounds[key]?.() ?? [this.step(key), Infinity] return clean(Math.min(high, Math.max(low, value))) } @@ -126,6 +150,17 @@ export default class extends Controller { this.refresh() } + // Upright or sloped. A sloped box starts from SLOPE_START, and swaps the + // lid with tabs along the back, which it cannot have, for the closed box. + reshape() { + if (this.sloped) { + if (this.slopeTarget.value === "") this.slopeTarget.value = SLOPE_START.slope + if (this.frontHeightTarget.value === "") this.frontHeightTarget.value = clean(this.number("height") * SLOPE_START.front) + if (this.lidTarget.value === "back") this.lidTarget.value = "full" + } + this.refresh() + } + focus(event) { this.hot = event.target.closest("[data-key]").dataset.key event.target.select() @@ -146,15 +181,17 @@ export default class extends Controller { this.refresh() } - // Dragging a label left or right changes its number. + // Dragging a label changes its number: right or up for more, left or down + // for less, by whichever way the pointer has moved further. scrub(event) { const label = event.currentTarget, key = label.closest("[data-key]").dataset.key, input = this.input(key) - const from = event.clientX, base = this.start(key) + const [fromX, fromY] = [event.clientX, event.clientY], base = this.start(key) event.preventDefault() label.setPointerCapture(event.pointerId) this.hot = key const move = (drag) => { - input.value = this.clamp(key, base + Math.round((drag.clientX - from) / 6) * this.step(key)) + const [dx, dy] = [drag.clientX - fromX, fromY - drag.clientY] + input.value = this.clamp(key, base + Math.round((Math.abs(dy) > Math.abs(dx) ? dy : dx) / 6) * this.step(key)) this.refresh() } label.addEventListener("pointermove", move) @@ -171,12 +208,41 @@ export default class extends Controller { this.refresh() } - // Back to a 5 × 4 × 3 in box of 1/8″ material with the default kerf. - // Everything else on the form is left as it is. + // Reset opens a popup that asks before the box is thrown away; a second click closes it. + ask() { + this.confirming(this.confirmTarget.hidden) + } + + // No, or Escape: close the popup and go back to Reset. + keep() { + if (this.confirmTarget.hidden) return + this.confirming(false) + this.restartTarget.focus() + } + + // A click anywhere outside Reset and its popup closes the popup. + dismiss(event) { + if (!this.confirmTarget.hidden && !event.target.closest(".reset")) this.confirming(false) + } + + // Opens or closes the popup. Open, No has the focus, so a stray Enter keeps the box. + confirming(open) { + this.confirmTarget.hidden = !open + this.restartTarget.setAttribute("aria-expanded", String(open)) + if (open) this.confirmTarget.querySelector(".no").focus() + } + + // Back to a closed, upright 5 × 4 × 3 in box of 1/4″ material with the default kerf. + // The slope fields are emptied, so a sloped front starts afresh. Everything + // else on the form is left as it is. restart() { + this.confirming(false) if (this.unit !== "in") this.pageSizeTarget.value = "" // a page size in mm has no match in inches this.unitsTargets.forEach((radio) => { radio.checked = radio.value === "in" }) for (const [key, value] of Object.entries(STARTING_BOX)) this.input(key).value = value + this.lidTarget.value = "full" + this.shapeTarget.value = "upright" + this.slopeTarget.value = this.frontHeightTarget.value = "" this.refresh() } @@ -191,7 +257,7 @@ export default class extends Controller { const to = event.target.value if (to === this.unit) return const factor = to === "mm" ? MM_PER_INCH : 1 / MM_PER_INCH, digits = to === "mm" ? 2 : 4 - for (const input of [...this.numberTargets, ...this.optionalTargets]) { + for (const input of [...this.numberTargets, ...this.optionalTargets, this.frontHeightTarget]) { const value = parse(input.value) if (Number.isFinite(value)) input.value = Number((value * factor).toFixed(digits)) } @@ -222,6 +288,7 @@ export default class extends Controller { reset() { try { localStorage.removeItem(STORAGE_KEY) } catch (error) { /* storage is optional */ } this.formTarget.reset() + this.slopeTarget.value = this.frontHeightTarget.value = "" this.unit = "in" this.refresh() } @@ -245,6 +312,7 @@ export default class extends Controller { }) this.pageSizes(unit) this.kerf(unit) + this.shapeFields() this.numberTargets.forEach((input) => input.closest(".field").classList.toggle("bad", !(parse(input.value) > 0))) this.rangeTarget.textContent = this.notchRange()[1] > 0 ? `${this.notchRange().join(" to ")} ${unit}` : "" this.rangeTarget.closest(".field").classList.toggle("bad", this.notchProblem()) @@ -290,6 +358,17 @@ export default class extends Controller { this.kerfFitTarget.dataset.zone = zone } + // Disabled fields are left out of the form, so an upright box sends no slope. + shapeFields() { + const sloped = this.sloped + this.slopedTarget.hidden = !sloped + this.slopeTarget.disabled = this.frontHeightTarget.disabled = !sloped + this.lidTarget.querySelector('option[value="back"]').disabled = sloped + const bad = (input) => input.closest(".field").classList.toggle("bad", sloped && !(parse(input.value) >= 0)) + bad(this.slopeTarget) + bad(this.frontHeightTarget) + } + pageSizes(unit) { const select = this.pageSizeTarget if (select.dataset.unit === unit) return @@ -303,10 +382,14 @@ export default class extends Controller { // so many notches that building the preview stalls the page. draw() { if (this.problem()) return - const { viewBox, markup } = isoBox({ + const box = { width: this.number("width"), height: this.number("height"), depth: this.number("depth"), thickness: this.number("thickness"), - notch: this.number("notch"), units: this.unit, lid: this.lidTarget.value, hot: this.hot - }) + notch: this.number("notch"), units: this.unit, lid: this.lidTarget.value, hot: this.hot === "front_height" ? "frontHeight" : this.hot + } + const profile = this.sloped && this.profile + const { viewBox, markup } = profile + ? isoSlopedBox({ ...box, frontHeight: parse(this.fields.front_height), slope: parse(this.fields.slope) }, profile, tabCount) + : isoBox(box) this.previewTarget.setAttribute("viewBox", viewBox) this.previewTarget.classList.toggle("hot-thickness", this.hot === "thickness" || this.hot === "notch") this.previewTarget.innerHTML = markup // numbers and fixed class names only, see iso_box.js @@ -323,6 +406,11 @@ export default class extends Controller { const unit = saved.units === "mm" ? "mm" : "in" this.unitsTargets.forEach((radio) => { radio.checked = radio.value === unit }) this.pageSizes(unit) // the saved page size needs its option to exist first + // Only a sloped box saves a slope: an upright one leaves the fields disabled. + if (saved.slope !== undefined) { + this.shapeTarget.value = "sloped" + this.shapeFields() + } for (const [key, value] of Object.entries(saved)) { if (key === "metadata") { this.metadataTarget.checked = value !== "0"; continue } const field = this.input(key) @@ -383,6 +471,7 @@ export default class extends Controller { this.cutMaterialTarget.textContent = `${this.number("thickness")} ${unit} material` const rows = [["Inside", `${sides} ${unit}`], ["Material", `${this.number("thickness")} ${unit}`], ["Notch length", tab], ["Top", this.lidTarget.selectedOptions[0].textContent], ["Page", this.pageSizeTarget.value || "fits the box"]] + if (this.sloped) rows.splice(1, 0, ["Front", `${parse(this.fields.front_height)} ${unit}, sloping back at ${parse(this.fields.slope)}°`]) this.specsTarget.replaceChildren(...rows.flatMap(([term, detail]) => { const dt = document.createElement("dt"), dd = document.createElement("dd") dt.textContent = term diff --git a/app/javascript/lib/iso_sloped_box.js b/app/javascript/lib/iso_sloped_box.js index 0e81b02..292f02a 100644 --- a/app/javascript/lib/iso_sloped_box.js +++ b/app/javascript/lib/iso_sloped_box.js @@ -83,7 +83,8 @@ export function isoSlopedBox(box, profile, tabCount) { if (open) { // The opening the tilted panel leaves, then the panel, lifted along its - // own normal, a slab one thickness deep. + // own normal, a slab one thickness deep. A plain lid lies on the side + // walls, so it has no tabs, and neither has the sloped edge under it. shape("inside floor", slope, [[0, 0], [W, 0], [W, S], [0, S]]) const lift = Math.max(0.35 * H, 0.18 * unit) const up = [0, sin * lift, cos * lift] @@ -91,7 +92,6 @@ export function isoSlopedBox(box, profile, tabCount) { const edge = lifted.o.map((c, i) => c + slope.v[i] * start) // the low edge of the lifted panel rect("face left", face(edge, [1, 0, 0], [0, -sin, -cos]), W, t) shape("face tilted", lifted, [[0, start], [W, start], [W, start + tilted], [0, start + tilted]]) - fingers(lifted, [W, start], [0, 1], [-1, 0], tilted, 0) } else { rect("face tilted", slope, W, S) fingers(slope, [W, start], [0, 1], [-1, 0], tilted, 0) diff --git a/app/javascript/lib/sloped_profile.js b/app/javascript/lib/sloped_profile.js index 89af235..cfb1062 100644 --- a/app/javascript/lib/sloped_profile.js +++ b/app/javascript/lib/sloped_profile.js @@ -46,3 +46,17 @@ export function slopedProfile({ depth: D, height: H, frontHeight: Hf, slope, thi } } } + +// Why a sloped box cannot be drawn, in the words BoxRequest#check_slope uses; +// "" when it can. slope and frontHeight may be NaN for a blank or bad field. +// { height, depth, slope, frontHeight, lid, unit } +export function slopeProblem({ height, depth, slope, frontHeight, lid, unit }) { + if (!(slope > 0 && slope < 90)) return "Slope needs an angle above 0 and below 90 degrees." + if (!(frontHeight >= 0)) return "Front height needs a number, zero or more." + if (frontHeight >= height) return "Front height has to be lower than the height of the box." + if (lid === "back") return "A sloped box cannot have the lid with tabs along the back." + const run = (height - frontHeight) / Math.tan((slope * Math.PI) / 180) + if (run <= depth + PRECISION) return "" + const round = (value) => Number(value.toFixed(2)) + return `At ${round(slope)}° the slope runs ${round(run)} ${unit} back, deeper than the box. Make the slope steeper, the front taller, or the box deeper.` +} diff --git a/app/models/box_request.rb b/app/models/box_request.rb index 2970fa7..b44a287 100644 --- a/app/models/box_request.rb +++ b/app/models/box_request.rb @@ -16,7 +16,13 @@ class BoxRequest # 'plain' is a rectangle that lies on top. The last two lift off.log LIDS = %w[full back plain].freeze - LABELS = { notch: 'Notch length' }.freeze + # A front that slopes back: the angle above horizontal, in degrees, and the + # inside height of the front where the slope begins. Both blank is the + # upright box. A sloped box cannot have the lid with tabs along the back. + SLOPED = %i[slope front_height].freeze + SLOPED_LIDS = %w[full plain].freeze + + LABELS = { notch: 'Notch length', front_height: 'Front height' }.freeze # The narrowest notch worth cutting, per unit. The widest is a third of the # shortest side. On a box too small for both, the narrowest drops to half @@ -34,12 +40,6 @@ class BoxRequest KERF_DEFAULT = { 'in' => 0.026, 'mm' => 0.66 }.freeze class << self - # laser-cutter 2.0.0 draws only the full lid. Releases that draw the - # others say so with Laser::Cutter::Box::LIDS. - def lids_supported? - Laser::Cutter::Box.const_defined?(:LIDS) - end - # @return [Hash] what the gem fills in when a field is left blank, per unit def defaults gem_defaults = Laser::Cutter::Configuration.defaults @@ -70,6 +70,7 @@ def valid? check_notch if errors.empty? check_notch_count if errors.empty? check_choices + check_slope if errors.empty? errors.empty? end @@ -81,10 +82,16 @@ def lid LIDS.include?(@params[:lid]) ? @params[:lid] : LIDS.first end + # @return [Boolean] whether the form asks for a front that slopes back + def sloped? + SLOPED.any? { |key| @params[key].present? } + end + # @return [String] a file name that says which box is inside def filename(format) size = DIMENSIONS.first(3).map { |key| trim(number(key)) }.join('x') - "makeabox-#{size}#{units}-#{trim(number(:thickness))}t.#{format}" + slope = sloped? ? "-#{trim(number(:slope))}deg" : '' + "makeabox-#{size}#{units}-#{trim(number(:thickness))}t#{slope}.#{format}" end # Draws the box and returns the file's bytes. Yields the number of lines @@ -109,7 +116,8 @@ def configuration(file) (DIMENSIONS + OPTIONAL).each { |key| options[key] = number(key) if number(key) } options[:kerf] ||= KERF_DEFAULT.fetch(units) options[:page_size] = @params[:page_size] if @params[:page_size].present? - options[:lid] = lid if self.class.lids_supported? && lid != LIDS.first + options[:lid] = lid if lid != LIDS.first + SLOPED.each { |key| options[key] = number(key) } if sloped? Laser::Cutter::Configuration.new(options).tap(&:validate!) end @@ -202,6 +210,22 @@ def check_choices end size = @params[:page_size] errors << "#{size} is not a page size we know." if size.present? && !Laser::Cutter::PageManager::SIZES.key?(size) - errors << 'This lid needs laser-cutter 2.0.1 or newer.' if lid != LIDS.first && !self.class.lids_supported? + end + + # The same rules laser-cutter's Sloped::Request applies, said in the form's words. + def check_slope + return unless sloped? + + slope, front = SLOPED.map { |key| number(key) } + return errors << 'Slope needs an angle above 0 and below 90 degrees.' unless slope&.positive? && slope < 90 + return errors << 'Front height needs a number, zero or more.' unless front&.finite? && !front.negative? + return errors << 'Front height has to be lower than the height of the box.' if front >= number(:height) + return errors << 'A sloped box cannot have the lid with tabs along the back.' if SLOPED_LIDS.exclude?(lid) + + run = (number(:height) - front) / Math.tan(slope * Math::PI / 180) + return if run <= number(:depth) + 1e-6 + + errors << "At #{trim(slope)}° the slope runs #{trim(run.round(2))} #{units} back, deeper than the box. " \ + 'Make the slope steeper, the front taller, or the box deeper.' end end diff --git a/app/views/home/_generator.html.haml b/app/views/home/_generator.html.haml index c616546..abdcce8 100644 --- a/app/views/home/_generator.html.haml +++ b/app/views/home/_generator.html.haml @@ -18,25 +18,53 @@ data: {generator_target: 'form', action: 'submit->generator#generate'}} %p.hint{role: 'status', data: {generator_target: 'hint'}} + -# The first choices: the units, the lid and the shape of the front. + .side + .seg{role: 'group', 'aria-label': 'Units'} + - { 'in' => 'inches', 'mm' => 'mm' }.each do |unit, text| + %label + %input{type: 'radio', name: 'box[units]', value: unit, checked: unit == 'in', data: {generator_target: 'units', action: 'change->generator#convert'}} + %span= text + %label.pick + %span.sr Top of the box + %select{name: 'box[lid]', data: {generator_target: 'lid', action: 'change->generator#edit'}} + %option{value: 'full'} Closed box + %option{value: 'back'} Lid, tabs along the back + %option{value: 'plain'} Lid, no tabs + -# Not sent: an upright box leaves the slope fields disabled, so the form leaves them out. + %label.pick + %span.sr Front of the box + %select{data: {generator_target: 'shape', action: 'change->generator#reshape'}} + %option{value: 'upright'} Upright front + %option{value: 'sloped'} Front slopes back + %button.more{type: 'button', data: {action: 'generator#openSettings'}} Kerf, page, margins… + - { width: 5, height: 3, depth: 4 }.each do |name, value| .field{data: {key: name}} %label{for: "box_#{name}", data: {action: 'pointerdown->generator#scrub'}} = name.to_s.capitalize - %i drag or ↑↓ + %i drag, or ↑↓ keys .num %input{id: "box_#{name}", name: "box[#{name}]", value: value, inputmode: 'decimal', required: true, data: {generator_target: 'number', action: 'input->generator#edit focus->generator#focus blur->generator#blur keydown->generator#nudge'}} %span{data: {generator_target: 'unit'}} in - if name == :width -# On a phone the cell is too narrow for the whole label, so it says just "Reset". - %button.more.restart{type: 'button', 'aria-label': 'Reset to defaults', data: {action: 'generator#restart'}} - Reset - %span.wide to defaults + -# Reset asks first, in a small popup beside it. No, Escape or a click elsewhere puts it away. + .reset{data: {action: 'keydown.esc->generator#keep click@window->generator#dismiss'}} + %button.more.restart{type: 'button', 'aria-label': 'Reset to defaults', 'aria-haspopup': 'dialog', 'aria-expanded': 'false', + data: {generator_target: 'restart', action: 'generator#ask'}} + Reset + %span.wide to defaults + .confirm{role: 'dialog', 'aria-label': 'Reset to defaults?', hidden: true, data: {generator_target: 'confirm'}} + %span Reset to defaults? + %button.more.yes{type: 'button', data: {action: 'generator#restart'}} Yes + %button.more.no{type: 'button', data: {action: 'generator#keep'}} No .field.thickness{data: {key: 'thickness'}} %label{for: 'box_thickness', data: {action: 'pointerdown->generator#scrub'}} Material thickness - %i drag or ↑↓ + %i drag, or ↑↓ keys .num %input#box_thickness{name: 'box[thickness]', value: 0.245, inputmode: 'decimal', required: true, data: {generator_target: 'number', action: 'input->generator#edit focus->generator#focus blur->generator#blur keydown->generator#nudge'}} @@ -46,28 +74,33 @@ .field.notch{data: {key: 'notch'}} %label{for: 'box_notch', data: {action: 'pointerdown->generator#scrub'}} Notch length - %i drag or ↑↓ + %i drag, or ↑↓ keys .num %input#box_notch{name: 'box[notch]', inputmode: 'decimal', placeholder: 'auto', data: {generator_target: 'optional', action: 'input->generator#edit focus->generator#focus blur->generator#blur keydown->generator#nudge'}} %span{data: {generator_target: 'unit'}} in %small.range{data: {generator_target: 'range'}} - .side - .seg{role: 'group', 'aria-label': 'Units'} - - { 'in' => 'inches', 'mm' => 'mm' }.each do |unit, text| - %label - %input{type: 'radio', name: 'box[units]', value: unit, checked: unit == 'in', data: {generator_target: 'units', action: 'change->generator#convert'}} - %span= text - %label.pick - %span.sr Top of the box - %select{name: 'box[lid]', data: {generator_target: 'lid', action: 'change->generator#edit'}} - %option{value: 'full'} Closed box - %option{value: 'back', disabled: !@settings[:lidsSupported]} Lid, tabs along the back - %option{value: 'plain', disabled: !@settings[:lidsSupported]} Lid, no tabs - - unless @settings[:lidsSupported] - %small.soon Lids need laser-cutter 2.0.1 or newer. - %button.more{type: 'button', data: {action: 'generator#openSettings'}} Kerf, page, margins… + .sloped{hidden: true, data: {generator_target: 'sloped'}} + .field{data: {key: 'slope'}} + %label{for: 'box_slope', data: {action: 'pointerdown->generator#scrub'}} + Slope + %i drag, or ↑↓ keys + .num + %input#box_slope{name: 'box[slope]', inputmode: 'decimal', disabled: true, + data: {generator_target: 'slope', action: 'input->generator#edit focus->generator#focus blur->generator#blur keydown->generator#nudge'}} + %span ° + .field{data: {key: 'front_height'}} + %label{for: 'box_front_height', data: {action: 'pointerdown->generator#scrub'}} + Front height + %i drag, or ↑↓ keys + .num + %input#box_front_height{name: 'box[front_height]', inputmode: 'decimal', disabled: true, + data: {generator_target: 'frontHeight', action: 'input->generator#edit focus->generator#focus blur->generator#blur keydown->generator#nudge'}} + %span{data: {generator_target: 'unit'}} in + %p.note + The front rises to the front height, then slopes back at this angle above horizontal until it meets the top. + Zero starts the slope at the bottom. Seven panels; the lid can be notched in or lie on top. %button.go{type: 'submit', data: {generator_target: 'go'}} Generate diff --git a/cypress/e2e/generator.cy.js b/cypress/e2e/generator.cy.js index 640f5d1..c026912 100644 --- a/cypress/e2e/generator.cy.js +++ b/cypress/e2e/generator.cy.js @@ -75,17 +75,38 @@ describe("making a box", () => { }) }) - it("resets the box to 5 × 4 × 3 in of 1/8 in material with the default kerf", () => { + it("resets to a closed, upright 5 × 4 × 3 in box of 1/4 in material with the default kerf", () => { cy.contains(".seg span", "mm").click() field("width").clear().type("300") field("thickness").clear().type("6") + field("lid").select("plain") + cy.get('[data-generator-target="shape"]').select("sloped") + cy.get(".sloped").should("be.visible") cy.contains(".field button", "Reset to defaults").click() + cy.contains(".reset .confirm button", "Yes").click() + cy.get(".reset .confirm").should("not.be.visible") cy.get('[name="box[units]"][value="in"]').should("be.checked") - for (const [name, value] of [["width", "5"], ["height", "4"], ["depth", "3"], ["thickness", "0.125"], ["kerf", "0.026"]]) field(name).should("have.value", value) + for (const [name, value] of [["width", "5"], ["height", "4"], ["depth", "3"], ["thickness", "0.25"], ["kerf", "0.026"]]) field(name).should("have.value", value) + field("lid").should("have.value", "full") + cy.get('[data-generator-target="shape"]').should("have.value", "upright") + cy.get(".sloped").should("not.be.visible") + cy.get(".stage svg polygon.tilted").should("not.exist") cy.get(".stage svg text").should("contain", "5 in").and("contain", "4 in").and("contain", "3 in") }) + it("keeps the box when the reset is answered No, or with Escape", () => { + field("width").clear().type("7") + cy.contains(".field button", "Reset to defaults").click() + cy.get(".reset .confirm").should("be.visible").and("contain", "Reset to defaults?") + cy.contains(".reset .confirm button", "No").should("be.focused").click() + cy.get(".reset .confirm").should("not.be.visible") + cy.contains(".field button", "Reset to defaults").should("be.focused").click() + cy.focused().type("{esc}") + cy.get(".reset .confirm").should("not.be.visible") + field("width").should("have.value", "7") + }) + it("reads a decimal comma, and converts it", () => { field("thickness").clear().type("0,25") cy.get(".hint").should("be.empty") @@ -337,6 +358,121 @@ describe("making a box", () => { }) }) + it("puts the units, the lid and the front first, wide enough for every option", () => { + // The widest option's text, in the select's own font, plus its padding and arrow. + const fits = ($select) => { + const select = $select[0], style = getComputedStyle(select) + const context = document.createElement("canvas").getContext("2d") + context.font = `${style.fontWeight} ${style.fontSize} ${style.fontFamily}` + const widest = Math.max(...[...select.options].map((option) => context.measureText(option.textContent).width)) + expect(select.getBoundingClientRect().width, select.options[0].textContent).to.be.at.least(widest + parseFloat(style.paddingLeft) + 16) + } + for (const width of [1440, 1000]) { + cy.viewport(width, 900) + cy.get(".side").then(($side) => cy.get(".field[data-key='width']").should(($width) => { + expect($side[0].getBoundingClientRect().right).to.be.at.most($width[0].getBoundingClientRect().left + 1) + })) + cy.get(".side select").each(($select) => cy.wrap($select).should(fits)) + cy.get("body").should(($body) => expect($body[0].scrollWidth).to.be.at.most(width)) + } + cy.viewport(1440, 900) + cy.screenshot("choices-first", { capture: "viewport" }) + }) + + it("lines the choices up beside the units pill when they sit above the measurements", () => { + const middle = (el) => { const box = el.getBoundingClientRect(); return Math.round(box.top + box.height / 2) } + cy.viewport(800, 900) + cy.get(".side .seg").then(($seg) => { + cy.get(".side select").each(($select) => expect(Math.abs(middle($select[0]) - middle($seg[0]))).to.be.at.most(4)) + }) + cy.get(".side").then(($side) => cy.get("#box_width").should(($width) => { + expect($side[0].getBoundingClientRect().bottom).to.be.at.most($width[0].getBoundingClientRect().top) + })) + cy.get(".side").scrollIntoView() + cy.screenshot("choices-tablet", { capture: "viewport" }) + + cy.viewport(390, 844) + cy.get("body").should(($body) => expect($body[0].scrollWidth).to.be.at.most(390)) + cy.get(".side").scrollIntoView() + cy.screenshot("choices-phone", { capture: "viewport" }) + }) + + it("changes a number by dragging its label right or up, and back left or down", () => { + const drag = (moves) => { + cy.get('label[for="box_width"]').then(($label) => { + const { left, top } = $label[0].getBoundingClientRect(), start = { clientX: left + 10, clientY: top + 5, pointerId: 1 } + cy.wrap($label).trigger("pointerdown", { ...start, button: 0 }) + for (const [dx, dy] of moves) cy.wrap($label).trigger("pointermove", { clientX: start.clientX + dx, clientY: start.clientY + dy, pointerId: 1 }) + cy.wrap($label).trigger("pointerup", { pointerId: 1 }) + }) + } + cy.get('label[for="box_width"] i').should("have.text", "drag, or ↑↓ keys") + drag([[24, 0]]) // four steps of 0.25 in to the right + field("width").should("have.value", "6") + drag([[0, -24]]) // and four more up + field("width").should("have.value", "7") + drag([[0, 48]]) // eight down + field("width").should("have.value", "5") + }) + + it("previews and cuts a box whose front slopes back", () => { + const shape = () => cy.get('[data-generator-target="shape"]') + field("lid").select("back") + cy.get(".sloped").should("not.be.visible") + field("slope").should("be.disabled") + + shape().select("sloped") + cy.get(".sloped").should("be.visible") + field("slope").should("have.value", "45") + field("front_height").should("have.value", "1.2") + field("lid").should("have.value", "full").find('option[value="back"]').should("be.disabled") + cy.get(".stage svg polygon.tilted").should("have.length", 1) + cy.get(".stage svg .dim text").should("contain", "45°") + + field("slope").clear().type("20") + cy.get(".hint").should("contain", "deeper than the box") + .and("have.css", "background-color", "rgb(255, 32, 32)") + .and("have.css", "color", "rgb(255, 255, 255)") + .and("have.css", "font-weight", "700") + cy.screenshot("hint", { capture: "viewport" }) + cy.get(".go").should("be.disabled") + field("slope").clear().type("60") + cy.get(".hint").should("be.empty") + + cy.get(".go").click() + cy.contains("dialog.cut dd", "1.2 in, sloping back at 60°") + cy.contains("dialog.cut .progress", "Ready", { timeout: 10000 }) + cy.screenshot("sloped", { capture: "viewport" }) + cy.get("dialog.cut button.x").click() + + // An upright box sends no slope at all. + shape().select("upright") + cy.get(".stage svg polygon.tilted").should("not.exist") + cy.request(`/box/download.svg?box[width]=5&box[height]=3&box[depth]=4&box[thickness]=0.245&box[slope]=60&box[front_height]=1.2`) + .its("headers.content-disposition").should("contain", "makeabox-5x3x4in-0.245t-60deg.svg") + }) + + it("lays the slope fields out on a phone", () => { + cy.viewport(390, 844) + cy.get('[data-generator-target="shape"]').select("sloped") + const top = (name) => field(name).then(($input) => Math.round($input[0].getBoundingClientRect().top)) + // Thickness, slope, front height and notch share a row, and Generate comes after them. + top("slope").then((row) => { + for (const name of ["thickness", "front_height", "notch"]) top(name).should("eq", row) + cy.get(".go").should(($go) => expect($go[0].getBoundingClientRect().top).to.be.greaterThan(row)) + }) + cy.get(".stage svg polygon.tilted").should("have.length", 1) + cy.get("body").should(($body) => expect($body[0].scrollWidth).to.be.at.most(390)) + field("front_height").clear().type("3") + cy.get(".hint").should("have.text", "Front height has to be lower than the height of the box.").and("be.visible") + cy.get("body").should(($body) => expect($body[0].scrollWidth).to.be.at.most(390)) + cy.get(".hint").scrollIntoView() + cy.screenshot("phone-hint", { capture: "viewport" }) + field("front_height").clear().type("1.2") + cy.get(".sloped").scrollIntoView() + cy.screenshot("phone-sloped", { capture: "viewport" }) + }) + it("shortens the heading on a phone", () => { cy.get(".hero h1").should("contain.text", "Fully symmetric enclosure boxes") cy.get(".hero h1 .short").should("not.be.visible") @@ -356,8 +492,8 @@ describe("making a box", () => { top("notch").should("be.greaterThan", first) }) cy.get("body").should(($body) => expect($body[0].scrollWidth).to.be.at.most(390)) - // A slim Generate bar sits above the controls. - cy.get(".go").then(($go) => cy.get("#box_width").should(($width) => expect($go[0].getBoundingClientRect().bottom).to.be.lessThan($width[0].getBoundingClientRect().top))) + // A slim Generate bar sits under the controls. + cy.get(".go").then(($go) => cy.get("#box_notch").should(($notch) => expect($go[0].getBoundingClientRect().top).to.be.greaterThan($notch[0].getBoundingClientRect().bottom))) cy.get(".go small").should("not.be.visible") cy.screenshot("phone", { capture: "viewport" }) }) diff --git a/cypress/e2e/lib.cy.js b/cypress/e2e/lib.cy.js index aeb72d2..f6eaf7b 100644 --- a/cypress/e2e/lib.cy.js +++ b/cypress/e2e/lib.cy.js @@ -1,7 +1,7 @@ // The pure modules behind the preview and the trace, tested without a page. import { tabCount, isoBox } from "../../app/javascript/lib/iso_box" import { chain } from "../../app/javascript/lib/laser_trace" -import { slopedProfile } from "../../app/javascript/lib/sloped_profile" +import { slopedProfile, slopeProblem } from "../../app/javascript/lib/sloped_profile" import { isoSlopedBox } from "../../app/javascript/lib/iso_sloped_box" describe("tabCount", () => { @@ -122,6 +122,13 @@ describe("isoSlopedBox", () => { expect(draw({ lid: "full" }).markup).not.to.contain('class="inside floor"') }) + // A plain lid lies on the side walls: a rectangle with no tabs, and none drawn after it. + it("draws the lifted plain lid without tabs", () => { + const afterTilted = (markup) => markup.slice(markup.indexOf('class="face tilted"')) + expect(count(afterTilted(draw({ lid: "plain" }).markup), "finger")).to.eq(0) + expect(count(afterTilted(draw({ lid: "full" }).markup), "finger")).to.be.greaterThan(0) + }) + it("leaves out a strip of zero size", () => { const { markup } = draw({ lid: "full", frontHeight: 0, slope: (Math.atan(4 / 6) * 180) / Math.PI }) expect(count(markup, "face left") + count(markup, "face top")).to.eq(0) @@ -137,3 +144,23 @@ describe("isoSlopedBox", () => { expect(count(draw({ lid: "full", hot: "slope" }).markup, "dim hot")).to.eq(1) }) }) + +describe("slopeProblem", () => { + const box = { height: 3, depth: 5, slope: 45, frontHeight: 1, lid: "full", unit: "in" } + + it("passes a box that can be drawn, from a front of zero too", () => { + expect(slopeProblem(box)).to.eq("") + expect(slopeProblem({ ...box, frontHeight: 0, slope: 60, lid: "plain" })).to.eq("") + }) + + it("says what is wrong in the words BoxRequest uses", () => { + expect(slopeProblem({ ...box, slope: 90 })).to.eq("Slope needs an angle above 0 and below 90 degrees.") + expect(slopeProblem({ ...box, slope: NaN })).to.eq("Slope needs an angle above 0 and below 90 degrees.") + expect(slopeProblem({ ...box, frontHeight: NaN })).to.eq("Front height needs a number, zero or more.") + expect(slopeProblem({ ...box, frontHeight: 3 })).to.eq("Front height has to be lower than the height of the box.") + expect(slopeProblem({ ...box, lid: "back" })).to.eq("A sloped box cannot have the lid with tabs along the back.") + expect(slopeProblem({ ...box, slope: 20 })).to.eq( + "At 20° the slope runs 5.49 in back, deeper than the box. Make the slope steeper, the front taller, or the box deeper." + ) + }) +}) diff --git a/docs/badges/coverage_badge.svg b/docs/badges/coverage_badge.svg index f8bd31b..c311ec5 100644 --- a/docs/badges/coverage_badge.svg +++ b/docs/badges/coverage_badge.svg @@ -15,7 +15,7 @@ coverage coverage - 52% - 52% + 53% + 53% diff --git a/lib/makeabox/svg_renderer.rb b/lib/makeabox/svg_renderer.rb index 1ff63ee..c73dc71 100644 --- a/lib/makeabox/svg_renderer.rb +++ b/lib/makeabox/svg_renderer.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Makeabox - # laser-cutter (2.0.0 and 2.0.1) works out the size of the page again for every line it + # laser-cutter (2.x and 3.0) works out the size of the page again for every line it # writes to an SVG, which makes a 10 inch box take eight seconds instead of # a twentieth of one. The size cannot change while rendering, so it is kept. # diff --git a/spec/models/box_request_sloped_spec.rb b/spec/models/box_request_sloped_spec.rb new file mode 100644 index 0000000..2157946 --- /dev/null +++ b/spec/models/box_request_sloped_spec.rb @@ -0,0 +1,64 @@ +# frozen_string_literal: true + +require 'rails_helper' + +# A front that slopes back: BoxRequest's slope and front_height. +RSpec.describe BoxRequest do + subject(:box) { described_class.new(params) } + + let(:params) do + { 'width' => '4', 'height' => '3', 'depth' => '5', 'thickness' => '0.125', 'units' => 'in', 'slope' => '45', 'front_height' => '1' } + end + + def errors_for(changes) + described_class.new(params.merge(changes)).tap(&:valid?).errors + end + + it { is_expected.to be_valid } + it { is_expected.to be_sloped } + + it 'is upright when both slope fields are blank' do + expect(described_class.new(params.merge('slope' => '', 'front_height' => ''))).not_to be_sloped + end + + it 'starts the slope at the bottom with a front height of zero' do + expect(errors_for('front_height' => '0', 'slope' => '60')).to be_empty + end + + it 'refuses an angle that is flat, upright or not a number' do + %w[0 90 steep].each do |slope| + expect(errors_for('slope' => slope)).to eq ['Slope needs an angle above 0 and below 90 degrees.'] + end + end + + it 'refuses a front height that is missing, negative or reaches the top' do + expect(errors_for('front_height' => '')).to eq ['Front height needs a number, zero or more.'] + expect(errors_for('front_height' => '-1')).to eq ['Front height needs a number, zero or more.'] + expect(errors_for('front_height' => '3')).to eq ['Front height has to be lower than the height of the box.'] + end + + it 'refuses the lid with tabs along the back' do + expect(errors_for('lid' => 'back')).to eq ['A sloped box cannot have the lid with tabs along the back.'] + expect(errors_for('lid' => 'plain')).to be_empty + end + + it 'refuses a slope that runs deeper than the box' do + expect(errors_for('slope' => '20')).to eq [ + 'At 20° the slope runs 5.49 in back, deeper than the box. Make the slope steeper, the front taller, or the box deeper.' + ] + end + + it 'names the angle in the file name' do + expect(box.filename('svg')).to eq 'makeabox-4x3x5in-0.125t-45deg.svg' + end + + it 'hands laser-cutter the slope and the front height' do + config = box.configuration(File::NULL) + expect([config[:slope], config[:front_height]]).to eq [45.0, 1.0] + end + + it 'draws the box in both formats' do + expect(box.render('svg')).to include(' 'plain') } - it 'is refused while the installed laser-cutter cannot draw lids' do - allow(described_class).to receive(:lids_supported?).and_return(false) - expect(box).not_to be_valid - expect(box.errors).to eq ['This lid needs laser-cutter 2.0.1 or newer.'] - end - - it 'is accepted once it can' do - allow(described_class).to receive(:lids_supported?).and_return(true) - expect(box).to be_valid - end + it { is_expected.to be_valid } end end @@ -173,18 +164,6 @@ end end - describe '.lids_supported?' do - it 'is off for a laser-cutter that only draws the full lid' do - hide_const('Laser::Cutter::Box::LIDS') - expect(described_class.lids_supported?).to be false - end - - it 'is on once laser-cutter lists its lids' do - stub_const('Laser::Cutter::Box::LIDS', %i[full back plain]) - expect(described_class.lids_supported?).to be true - end - end - describe '#units and #lid' do it 'fall back to inches and the full lid for anything unknown' do box = described_class.new(params.merge('units' => 'furlongs', 'lid' => 'dome')) @@ -219,11 +198,6 @@ expect(box.configuration('/tmp/box.pdf')).to include(notch: 0.5, page_size: 'A4', page_layout: 'landscape', metadata: false) end - it 'falls back to the full lid when laser-cutter cannot draw another' do - allow(described_class).to receive(:lids_supported?).and_return(false) - expect(described_class.new(params.merge('lid' => 'plain')).configuration('/tmp/box.pdf')).to include(lid: 'full') - end - it 'passes the lid on' do expect(described_class.new(params.merge('lid' => 'plain')).configuration('/tmp/box.pdf')).to include(lid: 'plain') end diff --git a/spec/requests/boxes_spec.rb b/spec/requests/boxes_spec.rb index a34509f..621cfd7 100644 --- a/spec/requests/boxes_spec.rb +++ b/spec/requests/boxes_spec.rb @@ -140,6 +140,20 @@ def events expect(response.body).to include(']*disabled/) - expect(response.body).not_to include('Lids need laser-cutter 2.0.1 or newer.') end it 'embeds the discussion' do @@ -70,16 +69,4 @@ it 'leaves analytics out outside production' do expect(response.body).not_to include('googletagmanager') end - - context 'when the installed laser-cutter cannot draw lids' do - before do - allow(BoxRequest).to receive(:lids_supported?).and_return(false) - get '/' - end - - it 'shows them disabled, with a note' do - expect(response.body).to match(/]*disabled[^>]*value="plain"|]*value="plain"[^>]*disabled/) - expect(response.body).to include('Lids need laser-cutter 2.0.1 or newer.') - end - end end From fa57a0bce173b18c975a609eaec697cc179e041d Mon Sep 17 00:00:00 2001 From: Konstantin Gredeskoul Date: Wed, 2 Dec 2026 01:12:58 -0800 Subject: [PATCH 4/5] Draw the dropdown arrow in space kept for it --- app/assets/stylesheets/generator.css | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/generator.css b/app/assets/stylesheets/generator.css index 7945dad..3d15d7b 100644 --- a/app/assets/stylesheets/generator.css +++ b/app/assets/stylesheets/generator.css @@ -107,7 +107,11 @@ .seg span { display: block; padding: 3px 14px; font-size: 14px; border-radius: 99px; color: var(--soft); cursor: pointer; } .seg input:checked + span { background: var(--ink); color: var(--panel); } .seg input:focus-visible + span { outline: 2px solid var(--amber); outline-offset: 2px; } -.pick select { padding: 4px 10px; max-width: 100%; } +/* Our own arrow, in 26px of padding kept for it: the native one takes no room on Linux, so the longest option ran under it. */ +.pick select { + appearance: none; padding: 4px 26px 4px 10px; max-width: 100%; + background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23c3cbd3' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 10px center / 10px 6px; +} /* The column is as wide as its longest option; both dropdowns fill it, so they line up. */ .side .pick { justify-self: stretch; } .side .pick select { width: 100%; } From f7233b5a2eabca79231e168314640ccbdffd35cf Mon Sep 17 00:00:00 2001 From: Konstantin Gredeskoul Date: Wed, 2 Dec 2026 01:31:34 -0800 Subject: [PATCH 5/5] Fixing shit --- app/assets/stylesheets/generator.css | 6 +---- .../controllers/generator_controller.js | 2 +- app/javascript/lib/sloped_profile.js | 15 ++++++++---- app/models/box_request.rb | 23 +++++++++++++++---- config/puma.rb | 2 +- cypress/e2e/generator.cy.js | 15 ++++++++---- cypress/e2e/lib.cy.js | 9 +++++++- spec/models/box_request_sloped_spec.rb | 21 +++++++++++++++++ 8 files changed, 72 insertions(+), 21 deletions(-) diff --git a/app/assets/stylesheets/generator.css b/app/assets/stylesheets/generator.css index 3d15d7b..7945dad 100644 --- a/app/assets/stylesheets/generator.css +++ b/app/assets/stylesheets/generator.css @@ -107,11 +107,7 @@ .seg span { display: block; padding: 3px 14px; font-size: 14px; border-radius: 99px; color: var(--soft); cursor: pointer; } .seg input:checked + span { background: var(--ink); color: var(--panel); } .seg input:focus-visible + span { outline: 2px solid var(--amber); outline-offset: 2px; } -/* Our own arrow, in 26px of padding kept for it: the native one takes no room on Linux, so the longest option ran under it. */ -.pick select { - appearance: none; padding: 4px 26px 4px 10px; max-width: 100%; - background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23c3cbd3' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 10px center / 10px 6px; -} +.pick select { padding: 4px 10px; max-width: 100%; } /* The column is as wide as its longest option; both dropdowns fill it, so they line up. */ .side .pick { justify-self: stretch; } .side .pick select { width: 100%; } diff --git a/app/javascript/controllers/generator_controller.js b/app/javascript/controllers/generator_controller.js index 1a17ee1..6056d03 100644 --- a/app/javascript/controllers/generator_controller.js +++ b/app/javascript/controllers/generator_controller.js @@ -111,7 +111,7 @@ export default class extends Controller { slopeProblem() { if (!this.sloped) return "" - return slopeProblem({ height: this.number("height"), depth: this.number("depth"), slope: parse(this.fields.slope), + return slopeProblem({ height: this.number("height"), depth: this.number("depth"), thickness: this.number("thickness"), slope: parse(this.fields.slope), frontHeight: parse(this.fields.front_height), lid: this.lidTarget.value, unit: this.unit }) } diff --git a/app/javascript/lib/sloped_profile.js b/app/javascript/lib/sloped_profile.js index cfb1062..6bc3203 100644 --- a/app/javascript/lib/sloped_profile.js +++ b/app/javascript/lib/sloped_profile.js @@ -49,14 +49,19 @@ export function slopedProfile({ depth: D, height: H, frontHeight: Hf, slope, thi // Why a sloped box cannot be drawn, in the words BoxRequest#check_slope uses; // "" when it can. slope and frontHeight may be NaN for a blank or bad field. -// { height, depth, slope, frontHeight, lid, unit } -export function slopeProblem({ height, depth, slope, frontHeight, lid, unit }) { +// { height, depth, thickness, slope, frontHeight, lid, unit } +export function slopeProblem({ height, depth, thickness, slope, frontHeight, lid, unit }) { if (!(slope > 0 && slope < 90)) return "Slope needs an angle above 0 and below 90 degrees." if (!(frontHeight >= 0)) return "Front height needs a number, zero or more." if (frontHeight >= height) return "Front height has to be lower than the height of the box." if (lid === "back") return "A sloped box cannot have the lid with tabs along the back." - const run = (height - frontHeight) / Math.tan((slope * Math.PI) / 180) - if (run <= depth + PRECISION) return "" const round = (value) => Number(value.toFixed(2)) - return `At ${round(slope)}° the slope runs ${round(run)} ${unit} back, deeper than the box. Make the slope steeper, the front taller, or the box deeper.` + const run = (height - frontHeight) / Math.tan((slope * Math.PI) / 180) + if (run > depth + PRECISION) { + return `At ${round(slope)}° the slope runs ${round(run)} ${unit} back, deeper than the box. Make the slope steeper, the front taller, or the box deeper.` + } + // The strips cut the sloped panel short at both ends; laser-cutter refuses one with nothing left. + const profile = slopedProfile({ depth, height, frontHeight, slope, thickness }) + if (profile && profile.lengths.tilted > PRECISION) return "" + return `At ${round(slope)}° from a front of ${round(frontHeight)} ${unit}, nothing is left of the sloped panel in this material. Make the front lower.` } diff --git a/app/models/box_request.rb b/app/models/box_request.rb index b44a287..af1c169 100644 --- a/app/models/box_request.rb +++ b/app/models/box_request.rb @@ -222,10 +222,25 @@ def check_slope return errors << 'Front height has to be lower than the height of the box.' if front >= number(:height) return errors << 'A sloped box cannot have the lid with tabs along the back.' if SLOPED_LIDS.exclude?(lid) - run = (number(:height) - front) / Math.tan(slope * Math::PI / 180) - return if run <= number(:depth) + 1e-6 + angle = slope * Math::PI / 180 + run = (number(:height) - front) / Math.tan(angle) + if run > number(:depth) + 1e-6 + return errors << "At #{trim(slope.round(2))}° the slope runs #{trim(run.round(2))} #{units} back, deeper than the box. " \ + 'Make the slope steeper, the front taller, or the box deeper.' + end + return if tilted_length(angle, run, front) > 1e-6 + + errors << "At #{trim(slope.round(2))}° from a front of #{trim(front.round(2))} #{units}, " \ + 'nothing is left of the sloped panel in this material. Make the front lower.' + end - errors << "At #{trim(slope)}° the slope runs #{trim(run.round(2))} #{units} back, deeper than the box. " \ - 'Make the slope steeper, the front taller, or the box deeper.' + # The sloped panel's length once the strips at its ends have cut it short, + # as laser-cutter's Sloped::Profile#tilted_length works it out. + def tilted_length(angle, run, front) + thickness = number(:thickness) + top_depth = number(:depth) - run + front_cut = front.positive? ? thickness * Math.tan(angle) : 0.0 + top_cut = top_depth > 1e-6 ? thickness / Math.tan(angle) : 0.0 + Math.hypot(run, number(:height) - front) - front_cut - top_cut end end diff --git a/config/puma.rb b/config/puma.rb index 82c58d6..cfbb0b3 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -9,7 +9,7 @@ tag 'puma-makeabox' log_requests true -on_restart { puts 'restarting' } +before_restart { puts 'restarting' } worker_timeout 30 pidfile 'tmp/pids/puma.pid' diff --git a/cypress/e2e/generator.cy.js b/cypress/e2e/generator.cy.js index c026912..9fc7a38 100644 --- a/cypress/e2e/generator.cy.js +++ b/cypress/e2e/generator.cy.js @@ -360,11 +360,18 @@ describe("making a box", () => { it("puts the units, the lid and the front first, wide enough for every option", () => { // The widest option's text, in the select's own font, plus its padding and arrow. + // Measured in the app's document: the spec's own document has not loaded the + // app's web font, so it measures a fallback that is wider on Linux. const fits = ($select) => { - const select = $select[0], style = getComputedStyle(select) - const context = document.createElement("canvas").getContext("2d") - context.font = `${style.fontWeight} ${style.fontSize} ${style.fontFamily}` - const widest = Math.max(...[...select.options].map((option) => context.measureText(option.textContent).width)) + const select = $select[0], page = select.ownerDocument, style = page.defaultView.getComputedStyle(select) + const probe = page.createElement("span") + Object.assign(probe.style, { position: "absolute", visibility: "hidden", whiteSpace: "pre", font: style.font, fontStretch: style.fontStretch }) + page.body.append(probe) + const widest = Math.max(...[...select.options].map((option) => { + probe.textContent = option.textContent + return probe.getBoundingClientRect().width + })) + probe.remove() expect(select.getBoundingClientRect().width, select.options[0].textContent).to.be.at.least(widest + parseFloat(style.paddingLeft) + 16) } for (const width of [1440, 1000]) { diff --git a/cypress/e2e/lib.cy.js b/cypress/e2e/lib.cy.js index f6eaf7b..e786367 100644 --- a/cypress/e2e/lib.cy.js +++ b/cypress/e2e/lib.cy.js @@ -146,7 +146,7 @@ describe("isoSlopedBox", () => { }) describe("slopeProblem", () => { - const box = { height: 3, depth: 5, slope: 45, frontHeight: 1, lid: "full", unit: "in" } + const box = { height: 3, depth: 5, thickness: 0.125, slope: 45, frontHeight: 1, lid: "full", unit: "in" } it("passes a box that can be drawn, from a front of zero too", () => { expect(slopeProblem(box)).to.eq("") @@ -163,4 +163,11 @@ describe("slopeProblem", () => { "At 20° the slope runs 5.49 in back, deeper than the box. Make the slope steeper, the front taller, or the box deeper." ) }) + + // The same box BoxRequest refuses: the strips cut the sloped panel short until nothing is left. + it("refuses a slope that leaves nothing of the sloped panel", () => { + const tight = { ...box, depth: 4, thickness: 0.245, frontHeight: 2.75 } + expect(slopeProblem(tight)).to.eq("At 45° from a front of 2.75 in, nothing is left of the sloped panel in this material. Make the front lower.") + expect(slopeProblem({ ...tight, frontHeight: 2 })).to.eq("") + }) }) diff --git a/spec/models/box_request_sloped_spec.rb b/spec/models/box_request_sloped_spec.rb index 2157946..57d7ec2 100644 --- a/spec/models/box_request_sloped_spec.rb +++ b/spec/models/box_request_sloped_spec.rb @@ -48,6 +48,27 @@ def errors_for(changes) ] end + it 'rounds the angle it names to two places' do + expect(errors_for('slope' => '20.12345').first).to start_with 'At 20.12° the slope runs' + end + + # The strips cut the sloped panel short at both ends; laser-cutter refuses a panel with nothing left. + describe 'a slope that leaves nothing of the sloped panel' do + let(:tight) { { 'height' => '3', 'depth' => '4', 'thickness' => '0.245', 'slope' => '45', 'front_height' => '2.75' } } + + it 'is refused, and a lower front is not' do + expect(errors_for(tight)).to eq [ + 'At 45° from a front of 2.75 in, nothing is left of the sloped panel in this material. Make the front lower.' + ] + expect(errors_for(tight.merge('front_height' => '2'))).to be_empty + end + + it 'is what laser-cutter refuses too' do + expect { Laser::Cutter::Sloped::Profile.new(depth: 4, height: 3, front_height: 2.75, slope: 45, thickness: 0.245) } + .to raise_error(Laser::Cutter::InvalidOption, /no tilted panel/) + end + end + it 'names the angle in the file name' do expect(box.filename('svg')).to eq 'makeabox-4x3x5in-0.125t-45deg.svg' end