implement title properly and update 404 handling

pull/38/head
Mike Heijmans 2017-08-07 09:30:58 -05:00
parent 531229b508
commit 0b36fcb6a2
4 changed files with 22 additions and 13 deletions

View File

@ -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

View File

@ -28,13 +28,9 @@
</nav>
<br/><br/><br/>
<div class="container">
<h1>Not Found</h1>
<div>
UhOh! the page you're looking for doesn't exist here... Perhaps it fell off the boat?
</div>
<div>
<br/><br/>
<img class="img-responsive" src="/404.png"/>
<h3>404 page not found</h3>
<p>The page you are looking for does not exist.</p>
</div>
</div>
</body>

View File

@ -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

View File

@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Crane Operator</title>
<title><%=title%></title>
<!-- bootstrap css -->
<link rel="stylesheet" href="/bootstrap.min.css" crossorigin="anonymous">