Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
['name' => 'web_view#index', 'url' => '/', 'verb' => 'GET'],
['name' => 'web_view#index', 'url' => '/recent', 'verb' => 'GET', 'postfix' => 'recent'],
['name' => 'web_view#index', 'url' => '/search/{search}', 'verb' => 'GET', 'postfix' => 'search'],
['name' => 'web_view#index', 'url' => '/folder/{folder}', 'verb' => 'GET', 'postfix' => 'folder'],
['name' => 'web_view#index', 'url' => '/folders/{folder}', 'verb' => 'GET', 'postfix' => 'folder'],
['name' => 'web_view#index', 'url' => '/bookmarks/{bookmark}', 'verb' => 'GET', 'postfix' => 'bookmark'],
['name' => 'web_view#index', 'url' => '/tags/{tags}', 'verb' => 'GET', 'postfix' => 'tags'],
['name' => 'web_view#index', 'url' => '/untagged', 'verb' => 'GET', 'postfix' => 'untagged'],
['name' => 'web_view#index', 'url' => '/bookmarklet', 'verb' => 'GET', 'postfix' => 'bookmarklet'],
Expand Down
58 changes: 58 additions & 0 deletions lib/Search/Provider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
namespace OCA\Bookmarks\Search;

use OCA\Bookmarks\Db\Bookmark;
use OCA\Bookmarks\Db\BookmarkMapper;
use OCA\Bookmarks\QueryParameters;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\Search\IProvider;
use OCP\Search\ISearchQuery;
use OCP\Search\SearchResult;

class Provider implements IProvider {

/**
* @var IL10N
*/
private $l;

/**
* @var BookmarkMapper
*/
private $bookmarkMapper;

/**
* @var IURLGenerator
*/
private $url;

public function __construct(IL10N $l, BookmarkMapper $bookmarkMapper, IURLGenerator $url) {
$this->l = $l;
$this->bookmarkMapper = $bookmarkMapper;
$this->url = $url;
}

public function getId(): string {
return 'bookmarks';
}

public function getName(): string {
return $this->l->t('Bookmarks');
}

public function search(IUser $user, ISearchQuery $query): SearchResult {
$params = new QueryParameters();
$params->setLimit($query->getLimit());
$params->setOffset($query->getCursor() ?? 0);
$bookmarks = $this->bookmarkMapper->findAll($user->getUID(), explode(' ', $query->getTerm()), $params);

$results = array_map(function (Bookmark $bookmark) {
$favicon = $this->url->linkToRouteAbsolute('bookmarks.web_view.indexbookmark', ['bookmark' => $bookmark->getId()]);
return new SearchResultEntry($favicon, $bookmark->getTitle(), $bookmark->getUrl(), $bookmark->getUrl());
}, $bookmarks);

return SearchResult::paginated($this->getName(), $results, $params->getLimit()+$params->getOffset());
}
}
8 changes: 8 additions & 0 deletions lib/Search/SearchResultEntry.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php


namespace OCA\Bookmarks\Search;

