Wiki source code of Filter streams
Last modified by TerraIndex TerraIndex on 2021/05/06 10:15
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | {{warning}}Filter module is still young and experimental and while exporting should be safe enough, importing can be more risky for the current instance.{{/warning}} | ||
| 2 | |||
| 3 | {{include reference="FilterStreamDescriptorForm"/}} | ||
| 4 | |||
| 5 | {{velocity output="true"}} | ||
| 6 | #set($input = $request.input) | ||
| 7 | #set($output = $request.output) | ||
| 8 | |||
| 9 | #set($inputProperties = {}) | ||
| 10 | #foreach($parameterName in $request.parameterNames) | ||
| 11 | #if ($parameterName.startsWith('filter_input_properties_descriptor_')) | ||
| 12 | #set($propertyName = $parameterName.substring(35)) | ||
| 13 | #if ($request.getParameter($parameterName) && $request.getParameter($parameterName) != '') | ||
| 14 | #set($void = $inputProperties.put($propertyName, $request.getParameter($parameterName))) | ||
| 15 | #end | ||
| 16 | #end | ||
| 17 | #end | ||
| 18 | ## Set request input by default | ||
| 19 | #if (!$inputProperties.source && $services.filter.getInputFilterStreamDescriptor($request.input).getPropertyDescriptor('source')) | ||
| 20 | #set($sourceStandardInput = true) | ||
| 21 | #set($void = $inputProperties.put('source', $request.inputStream)) | ||
| 22 | #end | ||
| 23 | |||
| 24 | #set($outputProperties = {}) | ||
| 25 | #foreach($parameterName in $request.parameterNames) | ||
| 26 | #if ($parameterName.startsWith('filter_output_properties_descriptor_')) | ||
| 27 | #set($propertyName = $parameterName.substring(36)) | ||
| 28 | #if ($request.getParameter($parameterName) && $request.getParameter($parameterName) != '') | ||
| 29 | #set($void = $outputProperties.put($propertyName, $request.getParameter($parameterName))) | ||
| 30 | #end | ||
| 31 | #end | ||
| 32 | #end | ||
| 33 | ## Set response output by default | ||
| 34 | #if (!$outputProperties.target && $services.filter.getOutputFilterStreamDescriptor($request.output).getPropertyDescriptor('target')) | ||
| 35 | #set($targetStandardOutput = true) | ||
| 36 | #set($void = $outputProperties.put('target', $services.filter.createOutputStreamOutputTarget($response.outputStream, true))) | ||
| 37 | #end | ||
| 38 | {{/velocity}} | ||
| 39 | |||
| 40 | {{velocity}} | ||
| 41 | #if ($request.convert) | ||
| 42 | #if ($targetStandardOutput) | ||
| 43 | $response.setContentType('application/octet-stream') | ||
| 44 | $response.setHeader('Content-Disposition', 'attachment; filename=target'); | ||
| 45 | $services.filter.convert($input, $inputProperties, $output, $outputProperties) | ||
| 46 | $xcontext.setFinished(true) | ||
| 47 | #else | ||
| 48 | #if ($sourceStandardInput) | ||
| 49 | #set($job = $services.filter.convert($input, $inputProperties, $output, $outputProperties)) | ||
| 50 | #else | ||
| 51 | #set($job = $services.filter.startConvert($input, $inputProperties, $output, $outputProperties)) | ||
| 52 | #end | ||
| 53 | #if ($job) | ||
| 54 | #if (!$sourceStandardInput) | ||
| 55 | {{success}}Conversion started.{{/success}} | ||
| 56 | #end | ||
| 57 | #else | ||
| 58 | #set ($lastError = $services.filter.lastError) | ||
| 59 | #if ($lastError) | ||
| 60 | {{error}} | ||
| 61 | Failed to start conversion | ||
| 62 | |||
| 63 | {{html}} | ||
| 64 | <pre> | ||
| 65 | #printThrowable($lastError) | ||
| 66 | </pre> | ||
| 67 | {{/html}} | ||
| 68 | {{/error}} | ||
| 69 | #end | ||
| 70 | #end | ||
| 71 | #end | ||
| 72 | #end | ||
| 73 | {{/velocity}} | ||
| 74 | |||
| 75 | == Current conversion | ||
| 76 | |||
| 77 | {{include reference="FilterStreamJob"/}} | ||
| 78 | |||
| 79 | == Configuration == | ||
| 80 | |||
| 81 | {{velocity}} | ||
| 82 | {{html}} | ||
| 83 | <form class="xform" method="post"> | ||
| 84 | <div id="filter_form"> | ||
| 85 | <fieldset> | ||
| 86 | <legend>Input</legend> | ||
| 87 | <dl> | ||
| 88 | <dt><label for="filter_input_select">Input type</label></dt> | ||
| 89 | <dd> | ||
| 90 | <select name="input" id="filter_input_type"> | ||
| 91 | #foreach($type in $services.filter.availableInputStreams) | ||
| 92 | <option value="$escapetool.xml($type.serialize())"#if($type.serialize() == $input)selected="selected"#end>$services.filter.getInputFilterStreamDescriptor($type).name ($type)</option> | ||
| 93 | #if (!$input) | ||
| 94 | #set($input = $type.serialize()) | ||
| 95 | #end | ||
| 96 | #end | ||
| 97 | </select> | ||
| 98 | </dd> | ||
| 99 | #if ($input) | ||
| 100 | <dt><label>Input configuration</label></dt> | ||
| 101 | <dd> | ||
| 102 | #filterDescriptorForm($services.filter.getInputFilterStreamDescriptor($input), 'filter_input_properties') | ||
| 103 | </dd> | ||
| 104 | #end | ||
| 105 | </dl> | ||
| 106 | </fieldset> | ||
| 107 | |||
| 108 | <fieldset> | ||
| 109 | <legend>Output</legend> | ||
| 110 | <dl> | ||
| 111 | <dt><label for="filter_output_select">Output type</label></dt> | ||
| 112 | <dd> | ||
| 113 | <select name="output" id="filter_output_type"> | ||
| 114 | #foreach($type in $services.filter.availableOutputStreams) | ||
| 115 | <option value="$escapetool.xml($type.serialize())"#if($type.serialize() == $output)selected="selected"#end>$services.filter.getOutputFilterStreamDescriptor($type).name ($type)</option> | ||
| 116 | #if (!$output) | ||
| 117 | #set($output = $type.serialize()) | ||
| 118 | #end | ||
| 119 | #end | ||
| 120 | </select> | ||
| 121 | </dd> | ||
| 122 | #if ($output) | ||
| 123 | <dt><label>Output configuration</label></dt> | ||
| 124 | <dd> | ||
| 125 | #filterDescriptorForm($services.filter.getOutputFilterStreamDescriptor($output), 'filter_output_properties') | ||
| 126 | </dd> | ||
| 127 | #end | ||
| 128 | </dl> | ||
| 129 | </fieldset> | ||
| 130 | |||
| 131 | <p> | ||
| 132 | <input class="button" type="submit" name="convert" value="Convert"/> | ||
| 133 | </p> | ||
| 134 | </div> | ||
| 135 | </form> | ||
| 136 | {{/html}} | ||
| 137 | {{/velocity}} |