Show More
@@ -0,0 +1,35 b'' | |||
|
1 | ## -*- coding: utf-8 -*- | |
|
2 | <%! | |
|
3 | from pylons_app.lib import filters | |
|
4 | %> | |
|
5 | <%inherit file="./../base/base.html"/> | |
|
6 | ||
|
7 | <%def name="title()"> | |
|
8 | ${_('Repository not found')} | |
|
9 | </%def> | |
|
10 | ||
|
11 | <%def name="breadcrumbs()"> | |
|
12 | ${h.link_to(u'Home',h.url('hg_home'))} | |
|
13 | / | |
|
14 | ${h.link_to(u'Admin',h.url('admin_home'))} | |
|
15 | </%def> | |
|
16 | ||
|
17 | <%def name="page_nav()"> | |
|
18 | <li>${h.link_to(u'Home',h.url('hg_home'))}</li> | |
|
19 | <li class="current">${_('Admin')}</li> | |
|
20 | </%def> | |
|
21 | <%def name="js()"> | |
|
22 | ||
|
23 | </%def> | |
|
24 | <%def name="main()"> | |
|
25 | ||
|
26 | <h2 class="no-link no-border">Not Found</h2> | |
|
27 | <p class="normal">The specified repository "${c.repo_name}" is unknown, sorry.</p> | |
|
28 | <p class="normal"> | |
|
29 | <a href="/_admin/add_repo/${c.repo_name|n,filters.clean_repo}">Create "${c.repo_name}" repository as ${c.repo_name|n,filters.clean_repo}</a> | |
|
30 | ||
|
31 | </p> | |
|
32 | <p class="normal">Go back to the ${h.link_to(_('main repository list page'),h.url('hg_home'))}.</p> | |
|
33 | <div class="page-footer"> | |
|
34 | </div> | |
|
35 | </%def> No newline at end of file |
@@ -1,78 +1,88 b'' | |||
|
1 | 1 | import logging |
|
2 | 2 | from paste.urlparser import PkgResourcesParser |
|
3 | 3 | import paste.fileapp |
|
4 |
from pylons import |
|
|
4 | from pylons import tmpl_context as c, app_globals as g, request, config | |
|
5 | 5 | from pylons.controllers.util import forward |
|
6 | 6 | from pylons.i18n.translation import _ |
|
7 | 7 | from pylons_app.lib.base import BaseController, render |
|
8 | 8 | from pylons.middleware import error_document_template, media_path |
|
9 | 9 | import cgi |
|
10 | 10 | import os |
|
11 | 11 | |
|
12 | 12 | log = logging.getLogger(__name__) |
|
13 | 13 | class ErrorController(BaseController): |
|
14 | 14 | """ |
|
15 | 15 | Generates error documents as and when they are required. |
|
16 | 16 | |
|
17 | 17 | The ErrorDocuments middleware forwards to ErrorController when error |
|
18 | 18 | related status codes are returned from the application. |
|
19 | 19 | |
|
20 | 20 | This behaviour can be altered by changing the parameters to the |
|
21 | 21 | ErrorDocuments middleware in your config/middleware.py file. |
|
22 | 22 | """ |
|
23 | 23 | # |
|
24 | 24 | def __before__(self): |
|
25 | pass | |
|
25 | c.repos_prefix = config['repos_name'] | |
|
26 | c.staticurl = g.statics | |
|
27 | c.repo_name = request.environ['pylons.original_request']\ | |
|
28 | .environ.get('PATH_INFO').split('/')[-1] | |
|
26 | 29 | |
|
27 | 30 | def document(self): |
|
28 | ||
|
29 | 31 | resp = request.environ.get('pylons.original_response') |
|
30 | 32 | log.debug(resp.status) |
|
33 | ||
|
34 | e = request.environ | |
|
35 | c.serv_p = r'%(protocol)s://%(host)s/' % { | |
|
36 | 'protocol': e.get('wsgi.url_scheme'), | |
|
37 | 'host':e.get('HTTP_HOST'), | |
|
38 | } | |
|
39 | ||
|
40 | if resp.status_int == 404: | |
|
41 | return render('/errors/error_404.html') | |
|
42 | ||
|
31 | 43 | c.error_message = cgi.escape(request.GET.get('code', str(resp.status))) |
|
32 | 44 | c.error_explanation = self.get_error_explanation(resp.status_int) |
|
33 | 45 | |
|
34 | c.serv_p = ''.join(['http://', request.environ.get('HTTP_HOST', '')]) | |
|
35 | ||
|
36 | 46 | #redirect to when error with given seconds |
|
37 | 47 | c.redirect_time = 0 |
|
38 | 48 | c.redirect_module = _('Home page')# name to what your going to be redirected |
|
39 | 49 | c.url_redirect = "/" |
|
40 | 50 | |
|
41 | 51 | return render('/errors/error_document.html') |
|
42 | 52 | |
|
43 | 53 | |
|
44 | 54 | def img(self, id): |
|
45 | 55 | """Serve Pylons' stock images""" |
|
46 | 56 | return self._serve_file(os.path.join(media_path, 'img', id)) |
|
47 | 57 | |
|
48 | 58 | def style(self, id): |
|
49 | 59 | """Serve Pylons' stock stylesheets""" |
|
50 | 60 | return self._serve_file(os.path.join(media_path, 'style', id)) |
|
51 | 61 | |
|
52 | 62 | def _serve_file(self, path): |
|
53 | 63 | """Call Paste's FileApp (a WSGI application) to serve the file |
|
54 | 64 | at the specified path |
|
55 | 65 | """ |
|
56 | 66 | fapp = paste.fileapp.FileApp(path) |
|
57 | 67 | return fapp(request.environ, self.start_response) |
|
58 | 68 | |
|
59 | 69 | def get_error_explanation(self, code): |
|
60 | 70 | ''' get the error explanations of int codes |
|
61 | 71 | [400, 401, 403, 404, 500]''' |
|
62 | 72 | try: |
|
63 | 73 | code = int(code) |
|
64 | 74 | except: |
|
65 | 75 | code = 500 |
|
66 | 76 | |
|
67 | 77 | if code == 400: |
|
68 | 78 | return _('The request could not be understood by the server due to malformed syntax.') |
|
69 | 79 | if code == 401: |
|
70 | 80 | return _('Unathorized access to resource') |
|
71 | 81 | if code == 403: |
|
72 | 82 | return _("You don't have permission to view this page") |
|
73 | 83 | if code == 404: |
|
74 | 84 | return _('The resource could not be found') |
|
75 | 85 | if code == 500: |
|
76 | 86 | return _('The server encountered an unexpected condition which prevented it from fulfilling the request.') |
|
77 | 87 | |
|
78 | 88 |
@@ -1,15 +1,23 b'' | |||
|
1 | 1 | from mercurial import util |
|
2 | 2 | from mercurial.templatefilters import age as _age, person as _person |
|
3 | from string import punctuation | |
|
4 | ||
|
5 | def clean_repo(repo_name): | |
|
6 | for x in punctuation: | |
|
7 | if x != '_': | |
|
8 | repo_name = repo_name.replace(x, '') | |
|
9 | repo_name = repo_name.lower().strip() | |
|
10 | return repo_name.replace(' ', '_') | |
|
3 | 11 | |
|
4 | 12 | age = lambda x:_age(x) |
|
5 | 13 | capitalize = lambda x: x.capitalize() |
|
6 | 14 | date = lambda x: util.datestr(x) |
|
7 | 15 | email = util.email |
|
8 | 16 | person = lambda x: _person(x) |
|
9 | 17 | hgdate = lambda x: "%d %d" % x |
|
10 | 18 | isodate = lambda x: util.datestr(x, '%Y-%m-%d %H:%M %1%2') |
|
11 | 19 | isodatesec = lambda x: util.datestr(x, '%Y-%m-%d %H:%M:%S %1%2') |
|
12 | 20 | localdate = lambda x: (x[0], util.makedate()[1]) |
|
13 | 21 | rfc822date = lambda x: util.datestr(x, "%a, %d %b %Y %H:%M:%S %1%2") |
|
14 | 22 | rfc3339date = lambda x: util.datestr(x, "%Y-%m-%dT%H:%M:%S%1:%2") |
|
15 | 23 | time_ago = lambda x: util.datestr(_age(x), "%a, %d %b %Y %H:%M:%S %1%2") |
General Comments 0
You need to be logged in to leave comments.
Login now