Templates

MiniShare 1.5.0 introduces a template system that makes it possible to customize the index page and error pages. The files index.tmpl and error.tmpl in the directory layout contain the templates for the pages. These files can be edited.

Basics

The basic format for a token is:

%token_name[:trim_length]%

I.e. %minishare.version:3% would return only the first 3 (or less) characters of the version string. %minishare.version:-3% returns the last 3 characters. No trim value specified returns the whole string.

To get the character '%', you need to use '%%'.

If-else-endif

%if token_name|value <test> token_name|value%
  ...
%else%
  ...
%endif%

I.e. token_name is any token (NOT any of the special tokens), value is a double quote delimited string. Test is either '==' or '=' for equal, '!=' or '<>' for not equal, '<' for less than and '>' for greater than. The testing works between two numerical values or two strings (in the case of greater and less than, lexical comparison is used). The comparison between two strings does not take the character case in account.

%if minishare.version:9=="minishare"%
<p>Everything is OK!</p>
%else%
<p>It seems something strange happened.</p>
%endif%

%if filelist.numfiles=="0"%
<p>Sorry, no files shared!</p>
%endif%

Error

%error.code%   E.g. '404'
%error.title%  E.g. 'File not found'

In case of an error, %error.title% contains a short description of the error. %error.code% contains the numerical code for the error (%error.code% contains 200 in case of a successful operation).

Filelist

%filelist.begin%     Begins file list section
%filelist.end%       Ends file list section
%filelist.numfiles%  Total number of (visible) files in the list
%filelist.size%      Total size of (visible) files in the list

The printing of the file list starts with %filelist.begin%. The token marks the beginning of the section that is repeated for every visible file. %filelist.end% marks the end of the section. During the parsing, the following tokens contain the data for the file that is parsed currently:

%file.id%         The number of the current file
%file.name%       Filename (e.g. file.zip)
%file.extension%  (e.g. 'zip')
%file.path%       The full path to the file (e.g. 'C:\Files\file.zip')
%file.size%       Filesize (e.g. '500 bytes');
%file.url%        Shared path (e.g. '/file.zip')
%file.date%       HTTP formatted date 
%file.mime%       The mime type (e.g. 'text/plain')

Example:

<p>Here are my files:</p>

<table>
%filelist.begin%
  <tr><td>%file.name%</td> <td>%file.size%</td></tr>
%filelist.end%  
</table>

Minishare

%minishare.homepage%  Currently 'http://minishare.sourceforge.net'
%minishare.version%   E.g. 'MiniShare 1.5.0'

Request

%request.login%           The login used (not implemented)
%request.password%        The password used (not implemented)
%request.path%            The requested path (e.g. '/page.html')
%request.request_string%  The string after a '?' after the request path

If the user requests for a path such as 'index.html?hello' %request.request_string% contains 'hello'. If no '?' is found in the path, %request.request_string% is an empty string.

Server

%server.address%         The current numerical IP address (or specified domain name)
%server.port%            The current port MiniShare listens to (or what is specified with -stunnel command line option)
%server.maxconnections%  Maximum number of allowed connections
%server.numconnections%  Current number of connections