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 | import logging |
|
1 | import logging | |
2 | from paste.urlparser import PkgResourcesParser |
|
2 | from paste.urlparser import PkgResourcesParser | |
3 | import paste.fileapp |
|
3 | import paste.fileapp | |
4 |
from pylons import |
|
4 | from pylons import tmpl_context as c, app_globals as g, request, config | |
5 | from pylons.controllers.util import forward |
|
5 | from pylons.controllers.util import forward | |
6 | from pylons.i18n.translation import _ |
|
6 | from pylons.i18n.translation import _ | |
7 | from pylons_app.lib.base import BaseController, render |
|
7 | from pylons_app.lib.base import BaseController, render | |
8 | from pylons.middleware import error_document_template, media_path |
|
8 | from pylons.middleware import error_document_template, media_path | |
9 | import cgi |
|
9 | import cgi | |
10 | import os |
|
10 | import os | |
11 |
|
11 | |||
12 | log = logging.getLogger(__name__) |
|
12 | log = logging.getLogger(__name__) | |
13 | class ErrorController(BaseController): |
|
13 | class ErrorController(BaseController): | |
14 | """ |
|
14 | """ | |
15 | Generates error documents as and when they are required. |
|
15 | Generates error documents as and when they are required. | |
16 |
|
16 | |||
17 | The ErrorDocuments middleware forwards to ErrorController when error |
|
17 | The ErrorDocuments middleware forwards to ErrorController when error | |
18 | related status codes are returned from the application. |
|
18 | related status codes are returned from the application. | |
19 |
|
19 | |||
20 | This behaviour can be altered by changing the parameters to the |
|
20 | This behaviour can be altered by changing the parameters to the | |
21 | ErrorDocuments middleware in your config/middleware.py file. |
|
21 | ErrorDocuments middleware in your config/middleware.py file. | |
22 | """ |
|
22 | """ | |
23 | # |
|
23 | # | |
24 | def __before__(self): |
|
24 | def __before__(self): | |
25 | pass |
|
25 | c.repos_prefix = config['repos_name'] | |
26 |
|
26 | c.staticurl = g.statics | ||
|
27 | c.repo_name = request.environ['pylons.original_request']\ | |||
|
28 | .environ.get('PATH_INFO').split('/')[-1] | |||
|
29 | ||||
27 | def document(self): |
|
30 | def document(self): | |
28 |
|
||||
29 | resp = request.environ.get('pylons.original_response') |
|
31 | resp = request.environ.get('pylons.original_response') | |
30 | log.debug(resp.status) |
|
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 | c.error_message = cgi.escape(request.GET.get('code', str(resp.status))) |
|
43 | c.error_message = cgi.escape(request.GET.get('code', str(resp.status))) | |
32 | c.error_explanation = self.get_error_explanation(resp.status_int) |
|
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 | #redirect to when error with given seconds |
|
46 | #redirect to when error with given seconds | |
37 | c.redirect_time = 0 |
|
47 | c.redirect_time = 0 | |
38 | c.redirect_module = _('Home page')# name to what your going to be redirected |
|
48 | c.redirect_module = _('Home page')# name to what your going to be redirected | |
39 | c.url_redirect = "/" |
|
49 | c.url_redirect = "/" | |
40 |
|
50 | |||
41 | return render('/errors/error_document.html') |
|
51 | return render('/errors/error_document.html') | |
42 |
|
52 | |||
43 |
|
53 | |||
44 | def img(self, id): |
|
54 | def img(self, id): | |
45 | """Serve Pylons' stock images""" |
|
55 | """Serve Pylons' stock images""" | |
46 | return self._serve_file(os.path.join(media_path, 'img', id)) |
|
56 | return self._serve_file(os.path.join(media_path, 'img', id)) | |
47 |
|
57 | |||
48 | def style(self, id): |
|
58 | def style(self, id): | |
49 | """Serve Pylons' stock stylesheets""" |
|
59 | """Serve Pylons' stock stylesheets""" | |
50 | return self._serve_file(os.path.join(media_path, 'style', id)) |
|
60 | return self._serve_file(os.path.join(media_path, 'style', id)) | |
51 |
|
61 | |||
52 | def _serve_file(self, path): |
|
62 | def _serve_file(self, path): | |
53 | """Call Paste's FileApp (a WSGI application) to serve the file |
|
63 | """Call Paste's FileApp (a WSGI application) to serve the file | |
54 | at the specified path |
|
64 | at the specified path | |
55 | """ |
|
65 | """ | |
56 | fapp = paste.fileapp.FileApp(path) |
|
66 | fapp = paste.fileapp.FileApp(path) | |
57 | return fapp(request.environ, self.start_response) |
|
67 | return fapp(request.environ, self.start_response) | |
58 |
|
68 | |||
59 | def get_error_explanation(self, code): |
|
69 | def get_error_explanation(self, code): | |
60 | ''' get the error explanations of int codes |
|
70 | ''' get the error explanations of int codes | |
61 | [400, 401, 403, 404, 500]''' |
|
71 | [400, 401, 403, 404, 500]''' | |
62 | try: |
|
72 | try: | |
63 | code = int(code) |
|
73 | code = int(code) | |
64 | except: |
|
74 | except: | |
65 | code = 500 |
|
75 | code = 500 | |
66 |
|
76 | |||
67 | if code == 400: |
|
77 | if code == 400: | |
68 | return _('The request could not be understood by the server due to malformed syntax.') |
|
78 | return _('The request could not be understood by the server due to malformed syntax.') | |
69 | if code == 401: |
|
79 | if code == 401: | |
70 | return _('Unathorized access to resource') |
|
80 | return _('Unathorized access to resource') | |
71 | if code == 403: |
|
81 | if code == 403: | |
72 | return _("You don't have permission to view this page") |
|
82 | return _("You don't have permission to view this page") | |
73 | if code == 404: |
|
83 | if code == 404: | |
74 | return _('The resource could not be found') |
|
84 | return _('The resource could not be found') | |
75 | if code == 500: |
|
85 | if code == 500: | |
76 | return _('The server encountered an unexpected condition which prevented it from fulfilling the request.') |
|
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 | from mercurial import util |
|
1 | from mercurial import util | |
2 | from mercurial.templatefilters import age as _age, person as _person |
|
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 | age = lambda x:_age(x) |
|
12 | age = lambda x:_age(x) | |
5 | capitalize = lambda x: x.capitalize() |
|
13 | capitalize = lambda x: x.capitalize() | |
6 | date = lambda x: util.datestr(x) |
|
14 | date = lambda x: util.datestr(x) | |
7 | email = util.email |
|
15 | email = util.email | |
8 | person = lambda x: _person(x) |
|
16 | person = lambda x: _person(x) | |
9 | hgdate = lambda x: "%d %d" % x |
|
17 | hgdate = lambda x: "%d %d" % x | |
10 | isodate = lambda x: util.datestr(x, '%Y-%m-%d %H:%M %1%2') |
|
18 | isodate = lambda x: util.datestr(x, '%Y-%m-%d %H:%M %1%2') | |
11 | isodatesec = lambda x: util.datestr(x, '%Y-%m-%d %H:%M:%S %1%2') |
|
19 | isodatesec = lambda x: util.datestr(x, '%Y-%m-%d %H:%M:%S %1%2') | |
12 | localdate = lambda x: (x[0], util.makedate()[1]) |
|
20 | localdate = lambda x: (x[0], util.makedate()[1]) | |
13 | rfc822date = lambda x: util.datestr(x, "%a, %d %b %Y %H:%M:%S %1%2") |
|
21 | rfc822date = lambda x: util.datestr(x, "%a, %d %b %Y %H:%M:%S %1%2") | |
14 | rfc3339date = lambda x: util.datestr(x, "%Y-%m-%dT%H:%M:%S%1:%2") |
|
22 | rfc3339date = lambda x: util.datestr(x, "%Y-%m-%dT%H:%M:%S%1:%2") | |
15 | time_ago = lambda x: util.datestr(_age(x), "%a, %d %b %Y %H:%M:%S %1%2") |
|
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