コード例 #1
0
ファイル: validate.py プロジェクト: racktivity/ext-lfw
def getInvalidLinks(spaces=None, pages=None, showValid=True):
    result = list()
    client = Alkira(p.api)

    if not spaces:
        spaces = client.listSpaces()

    for space in spaces:
        for page in client.listPages(space):
            if pages and (page not in pages):
                continue
            result += getPageReport(client,
                                    space,
                                    page,
                                    False,
                                    showValid=showValid)
    return result
コード例 #2
0
ファイル: validate.py プロジェクト: racktivity/ext-lfw
def main(q, i, p, params, tags):
    tags = params["tags"].tags
    appname = p.api.appname
    client = Alkira(p.api)
    #
    pages = spaces = None
    showValid = True
    if "pages" in tags:
        pages = list(item.strip() for item in tags["pages"].split(","))
    if "spaces" in tags:
        if tags["spaces"] == "*":
            spaces = client.listSpaces()
        else:
            spaces = list(item.strip() for item in tags["spaces"].split(","))
    if "showvalid" in tags:
        showValid = (tags["showvalid"].lower() == "true")
    #
    if pages or spaces:
        result = getInvalidLinks(spaces, pages, showValid)
    else:
        result = getPageReport(client,
                               tags["space"],
                               tags["page"],
                               True,
                               showValid=showValid)
    html = "<TABLE><TR><TD>Page</TD><TD>URL</TD><TD>Status</TD></TR>"
    row = "<TR><TD>%s</TD><TD>%s</TD><TD>%s</TD></TR>"
    for item in result:
        parenturl = "/%s/#/%s" % (appname, item[0])
        if item[1] == "link":
            html += row % ("[%s](%s)" % (parenturl, parenturl), "[%s](%s)" %
                           (item[2], item[2]), item[3])
        elif item[1] == "macro":
            html += row % ("[%s](%s)" % (parenturl, parenturl), "[[%s]]" %
                           (item[2]), item[3])
    html += "</TABLE>"
    html = html.replace('\n#', '\n\#')
    html = html.replace('\n', '')
    params['result'] = "%s" % html