redirect2web.map

Package: WA2L/WinTools 1.2.08
Section: Configuration Files (4)
Updated: 04 May 2018
Index Return to Main Contents

 

NAME

redirect2web.map - map file for redirect2web

 

SYNOPSIS

WA2LWinTools/etc/redirect2web.map

 

AVAILABILITY

WA2L/WinTools

 

DESCRIPTION

This is the map file for the redirect2web command.

The file is computed sequentially and as soon as a rule (regex_pattern) matches, the resolution is stopped and the remaining lines are not computed any more.

It is recommended to define a final rule that matches everything using the .* regex_pattern and a target with a meaningful hint to the user or to the root of the web server.

If no such final rule is defined that matches everything, there is no response to the user (no web browser is started).

 

FILEFORMAT

Rows starting with # are considered as comments.

The format of each line is:

rule_identifier ; regex_pattern ; target ; [ viewer ; ]

(leading and tailing white spaces between the field and the separator ; are trimmed away).

 

OPTIONS

rule_identifier
free text identifier of the rule line. This to identify the matching rule when running in test mode when redirect2web has been invoked using the -t option.

This identifier can also be used when doing a regression test of the defined rules in a map file against an input file containing a list of file names in conjunction with -f - .

regex_pattern
regular expression to analyze the filename given thru the -f option.

Remember: when a rule matches, the remaining rules are not resolved any more.

See: regexintro(4) for a short introduction to regular expressions.

Be aware, that a backslash ( \ ) as present in Windows™ file names have to be escaped in regular expressions ( \\ ).

Therefore the regular expression to match the file g:\data\project\calc.xlsx is g:\\data\\project\\calc\.xlsx .

target
when a rule matches, the URL defined in the target field is loaded into the web content viewer (=web browser).

Backslashes ( \ ) in the target definition are translated to slashes ( / ).

The target configuration can hold several @NAME@ placeholders that are replaced with a content resolved from the given filename thru the -f option:

@YEAR@
current year as four digit number (e.g. 2018).

@INSTALLDIR@
installation base directory of the WA2L/WinTools package.

@INSTALLDRIVE@
installation drive letter (including :) or UNC server name of the WA2L/WinTools package.

@FILENAME@
selected source file name including suffix.

@FQFN@
full qualified file name including drive.

@DIRECTORY@
directory of the file including the drive name.

@DIR@
directory of the file without drive name.

@PREFIX@
file name without suffix.

@SUFFIX@
suffix of the file name.

@DRIVE@
drive name or server name when specifying an UNC path.

@FOLDER:i@
folder name, where i is an integer number from 1 to n based on the path depth of the given filename.

The given filename g:\research\projects\Alpha\report.doc or the UNC variant example \\filesvr\share\research\projects\Alpha\report.doc would set @FOLDER:1@ to research, @FOLDER:2@ to projects and @FOLDER:3@ to Alpha.

Hint: For the UNC variant @FOLDER:0@ is set to share.

[ viewer ]
optional field for (Web) content viewer, if different from VIEWER=command setting in redirect2web.cfg file (or different from the built in default iexplore.exe).

This allows to open the redirected files (for example based on suffix) in different applications.

Also if a web application runs best in 'Internet Explorer' and another runs best in Firefox the viewer command can be defined for a specific rule.

In the viewer field setting the environment variables %USERNAME%, %USERPROFILE%, %ProgramFiles%, %ProgramFiles(x86)%, %APPDATA%, %INSTALLDIR%, and %INSTALLDRIVE% can be used.

 

EXAMPLES

1) Example map file explained

The following map file shows how it is possible to define direct mappings and also to support some cleanup during migration where some source folders are migrated to different destination locations:

#
# redirect2web.map - map file for redirect2web
#
# [00] 07.06.2017 CWa   Initial Version
# [01] 08.06.2017 CWa   ++
#

#id    ;regex_pattern                          ;target;
EXMP-01;(\\\\filesv\\data|g:)\\acct\\LToons\\.*;http://spoint.acme.ch/f/accounts/ACME/;
EXMP-02;(\\\\filesv\\data|g:)\\acct\\.*        ;http://spoint.acme.ch/f/accounts/@FOLDER:2@/;

