[daisy] Automatic HTMLHelp Publishing
Bruno Dumon
bruno at outerthought.org
Mon Apr 16 13:25:12 CDT 2007
On Mon, 2007-04-16 at 19:18 +0200, Robert Kindl wrote:
> > > Thanks - these classes was very helpfull.
> > > I made some customizations to them (
> > >
> > > Now I have problem with download of generated HTMLHelp .chm file
> > >
> > > When I click on following URL i will get content of this binary file as
> text
> > > which is obviosly nonsense.
> > >
> http://server:8888/books/sandbox_book--20070415-233831/publications/htmlhelp/output/book.chm
> > >
> > > I have no idea how to make "cocoon" to serve this file as mime type
> > > application/mshelp (or something else appropriate).
> >
> > So what mime type is used now? For non-known file extensions I think
> > application/octet-stream is used.
>
> This is response from Daisy - it doesn't contain Content-Type at all:
> HTTP/1.1 200 OK
> Date: Mon, 16 Apr 2007 17:09:53 GMT
> Server: Jetty/5.1.10 (Windows 2003/5.2 x86 java/1.5.0_11
> X-Cocoon-Version: 2.1.11-dev
> X-Daisy-Version: 2.0 (build: outertho-040c9b/20070403 15:19:17+0200; run:
> Windows 2003/x86/5.2 java/1.5.0_11-b03)
> Accept-Ranges: none
> Last-Modified: Sun, 15 Apr 2007 21:38:37 GMT
> Content-Length: 285900
>
> This is response from some "IIS" server (simple download of .chm file) - it
> sets Content-Type to application/octet-stream:
> HTTP/1.1 200 OK
> Content-Length: 63264
> Content-Type: application/octet-stream
> Last-Modified: Sat, 14 Apr 2007 22:20:11 GMT
> Accept-Ranges: bytes
> ETag: "42bf910e37ec71:589f"
> Server: Microsoft-IIS/6.0
> X-Powered-By: ASP.NET
> Date: Mon, 16 Apr 2007 17:11:11 GMT
>
> So my questions is how to make "cocoon" to serve this file as mime type
> application/octet-stream?
>
Cocoon takes the mime-type from the "source", this is the component
handling a certain URL schema (like 'file:' or 'http:').
In case of the books we have a custom 'bookstore' source, which
determines the source as follows:
(1) get it from the .meta.xml file in the bookstore
(2) if (1) is not defined, ask Java for the mimetype (the JVM has a
list of common mimetypes build-in)
So the solution is to have such '.meta.xml' file along with your file
(the .chm one) in the bookstore. This file should have the same name as
the original one but with .meta.xml appended, so the full name will e.g.
be test.chm.meta.xml.
Just for trying out, you can test this by adding such a file manually.
If you look in your bookstore, you should find existing *.meta.xml files
there in which you'll find the correct XML syntax.
And then to make this happen automatically you should have a publication
task to create this meta.xml file. This is very simpel to create, with
some code like this:
ResourcePropertiesDocument propertiesDocument = ResourcePropertiesDocument.Factory.newInstance();
propertiesDocument.addNewResourceProperties().setMimeType("application/octet-stream");
context.getBookInstance().storeResourceProperties("path/to/thefile", propertiesDocument);
(again something that seems useful to have included as a default task,
contributions welcome).
--
Bruno Dumon http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno at outerthought.org bruno at apache.org
More information about the daisy
mailing list