source script

This script manages navigation across the source-tree and individual file display.

Internal function iconlink is a support routine for diricon and fileicon. It works around the protection implemented in fileref which prevents from inserting HTML elements in the "description".

  1. $templ

    a string containing the HTML element without delimiters

  2. $path

    a string containing the path of the icon file

Custom delimiters are added to the HTML element which is transformed into a file link by fileref. The custom delimiters are replaced by standard HTML delimiters in the returned link which is then sent back to caller.

diricon ($templ, $node, $dir)

Function diricon is a "$variable" substitution function. It returns an HTML-string containing an < A > block surrounding an < IMG > tag for a folder icon. The link allows to jump to the directory.

  1. $templ

    a string containing the template (empty for a "variable")

  2. $node

    a string containing the name of the directory

  3. $dir

    a string containing the name of the parent directory

If parameters 'iconfolder' and 'diricon' have been defined, use the designated icon; otherwise revert to the default Apache icon.

dirname ($templ, $node, $dir)

Function dirname is a "$variable" substitution function. It returns an HTML-string containing an < A > tag linking to the directory.

  1. $templ

    a string containing the template (empty for a "variable")

  2. $node

    a string containing the name of the directory

  3. $dir

    a string containing the name of the parent directory

fileicon ($templ, $node, $dir)

Function fileicon is a "$variable" substitution function. It returns an HTML-string containing an < A > block surrounding an < IMG > tag for a file icon. The link allows to jump to the file.

  1. $templ

    a string containing the template (empty for a "variable")

  2. $node

    a string containing the name of the file

  3. $dir

    a string containing the name of the parent directory

If parameters 'iconfolder' and various icon descriptors have been defined, use the designated icon; otherwise revert to the default Apache icon.

filename ($templ, $node, $dir)

Function filename is a "$variable" substitution function. It returns a HTML-string containing an < A > tag linking to the file.

  1. $templ

    a string containing the template (empty for a "variable")

  2. $node

    a string containing the name of the file

  3. $dir

    a string containing the name of the parent directory

filesize ($templ, $node, $dir)

Function filesize is a "$function" substitution function. It returns its expanded argument, inserting the file size where appropriate.

  1. $templ

    a string containing the template (i.e. the function argument)

  2. $node

    a string containing the name of the file

  3. $dir

    a string containing the name of the parent directory

In the present implementation, specifying a size unit in the argument makes no difference. The size is "scaled" according to its textual length.

modtime ($templ, $node, $dir)

Function modtime is a "$variable" substitution function. It returns a human-readable date/time string for the file last-modification date.

  1. $templ

    a string containing the template (empty for a "variable")

  2. $node

    a string containing the name of the file

  3. $dir

    a string containing the name of the parent directory

The last-modification date is extracted from the database.

indextime ($templ, $node, $dir)

Function indextime is a "$variable" substitution function. It returns a human-readable date/time string for the file indexation date by genxref.

  1. $templ

    a string containing the template (empty for a "variable")

  2. $node

    a string containing the name of the file

  3. $dir

    a string containing the name of the parent directory

The indexation date is extracted from the database.

If it does not exist (file was never indexed or modified since indexation), a single dash is return.

descexpand ($templ, $node, $dir, $releaseid)

Function descexpand is a "$function" substitution function. It returns a short description for a file or a subdirectory in a directory listing. If no description can be extracted, the called support routines MUST return the string " " to keep the table looking pretty.

  1. $templ

    a string containing the template (empty for a "variable")

  2. $node

    a string containing the name of the file

  3. $dir

    a string containing the name of the parent directory

  4. $releaseid

    a string containing the version name

    Presently, not used.

Control is passed to custom function located in Local.pm.

rowclass ($templ, $line)

Function indextime is a "$variable" substitution function. It returns a CSS class name depending on line parity.

  1. $templ

    a string containing the template (empty for a "variable")

  2. $line

    an integer containing the line number of the display

direxpand ($templ, $dir)

Function direxpand is a "$function" substitution function. It returns its template argument expanded for every node in the directory.

  1. $templ

    a string containing the template

  2. $dir

    a string containing the directory name

The directory content is obtained from the storage engine.

The template is expanded depending on the nature of the node, file or directory, because processing of the nested substitutions is slightly different in each case.

printdir ($dir)

Procedure printdir retrieves the 'htmldir' template and launches template expansion.

  1. $dir

    a string containing the directory name

The procedure dispatches to dirdesc (located in Local.pm) for a description of the directory and to direxpand for content edition.

next_annot ($currev, $r, $bg)

Function next_annot returns an HTML < SPAN > block containing revision and author information for the next file line.

  1. $currev

    a string containing the requested version for the file

  2. $r

    a reference to a string containing the revision of the previous line

  3. $bg

    a reference to a flag toggling between 0 and 1

References allow to keep values between calls.

It returns an empty string if the repository manager has no annotation (either by design, e.g. plain files, or disabled by configuration parameters).

The returned block is a blank string if the line is part of the same change set as the previous line (to have a cleaner screen).

Revision information is checked for space overflow and eventually truncated as per repository rule.

Finally, a CSS class is computed (latest revision or alternating styles).

printfile ($raw)

Procedure printfile is the main driver for node display.

  1. $raw

    a "boolean" requesting raw mode if non zero

It checks first for a directory described by global variable $pathname to be handled by printdir.

In raw mode, source file is output "as is", without any editing or highlighting.

Various information related to the source file are retrieved (last indexation time, VCS annotations, ...). They are checked and/or prepared for mixed output with source lines.

If possible, links with other development tools are created and placed in the resulting HTML page.

Script entry point

Selects the correct header and footer and launches printfile for the real job.