Serve a page name from git repo (an old version of a page).

       then return the reST source code

       This function does not use any template it returns only plain text

    .. note:: this is a bottle view

    * this is a GET only method : you can not change a committed page

    Keyword Arguments:
        :name: (str) -- name of the rest file (without the .rst extension)
        :gitref: (str) -- hexsha of the git commit to look into

    Returns:
        bottle response object or 404 error page

def view_history_source(name, gitref=None):
    """Serve a page name from git repo (an old version of a page).

       then return the reST source code

       This function does not use any template it returns only plain text

    .. note:: this is a bottle view

    * this is a GET only method : you can not change a committed page

    Keyword Arguments:
        :name: (str) -- name of the rest file (without the .rst extension)
        :gitref: (str) -- hexsha of the git commit to look into

    Returns:
        bottle response object or 404 error page
    """
    response.set_header('Cache-control', 'no-cache')
    response.set_header('Pragma', 'no-cache')
    response.set_header('Content-Type', 'text/html; charset=utf-8')
    if gitref is None:
        files = glob.glob("{0}.rst".format(name))
        if len(files) > 0:
            file_handle = open(files[0], 'r')
            content = file_handle.read()
        else:
            return abort(404)
    else:
        content = read_committed_file(gitref, name + '.rst')
    if content:
        return template('source_view',
                        type="history",
                        name=name,
                        extended_name='__source__',
                        is_repo=check_repo(),
                        history=commit_history("{0}.rst".format(name)),
                        gitref=gitref,
                        content=content.decode('utf-8'))
    else:
        return abort(404)