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

       then return the diff between current source and the old commited source

       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_diff(name, gitref):
    """Serve a page name from git repo (an old version of a page).

       then return the diff between current source and the old commited source

       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')
    old_content = read_committed_file(gitref, name + '.rst')
    if old_content:
        old_content = old_content.decode('utf-8')
        files = glob.glob("{0}.rst".format(name))
        if len(files) > 0:
            file_handle = open(files[0], 'r')
            current_content = file_handle.read().decode('utf-8')
            differ = difflib.Differ()
            result = list(differ.compare(old_content.splitlines(),
                                         current_content.splitlines()))
            return template('diff_view',
                            type="history",
                            name=name,
                            extended_name='__diff__',
                            is_repo=check_repo(),
                            history=commit_history("{0}.rst".format(name)),
                            gitref=gitref,
                            content=result)
        else:
            return abort(404)
    else:
        return abort(404)