Пример #1
0
def _redirect_first_link_in_contents(request,
                                     content_id,
                                     version=None,
                                     lang=None,
                                     is_raw=False):
    """
    Given a version and a content service, redirect to the first link in it's
    navigation.
    """
    if not lang:
        lang = portal_helper.get_preferred_language(request)

    # Get the directory paths on the filesystem, AND of the URL.
    content_path, url_prefix = url_helper.get_full_content_path(
        content_id, lang, version)

    # If the content doesn't exist yet, try generating it.
    navigation = None
    try:
        navigation, menu_path = menu_helper.get_menu(content_id, lang, version)
        assert os.path.exists(content_path)

    except Exception, e:
        if type(e) in [AssertionError, IOError]:
            if type(e) == IOError:
                menu_path = e[1]

            _generate_content(os.path.dirname(menu_path), content_path,
                              content_id, lang, version)

            if not navigation:
                navigation, menu_path = menu_helper.get_menu(
                    content_id, lang, version)
        else:
            raise e
Пример #2
0
def documentation(source_dir, destination_dir, version, original_lang, raw_version):
    """
    Strip out the static and extract the body contents, ignoring the TOC,
    headers, and body.
    """
    try:
        menu_path = menu_helper.get_menu('docs', original_lang or 'en', version)[1]
    except IOError, e:
        menu_path = e[1]
Пример #3
0
def visualdl(source_dir, destination_dir, version, original_lang):
    """
    Given a VisualDL doc directory, invoke a script to generate docs using Sphinx
    and after parsing the code base based on given config, into an output dir.
    """
    try:
        menu_path = menu_helper.get_menu('visualdl', original_lang or 'en', version)[1]
    except IOError, e:
        menu_path = e[1]
Пример #4
0
 def docs(self):
     """
     Strip out the static and extract the body contents, ignoring the TOC,
     headers, and body.
     """
     try:
         menu_path = menu_helper.get_menu('docs', self.lang or 'en',
                                          self.version)[1]
     except IOError, e:
         menu_path = e[1]
Пример #5
0
def get_menu(request):
    if not settings.DEBUG:
        return HttpResponseServerError(
            'You need to be in a local development environment to show the raw menu'
        )

    path = urlparse(request.META.get('HTTP_REFERER')).path

    content_id, lang, version = url_helper.get_parts_from_url_path(path)

    navigation, menu_path = menu_helper.get_menu(content_id, lang, version)

    return HttpResponse(json.dumps(navigation),
                        content_type='application/json')