Skip to content

Commit 172e959

Browse files
committed
First working version of app name + database choice inputs
1 parent 345bda1 commit 172e959

35 files changed

+570
-34
lines changed

Dockerfile

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# syntax = docker/dockerfile:1
2+
# check=error=true
23

34
ARG RUBY_VERSION=3.3.5
45
FROM docker.io/library/ruby:$RUBY_VERSION-slim AS base
56

6-
# Rails app lives here
77
WORKDIR /rails
88

99
# Install base packages
@@ -20,6 +20,8 @@ ENV RAILS_ENV="production" \
2020
BUNDLE_DEPLOYMENT="1" \
2121
BUNDLE_PATH="/usr/local/bundle"
2222

23+
FROM base AS build
24+
2325
# Install Node.js and Yarn
2426
ARG NODE_VERSION=22.3.0
2527
ARG YARN_VERSION=1.22.19
@@ -53,19 +55,16 @@ RUN yarn install --frozen-lockfile
5355
# Copy application code
5456
COPY . .
5557

56-
# Precompile bootsnap code for faster boot times
57-
RUN bundle exec bootsnap precompile app/ lib/
58-
5958
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
6059
RUN RAILS_ENV=production SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile
6160

61+
RUN rm -rf node_modules
62+
6263
# Final stage for app image
6364
FROM base
6465

65-
# Copy built artifacts: gems, application, and node_modules
6666
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
6767
COPY --from=build /rails /rails
68-
COPY --from=build /rails/node_modules /rails/node_modules
6968

7069
# Run and own only the runtime files as a non-root user for security
7170
RUN groupadd --system --gid 1000 rails && \

Gemfile

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ source "https://rubygems.org"
22

33
gem "rails", "8.0.0.rc2"
44

5-
gem "bootsnap", require: false
65
gem "friendly_id", "~> 5.5.1"
76
gem "kamal", "~> 2.3.0", require: false
87
gem "thruster", "~> 0.1.8", require: false

Gemfile.lock

-4
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@ GEM
9191
smart_properties
9292
bigdecimal (3.1.8)
9393
bindex (0.8.1)
94-
bootsnap (1.18.4)
95-
msgpack (~> 1.2)
9694
brakeman (6.2.2)
9795
racc
9896
builder (3.3.0)
@@ -226,7 +224,6 @@ GEM
226224
turbo-rails
227225
mocha (2.5.0)
228226
ruby2_keywords (>= 0.0.5)
229-
msgpack (1.7.2)
230227
net-imap (0.5.0)
231228
date
232229
net-protocol
@@ -460,7 +457,6 @@ DEPENDENCIES
460457
amazing_print (~> 1.6)
461458
annotaterb
462459
better_html
463-
bootsnap
464460
brakeman (~> 6.2.2)
465461
capybara
466462
debug

app/assets/images/MySQL.svg

+10
Loading

app/assets/images/Postgres.svg

+19
Loading

app/assets/images/SQLite.svg

+18
Loading

app/controllers/pages_controller.rb

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class PagesController < ApplicationController
2+
def show
3+
@page = Page.includes(
4+
groups: {
5+
sub_groups: {
6+
elements: [ :variant ]
7+
}
8+
}
9+
).friendly.find(params[:id] || params[:slug])
10+
end
11+
end

