Modify the source definition.
Fix to keep text file README.
Bump up version number.
Guile-MIME is a MIME types utility for Guile, providing utility functions such as ext->type, type->exts, file->type.
http.server of Python or Rack of Ruby has MIME types database that doesn't depend on other external resources.
I wanted need those that unnecessary depend on external resources and easily use and modify the database why I created this.
SEE ALSO:
Original data is the mime-db project has. SEE: https://github.com/jshttp/mime-db
MIME types data is removed if they don't have extensions definition and converted from JSON to association list of Scheme. Also, if there are multiple MIME types candidates against an extension, keep one and delete the rest. The MIME type to keep is determined by the author's preference. So, please modify those if you want to keep another candidate.
SEE: conflict-ext-type-map
in (mime db)
This logic can be found "scripts/guile-mime-db.in".
$ guile
GNU Guile 3.0.8
Copyright (C) 1995-2021 Free Software Foundation, Inc.
Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.
Enter `,help' for help.
scheme@(guile-user)> ,use (mime)
scheme@(guile-user)> (ext->type "htm")
$1 = "text/html"
scheme@(guile-user)> (ext->type "html")
$2 = "text/html"
scheme@(guile-user)> (ext->type "unknown")
$3 = #f
scheme@(guile-user)> (type->exts "text/html")
$4 = ("html" "htm" "shtml")
scheme@(guile-user)> (type->exts "text/css")
$5 = ("css")
scheme@(guile-user)> (type->exts "unknown")
$6 = #f
scheme@(guile-user)> (file->type "index.html")
$7 = "text/html"
scheme@(guile-user)> (file->type "/assets/stylesheets/style.css")
$8 = "text/css"
scheme@(guile-user)> (file->type "https://example.com/js/script.js")
$9 = "application/javascript"
scheme@(guile-user)> (file->type "unknown")
$10 = #f
$ cd /path/to/here
$ guix package -f guix.scm
(ext->type extension)
(mime)
(ext->type "htm")
(type->exts mime-type)
(mime)
(type->exts "text/html")
(file->type filename)
(mime)
(file->type "index.html")
(file->type "/assets/stylesheets/style.css")
(file->type "https://example.com/js/script.js")
Here are some tips for using the library.
It doesn't provide a dedicated way yet that modifies databases.
However, feel free to change them and use them as shown below.
(use-modules (mime))
(set! (@ (mime db) ext-type-db)
(cons '("html" . "text/x-my-special-html") (@ (mime db) ext-type-db)))
(set! (@ (mime db) type-exts-db)
(cons '("text/x-my-special-html" "html" "htm" "shtml") (@ (mime db) type-exts-db)))
(display (ext->type "html"))
(newline)
;; => "text/x-my-special-html"
(display (type->exts "text/x-my-special-html"))
(newline)
;; => ("html" "htm" "shtml")
If you have any questions and feature requests, submit patches, please send them to the public mailing list ~taiju/Guile-MIME@lists.sr.ht
.