diff --git a/data/path_switch.yml b/data/path_switch.yml new file mode 100644 index 0000000..7a0d12c --- /dev/null +++ b/data/path_switch.yml @@ -0,0 +1 @@ +college/attack-on-blocks: projects/attack-on-blocks diff --git a/project/pages/utils.py b/project/pages/utils.py index cf54b01..c14cf37 100644 --- a/project/pages/utils.py +++ b/project/pages/utils.py @@ -21,3 +21,9 @@ def parse_content(content, extension): if extension == 'md': return markdown2.markdown(content) return content + + +def swap_page(path): + if path in settings.PAGE_SWITCH: + return settings.PAGE_SWITCH[path] + return path diff --git a/project/pages/views.py b/project/pages/views.py index c6e8a76..6841b04 100644 --- a/project/pages/views.py +++ b/project/pages/views.py @@ -3,7 +3,7 @@ from django.views.generic import FormView from django.conf import settings from django.http import HttpResponse, Http404 from django.template.loader import get_template -from .utils import get_context, parse_content, get_title_from_markdown +from .utils import get_context, parse_content, get_title_from_markdown, swap_page from project.common.forms import ContactForm @@ -12,6 +12,8 @@ def page_view(request, path): if path.endswith('/'): path = path[:-1] + path = swap_page(path) + if os.path.isdir(os.path.join(settings.BASE_DIR, 'templates', path)): path = os.path.join(path, 'index') for extension in ['md', 'html']: