Documentation
¶
Index ¶
- Constants
- Variables
- func GetHumanDate(link string) string
- func GetPotentialURLEarliest(archiveurl string) (*url.URL, error)
- func GetPotentialURLLatest(archiveurl string) (*url.URL, error)
- func GetSavedURL(resp http.Response) (*url.URL, error)
- func IsWayback(link string) bool
- func SaveURL(link string) string
- func SubmitToInternetArchive(link string, agent string) (simplerequest.SimpleResponse, error)
- func Version() string
- type Data
Constants ¶
const SaveForbidden = "save forbidden by website"
SaveForbidden indecates that a robots.txt may be blocking the save
const SaveGone = "bad gateway website maybe no more"
SaveGone indecates that the website may no longer exist at-all
const SaveTooMany = "too many requests for this url"
Too many requests for the given URL.
const SaveUnknown = "unknown save error inspect response to improve code"
SaveUnknown indicates an error in saving we haven't seen yet
Variables ¶
var ErrorIAExists = errors.New("already an internet archive record")
ErrorIAExists so that we can identify links we do not need to process a second time, or send to IA
var ErrorNoIALink = errors.New("no internet archive record")
ErrorNoIALink enables us to check for the non-existence of a record
Functions ¶
func GetHumanDate ¶
GetHumanDate returns a human readable date from an Internet Archive link rudimentary code for now. Can improve once we've got other pieces working.
func GetPotentialURLEarliest ¶
GetPotentialURLEarliest is used to returning the earliest possible record available in the internet archive. We can make it easier by using this function here. Example URI we need to create looks like this: web.archive.org/web/{date}/url-to-lookup
func GetPotentialURLLatest ¶
GetPotentialURLLatest is used to create a URL that we can test for a 404 error or 200 OK. The URL if it works can be used to display to the user for QA. The URL if it fails, can be used to prompt the user to save the URL as it is found today. A motivation, even if there is no saved IA record, to save copy today, even if it is a 404 is that the earliest date we can pin on a broken link the better we can satisfy outselves in future that we did all we can. Example URI we need to create looks like this: web.archive.org/web/{date}/url-to-lookup {date} == "20161104020243" == "YYYYMMDDHHMMSS" == %Y%m%d%k%M%S
func GetSavedURL ¶
GetSavedURL will help us to retrieve the URL returned by the Internet Archive when we've sent a request to the SaveNow function. We've constructed the URL to save ours in the Internet Archive We've submitted the URL via the IA REST API and we've receieved a 200 OK. In the response will be a partial SLUG that takes us to our newly archived record.
func IsWayback ¶
IsWayback checks a URL (string) and returns whether or not we expect it to be an internet archive link or not...
func SaveURL ¶
SaveURL is used to create a URL that will enable us to submit it to the Internet Archive SaveNow function
func SubmitToInternetArchive ¶
func SubmitToInternetArchive(link string, agent string) (simplerequest.SimpleResponse, error)
SubmitToInternetArchive will handle the request and response to and from the Internet Archive for a URL that we wish to save as part of this initiative.
Types ¶
type Data ¶
type Data struct {
AlreadyWayback error // Flags the URL as a Wayback URL already
NotInWayback bool // Flags the URL as having zero entries in Wayback
EarliestWayback string // String denoting the Earliest Wayback URL
LatestWayback string // String denoting the Latest available Wayback URL
WaybackSaveURL string // String to handle saving of the link in Wayback
ResponseCode int // Response code from the Internet Archive
ResponseText string // Human readable response text from the Internet Archive
}
Data stores information we're going to need for analysing what's in the internet archive. We need to follow a heuristic to use it most effectively. E.g. Use AlreadyWayback first to see what data we might have, NotWayback second to see if anything is already there...