Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show a welcome page when the application doesn't have routes
- Loading branch information
Showing
5 changed files
with
107 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Lotus — A complete web framework for Ruby</title> | ||
<style> | ||
* { margin: 0; padding: 0; } | ||
body { font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; color: #333; background-color: #ecf0f1; font-size: 16px; line-height: 24px; } | ||
h1, h2, h3 { margin: -20px; line-height: 100px; text-align: center; } | ||
h1 { font-size: 60px; color: #551e54; } | ||
h2 { font-size: 30px; } | ||
h3 { font-size: 20px; line-height: 22px; color: #666; } | ||
hr { margin: 2em; color: #ecf0f1; } | ||
ul { text-align: center; } | ||
li { display: inline; margin: 3em; line-height: 24px; list-style-type: none; vertical-align: text-top;} | ||
a { color: #333; padding: 1px; } | ||
#container { margin:0 auto; padding: 24px; width:700px; background-color:#fff; border: 1px solid #999; border-width: 0 1px 1px 1px; } | ||
#content { margin: 30px 10px 0 10px; } | ||
#footer { margin:0 auto 0; padding: 12px; width:700px; line-height: 24px; font-size: 12px; } | ||
.bold { font-weight: bold; } | ||
</style> | ||
</head> | ||
<body> | ||
<div id="container"> | ||
<h1>Lotus</h1> | ||
<hr /> | ||
<h2>A complete web framework for Ruby</h2> | ||
|
||
<h3>Lotus is Open Source Software for MVC web development.<br /> | ||
It's simple, fast and lightweight.</h3> | ||
|
||
<hr style="margin-top: 4em;"/> | ||
<div id="content"> | ||
<ul> | ||
<li><a href="http://lotusrb.org">Website</a></li> | ||
<li><a href="http://www.rubydoc.info/gems/lotusrb">API docs</a></li> | ||
<li><a href="https://github.com/lotus/lotus">Source code</a></li> | ||
<li><a href="https://gitter.im/lotus/chat">Chat</a></li> | ||
</ul> | ||
</div> | ||
</div> | ||
<div id="footer"> | ||
© 2014 Luca Guidi — Lotus is released under the MIT License. | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require 'pathname' | ||
|
||
module Lotus | ||
class Welcome | ||
def initialize(app) | ||
@root = Pathname.new(__dir__).join('templates').realpath | ||
@body = [@root.join('welcome.html').read] | ||
end | ||
|
||
def call(env) | ||
[200, {}, @body] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module WelcomeApp | ||
class Application < Lotus::Application | ||
configure do | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require 'test_helper' | ||
require 'rack/test' | ||
require 'fixtures/welcome_app/application' | ||
|
||
describe 'Welcome page' do | ||
include Rack::Test::Methods | ||
|
||
before do | ||
@current_dir = Dir.pwd | ||
Dir.chdir FIXTURES_ROOT.join('welcome') | ||
@app = WelcomeApp::Application.new | ||
end | ||
|
||
after do | ||
Dir.chdir @current_dir | ||
@current_dir = nil | ||
end | ||
|
||
def app | ||
@app | ||
end | ||
|
||
def response | ||
last_response | ||
end | ||
|
||
it 'shows a welcome page when no routes were set' do | ||
get '/' | ||
|
||
response.status.must_equal 200 | ||
response.body.must_include %(Lotus) | ||
end | ||
end |