Lewis Denizen wrote:
> Hi xwiki-users,
>
> I'm trying to create a plugin to dynamically create a download link
> for a SH or BAT file, and am wondering if I could get some ideas from
> people on the list. What I'm trying to do is the following:
>
> {{shell-script name="fixed_income.sh" display="true" type="sh"}}
> #!/bin/sh # Startup the bond server ${APP_DIR}/fi/ust/bond_server
> -conf=fi_ust_prod.xml&
>
> # Startup the pricing server ${APP_DIR}/fi/ust/pricing_server
> -conf=fi_ust_prod.xml -region=ny&
>
> # Startup the risk analysis tool ${APP_DIR}/fi/ust/risk_analysis
> -days=365& {{/shell-script}}
>
> I don't want the server to actually "execute" this (that's easy to
> do), but rather to dynamically create an output stream and pipe it to
> the user's browser. The user will then be able to save the
> fixed_income.sh file in his/her own local directory to execute it.
>
> I know this can be easily done with attachments, but I want to be
> able to display the contents of this file on the wiki (possibly in a
> <div> that's initially hidden), and also be able to edit this file
> "on the fly" without having to create locally/save locally/upload
> every time (kind of like a temporary attachment which disappears
> together with the {{shell-script /}} tag). I could also just create
> another servlet that takes in a single base64 encoded parameter to
> reconstruct the shell script, but that's not a clean solution imho.
> Any other way (perhaps via Javascript) of doing this cleanly within
> Xwiki space? Thanks in advance (and also for another successful
> release :-D)!
Quick plan:
1. Create a vm file (for example shbat.vm) in your <xwiki directory>/templates/
folder, which contains this:
$response.setContentType('text/plain')
#set($filename = "${doc.name}.sh") ## or some other way of retrieving the
target filename, like $doc.display('scriptTitle') if it is in an object.
$response.setHeader('Content-Disposition', attachment; filename=$filename")
$doc.getRenderedContent ## if you have the script content in a wiki document, or
$doc.use('XWiki.YourScriptClassname')
$doc.display('scriptContentProperty')
## if the content is placed in an object of the XWiki.YourScriptClassname type
attached to your document, and the script content is placed in a TextArea
property named scriptContentProperty.
2. Create links to your document like:
[Download this script>${doc.fullName}?xpage=shbat]
--
Sergiu Dumitriu
http://purl.org/net/sergiu/
_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users