diff options
| author | gbrandl <gbrandl@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2007-07-11 20:24:50 +0000 |
|---|---|---|
| committer | gbrandl <gbrandl@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2007-07-11 20:24:50 +0000 |
| commit | f6271da8b406c615b156ecb139ce0da2bd0aa9c9 (patch) | |
| tree | fe7413c40d7c6b67b5eb7ff65b5f5056b03d2928 /sandbox/py-rest-doc | |
| parent | cf1128db8bb4f4fb68e4d4c584d7445d34ba1e76 (diff) | |
| download | docutils-f6271da8b406c615b156ecb139ce0da2bd0aa9c9.tar.gz | |
Finished settings page.
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@5341 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'sandbox/py-rest-doc')
| -rw-r--r-- | sandbox/py-rest-doc/sphinx/templates/settings.html | 25 | ||||
| -rw-r--r-- | sandbox/py-rest-doc/sphinx/web/application.py | 46 |
2 files changed, 43 insertions, 28 deletions
diff --git a/sandbox/py-rest-doc/sphinx/templates/settings.html b/sandbox/py-rest-doc/sphinx/templates/settings.html index 8bf2d53a5..0eb6e361a 100644 --- a/sandbox/py-rest-doc/sphinx/templates/settings.html +++ b/sandbox/py-rest-doc/sphinx/templates/settings.html @@ -8,30 +8,25 @@ </p> {# XXX: stylesheet descriptions #} - <form action="{{ pathto('settings.rst') }}" method="get"> - <p class="subhead">Select your stylesheet</p> + <form action="{{ pathto('settings.rst') }}" method="post"> + <p class="subhead">Select your stylesheet:</p> <p> {%- for design, (foo, descr) in known_designs %} - <input type="radio" name="new_design" value="{{ design }}" id="stylesheet-{{ design }}" + <input type="radio" name="design" value="{{ design }}" id="stylesheet-{{ design }}" {% if curdesign == design %}checked="checked"{% endif %}> <label for="stylesheet-{{ design }}">{{ descr }}</label><br> {%- endfor %} </p> - <p class="subhead">Select how you want to view comments</p> + <p class="subhead">Select how you want to view comments:</p> <p> - <input type="radio" name="comments" value="in" id="comments-in" - {% if curcomments == "in" %}checked="checked"{% endif %}> - <label for="comments-in">Show all comments inline.</label><br> - <input type="radio" name="comments" value="bot" id="comments-bot" - {% if curcomments == "bot" %}checked="checked"{% endif %}> - <label for="comments-bot">Show all comments at the pages' bottom.</label><br> - <input type="radio" name="comments" value="no" id="comments-no" - {% if curcomments == "no" %}checked="checked"{% endif %}> - <label for="comments-no">Don't show comments at all.</label><br> + {%- for meth, descr in comments_methods %} + <input type="radio" name="comments" value="{{ meth }}" id="comments-{{ meth }}" + {% if curcomments == meth %}checked="checked"{% endif %}> + <label for="comments-{{ meth }}">{{ descr }}</label><br> + {%- endfor %} </p> <p><input type="submit" value="Save"></p> - <input type="hidden" name="do" value="commentsopt"> - </form> + </form> {% endblock %} diff --git a/sandbox/py-rest-doc/sphinx/web/application.py b/sandbox/py-rest-doc/sphinx/web/application.py index 0ccabb284..f40ac19ed 100644 --- a/sandbox/py-rest-doc/sphinx/web/application.py +++ b/sandbox/py-rest-doc/sphinx/web/application.py @@ -69,10 +69,13 @@ known_designs = { Display the sidebar on the left and don\'t scroll it with the content. This can cause parts of the content to become inaccessible when the table of contents is too long.'''), - } - +comments_methods = { + 'in': 'Show all comments inline.', + 'bot': 'Show all comments at the page bottom.', + 'no': 'Don\'t show comments at all.', +} class MockBuilder(object): @@ -251,6 +254,30 @@ class DocumentationApplication(object): ))) + def get_settings_page(self, req): + """ + Handle the settings page. + """ + if req.method == 'POST': + new_style = req.form.get('design') + if new_style and new_style in known_designs: + req.session['design'] = new_style + new_comments = req.form.get('comments') + if new_comments and new_comments in comments_methods: + req.session['comments'] = new_comments + + context = { + 'known_designs': sorted(known_designs.iteritems()), + 'comments_methods': comments_methods.items(), + 'on_index': False, + 'curdesign': req.session.get('design') or 'default', + 'curcomments': req.session.get('comments') or 'in', + } + + return Response(render_template(req, 'settings.html', + self.globalcontext, context)) + + def get_module_index(self, req): """ Get the module index or redirect to a module from the module index. @@ -329,11 +356,8 @@ class DocumentationApplication(object): if url in self.special_urls: page_id = '@' + url # only used as cache key filename = path.join(self.data_root, url + '.fpickle') - if os.path.isfile(filename): - with open(filename, 'rb') as f: - context.update(pickle.load(f)) - else: - cache_possible = False + with open(filename, 'rb') as f: + context.update(pickle.load(f)) templatename = url + '.html' comments = False @@ -518,12 +542,6 @@ class DocumentationApplication(object): if style not in known_designs: style = 'default' - new_style = req.args.get('new_design') - if new_style: - if new_style in known_designs: - req.session['design'] = new_style - return RedirectResponse('') - if style in self.generated_stylesheets: stylesheet = self.generated_stylesheets[style] else: @@ -583,6 +601,8 @@ class DocumentationApplication(object): # to /q/ which is handled below elif url == 'search': resp = self.search(req) + elif url == 'settings': + resp = self.get_settings_page(req) # module index page is special elif url == 'modindex': resp = self.get_module_index(req) |
