diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5d2ca8f..b44bfca 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -11,6 +11,13 @@ class ApplicationController < Sinatra::Base set :port, 4567 end + before do + local_network = LocalNetwork.first + @dark_hex = local_network.primary_dark_hex || "140029" + @light_hex = local_network.primary_light_hex || "8000FF" + @accent_hex = local_network.accent_hex || "2FD400" + end + get '/' do client_ip = request.ip.to_s puts client_ip @@ -37,13 +44,13 @@ class ApplicationController < Sinatra::Base get '/admin/local_network' do @local_network = LocalNetwork.first || LocalNetwork.new - @is_readonly = true + @editing = true erb :'admin/local_network/index' end get '/admin/local_network/edit' do @local_network = LocalNetwork.first || LocalNetwork.create - @is_readonly = false + @editing = false erb :'admin/local_network/index' end @@ -58,13 +65,13 @@ class ApplicationController < Sinatra::Base get '/admin/machines' do @machines = Machine.all - @is_readonly = true + @editing = true erb :'admin/machines/index' end get '/admin/machines/edit' do @machines = Machine.all - @is_readonly = false + @editing = false erb :'admin/machines/index' end @@ -83,37 +90,44 @@ class ApplicationController < Sinatra::Base get '/admin/service_types' do @service_types = ServiceType.all - @is_readonly = true + @editing = true erb :'admin/service_types/index' end get '/admin/service_types/edit' do @service_types = ServiceType.all - @is_readonly = false + @editing = false erb :'admin/service_types/index' end - get '/admin/service_types/media' do - @service_type = ServiceType.media + get '/admin/service_types/:name' do + type_name = params[:name] + @service_type = ServiceType.public_send(type_name) + # @service_type = ServiceType.media erb :'admin/service_types/position' end - get '/admin/service_types/admin' do - @service_type = ServiceType.admin - erb :'admin/service_types/position' - end + # get '/admin/service_types/media' do + # @service_type = ServiceType.media + # erb :'admin/service_types/position' + # end - get '/admin/service_types/support' do - @service_type = ServiceType.support - erb :'admin/service_types/position' - end + # get '/admin/service_types/admin' do + # @service_type = ServiceType.admin + # erb :'admin/service_types/position' + # end + + # get '/admin/service_types/support' do + # @service_type = ServiceType.support + # erb :'admin/service_types/position' + # end post '/admin/service_types' do puts params params[:service_types].each do |service_type_data| if service_type_data[:id].empty? && service_type_data[:name].present? ServiceType.create(service_type_data) - elsif service_type_data[:id].present? + elsif service_type_data[:id].present? && service_type_data[:name].present? @service_type = ServiceType.find(service_type_data[:id]) @service_type.update(service_type_data) end @@ -125,7 +139,7 @@ class ApplicationController < Sinatra::Base @services = Service.all @service_types = ServiceType.all @machines = Machine.all - @is_readonly = true + @editing = true erb :'admin/services/index' end @@ -133,7 +147,7 @@ class ApplicationController < Sinatra::Base @services = Service.all @service_types = ServiceType.all @machines = Machine.all - @is_readonly = false + @editing = false erb :'admin/services/index' end diff --git a/app/views/admin/index.erb b/app/views/admin/index.erb index c9b8881..a7bfa67 100644 --- a/app/views/admin/index.erb +++ b/app/views/admin/index.erb @@ -1,23 +1,28 @@ +
Network Directory Admin
-
- + - +
diff --git a/app/views/admin/local_network/index.erb b/app/views/admin/local_network/index.erb index b525026..392c012 100644 --- a/app/views/admin/local_network/index.erb +++ b/app/views/admin/local_network/index.erb @@ -3,10 +3,10 @@
Local Network Settings
- <% unless @is_readonly %> + <% unless @editing %>
-
Edit
-
+
Edit
+
<% end %>
@@ -14,35 +14,53 @@
- > -
Name
+ > +
Name
- > -
Subnet
+ > +
Subnet
- > -
Top Level Domain
+ > +
Top Level Domain
+
+ +
+ > +
Site Primary Dark Hex
+
+ +
+ > +
Site Primary Light Hex
+
+ +
+ > +
Site Accent Hex
- <% if @is_readonly %> -
- + <% if @editing %> + <% else %> -
- - + Cancel
diff --git a/app/views/admin/machines/index.erb b/app/views/admin/machines/index.erb index 592bcbe..8da547a 100644 --- a/app/views/admin/machines/index.erb +++ b/app/views/admin/machines/index.erb @@ -3,10 +3,10 @@
Network Machines
- <% unless @is_readonly %> + <% unless @editing %>
-
Edit
-
+
Edit
+
<% end %>
@@ -16,49 +16,49 @@
> + <%= 'readonly' if @editing %> > <% if index == @machines.length - 1 %> -
Name
+
Name
<% end %>
> + <%= 'readonly' if @editing %> > <% if index == @machines.length - 1 %> -
Domain
+
Domain
<% end %>
> + <%= 'readonly' if @editing %> > <% if index == @machines.length - 1 %> -
Local IP Octet
+
Local IP Octet
<% end %>
> + <%= 'readonly' if @editing %> > <% if index == @machines.length - 1 %> -
Tailscale IP
+
Tailscale IP
<% end %>
@@ -67,65 +67,68 @@
- <% if @is_readonly %> -
- + <% if @editing %> + <% else %>
-
New
-
+
New
+
> - + <%= 'readonly' if @editing %> > +
> - + <%= 'readonly' if @editing %> > +
> - + <%= 'readonly' if @editing %> > +
> - + <%= 'readonly' if @editing %> > +
-
- - + Cancel
diff --git a/app/views/admin/service_types/index.erb b/app/views/admin/service_types/index.erb index 3ba5633..0a17d5b 100644 --- a/app/views/admin/service_types/index.erb +++ b/app/views/admin/service_types/index.erb @@ -3,10 +3,10 @@
Service Types
- <% unless @is_readonly %> + <% unless @editing %>
-
Edit
-
+
Edit
+
<% end %>
@@ -16,72 +16,90 @@
> + <%= 'readonly' if @editing %> > <% if index == @service_types.length - 1 %> -
Name
+
Name
<% end %>
> + <%= 'readonly' if @editing %> > <% if index == @service_types.length - 1 %> -
Hex Color
+
Hex Color
<% end %>
+ +
+
+ <%= servt.services.count %> +
+ <% if index == @service_types.length - 1 %> +
Services Count
+ <% end %> +
+ +
<% end %>
- <% if @is_readonly %> -
- + <% if @editing %> + <% else %>
-
New
-
+
New
+
> - + <%= 'readonly' if @editing %> > +
> - + <%= 'readonly' if @editing %> > +
-
- - + Cancel
diff --git a/app/views/admin/service_types/position.erb b/app/views/admin/service_types/position.erb index 560afab..f70854b 100644 --- a/app/views/admin/service_types/position.erb +++ b/app/views/admin/service_types/position.erb @@ -10,33 +10,33 @@
<% if index == @service_type.services.length - 1 %> -
Name
+
Name
<% end %>
<% if index == @service_type.services.length - 1 %> -
Position
+
Position
<% end %>
<% end %> -
- - + Cancel
diff --git a/app/views/admin/services/index.erb b/app/views/admin/services/index.erb index e061fe9..5ad5d57 100644 --- a/app/views/admin/services/index.erb +++ b/app/views/admin/services/index.erb @@ -3,10 +3,10 @@
Services
- <% unless @is_readonly %> + <% unless @editing %>
-
Edit
-
+
Edit
+
<% end %>
@@ -16,73 +16,73 @@
> + <%= 'readonly' if @editing %> > <% if index == @services.length - 1 %> -
Name
+
">Name
<% end %>
- > <% @service_types.each do |service_type| %> <% end %> <% if index == @services.length - 1 %> -
Service Type
+
">Service Type
<% end %>
- > <% @machines.each do |machine| %> <% end %> <% if index == @services.length - 1 %> -
Machine
+
">Machine
<% end %>
> + <%= 'readonly' if @editing %> > <% if index == @services.length - 1 %> -
Subdomain
+
">Subdomain
<% end %>
> + <%= 'readonly' if @editing %> > <% if index == @services.length - 1 %> -
Port
+
">Port
<% end %>
> + <%= 'readonly' if @editing %> > <% if index == @services.length - 1 %> -
URL Path (optional)
+
">URL Path (optional)
<% end %>
@@ -92,82 +92,85 @@
- <% if @is_readonly %> -
- + <% if @editing %> + <% else %>
-
New
-
+
New
+
-
Name
+
Name
- > <% @service_types.each do |service_type| %> <% end %> -
Service Type
+
Service Type
- > <% @machines.each do |machine| %> <% end %> -
Machine
+
Machine
-
Subdomain
+
Subdomain
-
Port
+
Port
-
URL Path (optional)
+
URL Path (optional)
-
- - + Cancel
diff --git a/app/views/index.erb b/app/views/index.erb index ef0ca9f..fae0454 100644 --- a/app/views/index.erb +++ b/app/views/index.erb @@ -1,27 +1,27 @@ -
+
-
Local Network Directory
-
-
+
Local Network Directory
+
+
<% if @url_type == 'tailscale' %> <%= @url_type.gsub('_', ' ') %> <% elsif @url_type == 'local_ip' %> - + <%= @url_type.gsub('_', ' ') %> <% else %> - + <%= @url_type.gsub('_', ' ') %> <% end %>
-
+
- diff --git a/app/views/layout.erb b/app/views/layout.erb index 8fd8a0a..11588b4 100644 --- a/app/views/layout.erb +++ b/app/views/layout.erb @@ -5,7 +5,7 @@ Network Directory - +
<%= yield %>
diff --git a/db/migrate/20260615190916_add_colors_to_local_network.rb b/db/migrate/20260615190916_add_colors_to_local_network.rb new file mode 100644 index 0000000..746cdfc --- /dev/null +++ b/db/migrate/20260615190916_add_colors_to_local_network.rb @@ -0,0 +1,7 @@ +class AddColorsToLocalNetwork < ActiveRecord::Migration[7.2] + def change + add_column :local_networks, :primary_dark_hex, :string + add_column :local_networks, :primary_light_hex, :string + add_column :local_networks, :accent_hex, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index ec4fc7e..1e0c040 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,13 +10,16 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.2].define(version: 2026_05_27_212837) do +ActiveRecord::Schema[7.2].define(version: 2026_06_16_133017) do create_table "local_networks", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.string "name" t.string "subnet" t.string "tld" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.string "primary_dark_hex" + t.string "primary_light_hex" + t.string "accent_hex" end create_table "machines", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| diff --git a/public/images/purplegreenblackfire-0.svg b/public/images/purplegreenblackfire-0.svg new file mode 100644 index 0000000..cf13914 --- /dev/null +++ b/public/images/purplegreenblackfire-0.svg @@ -0,0 +1,1510 @@ + + + + greenfire + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + greenfire + + + + diff --git a/public/images/purplegreenblackfire.svg b/public/images/purplegreenblackfire.svg index d8c2046..0ff25c3 100644 --- a/public/images/purplegreenblackfire.svg +++ b/public/images/purplegreenblackfire.svg @@ -5,7 +5,7 @@ width="347pt" version="1.1" id="svg1497" - sodipodi:docname="fullyblackfire.svg" + sodipodi:docname="purplegreenblackfire.svg" inkscape:version="1.4.2 (ebf0e940, 2025-05-08)" inkscape:export-filename="fullyblackfire.svg" inkscape:export-xdpi="96" @@ -1094,24 +1094,24 @@ + style="stop-color:#46008a;stop-opacity:1;" />