Allow multiple links to the same page
This commit is contained in:
parent
e906aaef99
commit
e182e4c019
3 changed files with 10 additions and 1 deletions
1
data/path_switch.yml
Normal file
1
data/path_switch.yml
Normal file
|
@ -0,0 +1 @@
|
|||
college/attack-on-blocks: projects/attack-on-blocks
|
|
@ -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
|
||||
|
|
|
@ -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']:
|
||||
|
|
Reference in a new issue