unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* [PATCH] add web/mime support
@ 2012-02-23 14:53 Nala Ginrut
  2012-02-23 15:03 ` Catonano
  2013-01-16 10:46 ` Andy Wingo
  0 siblings, 2 replies; 14+ messages in thread
From: Nala Ginrut @ 2012-02-23 14:53 UTC (permalink / raw)
  To: guile-devel


[-- Attachment #1.1: Type: text/plain, Size: 320 bytes --]

There's no mime support in Guile module, so I modified the mime code of my
project Ragnarok and format a patch.
It's easy to use:
(use-modules (web mime))
(define mime (make <mime>))
(mime:guess mime 'pdf)
==> application/pdf
(mime:guess mime 'php)
==> application/x-httpd-php

Maybe useful for some guys~
Any comments?

[-- Attachment #1.2: Type: text/html, Size: 456 bytes --]

[-- Attachment #2: 0001-add-module-web-mime.patch --]
[-- Type: text/x-patch, Size: 17956 bytes --]

From 8165e431af6beb493e41e7ea5858cd253cf09535 Mon Sep 17 00:00:00 2001
From: NalaGinrut <NalaGinrut@gmail.com>
Date: Thu, 23 Feb 2012 22:43:35 +0800
Subject: [PATCH] add module/web/mime

---
 module/Makefile.am  |    3 +-
 module/web/mime.scm |  432 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 434 insertions(+), 1 deletions(-)
 create mode 100644 module/web/mime.scm

diff --git a/module/Makefile.am b/module/Makefile.am
index 9c9d8ed..9dadd32 100644
--- a/module/Makefile.am
+++ b/module/Makefile.am
@@ -370,7 +370,8 @@ WEB_SOURCES =					\
   web/response.scm				\
   web/server.scm				\
   web/server/http.scm				\
-  web/uri.scm
+  web/uri.scm					\
+  web/mime.scm
 
 EXTRA_DIST += oop/ChangeLog-2008
 
diff --git a/module/web/mime.scm b/module/web/mime.scm
new file mode 100644
index 0000000..1aa86d5
--- /dev/null
+++ b/module/web/mime.scm
@@ -0,0 +1,432 @@
+;;; MIME support
+
+;; Copyright (C) 2011 Free Software Foundation, Inc.
+
+;; This library is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU Lesser General Public
+;; License as published by the Free Software Foundation; either
+;; version 3 of the License, or (at your option) any later version.
+;;
+;; This library is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; Lesser General Public License for more details.
+;;
+;; You should have received a copy of the GNU Lesser General Public
+;; License along with this library; if not, write to the Free Software
+;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+;; 02110-1301 USA
+
+(define-module (web mime)
+  #:use-module (oop goops)
+  #:export (<mime> mime:guess))
+
+(define-class <mime> ()
+  (mime-types-table #:init-value (make-hash-table)
+                    #:accessor mime:mime-types-table))
+
+(define-method (mime:guess (self <mime>) (what <symbol>))
+  (let ((mime-types-table (mime:mime-types-table self)))
+    (hash-ref mime-types-table what)))
+
+(define-method (mime:guess (self <mime>) (what <string>))
+  (let ((mime-types-table (mime:mime-types-table self)))
+    (hash-ref mime-types-table (string->symbol what))))
+
+;; NOTE: This *mime-type-list* was generated from /etc/mime.types automatically.
+;;       So it looks strange but works.
+(define *mime-type-list*
+`(
+(application/andrew-inset (ez        ))
+(application/annodex (anx        ))
+(application/atom+xml (atom        ))
+(application/atomcat+xml (atomcat        ))
+(application/atomserv+xml (atomsrv        ))
+(application/bbolin (lin        ))
+(application/cap (cap pcap       ))
+(application/cu-seeme (cu        ))
+(application/davmount+xml (davmount        ))
+(application/dsptype (tsp        ))
+(application/ecmascript (es        ))
+(application/futuresplash (spl        ))
+(application/hta (hta        ))
+(application/java-archive (jar        ))
+(application/java-serialized-object (ser        ))
+(application/java-vm (class        ))
+(application/javascript (js        ))
+(application/m3g (m3g        ))
+(application/mac-binhex40 (hqx        ))
+(application/mac-compactpro (cpt        ))
+(application/mathematica (nb nbp       ))
+(application/msaccess (mdb        ))
+(application/msword (doc dot       ))
+(application/mxf (mxf        ))
+(application/octet-stream (bin        ))
+(application/oda (oda        ))
+(application/ogg (ogx        ))
+(application/pdf (pdf        ))
+(application/pgp-keys (key        ))
+(application/pgp-signature (pgp        ))
+(application/pics-rules (prf        ))
+(application/postscript (ps ai eps epsi epsf eps2 eps3  ))
+(application/rar (rar        ))
+(application/rdf+xml (rdf        ))
+(application/rss+xml (rss        ))
+(application/rtf (rtf        ))
+(application/smil (smi smil       ))
+(application/xhtml+xml (xhtml xht       ))
+(application/xml (xml xsl xsd      ))
+(application/xspf+xml (xspf        ))
+(application/zip (zip        ))
+(application/vnd.android.package-archive (apk        ))
+(application/vnd.cinderella (cdy        ))
+(application/vnd.google-earth.kml+xml (kml        ))
+(application/vnd.google-earth.kmz (kmz        ))
+(application/vnd.mozilla.xul+xml (xul        ))
+(application/vnd.ms-excel (xls xlb xlt      ))
+(application/vnd.ms-pki.seccat (cat        ))
+(application/vnd.ms-pki.stl (stl        ))
+(application/vnd.ms-powerpoint (ppt pps       ))
+(application/vnd.oasis.opendocument.chart (odc        ))
+(application/vnd.oasis.opendocument.database (odb        ))
+(application/vnd.oasis.opendocument.formula (odf        ))
+(application/vnd.oasis.opendocument.graphics (odg        ))
+(application/vnd.oasis.opendocument.graphics-template (otg        ))
+(application/vnd.oasis.opendocument.image (odi        ))
+(application/vnd.oasis.opendocument.presentation (odp        ))
+(application/vnd.oasis.opendocument.presentation-template (otp        ))
+(application/vnd.oasis.opendocument.spreadsheet (ods        ))
+(application/vnd.oasis.opendocument.spreadsheet-template (ots        ))
+(application/vnd.oasis.opendocument.text (odt        ))
+(application/vnd.oasis.opendocument.text-master (odm        ))
+(application/vnd.oasis.opendocument.text-template (ott        ))
+(application/vnd.oasis.opendocument.text-web (oth        ))
+(application/vnd.openxmlformats-officedocument.spreadsheetml.sheet (xlsx        ))
+(application/vnd.openxmlformats-officedocument.spreadsheetml.template (xltx        ))
+(application/vnd.openxmlformats-officedocument.presentationml.presentation (pptx        ))
+(application/vnd.openxmlformats-officedocument.presentationml.slideshow (ppsx        ))
+(application/vnd.openxmlformats-officedocument.presentationml.template (potx        ))
+(application/vnd.openxmlformats-officedocument.wordprocessingml.document (docx        ))
+(application/vnd.openxmlformats-officedocument.wordprocessingml.template (dotx        ))
+(application/vnd.rim.cod (cod        ))
+(application/vnd.smaf (mmf        ))
+(application/vnd.stardivision.calc (sdc        ))
+(application/vnd.stardivision.chart (sds        ))
+(application/vnd.stardivision.draw (sda        ))
+(application/vnd.stardivision.impress (sdd        ))
+(application/vnd.stardivision.math (sdf        ))
+(application/vnd.stardivision.writer (sdw        ))
+(application/vnd.stardivision.writer-global (sgl        ))
+(application/vnd.sun.xml.calc (sxc        ))
+(application/vnd.sun.xml.calc.template (stc        ))
+(application/vnd.sun.xml.draw (sxd        ))
+(application/vnd.sun.xml.draw.template (std        ))
+(application/vnd.sun.xml.impress (sxi        ))
+(application/vnd.sun.xml.impress.template (sti        ))
+(application/vnd.sun.xml.math (sxm        ))
+(application/vnd.sun.xml.writer (sxw        ))
+(application/vnd.sun.xml.writer.global (sxg        ))
+(application/vnd.sun.xml.writer.template (stw        ))
+(application/vnd.symbian.install (sis        ))
+(application/vnd.visio (vsd        ))
+(application/vnd.wap.wbxml (wbxml        ))
+(application/vnd.wap.wmlc (wmlc        ))
+(application/vnd.wap.wmlscriptc (wmlsc        ))
+(application/vnd.wordperfect (wpd        ))
+(application/vnd.wordperfect5.1 (wp5        ))
+(application/x-123 (wk        ))
+(application/x-7z-compressed (7z        ))
+(application/x-abiword (abw        ))
+(application/x-apple-diskimage (dmg        ))
+(application/x-bcpio (bcpio        ))
+(application/x-bittorrent (torrent        ))
+(application/x-cab (cab        ))
+(application/x-cbr (cbr        ))
+(application/x-cbz (cbz        ))
+(application/x-cdf (cdf cda       ))
+(application/x-cdlink (vcd        ))
+(application/x-chess-pgn (pgn        ))
+(application/x-cpio (cpio        ))
+(application/x-csh (csh        ))
+(application/x-debian-package (deb udeb       ))
+(application/x-director (dcr dir dxr      ))
+(application/x-dms (dms        ))
+(application/x-doom (wad        ))
+(application/x-dvi (dvi        ))
+(application/x-httpd-eruby (rhtml        ))
+(application/x-font (pfa pfb gsf pcf pcf.Z    ))
+(application/x-freemind (mm        ))
+(application/x-futuresplash (spl        ))
+(application/x-gnumeric (gnumeric        ))
+(application/x-go-sgf (sgf        ))
+(application/x-graphing-calculator (gcf        ))
+(application/x-gtar (gtar tgz taz      ))
+(application/x-hdf (hdf        ))
+(application/x-httpd-php (phtml pht php      ))
+(application/x-httpd-php-source (phps        ))
+(application/x-httpd-php3 (php3        ))
+(application/x-httpd-php3-preprocessed (php3p        ))
+(application/x-httpd-php4 (php4        ))
+(application/x-httpd-php5 (php5        ))
+(application/x-ica (ica        ))
+(application/x-info (info        ))
+(application/x-internet-signup (ins isp       ))
+(application/x-iphone (iii        ))
+(application/x-iso9660-image (iso        ))
+(application/x-jam (jam        ))
+(application/x-java-jnlp-file (jnlp        ))
+(application/x-jmol (jmz        ))
+(application/x-kchart (chrt        ))
+(application/x-killustrator (kil        ))
+(application/x-koan (skp skd skt skm     ))
+(application/x-kpresenter (kpr kpt       ))
+(application/x-kspread (ksp        ))
+(application/x-kword (kwd kwt       ))
+(application/x-latex (latex        ))
+(application/x-lha (lha        ))
+(application/x-lyx (lyx        ))
+(application/x-lzh (lzh        ))
+(application/x-lzx (lzx        ))
+(application/x-maker (frm maker frame fm fb book fbdoc  ))
+(application/x-mif (mif        ))
+(application/x-ms-wmd (wmd        ))
+(application/x-ms-wmz (wmz        ))
+(application/x-msdos-program (com exe bat dll     ))
+(application/x-msi (msi        ))
+(application/x-netcdf (nc        ))
+(application/x-ns-proxy-autoconfig (pac dat       ))
+(application/x-nwc (nwc        ))
+(application/x-object (o        ))
+(application/x-oz-application (oza        ))
+(application/x-pkcs7-certreqresp (p7r        ))
+(application/x-pkcs7-crl (crl        ))
+(application/x-python-code (pyc pyo       ))
+(application/x-qgis (qgs shp shx      ))
+(application/x-quicktimeplayer (qtl        ))
+(application/x-redhat-package-manager (rpm        ))
+(application/x-ruby (rb        ))
+(application/x-sh (sh        ))
+(application/x-shar (shar        ))
+(application/x-shockwave-flash (swf swfl       ))
+(application/x-silverlight (scr        ))
+(application/x-stuffit (sit sitx       ))
+(application/x-sv4cpio (sv4cpio        ))
+(application/x-sv4crc (sv4crc        ))
+(application/x-tar (tar        ))
+(application/x-tcl (tcl        ))
+(application/x-tex-gf (gf        ))
+(application/x-tex-pk (pk        ))
+(application/x-texinfo (texinfo texi       ))
+(application/x-trash (~ % bak old sik    ))
+(application/x-troff (t tr roff      ))
+(application/x-troff-man (man        ))
+(application/x-troff-me (me        ))
+(application/x-troff-ms (ms        ))
+(application/x-ustar (ustar        ))
+(application/x-wais-source (src        ))
+(application/x-wingz (wz        ))
+(application/x-x509-ca-cert (crt        ))
+(application/x-xcf (xcf        ))
+(application/x-xfig (fig        ))
+(application/x-xpinstall (xpi        ))
+(audio/amr (amr        ))
+(audio/amr-wb (awb        ))
+(audio/amr (amr        ))
+(audio/amr-wb (awb        ))
+(audio/annodex (axa        ))
+(audio/basic (au snd       ))
+(audio/flac (flac        ))
+(audio/midi (mid midi kar      ))
+(audio/mpeg (mpga mpega mp2 mp3 m4a    ))
+(audio/mpegurl (m3u        ))
+(audio/ogg (oga ogg spx      ))
+(audio/prs.sid (sid        ))
+(audio/x-aiff (aif aiff aifc      ))
+(audio/x-gsm (gsm        ))
+(audio/x-mpegurl (m3u        ))
+(audio/x-ms-wma (wma        ))
+(audio/x-ms-wax (wax        ))
+(audio/x-pn-realaudio (ra rm ram      ))
+(audio/x-realaudio (ra        ))
+(audio/x-scpls (pls        ))
+(audio/x-sd2 (sd2        ))
+(audio/x-wav (wav        ))
+(chemical/x-alchemy (alc        ))
+(chemical/x-cache (cac cache       ))
+(chemical/x-cache-csf (csf        ))
+(chemical/x-cactvs-binary (cbin cascii ctab      ))
+(chemical/x-cdx (cdx        ))
+(chemical/x-cerius (cer        ))
+(chemical/x-chem3d (c3d        ))
+(chemical/x-chemdraw (chm        ))
+(chemical/x-cif (cif        ))
+(chemical/x-cmdf (cmdf        ))
+(chemical/x-cml (cml        ))
+(chemical/x-compass (cpa        ))
+(chemical/x-crossfire (bsd        ))
+(chemical/x-csml (csml csm       ))
+(chemical/x-ctx (ctx        ))
+(chemical/x-cxf (cxf cef       ))
+(chemical/x-embl-dl-nucleotide (emb embl       ))
+(chemical/x-galactic-spc (spc        ))
+(chemical/x-gamess-input (inp gam gamin      ))
+(chemical/x-gaussian-checkpoint (fch fchk       ))
+(chemical/x-gaussian-cube (cub        ))
+(chemical/x-gaussian-input (gau gjc gjf      ))
+(chemical/x-gaussian-log (gal        ))
+(chemical/x-gcg8-sequence (gcg        ))
+(chemical/x-genbank (gen        ))
+(chemical/x-hin (hin        ))
+(chemical/x-isostar (istr ist       ))
+(chemical/x-jcamp-dx (jdx dx       ))
+(chemical/x-kinemage (kin        ))
+(chemical/x-macmolecule (mcm        ))
+(chemical/x-macromodel-input (mmd mmod       ))
+(chemical/x-mdl-molfile (mol        ))
+(chemical/x-mdl-rdfile (rd        ))
+(chemical/x-mdl-rxnfile (rxn        ))
+(chemical/x-mdl-sdfile (sd sdf       ))
+(chemical/x-mdl-tgf (tgf        ))
+(chemical/x-mmcif (mcif        ))
+(chemical/x-mol2 (mol2        ))
+(chemical/x-molconn-Z (b        ))
+(chemical/x-mopac-graph (gpt        ))
+(chemical/x-mopac-input (mop mopcrt mpc zmt     ))
+(chemical/x-mopac-out (moo        ))
+(chemical/x-mopac-vib (mvb        ))
+(chemical/x-ncbi-asn1 (asn        ))
+(chemical/x-ncbi-asn1-ascii (prt ent       ))
+(chemical/x-ncbi-asn1-binary (val aso       ))
+(chemical/x-ncbi-asn1-spec (asn        ))
+(chemical/x-pdb (pdb ent       ))
+(chemical/x-rosdal (ros        ))
+(chemical/x-swissprot (sw        ))
+(chemical/x-vamas-iso14976 (vms        ))
+(chemical/x-vmd (vmd        ))
+(chemical/x-xtel (xtel        ))
+(chemical/x-xyz (xyz        ))
+(image/gif (gif        ))
+(image/ief (ief        ))
+(image/jpeg (jpeg jpg jpe      ))
+(image/pcx (pcx        ))
+(image/png (png        ))
+(image/svg+xml (svg svgz       ))
+(image/tiff (tiff tif       ))
+(image/vnd.djvu (djvu djv       ))
+(image/vnd.wap.wbmp (wbmp        ))
+(image/x-canon-cr2 (cr2        ))
+(image/x-canon-crw (crw        ))
+(image/x-cmu-raster (ras        ))
+(image/x-coreldraw (cdr        ))
+(image/x-coreldrawpattern (pat        ))
+(image/x-coreldrawtemplate (cdt        ))
+(image/x-corelphotopaint (cpt        ))
+(image/x-epson-erf (erf        ))
+(image/x-icon (ico        ))
+(image/x-jg (art        ))
+(image/x-jng (jng        ))
+(image/x-ms-bmp (bmp        ))
+(image/x-nikon-nef (nef        ))
+(image/x-olympus-orf (orf        ))
+(image/x-photoshop (psd        ))
+(image/x-portable-anymap (pnm        ))
+(image/x-portable-bitmap (pbm        ))
+(image/x-portable-graymap (pgm        ))
+(image/x-portable-pixmap (ppm        ))
+(image/x-rgb (rgb        ))
+(image/x-xbitmap (xbm        ))
+(image/x-xpixmap (xpm        ))
+(image/x-xwindowdump (xwd        ))
+(message/rfc822 (eml        ))
+(model/iges (igs iges       ))
+(model/mesh (msh mesh silo      ))
+(model/vrml (wrl vrml       ))
+(model/x3d+vrml (x3dv        ))
+(model/x3d+xml (x3d        ))
+(model/x3d+binary (x3db        ))
+(text/cache-manifest (manifest        ))
+(text/calendar (ics icz       ))
+(text/css (css        ))
+(text/csv (csv        ))
+(text/h323 (323        ))
+(text/html (html htm shtml      ))
+(text/iuls (uls        ))
+(text/mathml (mml        ))
+(text/plain (asc txt text pot brf    ))
+(text/richtext (rtx        ))
+(text/scriptlet (sct wsc       ))
+(text/texmacs (tm ts       ))
+(text/tab-separated-values (tsv        ))
+(text/vnd.sun.j2me.app-descriptor (jad        ))
+(text/vnd.wap.wml (wml        ))
+(text/vnd.wap.wmlscript (wmls        ))
+(text/x-bibtex (bib        ))
+(text/x-boo (boo        ))
+(text/x-c++hdr (h++ hpp hxx hh     ))
+(text/x-c++src (c++ cpp cxx cc     ))
+(text/x-chdr (h        ))
+(text/x-component (htc        ))
+(text/x-csh (csh        ))
+(text/x-csrc (c        ))
+(text/x-dsrc (d        ))
+(text/x-diff (diff patch       ))
+(text/x-haskell (hs        ))
+(text/x-java (java        ))
+(text/x-literate-haskell (lhs        ))
+(text/x-moc (moc        ))
+(text/x-pascal (p pas       ))
+(text/x-pcs-gcd (gcd        ))
+(text/x-perl (pl pm       ))
+(text/x-python (py        ))
+(text/x-scala (scala        ))
+(text/x-setext (etx        ))
+(text/x-sh (sh        ))
+(text/x-tcl (tcl tk       ))
+(text/x-tex (tex ltx sty cls     ))
+(text/x-vcalendar (vcs        ))
+(text/x-vcard (vcf        ))
+(video/3gpp (3gp        ))
+(video/annodex (axv        ))
+(video/dl (dl        ))
+(video/dv (dif dv       ))
+(video/fli (fli        ))
+(video/gl (gl        ))
+(video/mpeg (mpeg mpg mpe      ))
+(video/mp4 (mp4        ))
+(video/quicktime (qt mov       ))
+(video/ogg (ogv        ))
+(video/vnd.mpegurl (mxu        ))
+(video/x-flv (flv        ))
+(video/x-la-asf (lsf lsx       ))
+(video/x-mng (mng        ))
+(video/x-ms-asf (asf asx       ))
+(video/x-ms-wm (wm        ))
+(video/x-ms-wmv (wmv        ))
+(video/x-ms-wmx (wmx        ))
+(video/x-ms-wvx (wvx        ))
+(video/x-msvideo (avi        ))
+(video/x-sgi-movie (movie        ))
+(video/x-matroska (mpv mkv       ))
+(x-conference/x-cooltalk (ice        ))
+(x-epoc/x-sisx-app (sisx        ))
+(x-world/x-vrml (vrm vrml wrl      ))
+
+;; ragnarok mime extension
+(application/x-guile-tpl (gl scm))))
+
+(define-method (initialize (self <mime>) args)
+  (next-method)
+  (let ((mime-types-table (mime:mime-types-table self)))
+    ;; init mime type table
+    (for-each (lambda (x)
+		(let* ((mtype (car x)) (mimes (cadr x)))
+		  (for-each (lambda (m)
+			      (hash-set! mime-types-table
+					 m
+					 mtype))
+			    mimes)))
+	      *mime-type-list*)))
+
+
+
+
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH] add web/mime support
  2012-02-23 14:53 [PATCH] add web/mime support Nala Ginrut
@ 2012-02-23 15:03 ` Catonano
  2012-02-23 15:39   ` Nala Ginrut
  2013-01-16 10:46 ` Andy Wingo
  1 sibling, 1 reply; 14+ messages in thread
From: Catonano @ 2012-02-23 15:03 UTC (permalink / raw)
  To: Nala Ginrut; +Cc: guile-devel

[-- Attachment #1: Type: text/plain, Size: 835 bytes --]

Il giorno 23 febbraio 2012 15:53, Nala Ginrut <nalaginrut@gmail.com> ha
scritto:

> There's no mime support in Guile module, so I modified the mime code of my
> project Ragnarok and format a patch.
> It's easy to use:
> (use-modules (web mime))
> (define mime (make <mime>))
> (mime:guess mime 'pdf)
> ==> application/pdf
> (mime:guess mime 'php)
> ==> application/x-httpd-php
>
> Maybe useful for some guys~
> Any comments?
>

just recently I happened to download something and the mimetype was not
textual even though the content was textual indeed (it was a .ram link hat
is a url starting with rtsp://...)

So what I got back was a bytevector and I had to decode it in my code; a
ugly hack

Personally I'd be interested in see how your stuff could be used together
with http-get to download something with a weird mimetype

Thanks

[-- Attachment #2: Type: text/html, Size: 1218 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] add web/mime support
  2012-02-23 15:03 ` Catonano
@ 2012-02-23 15:39   ` Nala Ginrut
  2012-02-23 15:58     ` Catonano
  0 siblings, 1 reply; 14+ messages in thread
From: Nala Ginrut @ 2012-02-23 15:39 UTC (permalink / raw)
  To: Catonano; +Cc: guile-devel

[-- Attachment #1: Type: text/plain, Size: 1705 bytes --]

Well, I'm not sure what you did.
And this MIME support is mainly used for a server rather than a client. So
your client must know how to deal with the given MIME. I think your client
is not going to use my mime.scm, unless you're writing a web browser.  If
you do, you must have many handlers  for these mime types and decide which
to go with the information "mime.scm" gives you. But in general, you don't
have to use mime.scm in your client/browser, the server will return mime
type to you.
And I think "http-get" could get whatever data from remote, so if you're
not writing a web browser, you just store the data to a file or redirect to
player something. In this case, you don't have to detect mime type
automatically.
Anyway, thanks for reply. ;-)

On Thu, Feb 23, 2012 at 11:03 PM, Catonano <catonano@gmail.com> wrote:

>
>
> Il giorno 23 febbraio 2012 15:53, Nala Ginrut <nalaginrut@gmail.com> ha
> scritto:
>
> There's no mime support in Guile module, so I modified the mime code of my
>> project Ragnarok and format a patch.
>> It's easy to use:
>> (use-modules (web mime))
>> (define mime (make <mime>))
>> (mime:guess mime 'pdf)
>> ==> application/pdf
>> (mime:guess mime 'php)
>> ==> application/x-httpd-php
>>
>> Maybe useful for some guys~
>> Any comments?
>>
>
> just recently I happened to download something and the mimetype was not
> textual even though the content was textual indeed (it was a .ram link hat
> is a url starting with rtsp://...)
>
> So what I got back was a bytevector and I had to decode it in my code; a
> ugly hack
>
> Personally I'd be interested in see how your stuff could be used together
> with http-get to download something with a weird mimetype
>
> Thanks
>

[-- Attachment #2: Type: text/html, Size: 2411 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] add web/mime support
  2012-02-23 15:39   ` Nala Ginrut
@ 2012-02-23 15:58     ` Catonano
  0 siblings, 0 replies; 14+ messages in thread
From: Catonano @ 2012-02-23 15:58 UTC (permalink / raw)
  To: Nala Ginrut; +Cc: guile-devel

[-- Attachment #1: Type: text/plain, Size: 520 bytes --]

Il giorno 23 febbraio 2012 16:39, Nala Ginrut <nalaginrut@gmail.com> ha
scritto:

>
> And I think "http-get" could get whatever data from remote, so if you're
> not writing a web browser, you just store the data to a file or redirect to
> player something. In this case, you don't have to detect mime type
> automatically.
>

I thought that handling the decoding in my code was ugly. Now I read your
argument as "that's not that ugly". Ok, I can go along with that


> Anyway, thanks for reply. ;-)
>

Tankhs to you ;-)

[-- Attachment #2: Type: text/html, Size: 965 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] add web/mime support
  2012-02-23 14:53 [PATCH] add web/mime support Nala Ginrut
  2012-02-23 15:03 ` Catonano
@ 2013-01-16 10:46 ` Andy Wingo
  2013-01-16 11:06   ` Nala Ginrut
  2013-01-17  8:17   ` Nala Ginrut
  1 sibling, 2 replies; 14+ messages in thread
From: Andy Wingo @ 2013-01-16 10:46 UTC (permalink / raw)
  To: Nala Ginrut; +Cc: guile-devel

Hi,

On Thu 23 Feb 2012 15:53, Nala Ginrut <nalaginrut@gmail.com> writes:

> There's no mime support in Guile module, so I modified the mime code of
> my project Ragnarok and format a patch.
>
> It's easy to use:
> (use-modules (web mime))
> (define mime (make <mime>))
> (mime:guess mime 'pdf)
> ==> application/pdf
> (mime:guess mime 'php)
> ==> application/x-httpd-php

Just a note to say that I liked this module, and that it would be a
great thing to have in the guildhall.

It would be nice to use
http://freedesktop.org/wiki/Specifications/shared-mime-info-spec on free
software systems.

Cheers,

Andy
-- 
http://wingolog.org/



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] add web/mime support
  2013-01-16 10:46 ` Andy Wingo
@ 2013-01-16 11:06   ` Nala Ginrut
  2013-01-17  8:17   ` Nala Ginrut
  1 sibling, 0 replies; 14+ messages in thread
From: Nala Ginrut @ 2013-01-16 11:06 UTC (permalink / raw)
  To: Andy Wingo; +Cc: guile-devel

On Wed, 2013-01-16 at 11:46 +0100, Andy Wingo wrote:
> Hi,
> 
> On Thu 23 Feb 2012 15:53, Nala Ginrut <nalaginrut@gmail.com> writes:
> 
> > There's no mime support in Guile module, so I modified the mime code of
> > my project Ragnarok and format a patch.
> >
> > It's easy to use:
> > (use-modules (web mime))
> > (define mime (make <mime>))
> > (mime:guess mime 'pdf)
> > ==> application/pdf
> > (mime:guess mime 'php)
> > ==> application/x-httpd-php
> 
> Just a note to say that I liked this module, and that it would be a
> great thing to have in the guildhall.
> 

Ah~nice, and useful for inner server.

> It would be nice to use
> http://freedesktop.org/wiki/Specifications/shared-mime-info-spec on free
> software systems.
> 

OK, I'll add them. ;-D

> Cheers,
> 
> Andy





^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] add web/mime support
  2013-01-16 10:46 ` Andy Wingo
  2013-01-16 11:06   ` Nala Ginrut
@ 2013-01-17  8:17   ` Nala Ginrut
  2013-01-17 10:06     ` Andy Wingo
  1 sibling, 1 reply; 14+ messages in thread
From: Nala Ginrut @ 2013-01-17  8:17 UTC (permalink / raw)
  To: Andy Wingo; +Cc: guile-devel

On Wed, 2013-01-16 at 11:46 +0100, Andy Wingo wrote:
> Hi,
> 
> On Thu 23 Feb 2012 15:53, Nala Ginrut <nalaginrut@gmail.com> writes:
> 
> > There's no mime support in Guile module, so I modified the mime code of
> > my project Ragnarok and format a patch.
> >
> > It's easy to use:
> > (use-modules (web mime))
> > (define mime (make <mime>))
> > (mime:guess mime 'pdf)
> > ==> application/pdf
> > (mime:guess mime 'php)
> > ==> application/x-httpd-php
> 
> Just a note to say that I liked this module, and that it would be a
> great thing to have in the guildhall.
> 
> It would be nice to use
> http://freedesktop.org/wiki/Specifications/shared-mime-info-spec on free
> software systems.
> 

Are you suggesting use mime-info of freedesktop? I think we can write a
parser for that XML files, but it makes Guile depends on desktop.
Did I miss something?

> Cheers,
> 
> Andy





^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] add web/mime support
  2013-01-17  8:17   ` Nala Ginrut
@ 2013-01-17 10:06     ` Andy Wingo
  2013-01-17 10:37       ` Nala Ginrut
  0 siblings, 1 reply; 14+ messages in thread
From: Andy Wingo @ 2013-01-17 10:06 UTC (permalink / raw)
  To: Nala Ginrut; +Cc: guile-devel

On Thu 17 Jan 2013 09:17, Nala Ginrut <nalaginrut@gmail.com> writes:

> On Wed, 2013-01-16 at 11:46 +0100, Andy Wingo wrote:
>> It would be nice to use
>> http://freedesktop.org/wiki/Specifications/shared-mime-info-spec on free
>> software systems.
>
> Are you suggesting use mime-info of freedesktop? I think we can write a
> parser for that XML files, but it makes Guile depends on desktop.
> Did I miss something?

That is a specification of where files live on disk and what meaning
they have.  So the thing that your module would have to do would be to
parse those files, and fall back on some other mechanism if those files
are unavailable.

Cheers,

Andy
-- 
http://wingolog.org/



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] add web/mime support
  2013-01-17 10:06     ` Andy Wingo
@ 2013-01-17 10:37       ` Nala Ginrut
  2013-01-17 14:48         ` Andy Wingo
  0 siblings, 1 reply; 14+ messages in thread
From: Nala Ginrut @ 2013-01-17 10:37 UTC (permalink / raw)
  To: Andy Wingo; +Cc: guile-devel

On Thu, 2013-01-17 at 11:06 +0100, Andy Wingo wrote:
> On Thu 17 Jan 2013 09:17, Nala Ginrut <nalaginrut@gmail.com> writes:
> 
> > On Wed, 2013-01-16 at 11:46 +0100, Andy Wingo wrote:
> >> It would be nice to use
> >> http://freedesktop.org/wiki/Specifications/shared-mime-info-spec on free
> >> software systems.
> >
> > Are you suggesting use mime-info of freedesktop? I think we can write a
> > parser for that XML files, but it makes Guile depends on desktop.
> > Did I miss something?
> 
> That is a specification of where files live on disk and what meaning
> they have.  So the thing that your module would have to do would be to
> parse those files, and fall back on some other mechanism if those files
> are unavailable.
> 

I see, it's easy to do that with parsing 'mime/glob', and more generic.
To avoid parse this file each time, it's necessary to write a cache
mechanism.
Besides, I think a filename parser to checkout its mime could also be
added.

PS: Do you think it's proper to use the same implementation in my server
project? I'm not sure whether this mime thing would exist in any GNU
system for a server purpose rather than a desktop one.

> Cheers,
> 
> Andy





^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] add web/mime support
  2013-01-17 10:37       ` Nala Ginrut
@ 2013-01-17 14:48         ` Andy Wingo
  2013-02-06 13:13           ` Nala Ginrut
  0 siblings, 1 reply; 14+ messages in thread
From: Andy Wingo @ 2013-01-17 14:48 UTC (permalink / raw)
  To: Nala Ginrut; +Cc: guile-devel

On Thu 17 Jan 2013 11:37, Nala Ginrut <nalaginrut@gmail.com> writes:

> PS: Do you think it's proper to use the same implementation in my server
> project? I'm not sure whether this mime thing would exist in any GNU
> system for a server purpose rather than a desktop one.

Why would it not exist on a server?  My server has a full
/usr/share/mime directory, and I know I haven't installed anything
desktop-related.

In any case you could fall back on /etc/mime.types, I guess.

Andy
-- 
http://wingolog.org/



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] add web/mime support
  2013-01-17 14:48         ` Andy Wingo
@ 2013-02-06 13:13           ` Nala Ginrut
  2013-02-10  1:41             ` Daniel Hartwig
  0 siblings, 1 reply; 14+ messages in thread
From: Nala Ginrut @ 2013-02-06 13:13 UTC (permalink / raw)
  To: Andy Wingo; +Cc: guile-devel

On Thu, 2013-01-17 at 15:48 +0100, Andy Wingo wrote:
> On Thu 17 Jan 2013 11:37, Nala Ginrut <nalaginrut@gmail.com> writes:
> 
> > PS: Do you think it's proper to use the same implementation in my server
> > project? I'm not sure whether this mime thing would exist in any GNU
> > system for a server purpose rather than a desktop one.
> 
> Why would it not exist on a server?  My server has a full
> /usr/share/mime directory, and I know I haven't installed anything
> desktop-related.
> 

/usr/share/mime is contained in 'shared-mime-info' package, at least for
openSUSE. The suggestion you gave means Guile will depend on this
package. Personally, I don't think that's what you want. ;-P

> In any case you could fall back on /etc/mime.types, I guess.
> 
> Andy





^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] add web/mime support
  2013-02-06 13:13           ` Nala Ginrut
@ 2013-02-10  1:41             ` Daniel Hartwig
  2013-02-11  9:38               ` Nala Ginrut
  0 siblings, 1 reply; 14+ messages in thread
From: Daniel Hartwig @ 2013-02-10  1:41 UTC (permalink / raw)
  To: guile-devel

On 6 February 2013 21:13, Nala Ginrut <nalaginrut@gmail.com> wrote:
> /usr/share/mime is contained in 'shared-mime-info' package, at least for
> openSUSE. The suggestion you gave means Guile will depend on this
> package. Personally, I don't think that's what you want. ;-P

Hi

The suggestion was to support reading the mime type data from that
path /if it exists/, and use an appropriate fallback mechanism
otherwise.  This introduces no dependency.

Also, please distribute as an external module rather than a patch against Guile.

Regards



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] add web/mime support
  2013-02-10  1:41             ` Daniel Hartwig
@ 2013-02-11  9:38               ` Nala Ginrut
  2013-02-11 12:33                 ` Daniel Hartwig
  0 siblings, 1 reply; 14+ messages in thread
From: Nala Ginrut @ 2013-02-11  9:38 UTC (permalink / raw)
  To: Daniel Hartwig; +Cc: guile-devel

On Sun, 2013-02-10 at 09:41 +0800, Daniel Hartwig wrote:
> On 6 February 2013 21:13, Nala Ginrut <nalaginrut@gmail.com> wrote:
> > /usr/share/mime is contained in 'shared-mime-info' package, at least for
> > openSUSE. The suggestion you gave means Guile will depend on this
> > package. Personally, I don't think that's what you want. ;-P
> 
> Hi
> 
> The suggestion was to support reading the mime type data from that
> path /if it exists/, and use an appropriate fallback mechanism
> otherwise.  This introduces no dependency.
> 
> Also, please distribute as an external module rather than a patch against Guile.
> 

I'm playing guildhall these days, and it's very convenient for using now
(though some bugs/requests there). I do believe an external module is a
nice choice too. 
But there's a different for MIME, since it should be a part of web
module IMO (or not?). So I'm hesitated again.

I think there should be an unanimous idea before I wrote the patch, or
it's non-sense to us. ;-)
  

> Regards
> 





^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH] add web/mime support
  2013-02-11  9:38               ` Nala Ginrut
@ 2013-02-11 12:33                 ` Daniel Hartwig
  0 siblings, 0 replies; 14+ messages in thread
From: Daniel Hartwig @ 2013-02-11 12:33 UTC (permalink / raw)
  To: guile-devel

On 11 February 2013 17:38, Nala Ginrut <nalaginrut@gmail.com> wrote:
> But there's a different for MIME, since it should be a part of web
> module IMO (or not?). So I'm hesitated again.

There is no pressing need to include or not.  While it is a work in
progress it is easier to distribute and inspect if it is an external
package.  As it accumulates users and matures more, then it can be
considered for inclusion in the core.

Incorporating external packages in to the core is very easy.

Anyways.  Get a useful package is more important than
include-everything-in-core.



^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2013-02-11 12:33 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-23 14:53 [PATCH] add web/mime support Nala Ginrut
2012-02-23 15:03 ` Catonano
2012-02-23 15:39   ` Nala Ginrut
2012-02-23 15:58     ` Catonano
2013-01-16 10:46 ` Andy Wingo
2013-01-16 11:06   ` Nala Ginrut
2013-01-17  8:17   ` Nala Ginrut
2013-01-17 10:06     ` Andy Wingo
2013-01-17 10:37       ` Nala Ginrut
2013-01-17 14:48         ` Andy Wingo
2013-02-06 13:13           ` Nala Ginrut
2013-02-10  1:41             ` Daniel Hartwig
2013-02-11  9:38               ` Nala Ginrut
2013-02-11 12:33                 ` Daniel Hartwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).