📚 The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.
Vue dockergolangkanbanknowledge-baseknowledge-managementmarkdownnote-takingnotesnotes-appnotionnuxtnuxtjsoffline-firstoidcpwaselfhostedssovuevuejswiki
Simplify HTML structure and fix server fetch
Smaug673935d3b0eb07f9
diff --git a/backend/config.ts b/backend/config.tsindex 43d509de..2fbbf1cc 100644--- a/backend/config.ts+++ b/backend/config.ts@@ -3,7 +3,7 @@ import { resolve } from 'path';export const config = {max_file_size: 20 * 1024 * 1024, // 20MBupload_path: resolve(__dirname, '../uploads'),- access_token_expiration: '10s',- access_token_expiration_ms: 10 * 1000,+ access_token_expiration: '1800s',+ access_token_expiration_ms: 1800 * 1000,refresh_token_expiration: 7 * 24 * 60 * 60 * 1000,};diff --git a/frontend/components/Icon.vue b/frontend/components/Icon.vueindex 36e07581..d2a16087 100644--- a/frontend/components/Icon.vue+++ b/frontend/components/Icon.vue@@ -1,5 +1,5 @@<template>- <i v-html="icon" class="icon" :style="{ fill: props.fill || 'var(--red)' }" :class="{ fill: props.fill, big: props.big }"></i>+ <i v-html="icon" class="icon" :style="{ fill: props.fill }" :class="{ fill: props.fill, big: props.big }"></i></template><script setup lang="ts">diff --git a/frontend/components/Sidebar/CollapseItem.vue b/frontend/components/Sidebar/CollapseItem.vueindex 9a258694..37df91b2 100644--- a/frontend/components/Sidebar/CollapseItem.vue+++ b/frontend/components/Sidebar/CollapseItem.vue@@ -1,63 +1,34 @@<template>- <div v-if="item.childrens?.length">- <div v-if="root" class="collapse-header">- <SidebarItem :item="item" @click="toggleShow">- <svg style="margin-left:auto;" :class="{ 'rotated': !show }" xmlns="http://www.w3.org/2000/svg" height="24"- viewBox="0 -960 960 960" width="24">- <path d="M480-345 240-585l56-56 184 184 184-184 56 56-240 240Z" />- </svg>- </SidebarItem>- </div>- <div v-else class="collapse-header">- <SidebarItem :item="item" />- </div>- <div v-if="show" class="collapse-body">- <div v-for="(child, index) in item.childrens">- <div style="margin-left:20px;">- <CollapseItem v-if="child.childrens?.length" :item="child" :key="index" />- <SidebarItem v-else :item="child" />- </div>- </div>- </div>- </div>- <SidebarItem v-else :item="item" />+ <div v-if="item.childrens?.length">+ <SidebarItem v-if="root" :item="item" @click="toggleShow" class="collapse-header">+ <svg style="margin-left: auto" :class="{ rotated: !show }" xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24">+ <path d="M480-345 240-585l56-56 184 184 184-184 56 56-240 240Z" />+ </svg>+ </SidebarItem>+ <SidebarItem v-else :item="item" class="collapse-header" />+ <div v-if="show" class="collapse-body" v-for="(child, index) in item.childrens" style="margin-left: 20px">+ <CollapseItem v-if="child.childrens?.length" :item="child" :key="index" />+ <SidebarItem v-else :item="child" />+ </div>+ </div>+ <SidebarItem v-else :item="item" /></template><script setup lang="ts">import type { Item } from './tree_builder';-import SidebarItem from './SidebarItem.vue';-defineProps<{ item: Item, root?: boolean }>();+defineProps<{ item: Item; root?: boolean }>();const show = ref(true);-const toggleShow = () => show.value = !show.value;+const toggleShow = () => (show.value = !show.value);</script><style lang="scss" scoped>-h2 {- font-size: 16px;- font-weight: 600;- border: none;- margin: 3px;- line-height: 24px;- padding: 0 !important;-}-.collapse-header {- display: flex;- align-items: center;- justify-content: space-between;-- svg {- height: 20px;- fill: var(--font-color);-- :hover {- cursor: pointer;- }-- &.rotated {- transform: rotate(-90deg);- }- }+ svg {+ fill: var(--font-color);+ &.rotated {+ transform: rotate(-90deg);+ }+ }}-</style>\ No newline at end of file+</style>diff --git a/frontend/components/Sidebar/Search.vue b/frontend/components/Sidebar/Search.vueindex 81c9b2aa..6e73122a 100644--- a/frontend/components/Sidebar/Search.vue+++ b/frontend/components/Sidebar/Search.vue@@ -16,8 +16,6 @@</template><script setup lang="ts">-import { useDocumentsStore } from '~/stores';-const documents = computed(() => useDocumentsStore().getAll.filter(c => c.name.toLowerCase().includes(filter.value.toLowerCase())));const filter = ref<string>('');const showSearchModal = ref<boolean>(false);diff --git a/frontend/components/Sidebar/Sidebar.vue b/frontend/components/Sidebar/Sidebar.vueindex 4b1629d9..4e2550da 100644--- a/frontend/components/Sidebar/Sidebar.vue+++ b/frontend/components/Sidebar/Sidebar.vue@@ -11,11 +11,11 @@</section><input type="text" placeholder="Search or ctrl + q" class="search" v-model="filter" />- <div class="user" v-if="usrStr.user">- <img :src="useAvatar(usrStr.user)" alt="Avatar" style="width: 25px; height: 25px; border-radius: 50%" />+ <div class="user" v-if="userStore.user">+ <img :src="useAvatar(userStore.user)" alt="Avatar" style="width: 25px; height: 25px; border-radius: 50%" /><div>- <div>{{ usrStr.user.username }}</div>- <div class="email">{{ usrStr.user.email }}</div>+ <div>{{ userStore.user.username }}</div>+ <div class="email">{{ userStore.user.email }}</div></div></div><Search />@@ -30,14 +30,14 @@ import Resizable from './Resizable.vue';import IconClose from './IconClose.vue';import IconApp from './IconApp.vue';import Search from './Search.vue';-import { useCategoriesStore, useDocumentsStore, useUserStore, type Category } from '~/stores';import { ItemsManager, type Item } from './tree_builder';import { navigationItems } from './helpers';+import type { Category } from '~/stores';const { isOpened, hasSidebar } = useSidebar();const categoriesStore = useCategoriesStore();const documentsStore = useDocumentsStore();-const usrStr = useUserStore();+const userStore = useUserStore();const filter = ref<string>('');const showSearchModal = ref<boolean>(false);diff --git a/frontend/components/Sidebar/SidebarItem.vue b/frontend/components/Sidebar/SidebarItem.vueindex 597c88a3..b24d8999 100644--- a/frontend/components/Sidebar/SidebarItem.vue+++ b/frontend/components/Sidebar/SidebarItem.vue@@ -1,15 +1,13 @@<template>- <NuxtLink class="item" :to="item.route" @click="onClick" :draggable="draggable" @dragstart="dragStart"- @dragover.prevent="dragOver" @drop="drop" @dragleave="dragLeave" :class="{ 'drag-over': isDragOver }">- <Icon :name="getIcon(item)" />- <span>{{ item.title }}</span>- <slot></slot>- </NuxtLink>+ <span class="item" @click="onClick" :draggable="draggable" @dragstart="dragStart" @dragover.prevent="dragOver" @drop="drop" @dragleave="dragLeave" :class="{ 'drag-over': isDragOver }">+ <Icon :name="getIcon(item)" />+ <NuxtLink :to="item.route" style="width: 100%">{{ item.title }} </NuxtLink>+ <NuxtLink to="/dashboard/docs/new" class="new"> <Icon name="plus" v-if="item.data.type === 'category' && item.parent_id" fill="var(--font-color)" /> </NuxtLink>+ <slot></slot>+ </span></template><script setup lang="ts">-import { useDocumentsStore, useCategoriesStore } from '~/stores';-const documentStore = useDocumentsStore();const categoriesStore = useCategoriesStore();@@ -19,121 +17,123 @@ const { isOpened } = useSidebar();const props = defineProps<{ item: Item }>();function getIcon(item: Item) {- if ('icon' in item.data && item.data.icon) return item.data.icon;- if (item.data.type === 'category') return 'folder';- if (item.data.type === 'document' && item.childrens?.length) return 'file_parent';- if (item.data.type === 'document' && item.data.accessibility == 2) return 'draft';- if (item.data.type === 'document' && item.data.accessibility == 3) return 'archive';- return 'file';+ if ('icon' in item.data && item.data.icon) return item.data.icon;+ if (item.data.type === 'category') return 'folder';+ if (item.data.type === 'document' && item.childrens?.length) return 'file_parent';+ if (item.data.type === 'document' && item.data.accessibility == 2) return 'draft';+ if (item.data.type === 'document' && item.data.accessibility == 3) return 'archive';+ return 'file';}const draggable = ref<boolean>(true);const isDragOver = ref<boolean>(false);const onClick = () => {- if (isMobile()) isOpened.value = false;+ if (isMobile()) isOpened.value = false;};const dragStart = (event: DragEvent) => {- // Stocke l'ID de l'élément en cours de glissement- event.dataTransfer!.setData('text/plain', props.item.id.toString());+ // Stocke l'ID de l'élément en cours de glissement+ event.dataTransfer!.setData('text/plain', props.item.id.toString());};const dragOver = () => {- // Indique que l'élément est survolé lors du glisser-déposer- isDragOver.value = true;+ // Indique que l'élément est survolé lors du glisser-déposer+ isDragOver.value = true;};const dragLeave = () => {- // Réinitialise l'état de survol lorsque l'élément quitte la zone de dépôt- isDragOver.value = false;+ // Réinitialise l'état de survol lorsque l'élément quitte la zone de dépôt+ isDragOver.value = false;};const drop = async (event: DragEvent) => {- isDragOver.value = false;- const draggedItemId = event.dataTransfer!.getData('text/plain');-- let draggedItem = documentStore.getById(draggedItemId) || categoriesStore.getById(draggedItemId) || navigationItems.find((item) => item.id === draggedItemId);-- if (!draggedItem) return;-- if (draggedItem.type === "document" && draggedItem.partial) {- draggedItem = await documentStore.fetch({ id: draggedItem.id });- }-- if (draggedItem.type === "document" && props.item.data.type === "category") { // Move document to category- documentStore.update(- { ...draggedItem, category: props.item.id, parent_id: null }- );- }- if (draggedItem.type === "category" && props.item.data.type === "category") { // Move category to category- if (draggedItem.id === props.item.id) return; // Prevent moving to the same category- categoriesStore.update(- { ...draggedItem, parent_id: props.item.id }- );- }- if (draggedItem.type === "document" && props.item.data.type === "document") { // Move document to document- if (documentStore.getAllChildrensIds(draggedItem.id).includes(props.item.parent_id)) return; // Prevent moving parent to child- if (draggedItem.id === props.item.id) return; // Prevent moving to the same document- documentStore.update(- { ...draggedItem, parent_id: props.item.id, category: props.item.data.category }- );- }- if (draggedItem.type === "category" && props.item.data.type === "category") { // Move category to category- if (draggedItem.id === props.item.id) return; // Prevent moving to the same category- categoriesStore.update(- { ...draggedItem, parent_id: props.item.id }- );- }- if (draggedItem.type === "category" && props.item.data.type === "default") { // Move category to root- categoriesStore.update(- { ...draggedItem, parent_id: undefined }- );- }- if (draggedItem.type === "document" && props.item.data.type === "default") { // Move document to root- documentStore.update(- { ...draggedItem, parent_id: undefined, category: undefined }- );- }-+ isDragOver.value = false;+ const draggedItemId = event.dataTransfer!.getData('text/plain');++ let draggedItem = documentStore.getById(draggedItemId) || categoriesStore.getById(draggedItemId) || navigationItems.find(item => item.id === draggedItemId);++ if (!draggedItem) return;++ if (draggedItem.type === 'document' && draggedItem.partial) {+ draggedItem = await documentStore.fetch({ id: draggedItem.id });+ }++ if (draggedItem.type === 'document' && props.item.data.type === 'category') {+ // Move document to category+ documentStore.update({ ...draggedItem, category: props.item.id, parent_id: null });+ }+ if (draggedItem.type === 'category' && props.item.data.type === 'category') {+ // Move category to category+ if (draggedItem.id === props.item.id) return; // Prevent moving to the same category+ categoriesStore.update({ ...draggedItem, parent_id: props.item.id });+ }+ if (draggedItem.type === 'document' && props.item.data.type === 'document') {+ // Move document to document+ if (documentStore.getAllChildrensIds(draggedItem.id).includes(props.item.parent_id)) return; // Prevent moving parent to child+ if (draggedItem.id === props.item.id) return; // Prevent moving to the same document+ documentStore.update({ ...draggedItem, parent_id: props.item.id, category: props.item.data.category });+ }+ if (draggedItem.type === 'category' && props.item.data.type === 'category') {+ // Move category to category+ if (draggedItem.id === props.item.id) return; // Prevent moving to the same category+ categoriesStore.update({ ...draggedItem, parent_id: props.item.id });+ }+ if (draggedItem.type === 'category' && props.item.data.type === 'default') {+ // Move category to root+ categoriesStore.update({ ...draggedItem, parent_id: undefined });+ }+ if (draggedItem.type === 'document' && props.item.data.type === 'default') {+ // Move document to root+ documentStore.update({ ...draggedItem, parent_id: undefined, category: undefined });+ }};</script><style lang="scss" scoped>.item {- display: flex;- justify-content: flex-start;- align-items: center;- padding: 0 2.5px;- margin: 2.5px 0;- border-radius: 5px;- color: var(--font-color);- cursor: pointer;- width: 98%;-- &:hover,- &.router-link-exact-active {- background: var(--bg-contrast-2);- }-- .icon {- display: flex;- align-items: center;-- &:deep(svg) {- fill: var(--blue);- width: 20px;- max-height: 22px;- margin-right: 5px;-- path {- fill: var(--blue);- }- }- }+ display: flex;+ justify-content: flex-start;+ align-items: center;+ padding: 0 2.5px;+ margin: 2.5px 0;+ border-radius: 5px;+ color: var(--font-color);+ cursor: pointer;+ width: 98%;++ &:hover,+ &.router-link-exact-active {+ background: var(--bg-contrast-2);+ }++ .icon {+ display: flex;+ align-items: center;++ &:deep(svg) {+ fill: var(--blue);+ width: 20px;+ max-height: 22px;+ margin-right: 5px;++ path {+ fill: var(--blue);+ }+ }+ }}.drag-over {- border-bottom: 2px solid var(--blue);- box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);+ border-bottom: 2px solid var(--blue);+ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);+}+.new {+ display: none;+ &:deep(svg) {+ fill: inherit !important;+ }+}+.item:hover .new {+ display: block;}-</style>\ No newline at end of file+</style>diff --git a/frontend/composables/icons.ts b/frontend/composables/icons.tsindex 3d383d73..50588c73 100644--- a/frontend/composables/icons.ts+++ b/frontend/composables/icons.ts@@ -7,7 +7,8 @@ const icons = {security: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="m438-338 226-226-57-57-169 169-84-84-57 57 141 141Zm42 258q-139-35-229.5-159.5T160-516v-244l320-120 320 120v244q0 152-90.5 276.5T480-80Zm0-84q104-33 172-132t68-220v-189l-240-90-240 90v189q0 121 68 220t172 132Zm0-316Z"/></svg>`,close: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"stroke-linecap="round" stroke-linejoin="round" class="h-4 w-4"><path d="M18 6 6 18"></path><path d="m6 6 12 12"></path></svg>`,profil: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M234-276q51-39 114-61.5T480-360q69 0 132 22.5T726-276q35-41 54.5-93T800-480q0-133-93.5-226.5T480-800q-133 0-226.5 93.5T160-480q0 59 19.5 111t54.5 93Zm246-164q-59 0-99.5-40.5T340-580q0-59 40.5-99.5T480-720q59 0 99.5 40.5T620-580q0 59-40.5 99.5T480-440Zm0 360q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q53 0 100-15.5t86-44.5q-39-29-86-44.5T480-280q-53 0-100 15.5T294-220q39 29 86 44.5T480-160Zm0-360q26 0 43-17t17-43q0-26-17-43t-43-17q-26 0-43 17t-17 43q0 26 17 43t43 17Zm0-60Zm0 360Z"/></svg>`,- search: `<svg xmlns="http://www.w3.org/2000/svg"height="24" viewBox="0 0 24 24" fill="none"stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"class="mr-2 h-4 w-4 shrink-0 opacity-50"><circle cx="11" cy="11" r="8"></circle><path d="m21 21-4.3-4.3"></path></svg>`,+ search: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"class="mr-2 h-4 w-4 shrink-0 opacity-50"><circle cx="11" cy="11" r="8"></circle><path d="m21 21-4.3-4.3"></path></svg>`,+ plus: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="M440-440H200v-80h240v-240h80v240h240v80H520v240h-80v-240Z"/></svg>`,draft: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path style="fill:var(--turquoise)" d="M240-80q-33 0-56.5-23.5T160-160v-640q0-33 23.5-56.5T240-880h320l240 240v480q0 33-23.5 56.5T720-80H240Zm280-520v-200H240v640h480v-440H520ZM240-800v200-200 640-640Z"/></svg>`,folder: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path style="fill:var(--yellow);" d="M160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h240l80 80h320q33 0 56.5 23.5T880-640H447l-80-80H160v480l96-320h684L837-217q-8 26-29.5 41.5T760-160H160Zm84-80h516l72-240H316l-72 240Zm0 0 72-240-72 240Zm-84-400v-80 80Z"/></svg>`,diff --git a/frontend/pages/dashboard.vue b/frontend/pages/dashboard.vueindex cd363fac..e2ebccb6 100644--- a/frontend/pages/dashboard.vue+++ b/frontend/pages/dashboard.vue@@ -9,7 +9,5 @@</template><script setup lang="ts">definePageMeta({ breadcrumb: 'Home' });-useDocumentsStore().fetch();-useCategoriesStore().fetch();-useUserStore().fetch();+await Promise.all([useDocumentsStore().fetch(), useCategoriesStore().fetch(), useUserStore().fetch()]);</script>diff --git a/old.txt b/old.txtdeleted file mode 100644index 9bdd2e6e..00000000--- a/old.txt+++ /dev/null@@ -1,21 +0,0 @@-const mysqldump = spawn('mysqldump', [- '-u',- `${process.env.DATABASE_USER}`,- `-p${process.env.DATABASE_PASSWORD}`,- 'alexandrie',- ]);-- const wstream = createWriteStream(`${this.app.config.upload_path}/backups/${name}.sql`);- const backupPromise = new Promise<void | string>((resolve, reject) => {- mysqldump.stdout- .pipe(wstream)- .on('finish', function () {- resolve();- })- .on('error', function (err) {- reject(err.message);- });- });- backupPromise- .then(() => res.json(success({ url: `/backups/${name}.sql` })))- .catch((err: Error) => res.json(error(err.message)));\ No newline at end of file