Merge pull request #17 from timar/master
remove dead code (from Collabora Online perspective)pull/1/head
commit
fc1126506b
@ -1,15 +0,0 @@
|
||||
$(document).ready(function(){
|
||||
|
||||
var documentsSettings = {
|
||||
save : function() {
|
||||
var data = {
|
||||
unstable : $('#webodf-unstable').attr('checked')==="checked"
|
||||
};
|
||||
$.post(OC.generateUrl('apps/richdocuments/ajax/config/unstable'), data, documentsSettings.afterSave);
|
||||
},
|
||||
afterSave : function(){
|
||||
documentsMain.useUnstable = $('#webodf-unstable').attr('checked')==="checked";
|
||||
}
|
||||
};
|
||||
$('#webodf-unstable').change(documentsSettings.save);
|
||||
});
|
@ -1,147 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ownCloud - Richdocuments App
|
||||
*
|
||||
* @author Victor Dubiniuk
|
||||
* @copyright 2014 Victor Dubiniuk victor.dubiniuk@gmail.com
|
||||
*
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
*/
|
||||
|
||||
namespace OCA\Richdocuments;
|
||||
|
||||
use OCA\Richdocuments\AppInfo\Application;
|
||||
|
||||
class Converter {
|
||||
|
||||
const TEST_DOC_PATH = '/assets/test.doc';
|
||||
|
||||
public static function testConversion(){
|
||||
$targetFilter = 'odt:writer8';
|
||||
$targetExtension = 'odt';
|
||||
$input = file_get_contents(dirname(__DIR__) . self::TEST_DOC_PATH);
|
||||
$infile = \OC::$server->getTempManager()->getTemporaryFile();
|
||||
$outdir = \OC::$server->getTempManager()->getTemporaryFolder();
|
||||
$outfile = $outdir . '/' . basename($infile) . '.' . $targetExtension;
|
||||
$cmd = Helper::findOpenOffice();
|
||||
|
||||
$params = ' --headless --convert-to ' . escapeshellarg($targetFilter) . ' --outdir '
|
||||
. escapeshellarg($outdir)
|
||||
. ' --writer '. escapeshellarg($infile)
|
||||
. ' -env:UserInstallation=file://'
|
||||
. escapeshellarg(\OC::$server->getTempManager()->getTempBaseDir() . '/owncloud-' . \OC_Util::getInstanceId().'/') . ' 2>&1'
|
||||
;
|
||||
file_put_contents($infile, $input);
|
||||
|
||||
$result = shell_exec($cmd . $params);
|
||||
$exists = file_exists($outfile);
|
||||
|
||||
if (!$exists){
|
||||
\OC::$server->getLogger()->warn(
|
||||
'Conversion test failed. Raw output:' . $result,
|
||||
['app' => 'richdocuments']
|
||||
|
||||
);
|
||||
return false;
|
||||
} else {
|
||||
unlink($outfile);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function convert($input, $targetFilter, $targetExtension){
|
||||
if (self::getAppConfig()->getAppValue('converter') === 'local'){
|
||||
$output = self::convertLocal($input, $targetFilter, $targetExtension);
|
||||
} else {
|
||||
$output = self::convertExternal($input, $targetExtension);
|
||||
}
|
||||
|
||||
if (empty($output)){
|
||||
\OC::$server->getLogger()->warn(
|
||||
'Empty conversion output',
|
||||
['app' => 'richdocuments']
|
||||
|
||||
);
|
||||
throw new \RuntimeException('Empty conversion output');
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
public static function checkConnection(){
|
||||
$expected = file_get_contents(dirname(__DIR__) . '/assets/response.odt');
|
||||
$converted = self::convertExternal('', 'odt');
|
||||
|
||||
return $converted === $expected;
|
||||
}
|
||||
|
||||
/**
|
||||
* convert via openOffice hosted on the same server
|
||||
* @param string $input
|
||||
* @param string $targetFilter
|
||||
* @param string $targetExtension
|
||||
* @return string
|
||||
*/
|
||||
protected static function convertLocal($input, $targetFilter, $targetExtension){
|
||||
$infile = \OC::$server->getTempManager()->getTemporaryFile();
|
||||
$outdir = \OC::$server->getTempManager()->getTemporaryFolder();
|
||||
$cmd = Helper::findOpenOffice();
|
||||
$params = ' --headless --convert-to ' . $targetFilter . ' --outdir '
|
||||
. escapeshellarg($outdir)
|
||||
. ' --writer '. escapeshellarg($infile)
|
||||
. ' -env:UserInstallation=file://'
|
||||
. escapeshellarg(\OC::$server->getTempManager()->getTempBaseDir() . '/owncloud-' . \OC_Util::getInstanceId().'/')
|
||||
;
|
||||
|
||||
file_put_contents($infile, $input);
|
||||
shell_exec($cmd . $params);
|
||||
$output = file_get_contents($outdir . '/' . basename($infile) . '.' . $targetExtension);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* convert via format-filter-server installed on the same host with openOffice
|
||||
* @param string $input
|
||||
* @return string
|
||||
*/
|
||||
protected static function convertExternal($input, $targetExtension){
|
||||
$options = array(
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_HEADER => false,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_ENCODING => "",
|
||||
CURLOPT_AUTOREFERER => true,
|
||||
CURLOPT_CONNECTTIMEOUT => 120,
|
||||
CURLOPT_TIMEOUT => 120,
|
||||
CURLOPT_MAXREDIRS => 2,
|
||||
CURLOPT_POST => 1,
|
||||
CURLOPT_POSTFIELDS => $input,
|
||||
CURLOPT_SSL_VERIFYHOST => 0,
|
||||
CURLOPT_SSL_VERIFYPEER => 0,
|
||||
CURLOPT_VERBOSE => 1
|
||||
);
|
||||
|
||||
$ch = curl_init(self::getAppConfig()->getAppValue('converter_url') . '?target_format=' . $targetExtension);
|
||||
curl_setopt_array($ch, $options);
|
||||
$content = curl_exec($ch);
|
||||
if (curl_errno($ch)){
|
||||
\OC::$server->getLogger()->debug(
|
||||
'cURL error' . curl_errno($ch) . ':' . curl_error($ch),
|
||||
['app' => 'richdocuments']
|
||||
|
||||
);
|
||||
}
|
||||
curl_close($ch);
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
protected static function getAppConfig(){
|
||||
$app = new Application();
|
||||
$c = $app->getContainer();
|
||||
return $c->query('AppConfig');
|
||||
}
|
||||
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ownCloud - RichDocuments App
|
||||
*
|
||||
* @author Victor Dubiniuk
|
||||
* @copyright 2014 Victor Dubiniuk victor.dubiniuk@gmail.com
|
||||
*
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
*/
|
||||
|
||||
namespace OCA\Richdocuments\Filter;
|
||||
|
||||
class Office {
|
||||
const NATIVE_MIMETYPE = 'application/vnd.oasis.opendocument.text';
|
||||
|
||||
private $readSpec;
|
||||
private $writeSpec;
|
||||
|
||||
/* sample mimespec
|
||||
array (
|
||||
'read' =>
|
||||
array (
|
||||
'target' => 'application/vnd.oasis.opendocument.text',
|
||||
'format' => 'odt:writer8',
|
||||
'extension' => 'odt'
|
||||
),
|
||||
'write' =>
|
||||
array (
|
||||
'target' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'format' => 'docx',
|
||||
'extension' => 'docx'
|
||||
)
|
||||
);
|
||||
|
||||
array(
|
||||
'read' =>
|
||||
array (
|
||||
'target' => 'application/vnd.oasis.opendocument.text',
|
||||
'format' => 'odt:writer8',
|
||||
'extension' => 'odt'
|
||||
),
|
||||
'write' =>
|
||||
array (
|
||||
'target' => 'application/msword',
|
||||
'format' => 'doc',
|
||||
'extension' => 'doc'
|
||||
)
|
||||
);
|
||||
|
||||
*/
|
||||
|
||||
public function __construct($mimeSpec){
|
||||
$this->readSpec = $mimeSpec['read'];
|
||||
$this->writeSpec = $mimeSpec['write'];
|
||||
|
||||
\OCA\Richdocuments\Filter::add($mimeSpec['write']['target'], $this);
|
||||
}
|
||||
|
||||
public function read($data){
|
||||
return array(
|
||||
'mimetype' => $this->readSpec['target'],
|
||||
'content' =>
|
||||
\OCA\Richdocuments\Converter::convert(
|
||||
$data['content'],
|
||||
$this->readSpec['format'],
|
||||
$this->readSpec['extension']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function write($data){
|
||||
return array(
|
||||
'mimetype' => $this->writeSpec['target'],
|
||||
'content' =>
|
||||
\OCA\Richdocuments\Converter::convert(
|
||||
$data['content'],
|
||||
$this->writeSpec['format'],
|
||||
$this->writeSpec['extension']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Copies the needed files from the build dir of the WebODF pullbox branch
|
||||
#
|
||||
# Prepare the webodf build dir by calling: make webodf-debug.js-target editor-compiled.js-target
|
||||
|
||||
if [ ! -e "README.md" ]; then
|
||||
echo "Call me in the toplevel dir of OwnCloud Documents."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "Usage : $0 prepare|copy|patch"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
WEBODF_BUILDDIR='build/'
|
||||
WEBODF_SRCDIR='webodf/'
|
||||
|
||||
# create folders
|
||||
function prepare(){
|
||||
if [ ! -d "$WEBODF_SRCDIR" ]; then
|
||||
git clone git@github.com:kogmbh/WebODF.git "$WEBODF_SRCDIR"
|
||||
else
|
||||
pushd "$WEBODF_SRCDIR"
|
||||
git pull --rebase
|
||||
popd
|
||||
fi
|
||||
|
||||
if [ ! -d "$WEBODF_BUILDDIR" ]; then
|
||||
mkdir "$WEBODF_BUILDDIR"
|
||||
fi
|
||||
|
||||
pushd "$WEBODF_BUILDDIR"
|
||||
cmake "../${WEBODF_SRCDIR}"
|
||||
make all webodf-debug.js-target build-wodocollabtexteditor
|
||||
popd
|
||||
}
|
||||
|
||||
# copy sources
|
||||
function copy_sources(){
|
||||
# webodf.js
|
||||
cp "$WEBODF_BUILDDIR"/webodf/webodf.js ./js/3rdparty/webodf
|
||||
cp "$WEBODF_BUILDDIR"/webodf/webodf-debug.js ./js/3rdparty/webodf
|
||||
# dojo
|
||||
cp "$WEBODF_BUILDDIR"/programs/editor/dojo-amalgamation.js ./js/3rdparty/webodf
|
||||
|
||||
# Tools, Editor, EditorSession, MemberListView:
|
||||
cp "$WEBODF_BUILDDIR"/programs/editor/{Tools,Editor,EditorSession,MemberListView}.js ./js/3rdparty/webodf/editor
|
||||
cp "$WEBODF_BUILDDIR"/programs/editor/backend/pullbox/* ./js/3rdparty/webodf/editor/backend/pullbox -R
|
||||
cp "$WEBODF_BUILDDIR"/programs/editor/backend/ServerFactory.js ./js/3rdparty/webodf/editor/backend -R
|
||||
cp "$WEBODF_BUILDDIR"/programs/editor/widgets ./js/3rdparty/webodf/editor -R
|
||||
cp "$WEBODF_BUILDDIR"/wodocollabtexteditor/wodo/{wodotexteditor,wodocollabpane}.css ./css/3rdparty/webodf
|
||||
|
||||
cp "$WEBODF_BUILDDIR"/programs/editor/dojo/* ./js/3rdparty/resources/dojo -R
|
||||
cp "$WEBODF_BUILDDIR"/programs/editor/dojox/* ./js/3rdparty/resources/dojox -R
|
||||
cp "$WEBODF_BUILDDIR"/programs/editor/dijit/* ./js/3rdparty/resources/dijit -R
|
||||
|
||||
# files which need to be adapted manually:
|
||||
# "$WEBODF_BUILDDIR"/programs/editor/dojo-deps/src/app/resources/app.css -> ./css/3rdparty/webodf/dojo-app.css
|
||||
# dojo-app.css has other paths then upstream, needs to be manually adapted to changes
|
||||
# also is dojo.css is not imported here, other than in upstream
|
||||
}
|
||||
|
||||
# patches against upstream
|
||||
function patch_sources(){
|
||||
patch -p1 -i src/patches/Patch-EditorSession.patch
|
||||
patch -p1 -i src/patches/Patch-MemberListView.patch
|
||||
patch -p1 -i src/patches/Patch-Tools.patch
|
||||
|
||||
#Just for the record
|
||||
#patch -p1 -i src/patches/dojoStylesPill.patch
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
'prepare' )
|
||||
prepare ;;
|
||||
'copy' )
|
||||
copy_sources ;;
|
||||
'patch' )
|
||||
patch_sources ;;
|
||||
esac
|
@ -1,43 +1,12 @@
|
||||
<?php
|
||||
script('richdocuments', 'admin');
|
||||
?>
|
||||
<div class="section" id="documents">
|
||||
<h2><?php p($l->t('Documents')) ?></h2>
|
||||
<p><?php p($l->t('MS Word support (requires openOffice/libreOffice)')) ?></p>
|
||||
<p>
|
||||
<input type="radio" name="docs_converter" value="local" id="docs_converter_local"
|
||||
<?php print_unescaped($_['converter']=='local' ? 'checked="checked"' : '') ?>
|
||||
/>
|
||||
<label for="docs_converter_local"><?php p($l->t('Local')) ?></label><br>
|
||||
<em><?php p($l->t('openOffice/libreOffice is installed on this server. Path to binary is provided via preview_libreoffice_path in config.php')) ?></em>
|
||||
</p>
|
||||
<p>
|
||||
<input type="radio" name="docs_converter" value="external" id="docs_converter_external"
|
||||
<?php print_unescaped($_['converter']=='external' ? 'checked="checked"' : '') ?>
|
||||
/>
|
||||
<label for="docs_converter_external"><?php p($l->t('External')) ?></label><br>
|
||||
<em><?php p($l->t('openOffice/libreOffice is installed on external server running a format filter server')) ?></em>
|
||||
</p>
|
||||
<p>
|
||||
<input type="radio" name="docs_converter" value="off" id="docs_converter_off"
|
||||
<?php print_unescaped($_['converter']=='off' ? 'checked="checked"' : '') ?>
|
||||
/>
|
||||
<label for="docs_converter_off"><?php p($l->t('Disabled')) ?></label><br>
|
||||
<em><?php p($l->t('No MS Word support')) ?></em>
|
||||
</p>
|
||||
<div id="docs_extra" <?php print_unescaped($_['converter']!=='external' ? 'style="display:none"' : '') ?>>
|
||||
<input type="text" name="docs_url" id="docs_url"
|
||||
value="<?php p($_['converter_url'])?>"
|
||||
original-title="<?php p($l->t('scheme://domain.tld[:port]')) ?>"
|
||||
style="width:250px;"
|
||||
/>
|
||||
<br /><em><?php p($l->t('Server URL')) ?></em>
|
||||
</div>
|
||||
<br />
|
||||
<div class="section" id="richdocuments">
|
||||
<h2><?php p($l->t('Collabora Online')) ?></h2>
|
||||
<div id="wopi_client">
|
||||
<input type="text" name="wopi_url" id="wopi_url" value="<?php p($_['wopi_url'])?>" style="width:250px;">
|
||||
<br /><em><?php p($l->t('WOPI Client')) ?></em>
|
||||
</div>
|
||||
<br /><button type="button" id="docs_apply"><?php p($l->t('Apply and test')) ?></button>
|
||||
<br /><button type="button" id="docs_apply"><?php p($l->t('Apply')) ?></button>
|
||||
<span id="documents-admin-msg" class="msg"></span>
|
||||
</div>
|
||||
|
@ -1,15 +0,0 @@
|
||||
<?php
|
||||
script('richdocuments', 'settings');
|
||||
?>
|
||||
<div id="documents" class="section">
|
||||
<h2><?php p($l->t('Documents')) ?></h2>
|
||||
<input id="webodf-unstable" type ="checkbox"
|
||||
<?php if ($_['unstable'] === 'true'){ ?>
|
||||
checked="checked"
|
||||
<?php } ?>
|
||||
/>
|
||||
<label for="webodf-unstable">
|
||||
<?php p($l->t('Advanced feature-set'))?>
|
||||
<?php p($l->t('(Unstable)')); ?>
|
||||
</label>
|
||||
</div>
|
Loading…
Reference in New Issue