The reblocks-file-server Reference Manual

This is the reblocks-file-server Reference Manual, version 0.3.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Wed May 15 06:44:57 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 reblocks-file-server

A Reblocks extension allowing to create routes for serving static files from disk.

Author

Alexander Artemenko <>

Home Page

https://40ants.com/reblocks-file-server/

Source Control

(GIT https://github.com/40ants/reblocks-file-server)

Bug Tracker

https://github.com/40ants/reblocks-file-server/issues

License

Unlicense

Long Description

<a id="x-28REBLOCKS-FILE-SERVER-DOCS-2FINDEX-3A-40README-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>

# reblocks-file-server - A Reblocks extension allowing to create routes for serving static files from disk.

<a id="reblocks-file-server-asdf-system-details"></a>

## REBLOCKS-FILE-SERVER ASDF System Details

* Version: 0.3.0

* Description: A Reblocks extension allowing to create routes for serving static files from disk.

* Licence: Unlicense

* Author: Alexander Artemenko <svetlyak.40wt@gmail.com>

* Homepage: [https://40ants.com/reblocks-file-server/][f449]

* Bug tracker: [https://github.com/40ants/reblocks-file-server/issues][a450]

* Source control: [GIT][b09a]

* Depends on: [cl-fad][1059], [cl-ppcre][49b9], [reblocks][184b], [routes][48e8], [trivial-mimes][a154]

[![](https://github-actions.40ants.com/40ants/reblocks-file-server/matrix.svg?only=ci.run-tests)][4729]

![](http://quickdocs.org/badge/reblocks-file-server.svg)

<a id="x-28REBLOCKS-FILE-SERVER-DOCS-2FINDEX-3A-3A-40INSTALLATION-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>

## Installation

You can install this library from Quicklisp, but you want to receive updates quickly, then install it from Ultralisp.org:

“‘
(ql-dist:install-dist "http://dist.ultralisp.org/"
:prompt nil)
(ql:quickload :reblocks-file-server)
“‘
<a id="x-28REBLOCKS-FILE-SERVER-DOCS-2FINDEX-3A-3A-40USAGE-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>

## Usage

Here is a few examples on how this library can be used. These lines can be added into the code
which starts your Reblocks web application.

This is how to serve all ‘*.txt‘ files from the ‘/var/www‘ folder:

“‘lisp
(reblocks-file-server:make-route :uri "/static/"
:root "/var/www/"
:dir-listing nil
:filter ".*.txt")
“‘
You also can provide a ‘DIR-LISTING‘ argument to repond on /static/ route with a rendered directory listing:

“‘lisp
(reblocks-file-server:make-route :uri "/static/"
:root "/var/www/"
:dir-listing t
:filter ".*.txt")
“‘
In case if you want to serve all files except ‘*.txt‘, you can negate filter expression by giving ‘NIL‘ in ‘FILTER-TYPE‘ argument:

“‘lisp
(reblocks-file-server:make-route :uri "/static/"
:root "/var/www/"
:dir-listing t
:filter ".*.txt"
:filter-type nil)
“‘
<a id="x-28REBLOCKS-FILE-SERVER-DOCS-2FINDEX-3A-3A-40API-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>

## API

<a id="x-28REBLOCKS-FILE-SERVER-DOCS-2FINDEX-3A-3A-40REBLOCKS-FILE-SERVER-2FCORE-3FPACKAGE-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>

### REBLOCKS-FILE-SERVER/CORE

<a id="x-28-23A-28-2825-29-20BASE-CHAR-20-2E-20-22REBLOCKS-FILE-SERVER-2FCORE-22-29-20PACKAGE-29"></a>

#### [package](c425) ‘reblocks-file-server/core‘

<a id="x-28REBLOCKS-FILE-SERVER-DOCS-2FINDEX-3A-3A-7C-40REBLOCKS-FILE-SERVER-2FCORE-3FClasses-SECTION-7C-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>

#### Classes

<a id="x-28REBLOCKS-FILE-SERVER-DOCS-2FINDEX-3A-3A-40REBLOCKS-FILE-SERVER-2FCORE-24STATIC-FILES-ROUTE-3FCLASS-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>

##### STATIC-FILES-ROUTE

<a id="x-28REBLOCKS-FILE-SERVER-2FCORE-3ASTATIC-FILES-ROUTE-20CLASS-29"></a>

###### [class](907c) ‘reblocks-file-server/core:static-files-route‘ (route)

**Readers**

<a id="x-28REBLOCKS-FILE-SERVER-2FCORE-3AGET-DIR-LISTING-20-2840ANTS-DOC-2FLOCATIVES-3AREADER-20REBLOCKS-FILE-SERVER-2FCORE-3ASTATIC-FILES-ROUTE-29-29"></a>

###### [reader](a9af) ‘reblocks-file-server/core:get-dir-listing‘ (static-files-route) (:dir-listing = t)

When nil, directory contents is not shown.

<a id="x-28REBLOCKS-FILE-SERVER-2FCORE-3AGET-FILTER-20-2840ANTS-DOC-2FLOCATIVES-3AREADER-20REBLOCKS-FILE-SERVER-2FCORE-3ASTATIC-FILES-ROUTE-29-29"></a>

###### [reader](0c78) ‘reblocks-file-server/core:get-filter‘ (static-files-route) (:filter)

A regular expression.

<a id="x-28REBLOCKS-FILE-SERVER-2FCORE-3AGET-FILTER-TYPE-20-2840ANTS-DOC-2FLOCATIVES-3AREADER-20REBLOCKS-FILE-SERVER-2FCORE-3ASTATIC-FILES-ROUTE-29-29"></a>

###### [reader](3c75) ‘reblocks-file-server/core:get-filter-type‘ (static-files-route) (:filter-type = t)

T means show files that match the filter regexp. ‘NIL‘ means hide files that match the filter regexp

<a id="x-28REBLOCKS-FILE-SERVER-2FCORE-3AGET-ROOT-20-2840ANTS-DOC-2FLOCATIVES-3AREADER-20REBLOCKS-FILE-SERVER-2FCORE-3ASTATIC-FILES-ROUTE-29-29"></a>

###### [reader](3dc9) ‘reblocks-file-server/core:get-root‘ (static-files-route) (:root)

<a id="x-28REBLOCKS-FILE-SERVER-2FCORE-3AGET-URI-20-2840ANTS-DOC-2FLOCATIVES-3AREADER-20REBLOCKS-FILE-SERVER-2FCORE-3ASTATIC-FILES-ROUTE-29-29"></a>

###### [reader](c8f8) ‘reblocks-file-server/core:get-uri‘ (static-files-route) (:uri)

<a id="x-28REBLOCKS-FILE-SERVER-DOCS-2FINDEX-3A-3A-7C-40REBLOCKS-FILE-SERVER-2FCORE-3FGenerics-SECTION-7C-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>

#### Generics

<a id="x-28REBLOCKS-FILE-SERVER-2FCORE-3ARENDER-404-20GENERIC-FUNCTION-29"></a>

##### [generic-function](cc57) ‘reblocks-file-server/core:render-404‘ route uri

Returns a string with ‘HTML‘ for a case when ‘uri’ wasn’t found on the disk.

<a id="x-28REBLOCKS-FILE-SERVER-2FCORE-3ARENDER-DIRECTORY-20GENERIC-FUNCTION-29"></a>

##### [generic-function](a9fe) ‘reblocks-file-server/core:render-directory‘ route uri children

Renders a list of files in a directory

<a id="x-28REBLOCKS-FILE-SERVER-2FCORE-3ARENDER-STYLES-20GENERIC-FUNCTION-29"></a>

##### [generic-function](7026) ‘reblocks-file-server/core:render-styles‘ route

This method should use reblocks/html:with-html and output a :style element.

<a id="x-28REBLOCKS-FILE-SERVER-2FCORE-3ASERVE-DIRECTORY-20GENERIC-FUNCTION-29"></a>

##### [generic-function](ffaf) ‘reblocks-file-server/core:serve-directory‘ route uri full-path

Returns a Lack response with a rendered directory listing.

<a id="x-28REBLOCKS-FILE-SERVER-2FCORE-3ASERVE-FILE-20GENERIC-FUNCTION-29"></a>

##### [generic-function](fef3) ‘reblocks-file-server/core:serve-file‘ route full-path

Returns content of the file.

<a id="x-28REBLOCKS-FILE-SERVER-DOCS-2FINDEX-3A-3A-7C-40REBLOCKS-FILE-SERVER-2FCORE-3FFunctions-SECTION-7C-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>

#### Functions

<a id="x-28REBLOCKS-FILE-SERVER-2FCORE-3ALIST-DIRECTORY-20FUNCTION-29"></a>

##### [function](dab9) ‘reblocks-file-server/core:list-directory‘ full-path filter filter-type

Returns a list of files in the directory.
All items of the list are relative.

<a id="x-28REBLOCKS-FILE-SERVER-2FCORE-3AMAKE-ROUTE-20FUNCTION-29"></a>

##### [function](7bda) ‘reblocks-file-server/core:make-route‘ &key (route-class ’static-files-route) (uri "/") (root "./") (dir-listing t) (filter ".\*") (filter-type t)

[f449]: https://40ants.com/reblocks-file-server/
[b09a]: https://github.com/40ants/reblocks-file-server
[4729]: https://github.com/40ants/reblocks-file-server/actions
[c425]: https://github.com/40ants/reblocks-file-server/blob/5d40b7f0df492eabbae5d0d047b91b361ad544f5/src/core.lisp#L1
[dab9]: https://github.com/40ants/reblocks-file-server/blob/5d40b7f0df492eabbae5d0d047b91b361ad544f5/src/core.lisp#L100
[907c]: https://github.com/40ants/reblocks-file-server/blob/5d40b7f0df492eabbae5d0d047b91b361ad544f5/src/core.lisp#L35
[3dc9]: https://github.com/40ants/reblocks-file-server/blob/5d40b7f0df492eabbae5d0d047b91b361ad544f5/src/core.lisp#L36
[c8f8]: https://github.com/40ants/reblocks-file-server/blob/5d40b7f0df492eabbae5d0d047b91b361ad544f5/src/core.lisp#L39
[a9af]: https://github.com/40ants/reblocks-file-server/blob/5d40b7f0df492eabbae5d0d047b91b361ad544f5/src/core.lisp#L42
[0c78]: https://github.com/40ants/reblocks-file-server/blob/5d40b7f0df492eabbae5d0d047b91b361ad544f5/src/core.lisp#L47
[3c75]: https://github.com/40ants/reblocks-file-server/blob/5d40b7f0df492eabbae5d0d047b91b361ad544f5/src/core.lisp#L52
[7bda]: https://github.com/40ants/reblocks-file-server/blob/5d40b7f0df492eabbae5d0d047b91b361ad544f5/src/core.lisp#L58
[ffaf]: https://github.com/40ants/reblocks-file-server/blob/5d40b7f0df492eabbae5d0d047b91b361ad544f5/src/core.lisp#L80
[fef3]: https://github.com/40ants/reblocks-file-server/blob/5d40b7f0df492eabbae5d0d047b91b361ad544f5/src/core.lisp#L84
[a9fe]: https://github.com/40ants/reblocks-file-server/blob/5d40b7f0df492eabbae5d0d047b91b361ad544f5/src/core.lisp#L88
[cc57]: https://github.com/40ants/reblocks-file-server/blob/5d40b7f0df492eabbae5d0d047b91b361ad544f5/src/core.lisp#L92
[7026]: https://github.com/40ants/reblocks-file-server/blob/5d40b7f0df492eabbae5d0d047b91b361ad544f5/src/core.lisp#L96
[a450]: https://github.com/40ants/reblocks-file-server/issues
[1059]: https://quickdocs.org/cl-fad
[49b9]: https://quickdocs.org/cl-ppcre
[184b]: https://quickdocs.org/reblocks
[48e8]: https://quickdocs.org/routes
[a154]: https://quickdocs.org/trivial-mimes

* * *
###### [generated by [40ANTS-DOC](https://40ants.com/doc/)]

Version

0.3.0

Defsystem Dependency

40ants-asdf-system (system).

Dependency

reblocks-file-server/core (system).

Source

reblocks-file-server.asd.


2.2 reblocks-file-server/core

Author

Alexander Artemenko <>

Home Page

https://40ants.com/reblocks-file-server/

Source Control

(GIT https://github.com/40ants/reblocks-file-server)

Bug Tracker

https://github.com/40ants/reblocks-file-server/issues

License

Unlicense

Dependencies
  • trivial-mimes (system).
  • reblocks/request (system).
  • reblocks/html (system).
  • reblocks/utils/misc (system).
  • reblocks/routes (system).
  • routes (system).
  • cl-fad (system).
  • cl-ppcre (system).
Source

reblocks-file-server.asd.


3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


3.1 Lisp


3.1.1 reblocks-file-server/reblocks-file-server.asd

Source

reblocks-file-server.asd.

Parent Component

reblocks-file-server (system).

ASDF Systems

3.1.2 reblocks-file-server/core/file-type.lisp

Source

reblocks-file-server.asd.

Parent Component

reblocks-file-server/core (system).

Packages

reblocks-file-server/core.

Public Interface
Internals

make-full-path (function).


4 Packages

Packages are listed by definition order.


4.1 reblocks-file-server/core

Source

file-type.lisp.

Nickname

reblocks-file-server

Use List

common-lisp.

Public Interface
Internals

make-full-path (function).


5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


5.1 Public Interface


5.1.1 Ordinary functions

Function: list-directory (full-path filter filter-type)

Returns a list of files in the directory. All items of the list are relative.

Package

reblocks-file-server/core.

Source

file-type.lisp.

Function: make-route (&key route-class uri root dir-listing filter filter-type)
Package

reblocks-file-server/core.

Source

file-type.lisp.


5.1.2 Generic functions

Generic Reader: get-dir-listing (object)
Package

reblocks-file-server/core.

Methods
Reader Method: get-dir-listing ((static-files-route static-files-route))

When nil, directory contents is not shown.

Source

file-type.lisp.

Target Slot

dir-listing.

Generic Reader: get-filter (object)
Package

reblocks-file-server/core.

Methods
Reader Method: get-filter ((static-files-route static-files-route))

A regular expression.

Source

file-type.lisp.

Target Slot

filter.

Generic Reader: get-filter-type (object)
Package

reblocks-file-server/core.

Methods
Reader Method: get-filter-type ((static-files-route static-files-route))

T means show files that match the filter regexp. NIL means hide files that match the filter regexp

Source

file-type.lisp.

Target Slot

filter-type.

Generic Reader: get-root (object)
Package

reblocks-file-server/core.

Methods
Reader Method: get-root ((static-files-route static-files-route))

automatically generated reader method

Source

file-type.lisp.

Target Slot

root.

Generic Reader: get-uri (object)
Package

reblocks-file-server/core.

Methods
Reader Method: get-uri ((static-files-route static-files-route))

automatically generated reader method

Source

file-type.lisp.

Target Slot

uri.

Generic Function: render-404 (route uri)

Returns a string with HTML for a case when ‘uri’ wasn’t found on the disk.

Package

reblocks-file-server/core.

Source

file-type.lisp.

Methods
Method: render-404 (route uri)
Generic Function: render-directory (route uri children)

Renders a list of files in a directory

Package

reblocks-file-server/core.

Source

file-type.lisp.

Methods
Method: render-directory (route uri children)
Generic Function: render-styles (route)

This method should use reblocks/html:with-html and output a :style element.

Package

reblocks-file-server/core.

Source

file-type.lisp.

Methods
Method: render-styles (route)
Generic Function: serve-directory (route uri full-path)

Returns a Lack response with a rendered directory listing.

Package

reblocks-file-server/core.

Source

file-type.lisp.

Methods
Method: serve-directory (route uri full-path)
Generic Function: serve-file (route full-path)

Returns content of the file.

Package

reblocks-file-server/core.

Source

file-type.lisp.

Methods
Method: serve-file (route full-path)

5.1.3 Standalone methods

Method: serve ((route static-files-route) env)

Returns a robots of the site.

Package

reblocks/routes.

Source

file-type.lisp.


5.1.4 Classes

Class: static-files-route
Package

reblocks-file-server/core.

Source

file-type.lisp.

Direct superclasses

route.

Direct methods
Direct slots
Slot: root
Type

pathname

Initargs

:root

Readers

get-root.

Writers

This slot is read-only.

Slot: uri
Type

pathname

Initargs

:uri

Readers

get-uri.

Writers

This slot is read-only.

Slot: dir-listing

When nil, directory contents is not shown.

Initform

t

Initargs

:dir-listing

Readers

get-dir-listing.

Writers

This slot is read-only.

Slot: filter

A regular expression.

Type

string

Initargs

:filter

Readers

get-filter.

Writers

This slot is read-only.

Slot: filter-type

T means show files that match the filter regexp. NIL means hide files that match the filter regexp

Initform

t

Initargs

:filter-type

Readers

get-filter-type.

Writers

This slot is read-only.


5.2 Internals


5.2.1 Ordinary functions

Function: make-full-path (root route-uri request-path)

Returns a pathname pointing to the file on the filesystem.

Root, is a base directory of the route, route-uri is a path on the webserver, where files should be served from
and request-path is a requested path from the webrowser. Request-path is always have a route-uri as a prefix.

For example, if:

root = "/app/build/dist/"
route-uri = "/dist/"
request-path = "/dist/the-file.txt"

Then this function should return a pathname
pointing to "/app/build/dist/the-file.txt"

Package

reblocks-file-server/core.

Source

file-type.lisp.


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   F   G   L   M   R   S  
Index Entry  Section

F
Function, list-directory: Public ordinary functions
Function, make-full-path: Private ordinary functions
Function, make-route: Public ordinary functions

G
Generic Function, get-dir-listing: Public generic functions
Generic Function, get-filter: Public generic functions
Generic Function, get-filter-type: Public generic functions
Generic Function, get-root: Public generic functions
Generic Function, get-uri: Public generic functions
Generic Function, render-404: Public generic functions
Generic Function, render-directory: Public generic functions
Generic Function, render-styles: Public generic functions
Generic Function, serve-directory: Public generic functions
Generic Function, serve-file: Public generic functions
get-dir-listing: Public generic functions
get-dir-listing: Public generic functions
get-filter: Public generic functions
get-filter: Public generic functions
get-filter-type: Public generic functions
get-filter-type: Public generic functions
get-root: Public generic functions
get-root: Public generic functions
get-uri: Public generic functions
get-uri: Public generic functions

L
list-directory: Public ordinary functions

M
make-full-path: Private ordinary functions
make-route: Public ordinary functions
Method, get-dir-listing: Public generic functions
Method, get-filter: Public generic functions
Method, get-filter-type: Public generic functions
Method, get-root: Public generic functions
Method, get-uri: Public generic functions
Method, render-404: Public generic functions
Method, render-directory: Public generic functions
Method, render-styles: Public generic functions
Method, serve: Public standalone methods
Method, serve-directory: Public generic functions
Method, serve-file: Public generic functions

R
render-404: Public generic functions
render-404: Public generic functions
render-directory: Public generic functions
render-directory: Public generic functions
render-styles: Public generic functions
render-styles: Public generic functions

S
serve: Public standalone methods
serve-directory: Public generic functions
serve-directory: Public generic functions
serve-file: Public generic functions
serve-file: Public generic functions