app/helpers/pages_helper.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module PagesHelper
2+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Controller } from "@hotwired/stimulus"
2+
3+
export default class extends Controller {
4+
updateText(text) {
5+
this.element.innerText = text
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { Controller } from "@hotwired/stimulus"
2+
3+
export default class extends Controller {
4+
static outlets = ["generated-output"]
5+
6+
connect() {
7+
if (this.hasDatabaseChoiceOutlet) {
8+
this.update()
9+
}
10+
}
11+
12+
update(event) {
13+
const groupElement = this.element.closest('ul')
14+
const selectedRadio = groupElement.querySelector('input[type="radio"]:checked')
15+
16+
const radio_value = selectedRadio ? selectedRadio.value.toLowerCase() : ''
17+
18+
let outputText = groupElement.dataset.outputPrefix ?
19+
`${groupElement.dataset.outputPrefix} ${radio_value}` :
20+
radio_value;
21+
22+
outputText = selectedRadio.dataset.isDefault === "true" ? '' : outputText
23+
24+
this.generatedOutputOutlet.updateText(outputText)
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Controller } from "@hotwired/stimulus"
2+
3+
export default class extends Controller {
4+
static targets = ["input"]
5+
static outlets = ["generated-output"]
6+
7+
connect() {
8+
this.update()
9+
}
10+
11+
update(event) {
12+
const inputValue = this.inputTarget.value || this.inputTarget.dataset.defaultValue || ""
13+
const prefix = this.inputTarget.dataset.outputPrefix || ""
14+
15+
const updatedText = prefix ? `${prefix} ${inputValue}` : inputValue
16+
this.generatedOutputOutlet.updateText(updatedText)
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
@import "tailwindcss/base";
22
@import "tailwindcss/components";
33
@import "tailwindcss/utilities";
4+
@import "./custom/basics.css";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
@layer base {
2+
pre {
3+
white-space: pre-wrap; /* css-3 */
4+
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
5+
white-space: -pre-wrap; /* Opera 4-6 */
6+
white-space: -o-pre-wrap; /* Opera 7 */
7+
word-wrap: break-word; /* Internet Explorer 5.5+ */
8+
}
9+
10+
body {
11+
background-color: #ffffff;
12+
background-image: url("data:image/svg+xml,%3Csvg width='180' height='180' viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M81.28 88H68.413l19.298 19.298L81.28 88zm2.107 0h13.226L90 107.838 83.387 88zm15.334 0h12.866l-19.298 19.298L98.72 88zm-32.927-2.207L73.586 78h32.827l.5.5 7.294 7.293L115.414 87l-24.707 24.707-.707.707L64.586 87l1.207-1.207zm2.62.207L74 80.414 79.586 86H68.414zm16 0L90 80.414 95.586 86H84.414zm16 0L106 80.414 111.586 86h-11.172zm-8-6h11.173L98 85.586 92.414 80zM82 85.586L87.586 80H76.414L82 85.586zM17.414 0L.707 16.707 0 17.414V0h17.414zM4.28 0L0 12.838V0h4.28zm10.306 0L2.288 12.298 6.388 0h8.198zM180 17.414L162.586 0H180v17.414zM165.414 0l12.298 12.298L173.612 0h-8.198zM180 12.838L175.72 0H180v12.838zM0 163h16.413l.5.5 7.294 7.293L25.414 172l-8 8H0v-17zm0 10h6.613l-2.334 7H0v-7zm14.586 7l7-7H8.72l-2.333 7h8.2zM0 165.414L5.586 171H0v-5.586zM10.414 171L16 165.414 21.586 171H10.414zm-8-6h11.172L8 170.586 2.414 165zM180 163h-16.413l-7.794 7.793-1.207 1.207 8 8H180v-17zm-14.586 17l-7-7h12.865l2.333 7h-8.2zM180 173h-6.613l2.334 7H180v-7zm-21.586-2l5.586-5.586 5.586 5.586h-11.172zM180 165.414L174.414 171H180v-5.586zm-8 5.172l5.586-5.586h-11.172l5.586 5.586zM152.933 25.653l1.414 1.414-33.94 33.942-1.416-1.416 33.943-33.94zm1.414 127.28l-1.414 1.414-33.942-33.94 1.416-1.416 33.94 33.943zm-127.28 1.414l-1.414-1.414 33.94-33.942 1.416 1.416-33.943 33.94zm-1.414-127.28l1.414-1.414 33.942 33.94-1.416 1.416-33.94-33.943zM0 85c2.21 0 4 1.79 4 4s-1.79 4-4 4v-8zm180 0c-2.21 0-4 1.79-4 4s1.79 4 4 4v-8zM94 0c0 2.21-1.79 4-4 4s-4-1.79-4-4h8zm0 180c0-2.21-1.79-4-4-4s-4 1.79-4 4h8z' fill='%23e2e8f0' fill-opacity='0.33' fill-rule='evenodd'/%3E%3C/svg%3E");
13+
background-attachment: fixed;
14+
/* background-size: cover; */
15+
}
16+
}
17+
18+
@layer components {
19+
#rails-new-command-generator-holder {
20+
position: -webkit-sticky;
21+
position: sticky;
22+
top: 0;
23+
}
24+
25+
pre.code {
26+
color: #4AF626;
27+
background: #071728;
28+
padding: 0.5rem;
29+
line-height: 1.2rem;
30+
font-size: 1rem;
31+
}
32+
33+
li.menu-card-row:hover {
34+
background-color: #ac3b61;
35+
}
36+
37+
li.menu-card-row:hover div.menu-card-row-title {
38+
color: #edc7b7;
39+
font-size: medium
40+
}
41+
42+
li.menu-card-row:hover div.menu-card-row-description {
43+
color: #eee2dc;
44+
}
45+
}

app/models/concerns/group_behavior.rb

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module GroupBehavior
2+
extend ActiveSupport::Concern
3+
4+
included do
5+
attribute :behavior_type, :string, default: "none"
6+
end
7+
8+
def stimulus_attributes
9+
case behavior_type
10+
when "database_choice"
11+
{
12+
controller: "radio-button-choice",
13+
"radio-button-choice-generated-output-outlet": "#database-choice",
14+
"output-prefix": "-d"
15+
}
16+
else
17+
{}
18+
end
19+
end
20+
end

app/models/element.rb

+4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
# Table name: elements
44
#
55
# id :integer not null, primary key
6+
# description :text
7+
# image_path :string
68
# label :string not null
9+
# position :integer
710
# variant_type :string
811
# created_at :datetime not null
912
# updated_at :datetime not null
@@ -13,6 +16,7 @@
1316
# Indexes
1417
#
1518
# index_elements_on_label (label)
19+
# index_elements_on_position (position)
1620
# index_elements_on_sub_group_id (sub_group_id)
1721
# index_elements_on_variant_type_and_variant_id (variant_type,variant_id)
1822
#

0 commit comments

Comments
 (0)