How to use the ipwb.util.getIPWBReplayIndexPath function in ipwb

To help you get started, we’ve selected a few ipwb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github oduwsdl / ipwb / ipwb / replay.py View on Github external
def resolveMemento(urir, datetime):
    """ Request a URI-R at a supplied datetime from the CDXJ """
    urir = getCompleteURI(urir)

    if ipwbUtils.isLocalHosty(urir):
        urir = urir.split('/', 4)[4]
    s = surt.surt(urir, path_strip_trailing_slash_unless_empty=False)
    indexPath = ipwbUtils.getIPWBReplayIndexPath()

    print('Getting CDXJ Lines with the URI-R {0} from {1}'
          .format(urir, indexPath))
    cdxjLinesWithURIR = getCDXJLinesWithURIR(urir, indexPath)

    closestLine = getCDXJLineClosestTo(datetime, cdxjLinesWithURIR)

    if closestLine is None:
        msg = '<h1>ERROR 404</h1>'
        msg += 'No capture found for {0} at {1}.'.format(urir, datetime)

        return Response(msg, status=404)

    uri = unsurt(closestLine.split(' ')[0])
    newDatetime = closestLine.split(' ')[1]
github oduwsdl / ipwb / ipwb / replay.py View on Github external
def getCDXJLinesWithURIR(urir, indexPath):
    """ Get all CDXJ records corresponding to a URI-R """
    if not indexPath:
        indexPath = ipwbUtils.getIPWBReplayIndexPath()
    indexPath = getIndexFileFullPath(indexPath)

    print('Getting CDXJ Lines with {0} in {1}'.format(urir, indexPath))
    s = surt.surt(urir, path_strip_trailing_slash_unless_empty=False)
    cdxjLinesWithURIR = []

    cdxjLineIndex = getCDXJLine_binarySearch(s, indexPath, True, True)  # get i

    if cdxjLineIndex is None:
        return []

    cdxjLines = []
    with open(indexPath, 'r') as f:
        cdxjLines = f.read().split('\n')
        baseCDXJLine = cdxjLines[cdxjLineIndex]  # via binsearch
github oduwsdl / ipwb / ipwb / replay.py View on Github external
def getLinkHeaderAbbreviatedTimeMap(urir, pivotDatetime):
    s = surt.surt(urir, path_strip_trailing_slash_unless_empty=False)
    indexPath = ipwbUtils.getIPWBReplayIndexPath()

    cdxjLinesWithURIR = getCDXJLinesWithURIR(urir, indexPath)
    hostAndPort = ipwbUtils.getIPWBReplayConfig()

    tgURI = 'http://{0}:{1}/timegate/{2}'.format(
        hostAndPort[0],
        hostAndPort[1], urir)

    tmURI = 'http://{0}:{1}/timemap/link/{2}'.format(
        hostAndPort[0],
        hostAndPort[1], urir)
    tm = generateLinkTimeMapFromCDXJLines(cdxjLinesWithURIR, s, tmURI, tgURI)

    # Fix base TM relation when viewing abbrev version in Link resp
    tm = tm.replace('rel="self timemap"', 'rel="timemap"')
github oduwsdl / ipwb / ipwb / replay.py View on Github external
def showAdmin():
    status = {'ipwbVersion': ipwbVersion,
              'ipfsEndpoint': ipwbUtils.IPFSAPI_MUTLIADDRESS}
    iFile = ipwbUtils.getIPWBReplayIndexPath()

    mementoInfo = calculateMementoInfoInIndex(iFile)

    mCount = mementoInfo['mementoCount']
    uniqueURIRs = len(mementoInfo['surtURIs'].keys())
    htmlCount = mementoInfo['htmlCount']
    oldestDatetime = mementoInfo['oldestDatetime']
    newestDatetime = mementoInfo['newestDatetime']

    uris = getURIsAndDatetimesInCDXJ(iFile)

    # TODO: Calculate actual URI-R/M counts
    indexes = [{'path': ipwbUtils.getIPWBReplayIndexPath(),
                'enabled': True,
                'urimCount': mCount,
                'urirCount': uniqueURIRs}]
github oduwsdl / ipwb / ipwb / replay.py View on Github external
def showTimeMap(urir, format):
    urir = getCompleteURI(urir)
    s = surt.surt(urir, path_strip_trailing_slash_unless_empty=False)
    indexPath = ipwbUtils.getIPWBReplayIndexPath()

    cdxjLinesWithURIR = getCDXJLinesWithURIR(urir, indexPath)
    tmContentType = ''

    hostAndPort = ipwbUtils.getIPWBReplayConfig()

    tgURI = 'http://{0}:{1}/timegate/{2}'.format(
        hostAndPort[0],
        hostAndPort[1], urir)

    tm = ''  # Initialize for usage beyond below conditionals
    if format == 'link':
        tm = generateLinkTimeMapFromCDXJLines(
            cdxjLinesWithURIR, s, request.url, tgURI)
        tmContentType = 'application/link-format'
    elif format == 'cdxj':
github oduwsdl / ipwb / ipwb / replay.py View on Github external
status = {'ipwbVersion': ipwbVersion,
              'ipfsEndpoint': ipwbUtils.IPFSAPI_MUTLIADDRESS}
    iFile = ipwbUtils.getIPWBReplayIndexPath()

    mementoInfo = calculateMementoInfoInIndex(iFile)

    mCount = mementoInfo['mementoCount']
    uniqueURIRs = len(mementoInfo['surtURIs'].keys())
    htmlCount = mementoInfo['htmlCount']
    oldestDatetime = mementoInfo['oldestDatetime']
    newestDatetime = mementoInfo['newestDatetime']

    uris = getURIsAndDatetimesInCDXJ(iFile)

    # TODO: Calculate actual URI-R/M counts
    indexes = [{'path': ipwbUtils.getIPWBReplayIndexPath(),
                'enabled': True,
                'urimCount': mCount,
                'urirCount': uniqueURIRs}]
    # TODO: Calculate actual values
    summary = {'urimCount': mCount,
               'urirCount': uniqueURIRs,
               'uris': uris,
               'htmlCount': htmlCount,
               'earliest': oldestDatetime,
               'latest': newestDatetime}
    return render_template('admin.html', status=status, indexes=indexes,
                           summary=summary)
github oduwsdl / ipwb / ipwb / replay.py View on Github external
def showLandingPage():
    iFile = ipwbUtils.getIPWBReplayIndexPath()
    mementoInfo = calculateMementoInfoInIndex(iFile)

    mCount = mementoInfo['mementoCount']
    uniqueURIRs = len(mementoInfo['surtURIs'].keys())
    htmlCount = mementoInfo['htmlCount']

    summary = {'indexPath': iFile,
               'urimCount': mCount,
               'urirCount': uniqueURIRs,
               'htmlCount': htmlCount}
    uris = getURIsAndDatetimesInCDXJ(iFile)
    return render_template('index.html', summary=summary, uris=uris)