| |
| /pliant/protocol/common/mime.pli |
| |
| 1 |
# Copyright Hubert Tonneau hubert.tonneau@pliant.cx | |
| 2 |
# | |
| 3 |
# This program is free software; you can redistribute it and/or | |
| 4 |
# modify it under the terms of the GNU General Public License version 2 | |
| 5 |
# as published by the Free Software Foundation. | |
| 6 |
# | |
| 7 |
# This program is distributed in the hope that it will be useful, | |
| 8 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 9 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 10 |
# GNU General Public License for more details. | |
| 11 |
# | |
| 12 |
# You should have received a copy of the GNU General Public License | |
| 13 |
# version 2 along with this program; if not, write to the Free Software | |
| 14 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
| 15 |
| |
| 16 |
module "/pliant/language/compiler.pli" | |
| 17 |
| |
| 18 |
| |
| 19 |
gvar Dictionary mime_types | |
| 20 |
| |
| 21 |
function declare_mime_type ext mime | |
| 22 |
arg Str ext mime | |
| 23 |
var Link:Str m :> (mime_types first ext) map Str | |
| 24 |
if addressof:m=null | |
| 25 |
m :> new Str | |
| 26 |
mime_types insert ext true addressof:m | |
| 27 |
m := mime | |
| 28 |
| |
| 29 |
function query_mime_type ext -> mime | |
| 30 |
arg Str ext mime | |
| 31 |
var Link:Str m :> (mime_types first ext) map Str | |
| 32 |
if exists:m | |
| 33 |
mime := m | |
| 34 |
else | |
| 35 |
mime := "" | |
| 36 |
| |
| 37 |
| |
| 38 |
gvar Dictionary mime_dynamic_filters | |
| 39 |
| |
| 40 |
function declare_mime_dynamic_filter ext fun | |
| 41 |
arg Str ext ; arg Function fun | |
| 42 |
# mime_filters remove ext null | |
| 43 |
mime_dynamic_filters insert ext true addressof:fun | |
| 44 |
| |
| 45 |
function query_mime_dynamic_filter ext -> fun | |
| 46 |
arg Str ext ; arg_R Function fun | |
| 47 |
fun :> (mime_dynamic_filters first ext) map Function | |
| 48 |
| |
| 49 |
| |
| 50 |
gvar Dictionary mime_static_filters | |
| 51 |
| |
| 52 |
function declare_mime_static_filter ext fun | |
| 53 |
arg Str ext ; arg Function fun | |
| 54 |
mime_static_filters insert ext true addressof:fun | |
| 55 |
| |
| 56 |
function query_mime_static_filter ext -> fun | |
| 57 |
arg Str ext ; arg_R Function fun | |
| 58 |
fun :> (mime_static_filters first ext) map Function | |
| 59 |
| |
| 60 |
declare_mime_type ".html" "text/html; charset=ISO-8859-1" | |
| 61 |
declare_mime_type ".css" "text/css" | |
| 62 |
declare_mime_type ".js" "application/x-javascript" | |
| 63 |
declare_mime_type ".wml" "text/vnd.wap.wml" | |
| 64 |
declare_mime_type ".txt" "text/plain" | |
| 65 |
declare_mime_type ".jpeg" "image/jpeg" | |
| 66 |
declare_mime_type ".jpg" "image/jpeg" | |
| 67 |
declare_mime_type ".png" "image/png" | |
| 68 |
declare_mime_type ".tgz" "binary/tgz" | |
| 69 |
declare_mime_type ".zip" "binary/zip" | |
| 70 |
| |
| 71 |
plugin mime | |
| 72 |
| |
| 73 |
# documents | |
| 74 |
declare_mime_type ".pdf" "application/pdf" | |
| 75 |
# declare_mime_type ".htm" "text/html" | |
| 76 |
# declare_mime_type ".ps" "application/postscript" | |
| 77 |
# declare_mime_type ".doc" "application/msword" | |
| 78 |
# declare_mime_type ".xls" "application/vnd.ms-excel" | |
| 79 |
# images | |
| 80 |
# declare_mime_type ".svg" "image/svg" | |
| 81 |
# scripting | |
| 82 |
# declare_mime_type ".jar" "application/java-archive" | |
| 83 |
# archiving | |
| 84 |
# declare_mime_type ".tar" "application/x-tar" | |
| 85 |
| |
| 86 |
export declare_mime_type query_mime_type | |
| 87 |
export declare_mime_dynamic_filter query_mime_dynamic_filter | |
| 88 |
export declare_mime_static_filter query_mime_static_filter | |
| |