summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files_versions/ajax/preview.php43
-rw-r--r--apps/files_versions/appinfo/routes.php5
-rw-r--r--apps/files_versions/css/versions.css6
-rw-r--r--apps/files_versions/js/versions.js4
-rw-r--r--apps/files_versions/lib/versions.php1
5 files changed, 57 insertions, 2 deletions
diff --git a/apps/files_versions/ajax/preview.php b/apps/files_versions/ajax/preview.php
new file mode 100644
index 00000000000..eec2d7c1e69
--- /dev/null
+++ b/apps/files_versions/ajax/preview.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ * Copyright (c) 2013 Georg Ehrke georg@ownCloud.com
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+\OC_Util::checkLoggedIn();
+
+if(!\OC_App::isEnabled('files_versions')){
+ exit;
+}
+
+$file = array_key_exists('file', $_GET) ? (string) urldecode($_GET['file']) : '';
+$maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : '44';
+$maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : '44';
+$version = array_key_exists('version', $_GET) ? $_GET['version'] : '';
+$scalingUp = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true;
+
+if($file === '' && $version === '') {
+ \OC_Response::setStatus(400); //400 Bad Request
+ \OC_Log::write('core-preview', 'No file parameter was passed', \OC_Log::DEBUG);
+ exit;
+}
+
+if($maxX === 0 || $maxY === 0) {
+ \OC_Response::setStatus(400); //400 Bad Request
+ \OC_Log::write('core-preview', 'x and/or y set to 0', \OC_Log::DEBUG);
+ exit;
+}
+
+try{
+ $preview = new \OC\Preview(\OC_User::getUser(), 'files_versions');
+ $preview->setFile($file.'.v'.$version);
+ $preview->setMaxX($maxX);
+ $preview->setMaxY($maxY);
+ $preview->setScalingUp($scalingUp);
+
+ $preview->showPreview();
+}catch(\Exception $e) {
+ \OC_Response::setStatus(500);
+ \OC_Log::write('core', $e->getmessage(), \OC_Log::DEBUG);
+} \ No newline at end of file
diff --git a/apps/files_versions/appinfo/routes.php b/apps/files_versions/appinfo/routes.php
index 38c288adf9d..dc36b66f39d 100644
--- a/apps/files_versions/appinfo/routes.php
+++ b/apps/files_versions/appinfo/routes.php
@@ -7,3 +7,8 @@
// Register with the capabilities API
OC_API::register('get', '/cloud/capabilities', array('OCA\Files_Versions\Capabilities', 'getCapabilities'), 'files_versions', OC_API::USER_AUTH);
+
+$this->create('core_ajax_versions_preview', '/preview.png')->action(
+function() {
+ require_once __DIR__ . '/../ajax/preview.php';
+}); \ No newline at end of file
diff --git a/apps/files_versions/css/versions.css b/apps/files_versions/css/versions.css
index 6a9b3a95698..d9a3c43d543 100644
--- a/apps/files_versions/css/versions.css
+++ b/apps/files_versions/css/versions.css
@@ -5,7 +5,7 @@
#found_versions li {
width: 100%;
cursor: default;
- height: 36px;
+ height: 56px;
float: left;
border-bottom: 1px solid rgba(100,100,100,.1);
}
@@ -33,6 +33,10 @@
padding-right: 4px;
}
+#found_versions img.preview {
+ cursor: default;
+}
+
#found_versions .versionDate {
min-width: 100px;
vertical-align: text-bottom;
diff --git a/apps/files_versions/js/versions.js b/apps/files_versions/js/versions.js
index f57e931bad9..3f56a3eb698 100644
--- a/apps/files_versions/js/versions.js
+++ b/apps/files_versions/js/versions.js
@@ -129,6 +129,8 @@ function createVersionsDropdown(filename, files) {
var path = OC.filePath('files_versions', '', 'download.php');
+ var preview = '<img class="preview" src="'+revision.preview+'"/>';
+
var download ='<a href="' + path + "?file=" + files + '&revision=' + revision.version + '">';
download+='<img';
download+=' src="' + OC.imagePath('core', 'actions/download') + '"';
@@ -146,7 +148,7 @@ function createVersionsDropdown(filename, files) {
var version=$('<li/>');
version.attr('value', revision.version);
- version.html(download + revert);
+ version.html(preview + download + revert);
version.appendTo('#found_versions');
}
diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php
index 0b4699dc5c0..fc8d0365c71 100644
--- a/apps/files_versions/lib/versions.php
+++ b/apps/files_versions/lib/versions.php
@@ -266,6 +266,7 @@ class Storage {
$versions[$key]['version'] = $version;
$versions[$key]['humanReadableTimestamp'] = self::getHumanReadableTimestamp($version);
$versions[$key]['path'] = $filename;
+ $versions[$key]['preview'] = \OCP\Util::linkToRoute('core_ajax_versions_preview', array('file' => $filename, 'version' => $version));
$versions[$key]['size'] = $versions_fileview->filesize($filename.'.v'.$version);
// if file with modified date exists, flag it in array as currently enabled version