From 5e75eec27cfda04574161b4d943a82bab24aee11 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Aug 03 2015 09:05:34 +0000 Subject: Simplify the doc server No need for all the boiler plate code we were using before to go from the project to the doc and vice-versa since we do not use the templates anymore. --- diff --git a/pagure/docs_server.py b/pagure/docs_server.py index 792dee6..62293b6 100644 --- a/pagure/docs_server.py +++ b/pagure/docs_server.py @@ -95,144 +95,6 @@ def __get_tree_and_content(repo_obj, commit, path): return (tree, content, safe, extended) -# Jinja filter required - -@APP.template_filter('markdown') -def markdown_filter(text): - """ Template filter converting a string into html content using the - markdown library. - """ - return pagure.lib.text2markdown(text, extended=False) - - -# Placeholder to allow re-using pagure's templates -@APP.route('/') -def index(): - ''' Redirects to the front page of this pagure instance. ''' - return flask.redirect(APP.config['APP_URL']) - - -@APP.route('/users/') -def view_users(): - ''' Redirects to the list of users on this pagure instance. ''' - root_url = APP.config['APP_URL'] - if root_url.endswith('/'): - root_url = root_url[:-1] - return flask.redirect(root_url + '/users/') - - -@APP.route('/groups/') -def group_lists(): - ''' Redirects to the list of groups on this pagure instance. ''' - root_url = APP.config['APP_URL'] - if root_url.endswith('/'): - root_url = root_url[:-1] - return flask.redirect(root_url + '/groups/') - - -@APP.route('/new/') -def new_project(): - ''' Redirects to the page to create a new project on this pagure - instance. - ''' - root_url = APP.config['APP_URL'] - if root_url.endswith('/'): - root_url = root_url[:-1] - return flask.redirect(root_url + '/new/') - - -@APP.route('/repo//') -@APP.route('/repo/fork///') -def view_repo(repo, username=None): - ''' Redirects to the overview page of this project. ''' - root_url = APP.config['APP_URL'] - if root_url.endswith('/'): - root_url = root_url[:-1] - return flask.redirect( - root_url + flask.url_for('.view_docs', repo=repo, username=username)) - - -@APP.route('//issues/') -@APP.route('/fork///issues/') -def view_issues(repo, username=None): - ''' Redirects to the page listing all issues of this project. ''' - root_url = APP.config['APP_URL'] - if root_url.endswith('/'): - root_url = root_url[:-1] - return flask.redirect( - root_url - + flask.url_for('.view_docs', repo=repo, username=username) - + '/issues/') - - -@APP.route('//commits/') -@APP.route('/fork///commits/') -def view_commits(repo, username=None): - ''' Redirects to the page listing all commits of this project. ''' - root_url = APP.config['APP_URL'] - if root_url.endswith('/'): - root_url = root_url[:-1] - return flask.redirect( - root_url - + flask.url_for('.view_docs', repo=repo, username=username) - + '/commits/') - - -@APP.route('//tree/') -@APP.route('/fork///tree/') -def view_tree(repo, username=None): - ''' Redirects to the page displaying the tree of files of this project. - ''' - root_url = APP.config['APP_URL'] - if root_url.endswith('/'): - root_url = root_url[:-1] - return flask.redirect( - root_url - + flask.url_for('.view_docs', repo=repo, username=username) - + '/tree/') - - -@APP.route('//tags/') -@APP.route('/fork///tags/') -def view_tags(repo, username=None): - ''' Redirects to the page listing all tags of this project. ''' - root_url = APP.config['APP_URL'] - if root_url.endswith('/'): - root_url = root_url[:-1] - return flask.redirect( - root_url - + flask.url_for('.view_docs', repo=repo, username=username) - + '/tags/') - - -@APP.route('//pull-requests/') -@APP.route('/fork///pull-requests/') -def request_pulls(repo, username=None): - ''' Redirects to the page listing all pull-requests of this project. ''' - root_url = APP.config['APP_URL'] - if root_url.endswith('/'): - root_url = root_url[:-1] - return flask.redirect( - root_url - + flask.url_for('.view_docs', repo=repo, username=username) - + '/pull-requests/') - - -@APP.route('//forks/') -@APP.route('/fork///forks/') -def view_forks(repo, username=None): - ''' Redirects to the page listing all forks of this project. ''' - root_url = APP.config['APP_URL'] - if root_url.endswith('/'): - root_url = root_url[:-1] - return flask.redirect( - root_url - + flask.url_for('.view_docs', repo=repo, username=username) - + '/forks/') - - -# The actual logic of the doc server - @APP.route('//') @APP.route('//') @APP.route('/fork///')