Dev support for context-sensitive help.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import ConfigParser
|
||||
from locale import getlocale
|
||||
from django.conf import settings
|
||||
|
||||
config_file = open(settings.REPO_ROOT / "docs" / "config.ini")
|
||||
@@ -6,15 +7,37 @@ config = ConfigParser.ConfigParser()
|
||||
config.readfp(config_file)
|
||||
|
||||
|
||||
def doc_url(request):
|
||||
# in the future, we will detect the locale; for now, we will
|
||||
# hardcode en_us, since we only have English documentation
|
||||
locale = "en_us"
|
||||
def doc_url(request=None):
|
||||
|
||||
def get_doc_url(token):
|
||||
try:
|
||||
return config.get(locale, token)
|
||||
except ConfigParser.NoOptionError:
|
||||
return config.get(locale, "default")
|
||||
def get_online_help_info(page_token):
|
||||
|
||||
return {"doc_url": get_doc_url}
|
||||
def get_config_value(section_name, key, default_key="default"):
|
||||
try:
|
||||
return config.get(section_name, key)
|
||||
except (ConfigParser.NoOptionError, AttributeError):
|
||||
return config.get(section_name, default_key)
|
||||
|
||||
def get_page_path(page_token):
|
||||
return get_config_value("pages", page_token)
|
||||
|
||||
def get_langage_path(request):
|
||||
language_code = settings.LANGUAGE_CODE
|
||||
return get_config_value("locales", language_code)
|
||||
|
||||
def get_url(base_option):
|
||||
return "{base_url}/{language}/{version}/{page_path}".format(
|
||||
base_url=config.get("server_settings", base_option),
|
||||
language=language_dir,
|
||||
version=config.get("server_settings", "version"),
|
||||
page_path=page_path,
|
||||
)
|
||||
|
||||
language_dir = get_langage_path(request)
|
||||
page_path = get_page_path(page_token)
|
||||
|
||||
return {
|
||||
"doc_url": get_url("base_url"),
|
||||
"pdf_url": get_url("base_pdf"),
|
||||
}
|
||||
|
||||
return {'get_online_help_info': get_online_help_info}
|
||||
|
||||
@@ -264,7 +264,8 @@
|
||||
|
||||
<!-- view -->
|
||||
<div class="wrapper wrapper-view">
|
||||
<%include file="widgets/header.html" />
|
||||
<% online_help_token = self.online_help_token() if hasattr(self, 'online_help_token') else None %>
|
||||
<%include file="widgets/header.html" args="online_help_token=online_help_token" />
|
||||
|
||||
<div id="page-alert"></div>
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<%inherit file="base.html" />
|
||||
<%def name="online_help_token()"><% return "pages" %></%def>
|
||||
<%namespace name='static' file='static_content.html'/>
|
||||
<%!
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<%inherit file="base.html" />
|
||||
<%def name="online_help_token()"><% return "textbooks" %></%def>
|
||||
<%namespace name='static' file='static_content.html'/>
|
||||
<%! import json %>
|
||||
<%! from django.utils.translation import ugettext as _ %>
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.translation import ugettext as _
|
||||
from xmodule.modulestore.django import loc_mapper
|
||||
from contentstore.context_processors import doc_url
|
||||
%>
|
||||
<%page args="online_help_token"/>
|
||||
|
||||
<div class="wrapper-header wrapper" id="view-top">
|
||||
<header class="primary" role="banner">
|
||||
@@ -123,6 +125,10 @@
|
||||
<nav class="nav-account nav-is-signedin nav-dd ui-right">
|
||||
<h2 class="sr">${_("Help & Account Navigation")}</h2>
|
||||
|
||||
<%
|
||||
help_doc_urls = get_online_help_info(online_help_token)
|
||||
%>
|
||||
|
||||
<ol>
|
||||
<li class="nav-item nav-account-help">
|
||||
<h3 class="title"><span class="label">${_("Help")}</span> <i class="icon-caret-down ui-toggle-dd"></i></h3>
|
||||
@@ -131,7 +137,7 @@
|
||||
<div class="nav-sub">
|
||||
<ul>
|
||||
<li class="nav-item nav-help-documentation">
|
||||
<a href="http://files.edx.org/Getting_Started_with_Studio.pdf" title="${_("This is a PDF Document")}">${_("Studio Documentation")}</a>
|
||||
<a href="${help_doc_urls['pdf_url']}" title="${_("This is a PDF Document")}">${_("Studio Documentation")}</a>
|
||||
</li>
|
||||
<li class="nav-item nav-help-helpcenter">
|
||||
<a href="http://help.edge.edx.org/" rel="external">${_("Studio Help Center")}</a>
|
||||
@@ -139,6 +145,11 @@
|
||||
<li class="nav-item nav-help-feedback">
|
||||
<a href="http://help.edge.edx.org/discussion/new" class="show-tender" title="${_("Use our feedback tool, Tender, to share your feedback")}">${_("Contact Us")}</a>
|
||||
</li>
|
||||
% if online_help_token:
|
||||
<li class="nav-item nav-help-online">
|
||||
<a href="${help_doc_urls['doc_url']}" title="${_("Contextual Online Help")}">${_("Online Help")}</a>
|
||||
</li>
|
||||
% endif
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,2 +1,29 @@
|
||||
[en_us]
|
||||
default=default
|
||||
# below are the server-wide settings for documentation
|
||||
[server_settings]
|
||||
base_url = http://edx.readthedocs.org/projects/edx-partner-course-staff
|
||||
base_pdf = https://media.readthedocs.org/pdf/edx-partner-course-staff
|
||||
version = latest
|
||||
|
||||
# below are the sub-paths to the documentation for the various pages
|
||||
[pages]
|
||||
default = index.html
|
||||
home = getting_started/get_started.html
|
||||
courses = building_course/creating_new_course.html
|
||||
outline = creating_content/organizing_course.html
|
||||
updates = creating_content/handouts_updates.html
|
||||
pages = creating_content/pages.html
|
||||
files = creating_content/course_files.html
|
||||
textbooks = creating_content/textbooks.html
|
||||
schedule = building_course/setting_up_student_view.html
|
||||
grading = building_course/establish_grading_policy.html
|
||||
team = building_course/creating_new_course.html#add-course-team-members
|
||||
advanced = index.html
|
||||
checklist = building_course/creating_new_course.html#use-the-course-checklist
|
||||
import = building_course/export_import_course.html
|
||||
export = building_course/export_import_course.html
|
||||
|
||||
# below are the language directory names for the different locales
|
||||
[locales]
|
||||
default = en
|
||||
en = en
|
||||
en_us = en
|
||||
|
||||
Reference in New Issue
Block a user