Commit 54a48a32 by Ari Rizzitano

[courseware] generate sequence-specific titles server-side (AC-695)

[courseware] generate sequence-specific titles server-side (AC-695)

[courseware] generate sequence-specific titles server-side (AC-695)

case for empty subsections [AC-695]

move title logic into courseware context method [AC-695]

pep8

coffeescript -> js

js mistake

jslint

refactor sequence title generation slightly

missed a line

line too long

python is not javascript

ugh js

ugh js part 2
parent d497e194
...@@ -57,8 +57,8 @@ ...@@ -57,8 +57,8 @@
this.ajaxUrl = this.el.data('ajax-url'); this.ajaxUrl = this.el.data('ajax-url');
this.nextUrl = this.el.data('next-url'); this.nextUrl = this.el.data('next-url');
this.prevUrl = this.el.data('prev-url'); this.prevUrl = this.el.data('prev-url');
this.base_page_title = ' | ' + document.title;
this.keydownHandler($(element).find('#sequence-list .tab')); this.keydownHandler($(element).find('#sequence-list .tab'));
this.base_page_title = ($('title').data('base-title') || '').trim();
this.bind(); this.bind();
this.render(parseInt(this.el.data('position'), 10)); this.render(parseInt(this.el.data('position'), 10));
} }
...@@ -136,10 +136,15 @@ ...@@ -136,10 +136,15 @@
Sequence.prototype.updatePageTitle = function() { Sequence.prototype.updatePageTitle = function() {
// update the page title to include the current section // update the page title to include the current section
var positionLink = this.link_for(this.position); var currentSectionTitle,
positionLink = this.link_for(this.position);
if (positionLink && positionLink.data('page-title')) { if (positionLink && positionLink.data('page-title')) {
document.title = positionLink.data('page-title') + this.base_page_title; currentSectionTitle = positionLink.data('page-title') + ' | ' + this.base_page_title;
if (currentSectionTitle !== document.title) {
document.title = currentSectionTitle;
}
} }
}; };
......
...@@ -1824,6 +1824,7 @@ class ViewCheckerBlock(XBlock): ...@@ -1824,6 +1824,7 @@ class ViewCheckerBlock(XBlock):
""" """
has_children = True has_children = True
state = String(scope=Scope.user_state) state = String(scope=Scope.user_state)
position = 0
def student_view(self, context): # pylint: disable=unused-argument def student_view(self, context): # pylint: disable=unused-argument
""" """
......
...@@ -388,6 +388,8 @@ class CoursewareIndex(View): ...@@ -388,6 +388,8 @@ class CoursewareIndex(View):
'bookmarks_api_url': reverse('bookmarks'), 'bookmarks_api_url': reverse('bookmarks'),
'language_preference': self._get_language_preference(), 'language_preference': self._get_language_preference(),
'disable_optimizely': True, 'disable_optimizely': True,
'section_title': None,
'sequence_title': None
} }
table_of_contents = toc_for_course( table_of_contents = toc_for_course(
self.effective_user, self.effective_user,
...@@ -437,6 +439,11 @@ class CoursewareIndex(View): ...@@ -437,6 +439,11 @@ class CoursewareIndex(View):
table_of_contents['next_of_active_section'], table_of_contents['next_of_active_section'],
) )
courseware_context['fragment'] = self.section.render(STUDENT_VIEW, section_context) courseware_context['fragment'] = self.section.render(STUDENT_VIEW, section_context)
if self.section.position and self.section.has_children:
display_items = self.section.get_display_items()
if display_items:
courseware_context['sequence_title'] = display_items[self.section.position - 1] \
.display_name_with_default
return courseware_context return courseware_context
......
...@@ -19,13 +19,11 @@ from openedx.core.djangolib.js_utils import js_escaped_string ...@@ -19,13 +19,11 @@ from openedx.core.djangolib.js_utils import js_escaped_string
<%block name="bodyclass">view-in-course view-courseware courseware ${course.css_class or ''}</%block> <%block name="bodyclass">view-in-course view-courseware courseware ${course.css_class or ''}</%block>
<%block name="title"><title> <%block name="title">
% if section_title: <title data-base-title="${static.get_page_title_breadcrumbs(section_title, course_name())}">
${static.get_page_title_breadcrumbs(section_title, course_name())} ${static.get_page_title_breadcrumbs(sequence_title, section_title, course_name())}
% else: </title>
${static.get_page_title_breadcrumbs(course_name())} </%block>
%endif
</title></%block>
<%block name="header_extras"> <%block name="header_extras">
......
...@@ -211,6 +211,7 @@ def page_title_breadcrumbs(*crumbs, **kwargs): ...@@ -211,6 +211,7 @@ def page_title_breadcrumbs(*crumbs, **kwargs):
""" """
platform_name = get_value('platform_name', settings.PLATFORM_NAME) platform_name = get_value('platform_name', settings.PLATFORM_NAME)
separator = kwargs.get("separator", " | ") separator = kwargs.get("separator", " | ")
crumbs = [c for c in crumbs if c is not None]
if crumbs: if crumbs:
return u'{}{}{}'.format(separator.join(crumbs), separator, platform_name) return u'{}{}{}'.format(separator.join(crumbs), separator, platform_name)
else: else:
......
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