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

REBLOCKS-FILE-SERVER ASDF System Details

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)

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 inside the initialize-instance method of your app:

(defmethod initialize-instance ((app app) &rest args)
  (declare (ignorable args))

  (reblocks-file-server:make-route :root (asdf:system-relative-pathname "ultralisp"
                                                                        "images/")
                                   :uri "/images/")
  (call-next-method))

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

(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:

(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:

(reblocks-file-server:make-route :uri "/static/"
                                 :root "/var/www/"
                                 :dir-listing t
                                 :filter ".*.txt"
                                 :filter-type nil)

API

REBLOCKS-FILE-SERVER/CORE

Classes

STATIC-FILES-ROUTE

Readers

When nil, directory contents is not shown.

A regular expression.

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

Generics

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

Renders a list of files in a directory

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

Returns a Lack response with a rendered directory listing.

Returns content of the file.

Functions

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

function
&key (route-class 'static-files-route) (uri "/") (root "./") (dir-listing t) (filter ".\*") (filter-type t)