| Index: app/handlers/doc.py
|
| diff --git a/app/handlers/doc.py b/app/handlers/doc.py
|
| deleted file mode 100644
|
| index a92bc3c714d90da0cc6f68267d5b5c6073a3bb9b..0000000000000000000000000000000000000000
|
| --- a/app/handlers/doc.py
|
| +++ /dev/null
|
| @@ -1,59 +0,0 @@
|
| -# Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
| -# for details. All rights reserved. Use of this source code is governed by a
|
| -# BSD-style license that can be found in the LICENSE file.
|
| -
|
| -import codecs
|
| -import itertools
|
| -import os
|
| -import re
|
| -
|
| -import cherrypy
|
| -import yaml
|
| -
|
| -import handlers
|
| -
|
| -class Doc(object):
|
| - """The handler for /doc/*."""
|
| -
|
| - def index(self):
|
| - raise cherrypy.HTTPRedirect('/doc/')
|
| -
|
| - def show(self, filename):
|
| - """Display a documentation page.
|
| -
|
| - Each page is static HTML wrapped in a dynamic layout. The HTML is
|
| - generated offline from Markdown source files in /doc; the titles are
|
| - loaded from those source files as well.
|
| - """
|
| -
|
| - # Redirect from the old names for the commands.
|
| - if filename == 'pub-install.html':
|
| - raise cherrypy.HTTPRedirect('/doc/pub-get.html')
|
| -
|
| - if filename == 'pub-update.html':
|
| - raise cherrypy.HTTPRedirect('/doc/pub-upgrade.html')
|
| -
|
| - if filename == '': filename = 'index.html'
|
| - root = os.path.join(os.path.dirname(__file__), '..')
|
| -
|
| - html_path = os.path.join(root, 'views', 'doc', filename)
|
| - if not os.path.isfile(html_path):
|
| - handlers.http_error(404)
|
| -
|
| - markdown_filename = re.sub("\.html$", ".markdown", filename)
|
| - markdown_path = os.path.join(root, 'doc', markdown_filename)
|
| - with codecs.open(markdown_path, encoding='utf-8') as f:
|
| - frontmatter = self._frontmatter(f)
|
| -
|
| - with codecs.open(html_path, encoding='utf-8') as f:
|
| - html = """<article>
|
| - <h1>%s</h1>
|
| - %s
|
| - </article>""" % (frontmatter['title'], f.read())
|
| - return handlers.layout(html, title=frontmatter['title'])
|
| -
|
| - def _frontmatter(self, f):
|
| - """Parses the YAML frontmatter of a file."""
|
| - if f.readline() != '---\n': return {}
|
| - yaml_lines = itertools.takewhile(lambda line: line != '---\n', f)
|
| - return yaml.load(''.join(yaml_lines))
|
|
|