Permalink
Browse files

Use a dynamic error page

That way there's no need to adapt Rails 4's asset digests in the static
page.
  • Loading branch information...
1 parent f02453b commit 9ef4ecbfdbaef96647f9dd68b6c3802a2e79ac02 @koraktor committed Aug 23, 2014
@@ -7,6 +7,8 @@ class ApplicationController < ActionController::Base
rescue_from Mongoid::Errors::DocumentNotFound, with: :not_found
+ rescue_from StandardError, with: :error_page
+
def index
@repository = Repository.main
@@ -29,6 +31,17 @@ def index
fresh_when etag: Repository.main.sha, public: true
end
+ def error_page(error)
+ Airbrake.notify error if defined? Airbrake
+
+ respond_to do |format|
+ render 'application/500', status: :internal_server_error
+ end
+
+ headers.delete 'ETag'
+ expires_in 5.minutes
+ end
+
def not_found
flash.now[:error] = 'The page you requested does not exist.'
index
@@ -0,0 +1,7 @@
+<h1>Someone spilled our beer!</h1>
+<p>Something went horribly wrong will you tried to access our pages.
+But fear not, we have been notified of the problem.</p>
+<p>Please try again in a few seconds. If the problem persists, feel
+free to contact
+<a href="https://twitter.com/braumeister_org">@braumeister_org</a> on
+Twitter.</p>
@@ -31,7 +31,7 @@
</script>
<% end %>
</head>
-<body<% unless @repository.main? %> data-repository="<%= @repository.name %>"<% end %>>
+<body<% unless @repository.nil? || @repository.main? %> data-repository="<%= @repository.name %>"<% end %>>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
View
@@ -1,75 +0,0 @@
-<!DOCTYPE html>
-<html itemscope itemtype="http://schema.org/WebPage" lang="en">
-<head>
- <title>What a mess! – braumeister.org</title>
-
- <link href="/feed.atom" rel="alternate" title="ATOM" type="application/atom+xml">
- <script src="/assets/flattr.js?body=1" type="text/javascript"></script>
- <script src="/assets/jquery.js?body=1" type="text/javascript"></script>
- <script src="/assets/jquery_ujs.js?body=1" type="text/javascript"></script>
- <script src="/assets/application.js?body=1" type="text/javascript"></script>
-
- <link href="/assets/application.css?body=1" media="screen" rel="stylesheet" type="text/css">
- <link rel="search" type="application/opensearchdescription+xml" title="RubyGems.org" href="/opensearch.xml">
-
- <meta http-equiv="content-type" content="text/html;charset=UTF-8">
- <meta itemprop="name" content="braumeister.org">
- <meta itemprop="description" content="An online package browser for Homebrew, the MacOS package manager.">
-
- <script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script>
-</head>
-<body>
- <div id="fb-root"></div>
- <script>(function(d, s, id) {
- var js, fjs = d.getElementsByTagName(s)[0];
- if (d.getElementById(id)) return;
- js = d.createElement(s); js.id = id;
- js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
- fjs.parentNode.insertBefore(js, fjs);
- }(document, 'script', 'facebook-jssdk'));</script>
- <a href="https://github.com/koraktor/braumeister.org">
- <img id="github-ribbon"
- src="http://s3.amazonaws.com/github/ribbons/forkme_left_orange_ff7600.png"
- alt="Fork me on GitHub">
- </a>
- <div id="header">
- <div id="social">
- <div class="g-plusone"
- data-href="http://braumeister.org"
- data-size="tall"></div>
- <a href="http://twitter.com/share" class="twitter-share-button"
- data-count="vertical"
- data-text="See information about Mac packages available via Homebrew – "
- data-url="http://braumeister.org">
- Tweet
- </a>
- <div class="fb-like" data-href="http://braumeister.org" data-width="55" data-height="62" data-colorscheme="light" data-layout="box_count" data-action="like" data-show-faces="true" data-send="false"></div>
- <script id='fbi7dqc'>(function(i){var f,s=document.getElementById(i);f=document.createElement('iframe');f.src='//api.flattr.com/button/view/?uid=Koraktor&url=http%3A%2F%2Fbraumeister.org';f.title='Flattr';f.height=62;f.width=55;f.style.borderWidth=0;s.parentNode.insertBefore(f,s);})('fbi7dqc');</script>
- </div>
- <a href="http://braumeister.org">Braumeister</a>
- </div>
- <div id="content">
- <h1>Someone spilled our beer!</h1>
- <p>Something went horribly wrong will you tried to access our pages.
- But fear not, we have been notified of the problem.</p>
- <p>Please try again in a few seconds. If the problem persists, feel
- free to contact
- <a href="https://twitter.com/braumeister_org">@braumeister_org</a> on
- Twitter.</p>
- </div>
- <div id="footer">
- © 2014 —
- <a href="https://plus.google.com/109586181974940228820?rel=author">
- Sebastian Staudt</a><br>
- Follow <a href="https://twitter.com/braumeister_org">@braumeister_org</a>
- on Twitter.
- </div>
- <script type="text/javascript">
- (function() {
- var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
- po.src = 'https://apis.google.com/js/plusone.js';
- var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
- })();
- </script>
-</body>
-</html>

0 comments on commit 9ef4ecb

Please sign in to comment.