-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4074 from BirkbeckCTP/3671-toc_cms_pages
CMS pages can now display a table of contents
- Loading branch information
Showing
7 changed files
with
107 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Generated by Django 3.2.20 on 2024-03-28 17:43 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('cms', '0018_merge_20240315_1649'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='historicalpage', | ||
name='display_toc', | ||
field=models.BooleanField(default=False, help_text='When enabled this page will display a thinner reading pane with a table of contents side bar.', verbose_name='Display table of contents'), | ||
), | ||
migrations.AddField( | ||
model_name='page', | ||
name='display_toc', | ||
field=models.BooleanField(default=False, help_text='When enabled this page will display a thinner reading pane with a table of contents side bar.', verbose_name='Display table of contents'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,53 @@ | ||
{% extends "core/base.html" %} | ||
{% load static %} | ||
|
||
{% block title %}{{ page.display_name }}{% endblock title %} | ||
|
||
{% block page_title %}{{ page.display_name }}{% endblock %} | ||
|
||
{% block body %} | ||
<div id="row"> | ||
<div class="col s12"> | ||
<div class="row"> | ||
<div class="col {% if page.display_toc %}m9 s12{% else %}m12{% endif %}"> | ||
<div class="card"> | ||
<div id="cms-title" class="card-content"> | ||
<h1 class="no-bottom-margin">{{ page.display_name }}</h1> | ||
<div class="divider spacer"></div> | ||
<div id="cms" class="default-li">{{ page.content|safe }}</<div> | ||
<h1 class="no-bottom-margin">{{ page.display_name }}</h1> | ||
<div class="divider spacer"></div> | ||
<div id="main_article" class="default-li">{{ page.content|safe }}</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% if page.display_toc %} | ||
<div class="col m3 hide-on-small-and-down"> | ||
<div class="card toc-card" id="toc-card" | ||
style="display: none;"> | ||
<div class="card-content"> | ||
<h4> | ||
{% trans "Table of Contents" %} | ||
</h4> | ||
<ul id="toc" class="section table-of-contents"> | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
{% endif %} | ||
</div> | ||
{% endblock body %} | ||
|
||
{% block js %} | ||
<script src="{% static 'material/toc.js' %}"></script> | ||
<script> | ||
$(document).ready(function () { | ||
$('.scrollspy').scrollSpy(); | ||
}); | ||
$(document).scroll(function () { | ||
var infobar_y = document.querySelector('nav').offsetHeight | ||
+ document.querySelector('.m3').offsetHeight | ||
var y = $(this).scrollTop(); | ||
if (y > infobar_y) { | ||
$('#toc-card').fadeIn(); | ||
} else { | ||
$('#toc-card').fadeOut(); | ||
} | ||
}); | ||
</script> | ||
{% endblock js %} |