add error page
parent
58c99d7f57
commit
9e116d4b20
|
@ -42,6 +42,7 @@ import QRCodePage
|
|||
import diagnostics
|
||||
import Sitemap
|
||||
import Formatters
|
||||
from errors import ErrorPage
|
||||
|
||||
import Timer
|
||||
|
||||
|
@ -51,6 +52,10 @@ install_dir = os.path.dirname(os.path.abspath(__file__))
|
|||
CHERRYPY_CONFIG = os.path.join(install_dir, 'CherryPy.conf')
|
||||
LOCAL_CONFIG = [os.path.expanduser('~/.autocat3'), '/etc/autocat3.conf']
|
||||
|
||||
def error_page_404(status, message, traceback, version):
|
||||
return ErrorPage(status, message).index()
|
||||
|
||||
|
||||
class MyRoutesDispatcher(cherrypy.dispatch.RoutesDispatcher):
|
||||
""" Dispatcher that tells us the matched route.
|
||||
|
||||
|
@ -157,6 +162,8 @@ def main():
|
|||
|
||||
cherrypy.config['all_hosts'] = (
|
||||
cherrypy.config['host'], cherrypy.config['host_mobile'], cherrypy.config['file_host'])
|
||||
|
||||
cherrypy.config.update({'error_page.404': error_page_404})
|
||||
|
||||
if hasattr(cherrypy.engine, 'signal_handler'):
|
||||
cherrypy.engine.signal_handler.subscribe()
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- mode: python; indent-tabs-mode: nil; -*- coding: utf-8 -*-
|
||||
|
||||
from BaseSearcher import OpenSearch
|
||||
from Page import Page
|
||||
import Formatters
|
||||
|
||||
class ErrorPage(Page):
|
||||
|
||||
def __init__(self, status=500, message='undefined error'):
|
||||
self.message = message
|
||||
self.status = status
|
||||
|
||||
def index(self):
|
||||
return Formatters.formatters['html'].render('error', self)
|
|
@ -0,0 +1,123 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:xi="http://www.w3.org/2001/XInclude"
|
||||
xmlns:py="http://genshi.edgewall.org/"
|
||||
xmlns:i18n="http://genshi.edgewall.org/i18n"
|
||||
xmlns:og="http://opengraphprotocol.org/schema/"
|
||||
xmlns:fb="http://www.facebook.com/2008/fbml"
|
||||
py:strip="">
|
||||
<head>
|
||||
<style type="text/css">
|
||||
.icon { background: transparent url(/pics/sprite.png?${cherrypy.config['css_mtime']}) 0 0 no-repeat; }
|
||||
</style>
|
||||
|
||||
<link rel="stylesheet" type="text/css"
|
||||
href="/css/pg-desktop-one.css?${cherrypy.config['css_mtime']}" />
|
||||
<link rel="shortcut icon" href="/pics/favicon" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<meta http-equiv="Content-Style-Type" content="text/css" />
|
||||
|
||||
<!--! plain old metadata -->
|
||||
<meta name="title" content="${os.message}" />
|
||||
<title>${os.message}</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="mw-head-dummy" class="noprint" />
|
||||
|
||||
<div id="content" i18n:comment="On the page of results of a search.">
|
||||
<div class="header">
|
||||
<h1>${os.message}</h1>
|
||||
</div>
|
||||
|
||||
<div class="body">
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="fb-root" />
|
||||
|
||||
<div id="print-head" class="noscreen">
|
||||
<div class="center">Project Gutenberg offers thousands of free ebooks to download.</div>
|
||||
</div>
|
||||
|
||||
<div id="screen-head" class="noprint">
|
||||
<table>
|
||||
<tr i18n:comment="The logo, tagline and badges at the very top of every page.">
|
||||
|
||||
<td rowspan="2" id="logo" i18n:comment="The PG logo at the top left of every page.">
|
||||
<a href="/wiki/Main_Page" title="Go to the Main Page.">
|
||||
<span class="icon icon_logo" />
|
||||
</a>
|
||||
</td>
|
||||
|
||||
<td id="tagline-badges" colspan="2">
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td id="tagline">Project Gutenberg offers thousands of free ebooks to download.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr id="menubar-search">
|
||||
<td id="menubar" i18n:comment="The menu bar at the top of every page.">
|
||||
<a id="menubar-first"
|
||||
tabindex="11" accesskey="1"
|
||||
title="Start a new search."
|
||||
href="/ebooks/">Search</a>
|
||||
|
||||
<a tabindex="22"
|
||||
title="Our latest releases."
|
||||
href="/ebooks/search/?sort_order=release_date">Latest</a>
|
||||
|
||||
<a tabindex="31"
|
||||
title="Read the Project Gutenberg terms of use."
|
||||
href="/terms_of_use/">Terms of Use</a>
|
||||
|
||||
<a tabindex="32"
|
||||
href="/wiki/Gutenberg:Project_Gutenberg_Needs_Your_Donation"
|
||||
title="Learn why we need some money.">Donate?</a>
|
||||
|
||||
</td>
|
||||
|
||||
<td id="search" i18n:comment="The search box at the top right of every page.">
|
||||
<form method="get" action="/ebooks/search/"
|
||||
enctype="multipart/form-data">
|
||||
<table class="borderless">
|
||||
<tr>
|
||||
<td id="search-button-cell">
|
||||
<button id="search-button" type="submit" title="Execute the search. <enter>">
|
||||
<span class="icon icon_smsearch" />
|
||||
</button>
|
||||
</td>
|
||||
<td id="search-input-cell">
|
||||
<input id="search-input" name="query" type="text" title="Search Project Gutenberg. <s>"
|
||||
accesskey="s" value="" />
|
||||
</td>
|
||||
<td id="help-button-cell">
|
||||
<button id="help-button" type="button" title="Open the help menu. <h>"
|
||||
accesskey="h">Help</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div id="helpbox" class="hide">
|
||||
<xi:include href="help.html" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
Loading…
Reference in New Issue