From e276ae2d36e1dbc267ad75afc9185aef2b35fe8a Mon Sep 17 00:00:00 2001 From: Peter Desjardins Date: Mon, 8 Aug 2016 18:00:35 -0400 Subject: [PATCH] Adds a context-sensitive link to learner documentation from the LMS. The base URL defaults to Open edX learner doc and can be overridden with the base URL for edx.org learner doc. Also relabels the tab for support from help to support. --- cms/envs/aws.py | 4 +++ cms/envs/common.py | 4 +++ .../djangoapps/util/help_context_processor.py | 35 +++++++++++++++++-- docs/cms_config.ini | 3 +- docs/lms_config.ini | 5 +-- lms/envs/aws.py | 5 +++ lms/envs/common.py | 4 +++ lms/static/sass/shared/_header.scss | 24 +++++++++++++ lms/templates/help_modal.html | 2 +- lms/templates/navigation.html | 4 +++ 10 files changed, 83 insertions(+), 7 deletions(-) diff --git a/cms/envs/aws.py b/cms/envs/aws.py index b2b536926c..65f0903a99 100644 --- a/cms/envs/aws.py +++ b/cms/envs/aws.py @@ -455,3 +455,7 @@ PARTNER_SUPPORT_EMAIL = ENV_TOKENS.get('PARTNER_SUPPORT_EMAIL', PARTNER_SUPPORT_ # Affiliate cookie tracking AFFILIATE_COOKIE_NAME = ENV_TOKENS.get('AFFILIATE_COOKIE_NAME', AFFILIATE_COOKIE_NAME) + +############## Settings for Studio Context Sensitive Help ############## + +DOC_LINK_BASE_URL = ENV_TOKENS.get('DOC_LINK_BASE_URL', DOC_LINK_BASE_URL) diff --git a/cms/envs/common.py b/cms/envs/common.py index e0ac5d4f35..b27a9dcab0 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -1190,3 +1190,7 @@ PARTNER_SUPPORT_EMAIL = '' # Affiliate cookie tracking AFFILIATE_COOKIE_NAME = 'affiliate_id' + +############## Settings for Studio Context Sensitive Help ############## + +DOC_LINK_BASE_URL = None diff --git a/common/djangoapps/util/help_context_processor.py b/common/djangoapps/util/help_context_processor.py index 5b037d8e13..5aa56e7bae 100644 --- a/common/djangoapps/util/help_context_processor.py +++ b/common/djangoapps/util/help_context_processor.py @@ -59,8 +59,22 @@ def common_doc_url(request, config_file_object): # pylint: disable=unused-argum Returns: The URL for the documentation """ + + # Read an optional configuration property that sets the base + # URL of documentation links. By default, DOC_LINK_BASE_URL + # is null, this test determines whether it is set to a non-null + # value. If it is set, this funtion will use its string value + # as the base of documentation link URLs. If it is not set, the + # function reads the base of the documentation link URLs from + # the .ini configuration file, lms_config.ini or cms_config.ini. + if settings.DOC_LINK_BASE_URL: + doc_base_url = settings.DOC_LINK_BASE_URL + else: + doc_base_url = config_file_object.get("help_settings", "url_base") + + # Construct and return the URL for the documentation link. return "{url_base}/{language}/{version}/{page_path}".format( - url_base=config_file_object.get("help_settings", "url_base"), + url_base=doc_base_url, language=get_config_value_with_default("locales", settings.LANGUAGE_CODE), version=config_file_object.get("help_settings", "version"), page_path=get_config_value_with_default("pages", page_token), @@ -69,10 +83,25 @@ def common_doc_url(request, config_file_object): # pylint: disable=unused-argum def get_pdf_url(): """ Returns: - The URL for the PDF document using the pdf_settings and the help_settings (version) in the configuration + The URL for the PDF document using the pdf_settings and the + help_settings (version) in the configuration """ + + # Read an optional configuration property that sets the base + # URL of pdf links. By default, DOC_LINK_BASE_URL + # is null, this test determines whether it is set to a non-null + # value. If it is set, this funtion will use its string value + # as the base of documentation link URLs. If it is not set, the + # function reads the base of the documentation link URLs from + # the .ini configuration file, lms_config.ini or cms_config.ini. + if settings.DOC_LINK_BASE_URL: + pdf_base_url = settings.DOC_LINK_BASE_URL + else: + pdf_base_url = config_file_object.get("pdf_settings", "pdf_base") + + # Construct and return the URL for the PDF link. return "{pdf_base}/{version}/{pdf_file}".format( - pdf_base=config_file_object.get("pdf_settings", "pdf_base"), + pdf_base=pdf_base_url, version=config_file_object.get("help_settings", "version"), pdf_file=config_file_object.get("pdf_settings", "pdf_file"), ) diff --git a/docs/cms_config.ini b/docs/cms_config.ini index 381846e17e..cf7bdec2f0 100644 --- a/docs/cms_config.ini +++ b/docs/cms_config.ini @@ -1,6 +1,7 @@ # below are the server-wide settings for documentation [help_settings] -url_base = http://edx.readthedocs.org/projects/edx-partner-course-staff +# The optional DOC_LINK_BASE_URL configuration property will override url_base +url_base = http://edx.readthedocs.io/projects/open-edx-building-and-running-a-course version = latest diff --git a/docs/lms_config.ini b/docs/lms_config.ini index c5ddfa305e..cd4cf3355a 100644 --- a/docs/lms_config.ini +++ b/docs/lms_config.ini @@ -1,5 +1,6 @@ # below are the server-wide settings for documentation [help_settings] +# The optional DOC_LINK_BASE_URL configuration property will override url_base url_base = http://edx.readthedocs.io/projects/open-edx-learner-guide version = latest @@ -17,9 +18,9 @@ pdf_file = open-edx-learner-guide.pdf default = index.html -instructor = set_up_course/creating_course_certificates.html +instructor = index.html -course = set_up_course/creating_course_certificates.html +course = index.html profile = sfd_dashboard_profile/index.html diff --git a/lms/envs/aws.py b/lms/envs/aws.py index 11268829c9..9f71896d22 100644 --- a/lms/envs/aws.py +++ b/lms/envs/aws.py @@ -865,4 +865,9 @@ APP_UPGRADE_CACHE_TIMEOUT = ENV_TOKENS.get('APP_UPGRADE_CACHE_TIMEOUT', APP_UPGR AFFILIATE_COOKIE_NAME = ENV_TOKENS.get('AFFILIATE_COOKIE_NAME', AFFILIATE_COOKIE_NAME) ############## Settings for Neo4j ############################ + NEO4J_CONFIG = AUTH_TOKENS.get('NEO4J_CONFIG') + +############## Settings for LMS Context Sensitive Help ############## + +DOC_LINK_BASE_URL = ENV_TOKENS.get('DOC_LINK_BASE_URL', DOC_LINK_BASE_URL) diff --git a/lms/envs/common.py b/lms/envs/common.py index 7c16d00fe0..f8de19911a 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -2965,3 +2965,7 @@ REDIRECT_CACHE_KEY_PREFIX = 'redirects' # This should be set in configuration NEO4J_CONFIG = None + +############## Settings for LMS Context Sensitive Help ############## + +DOC_LINK_BASE_URL = None diff --git a/lms/static/sass/shared/_header.scss b/lms/static/sass/shared/_header.scss index 38fa3215d4..ed1f99e8fd 100644 --- a/lms/static/sass/shared/_header.scss +++ b/lms/static/sass/shared/_header.scss @@ -10,6 +10,30 @@ width: 100%; height: 76px; + .doc-link { + position: relative; + @include float(right); + @include margin(($baseline*0.75), ($baseline*0.75), ($baseline*0.75), ($baseline*0.75)); + padding: 0; + text-transform: none; + font-size: 14px; + font-weight: bold; + letter-spacing: 0; + color: $base-font-color; + text-decoration: none; + + &:hover, + &:focus { + text-decoration: none; + color: $base-font-color; + } + + &:visited { + text-decoration: none; + color: $base-font-color; + } + } + .wrapper-header { @include clearfix(); height: 40px; diff --git a/lms/templates/help_modal.html b/lms/templates/help_modal.html index f50db88d87..7d9744e29e 100644 --- a/lms/templates/help_modal.html +++ b/lms/templates/help_modal.html @@ -15,7 +15,7 @@ from xmodule.tabs import CourseTabList % if settings.FEATURES.get('ENABLE_FEEDBACK_SUBMISSION', False):
- ${_("Help")} + ${_("Support")}