in kotlin-website.py [0:0]
def process_page(page_path):
# get_nav() has side effect to copy and patch files from the `external` folder
# under site folder. We need it for dev mode to make sure file is up-to-date
# TODO: extract get_nav and implement the explicit way to avoid side-effects
get_nav()
page = pages.get_or_404(page_path)
if 'redirect_path' in page.meta and page.meta['redirect_path'] is not None:
page_path = page.meta['redirect_path']
if page_path.startswith('https://') or page_path.startswith('http://'):
return render_template('redirect.html', url=page_path)
else:
return render_template('redirect.html', url=url_for('page', page_path=page_path))
if 'date' in page.meta and page['date'] is not None:
page.meta['formatted_date'] = page.meta['date'].strftime('%d %B %Y')
if page.meta['formatted_date'].startswith('0'):
page.meta['formatted_date'] = page.meta['formatted_date'][1:]
if 'github_edit_url' in page.meta:
edit_on_github_url = page.meta['github_edit_url']
else:
edit_on_github_url = app.config['EDIT_ON_GITHUB_URL'] + app.config['FLATPAGES_ROOT'] + "/" + page_path + \
app.config['FLATPAGES_EXTENSION']
assert_valid_git_hub_url(edit_on_github_url, page_path)
template = page.meta["layout"] if 'layout' in page.meta else 'default.html'
if not template.endswith(".html"):
template += ".html"
if build_check_links:
validate_links_weak(page, page_path)
return render_template(
template,
page=page,
baseurl="",
edit_on_github_url=edit_on_github_url,
)