EXMP-11;(\\\\filesv\\data|g:)\\cust\\Stone\\.* ;http://spoint.acme.ch/f/accounts/Quarry Inc/;
EXMP-12;(\\\\filesv\\data|g:)\\cust\\.*        ;http://spoint.acme.ch/f/accounts/@FOLDER:2@/;

LAST   ;.*                                     ;file:///@INSTALLDIR@/lib/redirect2web.html;

The redirect2web.map file example has the following capabilities:

-
The rules EXMP-* map files located on drive g: or on the data share of the file server \\filesv (when accessed thru the UNC name) from the sub directory \acct\ respectively \cust\ to the SharePoint server URL http://spoint.acme.ch/files/accounts/ .

-
The EXMP-01 rule furthermore maps the old customer name LToons to ACME, the current name of the LToons customer.

-
The EXMP-02 rule maps all other customers located in \acct\ with the original name to the /accounts/ URL.

-
The EXMP-11 rule furthermore maps the old customer name Stone to the also new company name Quarry Inc in this example.

-
The EXMP-12 rule maps all other customers located in \cust\ with the original name to the /accounts/ URL.

-
The LAST rule opens the lib/redirect2web.html notification file from the installation directory of the WA2L/WinTools package in the web browser to inform the user that no mapping for a file has been found.

In general you would define and create an own information html page (most likely residing on a web server or a central file location) to inform your users more specific.
Of course you can also use anchors ( e.g. acme-migration-info.html#INTRO ) to jump to a specific part of the information html page.

Hint: The rules EXMP-02 and EXMP-12 could also be replaced by a single rule, at the place of EXMP-12:

EXMP-22;(\\\\filesv\\data|g:)\\(acct|cust)\\.* ;http://spoint.acme.ch/f/accounts/@FOLDER:2@/;

2) Example config- and map-file using multiple viewers

The following redirect2web.cfg config file expands the PATH to Firefox browser installations and sets the default viewer to Firefox.exe.

The map file redirect2web.map is located on the network drive g:\ to allow central editing/enhancement of the map file without the need to distribute the changed map file to users:

#
# redirect2web.cfg - configuration file for redirect2web
#
# [00] 24.06.2017 CWa   Initial Version
#

MAPFILE=g:\migration\redirect2web.map
PATH=%USERPROFILE%\Documents\bin\FirefoxPortable;d:\bin\FirefoxPortable
VIEWER=FirefoxPortable.exe

In the map file redirect2web.map all targets are loaded into FirefoxPortable.exe except the target defined in the rule EXMP-40 which is loaded into 'Internet Explorer' (iexplore.exe) which is explicitly defined for that rule.

To speed up rule writing, it is recommended to set the most used viewer in the VIEWER=command setting in redirect2web.cfg and the exceptions in the viewer field in the redirect2web.map configuration file:

#
# redirect2web.map - map file for redirect2web
#
# [00] 24.06.2017 CWa   Initial Version
#

#id    ;regex_pattern      ;target                                          ;viewer;
EXMP-40;g:\\(acct|cust)\\.*;http://sharepoint.acme.ch/f/accounts/@FOLDER:2@/;iexplore.exe;
EXMP-41;g:\\manuals\\.*    ;http://opendocman.acme.ch/man/;
EXMP-42;g:\\project\\.*    ;http://openproject.acme.ch/prj/@FOLDER:2@/;
EXMP-43;i:\\checklists\\.* ;http://foswiki.acme.ch/;

LAST   ;.*                 ;file:///@INSTALLDIR@/lib/redirect2web.html;

 

SEE ALSO

wintoolsintro(1), redirect2web(1), redirect2web.cfg(4), regexintro(4)

 

NOTES

-

 

BUGS

-

 

AUTHOR

redirect2web.map was developed by Christian Walther. Send suggestions and bug reports to wa2l@users.sourceforge.net .

 

COPYRIGHT

Copyright © 2020 Christian Walther

This is free software; see WA2LWinTools/man/COPYING for copying conditions. There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


 

Index

NAME
SYNOPSIS
AVAILABILITY
DESCRIPTION
FILEFORMAT
OPTIONS
EXAMPLES
SEE ALSO
NOTES
BUGS
AUTHOR
COPYRIGHT

This document was created by man2html using the manual pages.
Time: 16:32:51 GMT, September 14, 2024