Merge pull request #5085 from owncloud/versioning_preview
add previews to versions dialog
This commit is contained in:
commit
7337b34110
|
@ -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);
|
||||
}
|
|
@ -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';
|
||||
});
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#dropdown.drop-versions {
|
||||
width:22em;
|
||||
width:24em;
|
||||
}
|
||||
|
||||
#found_versions li {
|
||||
width: 100%;
|
||||
cursor: default;
|
||||
height: 36px;
|
||||
height: 56px;
|
||||
float: left;
|
||||
border-bottom: 1px solid rgba(100,100,100,.1);
|
||||
}
|
||||
|
@ -21,6 +21,12 @@
|
|||
filter: alpha(opacity=50);
|
||||
opacity: .5;
|
||||
}
|
||||
|
||||
#found_versions li > a,
|
||||
#found_versions li > span {
|
||||
padding: 17px 7px;
|
||||
}
|
||||
|
||||
#found_versions li > *:hover,
|
||||
#found_versions li > *:focus {
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
|
||||
|
@ -33,6 +39,11 @@
|
|||
padding-right: 4px;
|
||||
}
|
||||
|
||||
#found_versions img.preview {
|
||||
cursor: default;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
#found_versions .versionDate {
|
||||
min-width: 100px;
|
||||
vertical-align: text-bottom;
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue