• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python wiki.get_personal_wiki_repo函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中seahub.wiki.get_personal_wiki_repo函数的典型用法代码示例。如果您正苦于以下问题:Python get_personal_wiki_repo函数的具体用法?Python get_personal_wiki_repo怎么用?Python get_personal_wiki_repo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_personal_wiki_repo函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: personal_wiki_page_new

def personal_wiki_page_new(request, page_name="home"):

    if request.method == 'POST':
        page_name = request.POST.get('page_name', '')
        if not page_name:
            return HttpResponseRedirect(request.META.get('HTTP_REFERER'))
        page_name = clean_page_name(page_name)

        try:
            repo = get_personal_wiki_repo(request.user.username)
        except WikiDoesNotExist:
            return render_error(request, _('Wiki is not found.'))

        filename = page_name + ".md"
        filepath = "/" + page_name + ".md"

        # check whether file exists
        if seaserv.get_file_id_by_path(repo.id, filepath):
            return render_error(request, _('Page "%s" already exists.') % filename)

        if not seaserv.post_empty_file(repo.id, "/", filename, request.user.username):
            return render_error(request, _('Failed to create wiki page. Please retry later.'))

        url = "%s?p=%s&from=personal_wiki_page_new" % (
            reverse('file_edit', args=[repo.id]),
            urlquote(filepath.encode('utf-8')))
        return HttpResponseRedirect(url)
开发者ID:belobrov-andrey,项目名称:seahub,代码行数:27,代码来源:wiki.py


示例2: personal_wiki

def personal_wiki(request, page_name="home"):
    username = request.user.username
    wiki_exists = True
    try:
        content, repo, dirent = get_personal_wiki_page(username, page_name)
    except WikiDoesNotExist:
        wiki_exists = False
        owned_repos = seafile_api.get_owned_repo_list(username)
        owned_repos = [r for r in owned_repos if not r.encrypted]
        return render_to_response(
            "wiki/personal_wiki.html",
            {"wiki_exists": wiki_exists, "owned_repos": owned_repos},
            context_instance=RequestContext(request),
        )
    except WikiPageMissing:
        repo = get_personal_wiki_repo(username)
        filename = clean_page_name(page_name) + ".md"
        if not seaserv.post_empty_file(repo.id, "/", filename, username):
            return render_error(request, _("Failed to create wiki page. Please retry later."))
        return HttpResponseRedirect(reverse("personal_wiki", args=[page_name]))
    else:
        url_prefix = reverse("personal_wiki", args=[])
        content = convert_wiki_link(content, url_prefix, repo.id, username)

        # fetch file latest contributor and last modified
        path = "/" + dirent.obj_name
        file_path_hash = hashlib.md5(urllib2.quote(path.encode("utf-8"))).hexdigest()[:12]
        contributors, last_modified, last_commit_id = FileContributors.objects.get_file_contributors(
            repo.id, path.encode("utf-8"), file_path_hash, dirent.obj_id
        )
        latest_contributor = contributors[0] if contributors else None

        wiki_index_exists = True
        index_pagename = "index"
        index_content = None
        try:
            index_content, index_repo, index_dirent = get_personal_wiki_page(username, index_pagename)
        except (WikiDoesNotExist, WikiPageMissing) as e:
            wiki_index_exists = False
        else:
            index_content = convert_wiki_link(index_content, url_prefix, index_repo.id, username)

        return render_to_response(
            "wiki/personal_wiki.html",
            {
                "wiki_exists": wiki_exists,
                "content": content,
                "page": os.path.splitext(dirent.obj_name)[0],
                "last_modified": last_modified,
                "latest_contributor": latest_contributor,
                "path": path,
                "repo_id": repo.id,
                "search_repo_id": repo.id,
                "search_wiki": True,
                "wiki_index_exists": wiki_index_exists,
                "index_content": index_content,
            },
            context_instance=RequestContext(request),
        )
开发者ID:vikingliu,项目名称:seahub,代码行数:59,代码来源:wiki.py


示例3: personal_wiki

def personal_wiki(request, page_name="home"):
    username = request.user.username
    wiki_exists = True
    try:
        content, repo, dirent = get_personal_wiki_page(username, page_name)
    except WikiDoesNotExist:
        wiki_exists = False
        owned_repos = seafile_api.get_owned_repo_list(username)
        owned_repos = [r for r in owned_repos if not r.encrypted]
        return render_to_response("wiki/personal_wiki.html", {
                "wiki_exists": wiki_exists,
                "owned_repos": owned_repos,
                }, context_instance=RequestContext(request))
    except WikiPageMissing:
        repo = get_personal_wiki_repo(username)
        filename = clean_page_name(page_name) + '.md'
        if not seaserv.post_empty_file(repo.id, "/", filename, username):
            return render_error(request, _("Failed to create wiki page. Please retry later."))
        return HttpResponseRedirect(reverse('personal_wiki', args=[page_name]))
    else:
        url_prefix = reverse('personal_wiki', args=[])
        content = convert_wiki_link(content, url_prefix, repo.id, username)
        
        # fetch file modified time and modifier
        path = '/' + dirent.obj_name
        try:
            dirent = seafile_api.get_dirent_by_path(repo.id, path)
            if dirent:
                latest_contributor, last_modified = dirent.modifier, dirent.mtime
            else:
                latest_contributor, last_modified = None, 0
        except SearpcError as e:
            logger.error(e)
            latest_contributor, last_modified = None, 0

        wiki_index_exists = True
        index_pagename = 'index'
        index_content = None
        try:
            index_content, index_repo, index_dirent = get_personal_wiki_page(username, index_pagename)
        except (WikiDoesNotExist, WikiPageMissing) as e:
            wiki_index_exists = False
        else:
            index_content = convert_wiki_link(index_content, url_prefix, index_repo.id, username)

        return render_to_response("wiki/personal_wiki.html", { 
            "wiki_exists": wiki_exists,
            "content": content,
            "page": os.path.splitext(dirent.obj_name)[0],
            "last_modified": last_modified,
            "latest_contributor": latest_contributor or _("Unknown"),
            "path": path,
            "repo_id": repo.id,
            "search_repo_id": repo.id,
            "search_wiki": True,
            "wiki_index_exists": wiki_index_exists,
            "index_content": index_content,
            }, context_instance=RequestContext(request))
开发者ID:hangshisitu,项目名称:seahub,代码行数:58,代码来源:wiki.py


示例4: personal_wiki_page_edit

def personal_wiki_page_edit(request, page_name="home"):
    try:
        repo = get_personal_wiki_repo(request.user.username)
    except WikiDoesNotExist:
        return render_error(request, _('Wiki is not found.'))

    filepath = "/" + page_name + ".md"
    url = "%s?p=%s&from=personal_wiki_page_edit" % (
            reverse('file_edit', args=[repo.id]),
            urllib2.quote(filepath.encode('utf-8')))

    return HttpResponseRedirect(url)
开发者ID:belobrov-andrey,项目名称:seahub,代码行数:12,代码来源:wiki.py


示例5: personal_wiki_page_delete

def personal_wiki_page_delete(request, page_name):
    try:
        repo = get_personal_wiki_repo(request.user.username)
    except WikiDoesNotExist:
        return render_error(request, _('Wiki is not found.'))
    
    file_name = page_name + '.md'
    username = request.user.username
    if seaserv.del_file(repo.id, '/', file_name, username):
        messages.success(request, 'Successfully deleted "%s".' % page_name)
    else:
        messages.error(request, 'Failed to delete "%s". Please retry later.' % page_name)

    return HttpResponseRedirect(reverse('personal_wiki', args=[]))
开发者ID:belobrov-andrey,项目名称:seahub,代码行数:14,代码来源:wiki.py


示例6: personal_wiki

def personal_wiki(request, page_name="home"):
    username = request.user.username
    wiki_exists = True
    try:
        content, repo, dirent = get_personal_wiki_page(username, page_name)
    except WikiDoesNotExist:
        wiki_exists = False
        # get available modules(wiki, etc)
        mods_available = get_available_mods_by_user(username)
        mods_enabled = get_enabled_mods_by_user(username)
        return render_to_response("wiki/personal_wiki.html", {
                "wiki_exists": wiki_exists,
                "mods_enabled": mods_enabled,
                "mods_available": mods_available,
                }, context_instance=RequestContext(request))
    except WikiPageMissing:
        repo = get_personal_wiki_repo(username)
        filename = clean_page_name(page_name) + '.md'
        if not seaserv.post_empty_file(repo.id, "/", filename, username):
            return render_error(request, _("Failed to create wiki page. Please retry later."))
        return HttpResponseRedirect(reverse('personal_wiki', args=[page_name]))
    else:
        url_prefix = reverse('personal_wiki', args=[])
        content = convert_wiki_link(content, url_prefix, repo.id, username)
        
        # fetch file latest contributor and last modified
        path = '/' + dirent.obj_name
        file_path_hash = hashlib.md5(urllib2.quote(path.encode('utf-8'))).hexdigest()[:12]            
        contributors, last_modified, last_commit_id = \
            FileContributors.objects.get_file_contributors(
            repo.id, path.encode('utf-8'), file_path_hash, dirent.obj_id)
        latest_contributor = contributors[0] if contributors else None

        # get available modules(wiki, etc)
        mods_available = get_available_mods_by_user(username)
        mods_enabled = get_enabled_mods_by_user(username)
        
        return render_to_response("wiki/personal_wiki.html", {
                "wiki_exists": wiki_exists,
                "content": content,
                "page": os.path.splitext(dirent.obj_name)[0],
                "last_modified": last_modified,
                "latest_contributor": latest_contributor,
                "path": path,
                "repo_id": repo.id,
                "search_repo_id": repo.id,
                "search_wiki": True,
                "mods_enabled": mods_enabled,
                "mods_available": mods_available,
                }, context_instance=RequestContext(request))
