Ejemplo n.º 1
0
def reload_docs(request):
    try:
        if settings.CURRENT_PPO_MODE != settings.PPO_MODES.DOC_EDIT_MODE:
            raise Exception("Can only reload docs in DOCS_MODE")

        folder_name = request.GET.get('folder_name', None)
        if folder_name:
            content_id = portal_helper.content_id_for_folder_name(folder_name)
        else:
            content_id = request.GET.get('content_id', None)
            if content_id:
                folder_name = portal_helper.folder_name_for_content_id(content_id)

        if not folder_name:
            raise Exception("Cannot get folder name")

        transform('%s/%s' % (settings.CONTENT_DIR, folder_name),
                  None,
                  settings.DEFAULT_DOCS_VERSION)

        sitemap_helper.generate_sitemap(settings.DEFAULT_DOCS_VERSION, 'en')
        sitemap_helper.generate_sitemap(settings.DEFAULT_DOCS_VERSION, 'zh')

        if content_id:
            return _redirect_first_link_in_contents(request, settings.DEFAULT_DOCS_VERSION, content_id)
        else:
            return redirect('/')

    except Exception as e:
        return HttpResponseServerError("Cannot reload docs: %s" % e)
Ejemplo n.º 2
0
def download_and_extract_workspace():
    dest_file_path = '%s/%s' % (settings.CONTENT_DIR,
                                settings.WORKSPACE_ZIP_FILE_NAME)

    if not os.path.isfile(dest_file_path):
        r = requests.get(settings.WORKSPACE_DOWNLOAD_URL, stream=True)
        with open(dest_file_path, 'wb') as f:
            for chunk in r.iter_content(chunk_size=1024):
                if chunk:  # filter out keep-alive new chunks
                    f.write(chunk)

        tar = tarfile.open(dest_file_path)
        tar.extractall(settings.CONTENT_DIR)
        tar.close()

    # Regenerate sitemaps
    sitemap_helper.remove_all_resolved_sitemaps()
    sitemap_helper.generate_sitemap('develop', 'en')
    sitemap_helper.generate_sitemap('develop', 'zh')
Ejemplo n.º 3
0
def reload_docs(request):
    try:
        if settings.CURRENT_PPO_MODE != settings.PPO_MODES.DOC_EDIT_MODE:
            raise Exception("Can only reload docs in DOCS_MODE")

        folder_name = request.GET.get('folder_name', None)
        build_type = request.GET.get('build_type', None)

        options = None
        if build_type:
            options = {'build_type': build_type}

        if folder_name:
            content_id = portal_helper.content_id_for_folder_name(folder_name)
        else:
            content_id = request.GET.get('content_id', None)
            if content_id:
                folder_name = portal_helper.folder_name_for_content_id(
                    content_id)

        if not folder_name:
            raise Exception("Cannot get folder name")

        transform('%s/%s' % (settings.CONTENT_DIR, folder_name), None,
                  settings.DEFAULT_DOCS_VERSION, options)

        sitemap_helper.generate_sitemap(settings.DEFAULT_DOCS_VERSION, 'en')
        sitemap_helper.generate_sitemap(settings.DEFAULT_DOCS_VERSION, 'zh')

        if content_id:
            # The default category for documentation is 'fluid'
            category = 'default'
            if content_id == Content.DOCUMENTATION:
                category = 'fluid'

            return _redirect_first_link_in_contents(
                request, settings.DEFAULT_DOCS_VERSION, content_id, category)
        else:
            return redirect('/')

    except Exception as e:
        return HttpResponseServerError("Cannot reload docs: %s" % e)
Ejemplo n.º 4
0
 def handle(self, *args, **options):
     if 'version' in options:
         for version in options['version']:
             sitemap_helper.generate_sitemap(version, 'en')
             sitemap_helper.generate_sitemap(version, 'zh')