Validating Links in Web Pages - Specification

Creating and accessing URLPATHs

URLPATHs are implemented as structures and work the normal way that structures do.

(urlpath-name urlpath) -> string

Returns the name of urlpath. SETFable.

(urlpath-directory urlpath) -> directory-spec

Given urlpath, returns its directory specification element. SETFable

(make-urlpath &key name directory) -> urlpath

Creates and returns a new urlpath with name name (default NIL) and directory directory (default (:ABSOLUTE)).

(urlpath->path-name urlpath) -> string

Given a urlpath, returns a pathname string.

(path-name->urlpath string) -> urlpath

Given a pathname string, constructs and returns a urlpath. A path-name starting with "/" is an absolute path-name; one ending with "/" represents a directory. "." components are elided, but ".." components are simply converted into :BACKs as above.

Reading data from a file

(map-page-descriptions fn file) -> <unspecified>

Maps over page data (page descriptions) in file, calling fn on each datum.

Merging and canonicalizing paths

(merge-urlpath urlpath default) -> urlpath

Merges a urlpath with a default :ABSOLUTE urlpath. Returns the merged path.

*index-file-name* -> string

The default name for an index file in a directory.

(indexify-urlpath urlpath &optional index-name) -> urlpath

Adds the index-name, which defaults to the value of *INDEX-FILE-NAME*, to a URLPATH if it has a null name component. This is destructive.

(prune-urlpath urlpath) -> urlpath

Destructively modifies urlpath to remove any unnecessary :BACK components, by calling PRUNE-DIRECTORY.

(prune-directory directory) -> directory

Given a full directory list, prune :BACK components. Remove pairs of DIRNAME :BACK components, and also remove any leading :BACK components in an :ABSOLUTE directory. Return pruned list. Calls ELIMINATE-BACKS.

(eliminate-backs dirlist) -> dirlist

Eliminate pairs of DIRNAME :BACK components from the tail of a directory specification (everything apart from the leading :ABSOLUTE or :RELATIVE).

(canonicalize-link urlpath &optional default) -> urlpath

Given a link, canonicalize it: indexifying it, merging with DEFAULT if given, and pruning. Destructive, because it calls PRUNE-URLPATH.

Creating and accessing PAGE-ATTRIBUTES

PAGE-ATTRIBUTEs are implemented as structures and work the normal way that structures do.

(make-page-attributes &key urlpath links) -> page-attribute

Creates a new PAGE-ATTRIBUTES structure. urlpath and links both default to NIL.

(page-attributes-urlpath page-attributes) -> urlpath

Returns the URLPATH from a PAGE-ATTRIBUTES. SETFable.

(page-attributes-links page-attributes) -> list

Returns the LINKS from a PAGE-ATTRIBUTES. SETFable.

Creating page structures

(page-description->page-attributes description) -> page-attributes

Takes a page description and returns a newly-built PAGE-ATTRIBUTES structure. All URLPATHs in the new structure must be canonicalized.

URLPATH trees

URLPATH trees consist of directory and file nodes. Directory nodes map from names to child nodes, file nodes contain values.

(map-upt-node-children fn node) -> <unspecified>

Maps fn over the children of node for side effect. Only valid for directory nodes. fn is called with two arguments: the name of the child and the child itself. The order in which the children are processed is undefined.

(upt-dir-node-p node) -> boolean

Returns T if node is a directory node, NIL otherwise.

(upt-file-node-p node) -> boolean

Returns T if node is a file node, NIL otherwise.

(upt-node-value node) -> object

Returns the value stored for the argument node, which must be a file node. The value may be any object.

(find-upt-node-child node string) -> child

Finds the child of node which has name string. Returns the child or NIL if it is not found. Only valid for nodes for which UPT-DIR-NODE-P returns true.

(make-upt &key (representation t)) -> urltree

Creates and returns an empty URLPATH tree (a directory node with no children). The representation keyword argument is used to ask for a specific representation of the tree: the only valid value for representation documented here is T, which gives the default representation.

(store-urlpath root path value) -> <unspecified>

Stores value under path path in tree root. Signals an error unless path is a URLPATH with an :ABSOLUTE directory and a non-null name. Signals an error also if a directory already in the tree clashes with the path being stored. Value may be any object.

Loading data

(store-all-page-descriptions file &key tree) -> tree

Stores PAGE-ATTRIBUTES objects corresponding to all the page descriptions in file in tree. tree defaults to *URLPATH-TREE*.

*urlpath-tree* -> urltree

Default URLPATH tree.

Finding pages in a URLPATH tree

(urlpath-value-in-upt path root) -> value or nil

Returns the value stored under path in tree root, or NIL if path is not found. An error is signalled if: path is not a URLPATH; path's directory is not absolute; or path's name component is null. If when walking over the tree a directory node is found where there should be a file node, a warning is given and NIL is returned. The same happens if a file node is found where there should be a directory node.

(map-upt-nodes fn root) -> <unspecified>

Map fn for side-effect over all the names and nodes in root. fn is called with two arguments: the name of the node and the node itself. When fn is called on the argument root node, fn will be passed "" as the name of the given root node.

(urlpath-dangling-links urlpath &key tree) -> list

Returns a list of URLPATH objects representing all the dangling links from path in tree. tree defaults to *URLPATH-TREE*. An error is signalled if path is not present in tree.

(upt-dangling-links &key tree) -> list

Returns a list of URLPATH objects representing all the dangling links for every file node in tree. tree defaults to *URLPATH-TREE*.

(upt-dangling-path-names &key tree) -> list

Returns a list of the names of all the dangling links found in the tree. tree defaults to *URLPATH-TREE*.

Exercise utilities

The following utilities exist

(clean-student-symbols) -> list of cleaned symbols

Makes all the symbols that you are meant to define have no definitions. You can use this after loading the compiled version and before loading your code to check that you are defining everything you think you are.

(draw-urlpath-tree &key tree) -> <unspecified>

Only available in CLIM versions. This runs the urltree browsing application. The TREE keyword argument defaults to *URLPATH-TREE*. This application is written entirely in terms of the API documented here (apart from the GUI code of course), and provides a reasonably good way of testing that your code is working, as well as a good way of seeing the trees that you are building. However you should not assume that your code is correct just because this works.

Authors: Gail Anderson (ga@cley.com), Tim Bradshaw(tfb@cley.com), Cley Limited.
Copyright 1999–2003 Cley Ltd. & Franz Inc.