Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support a real 404 page. #38

Merged
merged 2 commits into from
Oct 17, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ source "https://rubygems.org"
gem "rake"
gem "rack"
gem "rack-rewrite"
gem "rack-contrib"

group :development do
gem "middleman", "~>3.1.5"
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ GEM
rouge (~> 0.3.0)
multi_json (1.8.1)
rack (1.5.2)
rack-contrib (1.1.0)
rack (>= 0.9.1)
rack-livereload (0.3.15)
rack
rack-rewrite (1.4.01)
Expand Down Expand Up @@ -118,6 +120,7 @@ DEPENDENCIES
middleman-livereload
middleman-syntax
rack
rack-contrib
rack-rewrite
rake
redcarpet
Expand Down
22 changes: 12 additions & 10 deletions config.ru
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require "rubygems"

require "rack/rewrite"
require "rack/contrib/not_found"
require "rack/contrib/try_static"

use Rack::Rewrite do
r301 %r{/docs/yardoc/(.*)}, '/documentation/$1'
Expand All @@ -10,20 +12,20 @@ use Rack::Rewrite do
r301 '/documentation/_index.html', '/documentation/'
r301 '/try', 'http://sassmeister.com'
r301 '/try.html', 'http://sassmeister.com'

rewrite(%r{^(.*)/([^/.]+)$}, lambda do |match, rack_env|
path = "#{File.dirname(__FILE__)}/build#{match[0]}"
next "#{match[1]}/#{match[2]}/index.html" if Dir.exists?(path)
next match[0] if File.exists?(path)
"#{match[0]}.html"
end)
end

if ENV["HEROKU"].nil? || ENV["HEROKU"] == 'false'
require "middleman"
run Middleman.server

server = Middleman.server
run Rack::Cascade.new([
server,
lambda {|env| server.call(env.merge!('PATH_INFO' => '/404'))}
])
else
use Rack::Static, :urls => [""], :root => 'build', :index => 'index.html'
use Rack::TryStatic,
:urls => ["/"], :root => 'build', :index => 'index.html',
:try => ['.html', '/index.html']

run lambda {}
run Rack::NotFound.new("build/404/index.html")
end
157 changes: 0 additions & 157 deletions source/404.html.erb

This file was deleted.

19 changes: 19 additions & 0 deletions source/404.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: "Not found :("
---

- content_for :css do
= stylesheet_link_tag "404"

- content_for :introduction do
Sorry, but the page you were trying to view does not exist.

%p It looks like this was the result of either:
%ul
%li a mistyped address
%li an out-of-date link

- content_for :complementary do
:javascript
var GOOG_FIXURL_LANG = (navigator.language || '').slice(0,2),GOOG_FIXURL_SITE = location.host;
%script(src="//linkhelp.clients.google.com/tbproxy/lh/wm/fixurl.js")
21 changes: 21 additions & 0 deletions source/assets/css/404.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@import "compass";
@import "breakpoint";

@import "dependencies/layout";
@import "dependencies/color";

@import "foundation/forms";

@import "components/forms";
@import "components/buttons";

#goog-fixurl .content {
margin: 0;
padding: 0;
}

#goog-wm-sb {
@extend .button;
@extend .primary;
@include leader;
}
2 changes: 2 additions & 0 deletions source/layouts/head/_css.haml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
= stylesheet_link_tag "sass"
- if content_for?(:css)
= yield_content :css