class SearchResultEntry extends \OCP\Search\ASearchResultEntry {

}
92 changes: 45 additions & 47 deletions src/components/Breadcrumbs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
{{ t('bookmarks', 'RSS Feed') }}
</ActionButton>
</Actions>
<Search />
<div v-if="hasSelection" class="breadcrumbs__bulkediting">
{{
selectionDescription
Expand Down Expand Up @@ -92,10 +93,11 @@ import ActionButton from '@nextcloud/vue/dist/Components/ActionButton'
import ActionSeparator from '@nextcloud/vue/dist/Components/ActionSeparator'
import { actions, mutations } from '../store/'
import { generateUrl } from '@nextcloud/router'
import Search from './Search'

export default {
name: 'Breadcrumbs',
components: { Multiselect, Actions, ActionButton, ActionSeparator },
components: { Search, Multiselect, Actions, ActionButton, ActionSeparator },
props: {},
data() {
return {
Expand Down Expand Up @@ -126,7 +128,10 @@ export default {
if (this.$store.state.selection.bookmarks.length !== 0 && this.$store.state.selection.folders.length !== 0) {
return this.t('bookmarks',
'Selected {folders} folders and {bookmarks} bookmarks',
{ folders: this.$store.state.selection.folders.length, bookmarks: this.$store.state.selection.bookmarks.length }
{
folders: this.$store.state.selection.folders.length,
bookmarks: this.$store.state.selection.bookmarks.length,
}
)
}
if (this.$store.state.selection.bookmarks.length !== 0) {
Expand All @@ -146,22 +151,15 @@ export default {
return ''
},
rssURL() {
return (
window.location.origin
+ generateUrl(
'/apps/bookmarks/public/rest/v2/bookmark?'
+ new URLSearchParams(
Object.assign({}, this.$store.state.fetchState.query, {
format: 'rss',
page: -1,
...(this.$store.state.public && { token: this.$store.state.authToken }),
})
).toString()
)
return (window.location.origin
+ generateUrl('/apps/bookmarks/public/rest/v2/bookmark?'
+ new URLSearchParams(Object.assign({}, this.$store.state.fetchState.query, { format: 'rss', page: -1, ...(this.$store.state.public && { token: this.$store.state.authToken }) })).toString()
)
)
},
},
created() {},
created() {
},
methods: {
onSelectHome() {
this.$router.push({ name: this.routes.HOME })
Expand Down Expand Up @@ -224,67 +222,67 @@ export default {
</script>
<style>
.breadcrumbs {
padding: 0 8px 0 44px;
display: flex;
position: absolute;
z-index: 100;
background: var(--color-main-background-translucent);
left: 0;
right: 0;
top: 0;
padding: 0 8px 0 44px;
display: flex;
position: absolute;
z-index: 100;
background: var(--color-main-background-translucent);
left: 0;
right: 0;
top: 0;
}

.breadcrumbs + * {
margin-top: 50px;
margin-top: 50px;
}

.breadcrumbs__path {
display: flex;
align-items: center;
flex: 0;
display: flex;
align-items: center;
flex: 0;
}

.breadcrumbs__path > * {
display: inline-block;
height: 30px;
padding: 5px 7px;
flex-shrink: 0;
display: inline-block;
height: 30px;
padding: 5px 7px;
flex-shrink: 0;
}

.breadcrumbs__path > *:not(.icon-breadcrumb) {
min-width: 30px;
opacity: 0.7;
min-width: 30px;
opacity: 0.7;
}

.breadcrumbs__path > *:hover {
opacity: 1;
opacity: 1;
}

.breadcrumbs__tags {
width: 300px;
flex: 1;
width: 300px;
flex: 1;
}

.breadcrumbs__tags .multiselect__tags {
border-top: none !important;
border-left: none !important;
border-right: none !important;
border-top: none !important;
border-left: none !important;
border-right: none !important;
}

.breadcrumbs__AddFolder {
margin-left: 5px;
padding: 0;
margin-top: -10px;
margin-left: 5px;
padding: 0;
margin-top: -10px;
}

.breadcrumbs__controls {
flex: 2;
display: flex;
flex-direction: row-reverse;
padding: 0;
flex: 2;
display: flex;
flex-direction: row-reverse;
padding: 0;
}

.breadcrumbs__controls > * {
min-width: 30px;
min-width: 30px;
Comment on lines 224 to +286
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tabs? :p

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooops, github only displayed your comments only after I merged. Ah will fix those tabs.

}
</style>
60 changes: 60 additions & 0 deletions src/components/Search.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<template>
<div>
<input v-show="show"
ref="searchInput"
type="text"
:placeholder="t('bookmarks', 'Search')"
@keyup="onSearch($event.target.value)">
<Actions>
<ActionButton icon="icon-search" @click="toggleSearchInput">
{{ t('bookmarks', 'Search') }}
</ActionButton>
</Actions>
</div>
</template>

<script>
import { privateRoutes, publicRoutes } from '../router'
import Actions from '@nextcloud/vue/dist/Components/Actions'
import ActionButton from '@nextcloud/vue/dist/Components/ActionButton'

export default {
name: 'Search',
components: { ActionButton, Actions },
data() {
return { show: false }
},
computed: {
routes() {
return this.$store.state.public ? privateRoutes : publicRoutes
},
},
methods: {
toggleSearchInput() {
this.show = !this.show
setTimeout(() => {
this.$refs.searchInput.focus()
}, 100)
},
onSearch(search) {
this.$router.push({ name: this.routes.SEARCH, params: { search } })
},
onResetSearch() {
this.$router.push({ name: this.routes.HOME })
},
},
}
</script>

<style scoped>
input[type=text] {
position: relative;
top: 5px;
margin: 0;
left: 42px;
padding-right: 40px;
border-left: none;
border-right: none;
border-top: none;
}
</style>
14 changes: 5 additions & 9 deletions src/components/ViewPrivate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export default {
},

async created() {
this.search = new OCA.Search(this.onSearch, this.onResetSearch)
// set loading indicator
this.$store.commit(mutations.FETCH_START, { type: 'bookmarks' })
await Promise.all([
Expand All @@ -86,6 +85,11 @@ export default {
case privateRoutes.UNTAGGED:
this.$store.dispatch(actions.FILTER_BY_UNTAGGED)
break
case privateRoutes.BOOKMARK:
await this.$store.dispatch(actions.LOAD_BOOKMARK, route.params.bookmark)
this.$store.dispatch(actions.OPEN_BOOKMARK, route.params.bookmark)
this.$store.commit(mutations.FETCH_END, { type: 'bookmarks' })
break
case privateRoutes.FOLDER:
this.$store.dispatch(actions.FILTER_BY_FOLDER, route.params.folder)
break
Expand Down Expand Up @@ -115,14 +119,6 @@ export default {
async reloadCount() {
return this.$store.dispatch(actions.COUNT_BOOKMARKS, -1)
},

onSearch(search) {
this.$router.push({ name: privateRoutes.SEARCH, params: { search } })
},

onResetSearch() {
this.$router.push({ name: privateRoutes.HOME })
},
},
}
</script>
Expand Down
8 changes: 0 additions & 8 deletions src/components/ViewPublic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,6 @@ export default {
async reloadFolders() {
return this.$store.dispatch(actions.LOAD_FOLDERS)
},

onSearch(search) {
this.$router.push({ name: this.routes.SEARCH, params: { search } })
},

onResetSearch() {
this.$router.push({ name: this.routes.HOME })
},
},
}
</script>
Expand Down
8 changes: 7 additions & 1 deletion src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const privateRoutes = {
RECENT: 'recent',
SEARCH: 'search',
FOLDER: 'folder',
BOOKMARK: 'bookmark',
TAGS: 'tags',
UNTAGGED: 'untagged',
BOOKMARKLET: 'bookmarklet',
Expand Down Expand Up @@ -48,10 +49,15 @@ export default new Router({
component: ViewPrivate,
},
{
path: '/folder/:folder',
path: '/folders/:folder',
name: privateRoutes.FOLDER,
component: ViewPrivate,
},
{
path: '/bookmarks/:bookmark',
name: privateRoutes.BOOKMARK,
component: ViewPrivate,
},
{
path: '/tags/:tags',
name: privateRoutes.TAGS,
Expand Down
Loading