summaryrefslogtreecommitdiffstats
path: root/tcllib/examples/httpd/htdocs/content.file.md
blob: b2c1b3a1f8f0e3b17fa88393cb2d8917f33b1c5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
httpd::content::file
====================
Back to: [Index](index.md) | [Package httpd::content](content.md)

The **httpd::content::file** class implements a system for sharing a
local file structure via http.

## Special file handling

### Directories

When a directory path is requested, the system searches for one of the following (in order):

* index.tml
* index.md
* index.html

If one of these files is found, it is delivered as the response to the request. If no index file
was found, the object will call the object's *DirectoryListing* method to
deliver a dynamic listing of the files in the directory.

### .md files

Files with the .md extension are parsed using the *Markdown* package.

### .tml files

Files with the .tml extension are parsed using a call to *subst*.
This allows them to deliver content in the same manner as tclhttpd. The
contents of the *query_headers* are loaded as local variables prior to
the *subst* call. NOTE: Unlike Tclhttpd, the substitution is performed
inside of the reply object's namespace, not the local interpreter. Thus,
template files can exercise the object's methods using the "my" command.

## Dispatch Parameters

Objects of this class needs additional information from the server in
order to operate. These fields should be coded into the **add_root** call.

### path *filepath*

The **path** parameter specifies the root of the file path to be exposed.

## Methods

### DirectoryListing *local_file*

Generates an HTML listing of a file path. The default implementation is a *very*
rudimentary **glob --nocomplain [file join $local_path \*]**

### FileName

Converts the **REQUEST_URI** from query_headers into a local file path. This
method searches first for the file name verbatim. If not found, it then searches
for the same file name with a .md, .html, or .tml extension (in that order.)