Skip to content

Commit

Permalink
Merge pull request #418 from oduwsdl/issue-411
Browse files Browse the repository at this point in the history
Handle no mementos condition, supplying 404 and search box. Closes #411
  • Loading branch information
machawk1 authored Jul 4, 2018
2 parents a6d51b4 + 254a321 commit d0bf84f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions ipwb/replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ def showMementosForURIRs(urir):
msg += ('<li><a href="/{1}/{0}">{0} at {2}</a></li>'
.format(unsurt(fields[0]), dt14, dtrfc1123))
msg += '</ul>'
else: # No captures for URI-R
msg = generateNoMementosInterface_noDatetime(urir)

return Response(msg)


Expand Down Expand Up @@ -344,6 +347,7 @@ def showTimeMap(urir, format):
def getLinkHeaderAbbreviatedTimeMap(urir, pivotDatetime):
s = surt.surt(urir, path_strip_trailing_slash_unless_empty=False)
indexPath = ipwbConfig.getIPWBReplayIndexPath()

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

Expand Down Expand Up @@ -672,9 +676,24 @@ def handler(signum, frame):
return resp


def generateNoMementosInterface_noDatetime(urir):
msg = '<h1>ERROR 404</h1>'
msg += 'No capture(s) found for {0}.'.format(urir)

msg += ('<form method="get" action="/memento/*/" '
'style="margin-top: 1.0em;">'
'<input type="text" value="{0}" id="url"'
'name="url" aria-label="Enter a URI" />'
'<input type="submit" value="Search URL in the archive"/>'
'</form>').format(urir)

return msg


def generateNoMementosInterface(path, datetime):
msg = '<h1>ERROR 404</h1>'
msg += 'No capture found for {0} at {1}.'.format(path, datetime)

linesWithSameURIR = getCDXJLinesWithURIR(path, None)
print('CDXJ lines with URI-R at {0}'.format(path))
print(linesWithSameURIR)
Expand Down

0 comments on commit d0bf84f

Please sign in to comment.