diff options
author | daita <maxence@pontapreta.net> | 2016-10-07 03:37:08 +0300 |
---|---|---|
committer | daita <maxence@pontapreta.net> | 2016-10-07 03:37:08 +0300 |
commit | bd371674a4fb032698f0d257c1edd85b835add2a (patch) | |
tree | a59d8aa93257763d8495286927fc5185a8b55b74 | |
parent | df0271ce46736f5bee972ea4616833633124df91 (diff) |
#1 display documents from trash
-rw-r--r-- | css/navigate.css | 56 | ||||
-rw-r--r-- | js/navigate.js | 50 | ||||
-rw-r--r-- | lib/Controller/SearchController.php | 89 | ||||
-rw-r--r-- | lib/Cron/BackgroundIndex.php | 4 |
4 files changed, 127 insertions, 72 deletions
diff --git a/css/navigate.css b/css/navigate.css index 4b21b3b..7b4334d 100644 --- a/css/navigate.css +++ b/css/navigate.css @@ -11,44 +11,64 @@ DIV.nextant_entry { margin: 2px; } -SPAN.nextant_line1 { +DIV.nextant_details { + width: 22px; + background-size: 22px; + display: inline-block; + height: 22px; + margin-left: -8px; + margin-top: -8px; + cursor: pointer; + float: left; + position: absolute; + z-index: 4; + opacity: 0.5; + filter: alpha(opacity = 50) +} + +A.nextant_file { + cursor: default !important; + position: relative; + -moz-box-sizing: border-box; + box-sizing: border-box; + display: block; + height: 50px; + line-height: 50px; + padding: 0; + left: 50px; + margin-right: 50px; +} + +SPAN.nextant_line { position: absolute; left: 55px; - top: -15px; padding: 0; overflow: hidden; - font-style: italic; - text-overflow: ellipsis; padding-right: 20px; max-width: 800px; + text-overflow: ellipsis; +} + +SPAN.nextant_line1 { + top: -15px; + font-style: italic; font-weight: bold; } SPAN.nextant_line2 { - position: absolute; - left: 55px; top: 0px; - padding: 0; - overflow: hidden; font-style: italic; - text-overflow: ellipsis; - padding-right: 20px; - max-width: 800px; font-size: 12px; + left: 70px; color: #9e9e9e; } SPAN.nextant_line3 { - position: absolute; - left: 55px; - top: 15px; - padding: 0; - overflow: hidden; - text-overflow: ellipsis; - max-width: 800px; font-style: italic; font-size: 12px; color: #9e9e9e; + left: 70px; + top: 15px; padding-right: 20px; } diff --git a/js/navigate.js b/js/navigate.js index f56521c..6c21f2a 100644 --- a/js/navigate.js +++ b/js/navigate.js @@ -94,11 +94,13 @@ $(document) response .forEach(function(entry) { - $row = nextant + var row = nextant .template_entry() .replace(/%ID%/gi, entry.id) .replace(/%TYPE%/gi, entry.type) .replace(/%SIZE%/gi, entry.size) + .replace(/%FILESIZE%/gi, + entry.filesize) .replace(/%MIME%/gi, entry.mime) .replace(/%FILEICON%/gi, entry.fileicon) @@ -120,7 +122,22 @@ $(document) .replace(/%FILENAME%/gi, entry.filename); - $('#nextantList').append($row); + row = row + .replace( + /%SHARED%/gi, + (entry.shared != '') ? ' style="background-image:url(' + + entry.shared + + ');"' + : ''); + row = row + .replace( + /%DELETED%/gi, + (entry.deleted != '') ? ' style="background-image:url(' + + entry.deleted + + ');"' + : ''); + + $('#nextantList').append(row); }); }, @@ -128,18 +145,25 @@ $(document) $tmpl = '<tr data-id="%ID%" data-type="%TYPE%" data-size="%SIZE%" data-file="%FILENAME%" data-mime="%MIME%" data-mtime="%MTIME%000" data-etag="" data-permissions="" data-has-preview="false" data-path="%DIRNAME%" data-share-permissions="">'; $tmpl += '<td class="filename ui-draggable">'; - $tmpl += '<a href="#" class="action action-favorite " data-original-title="" title="">'; - $tmpl += '<span class="icon icon-star"></span><span class="hidden-visually">Favorite</span></a>'; - $tmpl += '<input id="select-files-%ID%" class="selectCheckBox checkbox" type="checkbox">'; - $tmpl += '<label for="select-files-%ID%"><div class="thumbnail" style="background-image:url(%FILEICON%); background-size: 32px;"></div>'; + $tmpl += '<a class="action action-favorite " data-original-title="" title="">'; + // $tmpl += '<span class="icon + // icon-star"></span><span + // class="hidden-visually">Favorite</span>'; + $tmpl += '</a>'; + // $tmpl += '<input id="select-files-%ID%" + // class="selectCheckBox checkbox" + // type="checkbox">'; + $tmpl += '<label for="select-files-%ID%"><div class="thumbnail" style="background-image:url(%FILEICON%); background-size: 32px;">'; + $tmpl += '<div class="nextant_details" %DELETED%%SHARED%></div>'; + $tmpl += '</div>'; $tmpl += '<span class="hidden-visually">Select</span></label>'; - $tmpl += '<a class="name" href="%WEBDAV%">'; + $tmpl += '<a class="nextant_file" href="%WEBDAV%">'; $tmpl += '<div>'; - $tmpl += '<span class="nextant_line1">%PATH%</span>'; - $tmpl += '<span class="nextant_line2">%HIGHLIGHT1%</span>'; - $tmpl += '<span class="nextant_line3">%HIGHLIGHT2%</span>'; - $tmpl += '</div>'; + $tmpl += '<span class="nextant_line nextant_line1">%PATH%</span>'; + $tmpl += '<span class="nextant_line nextant_line2">%HIGHLIGHT1%</span>'; + $tmpl += '<span class="nextant_line nextant_line3">%HIGHLIGHT2%</span>'; + $tmpl += '</div></a>'; // $tmpl += '<span class="fileactions"><a // class="action action-share permanent" href="#" @@ -154,8 +178,10 @@ $(document) // icon-more"></span>'; // $tmpl += '<span // class="hidden-visually">Actions</span></a></span></a>'; + $tmpl += '</td>'; - $tmpl += '<td class="filesize" style="color:rgb(-17,-17,-17)">13.3 MB</td><td class="date"><span class="modified" title="" style="color:rgb(155,155,155)" data-original-title="September 1, 2016 12:05 PM">a month ago</span></td></tr>'; + $tmpl += '<td class="filesize" style="color:rgb(-17,-17,-17)">%FILESIZE%</td>'; + $tmpl += '<td class="date"><span class="modified" title="" style="color:rgb(155,155,155)" data-original-title=""></span></td></tr>'; return $tmpl; diff --git a/lib/Controller/SearchController.php b/lib/Controller/SearchController.php index 4796d62..0e5f626 100644 --- a/lib/Controller/SearchController.php +++ b/lib/Controller/SearchController.php @@ -38,6 +38,7 @@ use OCP\AppFramework\Controller; use OCP\IRequest; use OC\Files\Filesystem; use OCP\Files\NotFoundException; +use OC\Files\View; class SearchController extends Controller { @@ -87,53 +88,61 @@ class SearchController extends Controller foreach ($solrResult as $data) { + $fileData = null; try { $path = $view->getPath($data['id']); $fileData = $view->getFileInfo($path); - - if ($fileData === false) + } catch (NotFoundException $e) { + try { + $trashview = new View('/' . $this->userId . '/files_trashbin/files'); + $path = $trashview->getPath($data['id']); + $fileData = $trashview->getFileInfo($path); + } catch (NotFoundException $e) { continue; - - $pathParts = pathinfo($path); - $basepath = str_replace('//', '/', '/' . $pathParts['dirname'] . '/'); - - $hl1 = ''; - $hl2 = ''; - if (key_exists('highlight', $data) && is_array($data['highlight'])) { - if (sizeof($data['highlight']) >= 1) - $hl1 = '... ' . $data['highlight'][0] . ' ...'; - if (sizeof($data['highlight']) > 1) - $hl2 = '... ' . $data['highlight'][1] . ' ...'; } - - if ($hl1 == '' || $hl1 == null) - $hl1 = ''; - if ($hl2 == '' || $hl2 == null) - $hl2 = ''; - - $response = array( - 'id' => $data['id'], - 'type' => 'file', - 'shared' => ($data['owner'] != $this->userId), - 'deleted' => ($data['deleted']), - 'size' => $fileData->getSize(), - 'path' => $path, - 'basepath' => $basepath, - 'filename' => $pathParts['basename'], - 'basefile' => $pathParts['filename'], - 'highlight1' => $hl1, - 'highlight2' => $hl2, - 'extension' => ($pathParts['extension'] != '') ? '.' . $pathParts['extension'] : '', - 'mime' => $fileData->getMimetype(), - 'fileicon' => SolrService::extractableFile($fileData->getMimeType(), $path), - 'webdav' => \OCP\Util::linkToRemote('webdav') . $path, - 'mtime' => $fileData->getMTime() - ); - - array_push($results, $response); - } catch (NotFoundException $e) { + } + + if ($fileData == null || $fileData === false) continue; + + $pathParts = pathinfo($path); + $basepath = str_replace('//', '/', '/' . $pathParts['dirname'] . '/'); + + $hl1 = ''; + $hl2 = ''; + if (key_exists('highlight', $data) && is_array($data['highlight'])) { + if (sizeof($data['highlight']) >= 1) + $hl1 = '... ' . $data['highlight'][0] . ' ...'; + if (sizeof($data['highlight']) > 1) + $hl2 = '... ' . $data['highlight'][1] . ' ...'; } + + if ($hl1 == '' || $hl1 == null) + $hl1 = ''; + if ($hl2 == '' || $hl2 == null) + $hl2 = ''; + + $response = array( + 'id' => $data['id'], + 'type' => 'file', + 'shared' => ($data['owner'] != $this->userId) ? \OCP\Util::imagePath('core', 'actions/shared.svg') : '', + 'deleted' => ($data['deleted']) ? \OCP\Util::imagePath('core', 'actions/delete.svg') : '', + 'size' => $fileData->getSize(), + 'filesize' => \OC_Helper::humanFileSize($fileData->getSize()), + 'path' => $path, + 'basepath' => $basepath, + 'filename' => $pathParts['basename'], + 'basefile' => $pathParts['filename'], + 'highlight1' => $hl1, + 'highlight2' => $hl2, + 'extension' => ($pathParts['extension'] != '') ? '.' . $pathParts['extension'] : '', + 'mime' => $fileData->getMimetype(), + 'fileicon' => SolrService::extractableFile($fileData->getMimeType(), $path), + 'webdav' => str_replace('//', '/', parse_url(\OCP\Util::linkToRemote('webdav') . $path, PHP_URL_PATH)), + 'mtime' => $fileData->getMTime() + ); + + array_push($results, $response); } } diff --git a/lib/Cron/BackgroundIndex.php b/lib/Cron/BackgroundIndex.php index ec20aeb..d3197ef 100644 --- a/lib/Cron/BackgroundIndex.php +++ b/lib/Cron/BackgroundIndex.php @@ -54,8 +54,8 @@ class BackgroundIndex extends \OC\BackgroundJob\TimedJob $this->solrTools = $c->query('SolrToolsService'); $this->fileService = $c->query('FileService'); $this->rootFolder = $c->query('RootFolder'); - - // $this->setDebug(true); + + // $this->setDebug(true); if (! $this->configService->neededIndex()) { $this->miscService->debug('Looks like there is no need to index'); return; |