diff options
author | gbrandl <gbrandl@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2007-06-16 22:57:00 +0000 |
---|---|---|
committer | gbrandl <gbrandl@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2007-06-16 22:57:00 +0000 |
commit | ab62eef84e0082d21872b34b8941dad85706a0fc (patch) | |
tree | 7a4e16f9be1613b998000531d4897055e4f47117 /sandbox/py-rest-doc/sphinx/web/application.py | |
parent | 3f9330646c91f9b3488ddb22dc8c1c3902704fad (diff) | |
download | docutils-ab62eef84e0082d21872b34b8941dad85706a0fc.tar.gz |
Restructure "special" file handling.
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@5245 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'sandbox/py-rest-doc/sphinx/web/application.py')
-rw-r--r-- | sandbox/py-rest-doc/sphinx/web/application.py | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/sandbox/py-rest-doc/sphinx/web/application.py b/sandbox/py-rest-doc/sphinx/web/application.py index c5cae371b..67a2aad5e 100644 --- a/sandbox/py-rest-doc/sphinx/web/application.py +++ b/sandbox/py-rest-doc/sphinx/web/application.py @@ -82,9 +82,19 @@ class DocumentationApplication(object): contents = f.read() return Response(render_template(req, 'edit.html', dict( - contents=contents + contents=contents, + pagename=page, + submiturl=relative_uri('/@edit/'+page+'/', '/@submit/'+page), ))) + def submit_changes(self, req, page): + author = req.args.get('name') + email = req.args.get('email') + contents = req.args.get('contents') + + if not author or not email or not contents: + raise NotFound() + def get_page(self, req, url): """ Show the requested documentation page or raise an @@ -96,11 +106,10 @@ class DocumentationApplication(object): 'on_index': url == 'index' } - # these are special because they have a different context - # XXX: this distinction is probably a mess! + # these are special because they have different templates if url in self.special_urls: rstfilename = '@' + url # only used as cache key - filename = path.join(self.data_root, 'specials.pickle') + filename = path.join(self.data_root, url + '.fpickle') with open(filename, 'rb') as f: context.update(pickle.load(f)) templatename = url + '.html' @@ -342,16 +351,19 @@ class DocumentationApplication(object): else: resp = self.get_page(req, 'index') # start the fuzzy search - elif url.startswith('q/'): + elif url[:2] == 'q/': resp = self.get_keyword_matches(req, url[2:]) # source view - elif url.startswith('@source/'): + elif url[:8] == '@source/': resp = self.show_source(req, url[8:]) # suggest changes view - elif url.startswith('@edit/'): + elif url[:6] == '@edit/': resp = self.suggest_changes(req, url[6:]) + # suggest changes submit + elif url[:8] == '@submit/': + resp = self.submit_changes(req, url[8:]) # dispatch requests to the admin panel - elif url == '@admin' or url.startswith('@admin/'): + elif url == '@admin' or url[:7] == '@admin/': resp = self.admin_panel.dispatch(req, url[7:]) # everything else is handled as page or fuzzy search # if a page does not exist. |