开发者ID:mhltlyc,项目名称:seahub,代码行数:50,代码来源:wiki.py


示例7: personal_wiki_pages

def personal_wiki_pages(request):
    """
    List personal wiki pages.
    """
    try:
        repo = get_personal_wiki_repo(request.user.username)
        pages = get_wiki_pages(repo)
    except SearpcError:
        return render_error(request, _("Internal Server Error"))
    except WikiDoesNotExist:
        return render_error(request, _("Wiki does not exists."))

    return render_to_response(
        "wiki/personal_wiki_pages.html", {"pages": pages, "repo_id": repo.id}, context_instance=RequestContext(request)
    )
开发者ID:sonicby,项目名称:seahub,代码行数:15,代码来源:wiki.py


示例8: personal_wiki

def personal_wiki(request, page_name="home"):
    username = request.user.username
    wiki_exists = True
    try:
        content, repo, dirent = get_personal_wiki_page(username, page_name)
    except WikiDoesNotExist:
        wiki_exists = False
        return render_to_response(
            "wiki/personal_wiki.html", {"wiki_exists": wiki_exists}, context_instance=RequestContext(request)
        )
    except WikiPageMissing:
        repo = get_personal_wiki_repo(username)
        filename = clean_page_name(page_name) + ".md"
        if not post_empty_file(repo.id, "/", filename, username):
            return render_error(request, _("Failed to create wiki page. Please retry later."))
        return HttpResponseRedirect(reverse("personal_wiki", args=[page_name]))
    else:
        url_prefix = reverse("personal_wiki", args=[])
        content = convert_wiki_link(content, url_prefix, repo.id, username)

        # fetch file latest contributor and last modified
        path = "/" + dirent.obj_name
        file_path_hash = md5_constructor(urllib2.quote(path.encode("utf-8"))).hexdigest()[:12]
        contributors, last_modified, last_commit_id = get_file_contributors(
            repo.id, path.encode("utf-8"), file_path_hash, dirent.obj_id
        )
        latest_contributor = contributors[0] if contributors else None

        return render_to_response(
            "wiki/personal_wiki.html",
            {
                "wiki_exists": wiki_exists,
                "content": content,
                "page": os.path.splitext(dirent.obj_name)[0],
                "last_modified": last_modified,
                "latest_contributor": latest_contributor,
                "path": path,
                "repo_id": repo.id,
            },
            context_instance=RequestContext(request),
        )
开发者ID:sonicby,项目名称:seahub,代码行数:41,代码来源:wiki.py


示例9: personal_wiki_pages

def personal_wiki_pages(request):
    """
    List personal wiki pages.
    """
    try:
        username = request.user.username
        repo = get_personal_wiki_repo(username)
        pages = get_wiki_pages(repo)
        mods_available = get_available_mods_by_user(username)
        mods_enabled = get_enabled_mods_by_user(username)
    except SearpcError:
        return render_error(request, _('Internal Server Error'))
    except WikiDoesNotExist:
        return render_error(request, _('Wiki does not exists.'))

    return render_to_response("wiki/personal_wiki_pages.html", {
            "pages": pages,
            "repo_id": repo.id,
            "search_repo_id": repo.id,
            "search_wiki": True,
            "mods_enabled": mods_enabled,
            "mods_available": mods_available,
            }, context_instance=RequestContext(request))
开发者ID:belobrov-andrey,项目名称:seahub,代码行数:23,代码来源:wiki.py



注:本文中的seahub.wiki.get_personal_wiki_repo函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python events._函数代码示例发布时间:2022-05-27
下一篇:
Python views.is_registered_user函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap