From b9778b7a28be0351008fde29b9ad3f61300b83a7 Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Thu, 17 Aug 2023 11:43:00 +0200 Subject: [PATCH] Allow specifying default folder in bookmarklet URL fixes #2017 Signed-off-by: Marcel Klehr --- src/components/Settings.vue | 7 ++++++- src/components/ViewBookmarklet.vue | 6 +++++- src/router.js | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/Settings.vue b/src/components/Settings.vue index 8fb7c7ab..ba5448ac 100644 --- a/src/components/Settings.vue +++ b/src/components/Settings.vue @@ -73,6 +73,7 @@ import { generateUrl } from '@nextcloud/router' import { actions } from '../store/index.js' import { getRequestToken } from '@nextcloud/auth' import { getFilePickerBuilder } from '@nextcloud/dialogs' +import { privateRoutes } from '../router.js' export default { name: 'Settings', @@ -103,7 +104,11 @@ export default { bookmarklet() { const bookmarkletUrl = window.location.origin + generateUrl('/apps/bookmarks/bookmarklet') - return `javascript:(function(){var a=window,b=document,c=encodeURIComponent,e=c(document.title),d=a.open('${bookmarkletUrl}?url='+c(b.location)+'&title='+e,'bkmk_popup','left='+((a.screenX||a.screenLeft)+10)+',top='+((a.screenY||a.screenTop)+10)+',height=650px,width=550px,resizable=1,alwaysRaised=1');a.setTimeout(function(){d.focus()},300);})();` + let queryStringExtension = '' + if (this.$route.name === privateRoutes.FOLDER) { + queryStringExtension = `+'&folderId=${this.$route.params.folder}'` + } + return `javascript:(function(){var a=window,b=document,c=encodeURIComponent,e=c(document.title),d=a.open('${bookmarkletUrl}?url='+c(b.location)+'&title='+e${queryStringExtension},'bkmk_popup','left='+((a.screenX||a.screenLeft)+10)+',top='+((a.screenY||a.screenTop)+10)+',height=650px,width=550px,resizable=1,alwaysRaised=1');a.setTimeout(function(){d.focus()},300);})();` }, archivePath() { return this.$store.state.settings.archivePath diff --git a/src/components/ViewBookmarklet.vue b/src/components/ViewBookmarklet.vue index 6d8badf9..488622a9 100644 --- a/src/components/ViewBookmarklet.vue +++ b/src/components/ViewBookmarklet.vue @@ -73,6 +73,10 @@ export default { type: String, default: '', }, + folderId: { + type: String, + default: '', + }, }, data() { return { @@ -86,7 +90,7 @@ export default { exists: false, loading: true, showPicker: false, - folder: -1, + folder: parseInt(this.folderId || -1), } }, computed: { diff --git a/src/router.js b/src/router.js index 874eb710..b296fc15 100644 --- a/src/router.js +++ b/src/router.js @@ -103,7 +103,7 @@ export default new Router({ path: '/bookmarklet', name: privateRoutes.BOOKMARKLET, component: ViewBookmarklet, - props: (route) => ({ url: route.query.url, title: route.query.title }), + props: (route) => ({ url: route.query.url, title: route.query.title, folderId: route.query.folderId }), }, { path: '/public/:token',