Commit 0b03834f by Matthew Mongeau

XML based table of contents for books.

parent ebd0458d
...@@ -2,12 +2,14 @@ from django.contrib.auth.decorators import login_required ...@@ -2,12 +2,14 @@ from django.contrib.auth.decorators import login_required
from mitxmako.shortcuts import render_to_response from mitxmako.shortcuts import render_to_response
from courseware.courses import check_course from courseware.courses import check_course
from lxml import etree
@login_required @login_required
def index(request, course_id, page=0): def index(request, course_id, page=0):
course = check_course(course_id) course = check_course(course_id)
return render_to_response('staticbook.html', {'page': int(page), 'course': course}) raw_table_of_contents = open('lms/templates/book_toc.xml', 'r') # TODO: This will need to come from S3
table_of_contents = etree.parse(raw_table_of_contents).getroot()
return render_to_response('staticbook.html', {'page': int(page), 'course': course, 'table_of_contents': table_of_contents})
def index_shifted(request, course_id, page): def index_shifted(request, course_id, page):
......
...@@ -71,7 +71,24 @@ $("#open_close_accordion a").click(function(){ ...@@ -71,7 +71,24 @@ $("#open_close_accordion a").click(function(){
</header> </header>
<ul id="booknav" class="treeview-booknav"> <ul id="booknav" class="treeview-booknav">
<%include file="book_toc.html" /> <%def name="print_entry(entry)">
<li>
<a href="javascript:goto_page(${entry.get('page')})">
${' '.join(entry.get(attribute, '') for attribute in ['chapter', 'name', 'page_label'])}
</a>
% if len(entry) > 0:
<ul>
% for child in entry:
${print_entry(child)}
% endfor
</ul>
% endif
</li>
</%def>
% for entry in table_of_contents:
${print_entry(entry)}
% endfor
</ul> </ul>
</section> </section>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment