aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/assets/builds/.keep0
-rw-r--r--app/assets/config/manifest.js2
-rw-r--r--app/assets/images/.keep0
-rw-r--r--app/assets/stylesheets/_header.scss4
-rw-r--r--app/assets/stylesheets/application.bootstrap.scss3
-rw-r--r--app/channels/application_cable/channel.rb4
-rw-r--r--app/channels/application_cable/connection.rb4
-rw-r--r--app/controllers/application_controller.rb2
-rw-r--r--app/controllers/concerns/.keep0
-rw-r--r--app/controllers/events_controller.rb70
-rw-r--r--app/controllers/pages_controller.rb4
-rw-r--r--app/helpers/application_helper.rb2
-rw-r--r--app/helpers/events_helper.rb2
-rw-r--r--app/helpers/pages_helper.rb2
-rw-r--r--app/javascript/application.js4
-rw-r--r--app/javascript/controllers/application.js9
-rw-r--r--app/javascript/controllers/hello_controller.js7
-rw-r--r--app/javascript/controllers/index.js8
-rw-r--r--app/jobs/application_job.rb7
-rw-r--r--app/mailers/application_mailer.rb4
-rw-r--r--app/models/application_record.rb3
-rw-r--r--app/models/concerns/.keep0
-rw-r--r--app/models/event.rb4
-rw-r--r--app/views/events/_event.html.erb12
-rw-r--r--app/views/events/_event.json.jbuilder2
-rw-r--r--app/views/events/_form.html.erb27
-rw-r--r--app/views/events/edit.html.erb10
-rw-r--r--app/views/events/index.html.erb18
-rw-r--r--app/views/events/index.json.jbuilder1
-rw-r--r--app/views/events/new.html.erb9
-rw-r--r--app/views/events/show.html.erb10
-rw-r--r--app/views/events/show.json.jbuilder1
-rw-r--r--app/views/layouts/application.html.erb18
-rw-r--r--app/views/layouts/mailer.html.erb13
-rw-r--r--app/views/layouts/mailer.text.erb1
-rw-r--r--app/views/pages/index.html.erb9
36 files changed, 276 insertions, 0 deletions
diff --git a/app/assets/builds/.keep b/app/assets/builds/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/app/assets/builds/.keep
diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js
new file mode 100644
index 0000000..9a99757
--- /dev/null
+++ b/app/assets/config/manifest.js
@@ -0,0 +1,2 @@
+//= link_tree ../images
+//= link_tree ../builds
diff --git a/app/assets/images/.keep b/app/assets/images/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/app/assets/images/.keep
diff --git a/app/assets/stylesheets/_header.scss b/app/assets/stylesheets/_header.scss
new file mode 100644
index 0000000..723e9d1
--- /dev/null
+++ b/app/assets/stylesheets/_header.scss
@@ -0,0 +1,4 @@
+#header-title {
+ background-color: yellow;
+ color: red;
+}
diff --git a/app/assets/stylesheets/application.bootstrap.scss b/app/assets/stylesheets/application.bootstrap.scss
new file mode 100644
index 0000000..834724c
--- /dev/null
+++ b/app/assets/stylesheets/application.bootstrap.scss
@@ -0,0 +1,3 @@
+@import 'bootstrap/scss/bootstrap';
+@import 'bootstrap-icons/font/bootstrap-icons';
+@import '_header.scss';
diff --git a/app/channels/application_cable/channel.rb b/app/channels/application_cable/channel.rb
new file mode 100644
index 0000000..d672697
--- /dev/null
+++ b/app/channels/application_cable/channel.rb
@@ -0,0 +1,4 @@
+module ApplicationCable
+ class Channel < ActionCable::Channel::Base
+ end
+end
diff --git a/app/channels/application_cable/connection.rb b/app/channels/application_cable/connection.rb
new file mode 100644
index 0000000..0ff5442
--- /dev/null
+++ b/app/channels/application_cable/connection.rb
@@ -0,0 +1,4 @@
+module ApplicationCable
+ class Connection < ActionCable::Connection::Base
+ end
+end
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
new file mode 100644
index 0000000..09705d1
--- /dev/null
+++ b/app/controllers/application_controller.rb
@@ -0,0 +1,2 @@
+class ApplicationController < ActionController::Base
+end
diff --git a/app/controllers/concerns/.keep b/app/controllers/concerns/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/app/controllers/concerns/.keep
diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb
new file mode 100644
index 0000000..13c7cec
--- /dev/null
+++ b/app/controllers/events_controller.rb
@@ -0,0 +1,70 @@
+class EventsController < ApplicationController
+ before_action :set_event, only: %i[ show edit update destroy ]
+
+ # GET /events or /events.json
+ def index
+ @events = Event.all
+ end
+
+ # GET /events/1 or /events/1.json
+ def show
+ end
+
+ # GET /events/new
+ def new
+ @event = Event.new
+ end
+
+ # GET /events/1/edit
+ def edit
+ end
+
+ # POST /events or /events.json
+ def create
+ @event = Event.new(event_params)
+
+ respond_to do |format|
+ if @event.save
+ format.html { redirect_to event_url(@event), notice: "Event was successfully created." }
+ format.json { render :show, status: :created, location: @event }
+ else
+ format.html { render :new, status: :unprocessable_entity }
+ format.json { render json: @event.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PATCH/PUT /events/1 or /events/1.json
+ def update
+ respond_to do |format|
+ if @event.update(event_params)
+ format.html { redirect_to event_url(@event), notice: "Event was successfully updated." }
+ format.json { render :show, status: :ok, location: @event }
+ else
+ format.html { render :edit, status: :unprocessable_entity }
+ format.json { render json: @event.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /events/1 or /events/1.json
+ def destroy
+ @event.destroy!
+
+ respond_to do |format|
+ format.html { redirect_to events_url, notice: "Event was successfully destroyed." }
+ format.json { head :no_content }
+ end
+ end
+
+ private
+ # Use callbacks to share common setup or constraints between actions.
+ def set_event
+ @event = Event.find(params[:id])
+ end
+
+ # Only allow a list of trusted parameters through.
+ def event_params
+ params.require(:event).permit(:date, :name)
+ end
+end
diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb
new file mode 100644
index 0000000..39848c6
--- /dev/null
+++ b/app/controllers/pages_controller.rb
@@ -0,0 +1,4 @@
+class PagesController < ApplicationController
+ def index
+ end
+end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
new file mode 100644
index 0000000..de6be79
--- /dev/null
+++ b/app/helpers/application_helper.rb
@@ -0,0 +1,2 @@
+module ApplicationHelper
+end
diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb
new file mode 100644
index 0000000..8a9a878
--- /dev/null
+++ b/app/helpers/events_helper.rb
@@ -0,0 +1,2 @@
+module EventsHelper
+end
diff --git a/app/helpers/pages_helper.rb b/app/helpers/pages_helper.rb
new file mode 100644
index 0000000..2c057fd
--- /dev/null
+++ b/app/helpers/pages_helper.rb
@@ -0,0 +1,2 @@
+module PagesHelper
+end
diff --git a/app/javascript/application.js b/app/javascript/application.js
new file mode 100644
index 0000000..3016c21
--- /dev/null
+++ b/app/javascript/application.js
@@ -0,0 +1,4 @@
+// Entry point for the build script in your package.json
+import "@hotwired/turbo-rails"
+import "./controllers"
+import * as bootstrap from "bootstrap"
diff --git a/app/javascript/controllers/application.js b/app/javascript/controllers/application.js
new file mode 100644
index 0000000..1213e85
--- /dev/null
+++ b/app/javascript/controllers/application.js
@@ -0,0 +1,9 @@
+import { Application } from "@hotwired/stimulus"
+
+const application = Application.start()
+
+// Configure Stimulus development experience
+application.debug = false
+window.Stimulus = application
+
+export { application }
diff --git a/app/javascript/controllers/hello_controller.js b/app/javascript/controllers/hello_controller.js
new file mode 100644
index 0000000..5975c07
--- /dev/null
+++ b/app/javascript/controllers/hello_controller.js
@@ -0,0 +1,7 @@
+import { Controller } from "@hotwired/stimulus"
+
+export default class extends Controller {
+ connect() {
+ this.element.textContent = "Hello World!"
+ }
+}
diff --git a/app/javascript/controllers/index.js b/app/javascript/controllers/index.js
new file mode 100644
index 0000000..d0685d3
--- /dev/null
+++ b/app/javascript/controllers/index.js
@@ -0,0 +1,8 @@
+// This file is auto-generated by ./bin/rails stimulus:manifest:update
+// Run that command whenever you add a new controller or create them with
+// ./bin/rails generate stimulus controllerName
+
+import { application } from "./application"
+
+import HelloController from "./hello_controller"
+application.register("hello", HelloController)
diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb
new file mode 100644
index 0000000..d394c3d
--- /dev/null
+++ b/app/jobs/application_job.rb
@@ -0,0 +1,7 @@
+class ApplicationJob < ActiveJob::Base
+ # Automatically retry jobs that encountered a deadlock
+ # retry_on ActiveRecord::Deadlocked
+
+ # Most jobs are safe to ignore if the underlying records are no longer available
+ # discard_on ActiveJob::DeserializationError
+end
diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb
new file mode 100644
index 0000000..3c34c81
--- /dev/null
+++ b/app/mailers/application_mailer.rb
@@ -0,0 +1,4 @@
+class ApplicationMailer < ActionMailer::Base
+ default from: "from@example.com"
+ layout "mailer"
+end
diff --git a/app/models/application_record.rb b/app/models/application_record.rb
new file mode 100644
index 0000000..b63caeb
--- /dev/null
+++ b/app/models/application_record.rb
@@ -0,0 +1,3 @@
+class ApplicationRecord < ActiveRecord::Base
+ primary_abstract_class
+end
diff --git a/app/models/concerns/.keep b/app/models/concerns/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/app/models/concerns/.keep
diff --git a/app/models/event.rb b/app/models/event.rb
new file mode 100644
index 0000000..1f722d3
--- /dev/null
+++ b/app/models/event.rb
@@ -0,0 +1,4 @@
+class Event < ApplicationRecord
+ validates :name, presence: true, length: { maximum: 50 }
+ validates :date, presence: true
+end
diff --git a/app/views/events/_event.html.erb b/app/views/events/_event.html.erb
new file mode 100644
index 0000000..ed43a66
--- /dev/null
+++ b/app/views/events/_event.html.erb
@@ -0,0 +1,12 @@
+<div id="<%= dom_id event %>">
+ <p>
+ <strong>Date:</strong>
+ <%= event.date %>
+ </p>
+
+ <p>
+ <strong>Name:</strong>
+ <%= event.name %>
+ </p>
+
+</div>
diff --git a/app/views/events/_event.json.jbuilder b/app/views/events/_event.json.jbuilder
new file mode 100644
index 0000000..64eb849
--- /dev/null
+++ b/app/views/events/_event.json.jbuilder
@@ -0,0 +1,2 @@
+json.extract! event, :id, :date, :name, :created_at, :updated_at
+json.url event_url(event, format: :json)
diff --git a/app/views/events/_form.html.erb b/app/views/events/_form.html.erb
new file mode 100644
index 0000000..db05a72
--- /dev/null
+++ b/app/views/events/_form.html.erb
@@ -0,0 +1,27 @@
+<%= form_with(model: event) do |form| %>
+ <% if event.errors.any? %>
+ <div style="color: red">
+ <h2><%= pluralize(event.errors.count, "error") %> prohibited this event from being saved:</h2>
+
+ <ul>
+ <% event.errors.each do |error| %>
+ <li><%= error.full_message %></li>
+ <% end %>
+ </ul>
+ </div>
+ <% end %>
+
+ <div>
+ <%= form.label :date, style: "display: block" %>
+ <%= form.date_field :date %>
+ </div>
+
+ <div>
+ <%= form.label :name, style: "display: block" %>
+ <%= form.text_field :name %>
+ </div>
+
+ <div>
+ <%= form.submit %>
+ </div>
+<% end %>
diff --git a/app/views/events/edit.html.erb b/app/views/events/edit.html.erb
new file mode 100644
index 0000000..e398927
--- /dev/null
+++ b/app/views/events/edit.html.erb
@@ -0,0 +1,10 @@
+<h1>Editing event</h1>
+
+<%= render "form", event: @event %>
+
+<br>
+
+<div>
+ <%= link_to "Show this event", @event %> |
+ <%= link_to "Back to events", events_path %>
+</div>
diff --git a/app/views/events/index.html.erb b/app/views/events/index.html.erb
new file mode 100644
index 0000000..654d317
--- /dev/null
+++ b/app/views/events/index.html.erb
@@ -0,0 +1,18 @@
+<p style="color: green"><%= notice %></p>
+
+<h1>Events</h1>
+
+<%= link_to "New event", new_event_path %>
+
+<table class="table table-success table-striped table-bordered mt-2">
+ <tr>
+ <th>Date</th>
+ <th>Name</th>
+ </tr>
+ <% @events.each do |e| %>
+ <tr>
+ <td><%= e.name %></td>
+ <td><%= e.date.to_formatted_s(:rfc822) %></td>
+ </tr>
+ <% end %>
+</table>
diff --git a/app/views/events/index.json.jbuilder b/app/views/events/index.json.jbuilder
new file mode 100644
index 0000000..034fd83
--- /dev/null
+++ b/app/views/events/index.json.jbuilder
@@ -0,0 +1 @@
+json.array! @events, partial: "events/event", as: :event
diff --git a/app/views/events/new.html.erb b/app/views/events/new.html.erb
new file mode 100644
index 0000000..efe61e5
--- /dev/null
+++ b/app/views/events/new.html.erb
@@ -0,0 +1,9 @@
+<h1>New event</h1>
+
+<%= render "form", event: @event %>
+
+<br>
+
+<div>
+ <%= link_to "Back to events", events_path %>
+</div>
diff --git a/app/views/events/show.html.erb b/app/views/events/show.html.erb
new file mode 100644
index 0000000..f8276e2
--- /dev/null
+++ b/app/views/events/show.html.erb
@@ -0,0 +1,10 @@
+<p style="color: green"><%= notice %></p>
+
+<%= render @event %>
+
+<div>
+ <%= link_to "Edit this event", edit_event_path(@event) %> |
+ <%= link_to "Back to events", events_path %>
+
+ <%= button_to "Destroy this event", @event, method: :delete %>
+</div>
diff --git a/app/views/events/show.json.jbuilder b/app/views/events/show.json.jbuilder
new file mode 100644
index 0000000..1b1c36e
--- /dev/null
+++ b/app/views/events/show.json.jbuilder
@@ -0,0 +1 @@
+json.partial! "events/event", event: @event
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
new file mode 100644
index 0000000..c502f4d
--- /dev/null
+++ b/app/views/layouts/application.html.erb
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Ded</title>
+ <meta name="viewport" content="width=device-width,initial-scale=1">
+ <%= csrf_meta_tags %>
+ <%= csp_meta_tag %>
+
+ <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
+ <%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>
+ </head>
+
+ <body>
+ <div class="container">
+ <%= yield %>
+ </div>
+ </body>
+</html>
diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb
new file mode 100644
index 0000000..3aac900
--- /dev/null
+++ b/app/views/layouts/mailer.html.erb
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <style>
+ /* Email styles need to be inline */
+ </style>
+ </head>
+
+ <body>
+ <%= yield %>
+ </body>
+</html>
diff --git a/app/views/layouts/mailer.text.erb b/app/views/layouts/mailer.text.erb
new file mode 100644
index 0000000..37f0bdd
--- /dev/null
+++ b/app/views/layouts/mailer.text.erb
@@ -0,0 +1 @@
+<%= yield %>
diff --git a/app/views/pages/index.html.erb b/app/views/pages/index.html.erb
new file mode 100644
index 0000000..cf72e40
--- /dev/null
+++ b/app/views/pages/index.html.erb
@@ -0,0 +1,9 @@
+<div class="row mt-2">
+
+ <h1 id="header-title">DefNucSyR Engagement Database</h1>
+
+ <p>This is some text about the page.</p>
+
+</div>
+
+