Browse Source

Add "not found" page

tags/v1.0
Matt Baer 8 years ago
parent
commit
81af860076
2 changed files with 51 additions and 0 deletions
  1. +11
    -0
      construction.go
  2. +40
    -0
      static/404.html

+ 11
- 0
construction.go View File

@@ -3,6 +3,7 @@ package htmlhouse
import (
"database/sql"
"fmt"
"io/ioutil"
"net/http"
"regexp"
"strings"
@@ -90,6 +91,16 @@ func getHouse(app *app, w http.ResponseWriter, r *http.Request) error {
// Fetch HTML
html, err := getHouseHTML(app, houseID)
if err != nil {
if err, ok := err.(impart.HTTPError); ok {
if err.Status == http.StatusNotFound {
page, err := ioutil.ReadFile(app.cfg.StaticDir + "/404.html")
if err != nil {
page = []byte("<!DOCTYPE html><html><body>HTMLlot.</body></html>")
}
fmt.Fprintf(w, "%s", page)
return nil
}
}
return err
}



+ 40
- 0
static/404.html View File

@@ -0,0 +1,40 @@
<!DOCTYPE HTML>
<html>
<head>

<title>HTMLlot</title>
<link rel="stylesheet" type="text/css" href="/css/house.css" />
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="icon" type="image/png" href="/img/favicon-chrome.png" sizes="192x192">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#888888" />

</head>
<body>
<header>
<h1>HTMLlot</h1>
<nav>
<a class="home" href="/">&lt;&#8962;/&gt;</a>
<a href="/about.html">about</a>
<a href="mailto:hello@write.as">contact</a>
<a target="_blank" href="https://twitter.com/htmlhouse">@HTMLhouse</a>
</nav>
</header>

<div id="wrapper">
<p>You arrive at a patch of dirt and detritus. <a href="/">Start building?</a></p>
</div>

<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-47877053-8', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>

Loading…
Cancel
Save