File: content.file.md

package info (click to toggle)
tcllib 1.20%2Bdfsg-1
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 68,064 kB
  • sloc: tcl: 216,842; ansic: 14,250; sh: 2,846; xml: 1,766; yacc: 1,145; pascal: 881; makefile: 107; perl: 84; f90: 84; python: 33; ruby: 13; php: 11
file content (55 lines) | stat: -rw-r--r-- 1,902 bytes parent folder | download | duplicates (3)
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.)