From 0b36fcb6a2c3be1088b4a3175f12c8cedbdeeb3a Mon Sep 17 00:00:00 2001 From: Mike Heijmans Date: Mon, 7 Aug 2017 09:30:58 -0500 Subject: [PATCH] implement title properly and update 404 handling --- lib/config.rb | 7 +++++-- public/404.html | 8 ++------ server.rb | 18 ++++++++++++++---- public/index.html => views/index.erb | 2 +- 4 files changed, 22 insertions(+), 13 deletions(-) rename public/index.html => views/index.erb (95%) diff --git a/lib/config.rb b/lib/config.rb index 14657bc..959b68a 100644 --- a/lib/config.rb +++ b/lib/config.rb @@ -12,7 +12,8 @@ class Configuration :password, :version, :debug, - :login_allowed + :login_allowed, + :title def initialize @registry_username = ENV['REGISTRY_USERNAME'] @@ -28,6 +29,7 @@ class Configuration @version = "2.2" @debug = to_bool(ENV['DEBUG'] || 'false') @login_allowed = to_bool(ENV['ALLOW_REGISTRY_LOGIN'] || 'false') + @title = ENV['TITLE'] || "Crane Operator" end def to_bool(str) @@ -52,7 +54,8 @@ class Configuration :password => @password, :version => @password, :debug => @debug, - :login_allowed => @login_allowed + :login_allowed => @login_allowed, + :title => @title, } end diff --git a/public/404.html b/public/404.html index caef20b..c49c02e 100644 --- a/public/404.html +++ b/public/404.html @@ -28,13 +28,9 @@


-

Not Found

- UhOh! the page you're looking for doesn't exist here... Perhaps it fell off the boat? -
-
-

- +

404 page not found

+

The page you are looking for does not exist.

diff --git a/server.rb b/server.rb index 3ed1c85..299c08f 100644 --- a/server.rb +++ b/server.rb @@ -174,6 +174,7 @@ class CraneOp < Sinatra::Base ssl_verify: conf.ssl_verify, delete_allowed: conf.delete_allowed, login_allowed: conf.login_allowed, + title: conf.title, } if session[:username] info[:username] = session[:username] @@ -190,6 +191,19 @@ class CraneOp < Sinatra::Base response.body end + # React app endpoints + [ + "/containers/*", + "/containers", + "/login", + "/login/", + "/", + ].each do |path| + get path do + erb :index, locals: { title: conf.title} + end + end + # Error Handlers error do File.read(File.join('public', '500.html')) @@ -226,8 +240,4 @@ class CraneOp < Sinatra::Base end - get '/*' do - html :index - end - end diff --git a/public/index.html b/views/index.erb similarity index 95% rename from public/index.html rename to views/index.erb index 1eee5ba..a610c9f 100644 --- a/public/index.html +++ b/views/index.erb @@ -2,7 +2,7 @@ - Crane Operator + <%=title%>