add method to from resource path to request path
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import datetime
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
|
||||
from flask import Blueprint, Markup, abort
|
||||
from flask import current_app as app
|
||||
@@ -110,6 +111,15 @@ def request_path_to_instance_resource_path(path):
|
||||
return absolute_resource.replace(f'{app.instance_path}{os.path.sep}', '')
|
||||
|
||||
|
||||
def instance_resource_path_to_request_path(path):
|
||||
"""Reverse a (presumed to exist) disk path to the canonical path that would show up in a Flask route.
|
||||
|
||||
This does not include the leading /, so aside from the root index case, this should be
|
||||
bidirectional.
|
||||
"""
|
||||
return re.sub(r'^pages/', '', re.sub(r'.md$', '', re.sub(r'index.md$', '', path)))
|
||||
|
||||
|
||||
def resolve_page_file(path):
|
||||
"""Manipulate the request path to find appropriate page file.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user