Static files in other places than /static/* without modifying WEB-INF/web.xml ?
Thursday, 19 February 2015 · 5 messages
MI
Maud Ingarao19 Feb 2015 10:14 #
Hi everybody
Thanks a lot for this wonderful BaseX 8 release and for distributing the dba module : Not only is it very practical, but it is also very inspiring to look carefully at how you guys wrote it and it gives us thousands of ideas to complete our own SynopsX module :)
But it doesn't mean we always manage to imitate you...
For example, exactly as you do, we want to distribute our static files inside our module, in a synopsx/files/ directory, and of course we don't want to ask people to modify the static path declaration in their WEB-INF/web.xml file to use our module.
It works perfectly in your dba module : for exemple in
dba/modules/tmpl.xqm, the created html element calls files/js.js or files/style.css and it simply works... But not in ours : we get this "No function matches the request" error because these files pathes are interpreted as restxq pathes (which sounds reasonable, but why not in yours ?)
We are know trying more and more complicated things that don't work neither, like in
https://github.com/mingarao/synopsx/blob/dev/webapp/synopsx/_restxq/files.xqm line 37...
So I think we should better stop there and ask you : what's the trick in dba ?
All the best !
Maud and the AHN/SynopsX people
--
/« Ne travaillez jamais »/
*Maud Ingarao*
IHPC (UMR 5037)
Institut d’histoire de la pensée classique, de l’Humanisme aux Lumières Ecole Normale Supérieure de Lyon - Site Descartes - Bureau R322 15 Parvis René Descartes - BP7000 - 69342 Lyon CEDEX 07
+33 4 37 37 65 79 - maud.ingarao at ens-lyon.fr
/Je suis absente le jeudi | Out of office on Thursdays/
http://pensee-classique.ens-lyon.fr
http://institutdesanti.ens-lyon.fr
http://ahn.ens-lyon.fr
http://www.mutec-shs.fr
http://cahier.hypotheses.org
CG
Christian Grün19 Feb 2015 11:08 #
Hi Maud,
We are glad to hear that the DBA code serves as a good inspiration! After all, I think this should be its primary purpose. The way how we integrate user components like buttons or tables is a bit unorthodox; this may be simplified in a future version.
Quoted text · Maud Ingarao · 2 lines
> we want to distribute our static files > inside our module, in a synopsx/files/ directory, [...]
In the DBA code, we solved this by creating a custom <rest:response> element for all files starting with the path "dba/files". I have slightly simplified the current code; please see here [1] how it's done! The web:mime-type($path) function calls an internal BaseX function to retrieve the content type of the response [2]; there may be a new XQuery function for that in future as well. We could even think about providing an XQuery function for everything that's happening in [1].
More feedback is welcome,
Christian
[1] https://github.com/BaseXdb/basex/blob/master/basex-api/src/main/webapp/dba/util.xqm#L23-L46 [2] https://github.com/BaseXdb/basex/blob/master/basex-api/src/main/webapp/dba/modules/web.xqm#L38-L47
Quoted text · Maud Ingarao · 35 lines
and of course we don't > want to ask people to modify the static path declaration in their > WEB-INF/web.xml file to use our module. > It works perfectly in your dba module : for exemple in dba/modules/tmpl.xqm, > the created html element calls files/js.js or files/style.css and it simply > works... But not in ours : we get this "No function matches the request" > error because these files pathes are interpreted as restxq pathes (which > sounds reasonable, but why not in yours ?) > We are know trying more and more complicated things that don't work neither, > like in > https://github.com/mingarao/synopsx/blob/dev/webapp/synopsx/_restxq/files.xqm > line 37... > So I think we should better stop there and ask you : what's the trick in dba > ? > All the best ! > Maud and the AHN/SynopsX people > > -- > > « Ne travaillez jamais » > > Maud Ingarao > IHPC (UMR 5037) > Institut d’histoire de la pensée classique, de l’Humanisme aux Lumières > Ecole Normale Supérieure de Lyon - Site Descartes - Bureau R322 > 15 Parvis René Descartes - BP7000 - 69342 Lyon CEDEX 07 > +33 4 37 37 65 79 - maud.ingarao at ens-lyon.fr > > Je suis absente le jeudi | Out of office on Thursdays > > http://pensee-classique.ens-lyon.fr > http://institutdesanti.ens-lyon.fr > http://ahn.ens-lyon.fr > http://www.mutec-shs.fr > http://cahier.hypotheses.org
MI
Maud Ingarao19 Feb 2015 11:24 #
And it works :))))
Thanks a lot for the trick and the instant answer !
Now we will be able to distribute SynopsX as an autonom module :)
/« Ne travaillez jamais »/
*Maud Ingarao*
IHPC (UMR 5037)
Institut d’histoire de la pensée classique, de l’Humanisme aux Lumières Ecole Normale Supérieure de Lyon - Site Descartes - Bureau R322 15 Parvis René Descartes - BP7000 - 69342 Lyon CEDEX 07
+33 4 37 37 65 79 - maud.ingarao at ens-lyon.fr
/Je suis absente le jeudi | Out of office on Thursdays/
http://pensee-classique.ens-lyon.fr
http://institutdesanti.ens-lyon.fr
http://ahn.ens-lyon.fr
http://www.mutec-shs.fr
http://cahier.hypotheses.org
Quoted text · Christian Grün · 62 lines
On 19/02/2015 11:08, Christian Grün wrote: > Hi Maud, > > We are glad to hear that the DBA code serves as a good inspiration! > After all, I think this should be its primary purpose. The way how we > integrate user components like buttons or tables is a bit unorthodox; > this may be simplified in a future version. > >> we want to distribute our static files >> inside our module, in a synopsx/files/ directory, [...] > In the DBA code, we solved this by creating a custom <rest:response> > element for all files starting with the path "dba/files". I have > slightly simplified the current code; please see here [1] how it's > done! The web:mime-type($path) function calls an internal BaseX > function to retrieve the content type of the response [2]; there may > be a new XQuery function for that in future as well. We could even > think about providing an XQuery function for everything that's > happening in [1]. > > More feedback is welcome, > Christian > > [1] https://github.com/BaseXdb/basex/blob/master/basex-api/src/main/webapp/dba/util.xqm#L23-L46 > [2] https://github.com/BaseXdb/basex/blob/master/basex-api/src/main/webapp/dba/modules/web.xqm#L38-L47 > > > > and of course we don't >> want to ask people to modify the static path declaration in their >> WEB-INF/web.xml file to use our module. >> It works perfectly in your dba module : for exemple in dba/modules/tmpl.xqm, >> the created html element calls files/js.js or files/style.css and it simply >> works... But not in ours : we get this "No function matches the request" >> error because these files pathes are interpreted as restxq pathes (which >> sounds reasonable, but why not in yours ?) >> We are know trying more and more complicated things that don't work neither, >> like in >> https://github.com/mingarao/synopsx/blob/dev/webapp/synopsx/_restxq/files.xqm >> line 37... >> So I think we should better stop there and ask you : what's the trick in dba >> ? >> All the best ! >> Maud and the AHN/SynopsX people >> >> -- >> >> « Ne travaillez jamais » >> >> Maud Ingarao >> IHPC (UMR 5037) >> Institut d’histoire de la pensée classique, de l’Humanisme aux Lumières >> Ecole Normale Supérieure de Lyon - Site Descartes - Bureau R322 >> 15 Parvis René Descartes - BP7000 - 69342 Lyon CEDEX 07 >> +33 4 37 37 65 79 - maud.ingarao at ens-lyon.fr >> >> Je suis absente le jeudi | Out of office on Thursdays >> >> http://pensee-classique.ens-lyon.fr >> http://institutdesanti.ens-lyon.fr >> http://ahn.ens-lyon.fr >> http://www.mutec-shs.fr >> http://cahier.hypotheses.org
MG
Hi,
Is there anything that can be said about the performance of handling static file serving via XQuery versus letting Jetty deal with it? I have toyed with this idea as well but in the back of my head it says that it's slow compared to Jetty static file serving. Haven't done any perf. testing though.
I also would like to see a way of doing efficient static file serving from within a module but then there should be a way of excluding this static file directory from the search for RESTXQ and other XQuery code because one could then just put a nasty XQuery file in such a static directory and affect server performance or even do nasty things.
--Marc
Quoted text · Christian Grün · 64 lines
On Thu, Feb 19, 2015 at 11:08 AM, Christian Grün <christian.gruen at gmail.com> wrote: > Hi Maud, > > We are glad to hear that the DBA code serves as a good inspiration! > After all, I think this should be its primary purpose. The way how we > integrate user components like buttons or tables is a bit unorthodox; > this may be simplified in a future version. > >> we want to distribute our static files >> inside our module, in a synopsx/files/ directory, [...] > > In the DBA code, we solved this by creating a custom <rest:response> > element for all files starting with the path "dba/files". I have > slightly simplified the current code; please see here [1] how it's > done! The web:mime-type($path) function calls an internal BaseX > function to retrieve the content type of the response [2]; there may > be a new XQuery function for that in future as well. We could even > think about providing an XQuery function for everything that's > happening in [1]. > > More feedback is welcome, > Christian > > [1] https://github.com/BaseXdb/basex/blob/master/basex-api/src/main/webapp/dba/util.xqm#L23-L46 > [2] https://github.com/BaseXdb/basex/blob/master/basex-api/src/main/webapp/dba/modules/web.xqm#L38-L47 > > > > and of course we don't >> want to ask people to modify the static path declaration in their >> WEB-INF/web.xml file to use our module. >> It works perfectly in your dba module : for exemple in dba/modules/tmpl.xqm, >> the created html element calls files/js.js or files/style.css and it simply >> works... But not in ours : we get this "No function matches the request" >> error because these files pathes are interpreted as restxq pathes (which >> sounds reasonable, but why not in yours ?) >> We are know trying more and more complicated things that don't work neither, >> like in >> https://github.com/mingarao/synopsx/blob/dev/webapp/synopsx/_restxq/files.xqm >> line 37... >> So I think we should better stop there and ask you : what's the trick in dba >> ? >> All the best ! >> Maud and the AHN/SynopsX people >> >> -- >> >> « Ne travaillez jamais » >> >> Maud Ingarao >> IHPC (UMR 5037) >> Institut d’histoire de la pensée classique, de l’Humanisme aux Lumières >> Ecole Normale Supérieure de Lyon - Site Descartes - Bureau R322 >> 15 Parvis René Descartes - BP7000 - 69342 Lyon CEDEX 07 >> +33 4 37 37 65 79 - maud.ingarao at ens-lyon.fr >> >> Je suis absente le jeudi | Out of office on Thursdays >> >> http://pensee-classique.ens-lyon.fr >> http://institutdesanti.ens-lyon.fr >> http://ahn.ens-lyon.fr >> http://www.mutec-shs.fr >> http://cahier.hypotheses.org
--
--Marc
CG
Christian Grün19 Feb 2015 11:41 #
Hi Marc,
Most time is usually spent for parsing all the RESTXQ files, or running queries on large databases. The discussed function for serving static files shouldn't represent a serious bottleneck I believe, even if big media files are sent out (at least it hasn't been so far in our own applications).
Quoted text · Marc van Grootel · 5 lines
> I also would like to see a way of doing efficient static file serving > from within a module but then there should be a way of excluding this > static file directory from the search for RESTXQ and other XQuery code > because one could then just put a nasty XQuery file in such a static > directory and affect server performance or even do nasty things.
The conventional way to do this is to configure such paths in the web.xml file. Other ideas for more fine-grained solutions are welcome.
Christian
Quoted text · Marc van Grootel · 73 lines
> > --Marc > > > On Thu, Feb 19, 2015 at 11:08 AM, Christian Grün > <christian.gruen at gmail.com> wrote: >> Hi Maud, >> >> We are glad to hear that the DBA code serves as a good inspiration! >> After all, I think this should be its primary purpose. The way how we >> integrate user components like buttons or tables is a bit unorthodox; >> this may be simplified in a future version. >> >>> we want to distribute our static files >>> inside our module, in a synopsx/files/ directory, [...] >> >> In the DBA code, we solved this by creating a custom <rest:response> >> element for all files starting with the path "dba/files". I have >> slightly simplified the current code; please see here [1] how it's >> done! The web:mime-type($path) function calls an internal BaseX >> function to retrieve the content type of the response [2]; there may >> be a new XQuery function for that in future as well. We could even >> think about providing an XQuery function for everything that's >> happening in [1]. >> >> More feedback is welcome, >> Christian >> >> [1] https://github.com/BaseXdb/basex/blob/master/basex-api/src/main/webapp/dba/util.xqm#L23-L46 >> [2] https://github.com/BaseXdb/basex/blob/master/basex-api/src/main/webapp/dba/modules/web.xqm#L38-L47 >> >> >> >> and of course we don't >>> want to ask people to modify the static path declaration in their >>> WEB-INF/web.xml file to use our module. >>> It works perfectly in your dba module : for exemple in dba/modules/tmpl.xqm, >>> the created html element calls files/js.js or files/style.css and it simply >>> works... But not in ours : we get this "No function matches the request" >>> error because these files pathes are interpreted as restxq pathes (which >>> sounds reasonable, but why not in yours ?) >>> We are know trying more and more complicated things that don't work neither, >>> like in >>> https://github.com/mingarao/synopsx/blob/dev/webapp/synopsx/_restxq/files.xqm >>> line 37... >>> So I think we should better stop there and ask you : what's the trick in dba >>> ? >>> All the best ! >>> Maud and the AHN/SynopsX people >>> >>> -- >>> >>> « Ne travaillez jamais » >>> >>> Maud Ingarao >>> IHPC (UMR 5037) >>> Institut d’histoire de la pensée classique, de l’Humanisme aux Lumières >>> Ecole Normale Supérieure de Lyon - Site Descartes - Bureau R322 >>> 15 Parvis René Descartes - BP7000 - 69342 Lyon CEDEX 07 >>> +33 4 37 37 65 79 - maud.ingarao at ens-lyon.fr >>> >>> Je suis absente le jeudi | Out of office on Thursdays >>> >>> http://pensee-classique.ens-lyon.fr >>> http://institutdesanti.ens-lyon.fr >>> http://ahn.ens-lyon.fr >>> http://www.mutec-shs.fr >>> http://cahier.hypotheses.org > > > > -- > --Marc
Written for BaseX 8.0. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery