📚 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
Improve app design & public link permissions
Smaug673924b1c946e163
diff --git a/backend/controllers/nodes.controller.go b/backend/controllers/nodes.controller.goindex 5ccd1d55..a0871893 100644--- a/backend/controllers/nodes.controller.go+++ b/backend/controllers/nodes.controller.go@@ -188,7 +188,7 @@ func (ctr *Controller) UpdateNode(c *gin.Context) (int, any) {return http.StatusInternalServerError, err}connectedUserId, userConnectedLevel, err := utils.NodePermission(c, db_node, ctr.app.Services.Permissions, utils.WRITE)- if err != nil && db_node.Access < 2 {+ if err != nil && (db_node.Access < 2 || *db_node.Accessibility != 3) {return http.StatusUnauthorized, err}node := &models.Node{}@@ -201,6 +201,7 @@ func (ctr *Controller) UpdateNode(c *gin.Context) (int, any) {node.ParentId = db_node.ParentIdnode.UserId = db_node.UserIdnode.Accessibility = db_node.Accessibility+ node.Access = db_node.Access}node = &models.Node{Id: nodeId,@@ -215,6 +216,7 @@ func (ctr *Controller) UpdateNode(c *gin.Context) (int, any) {Icon: node.Icon,Color: node.Color,Accessibility: node.Accessibility,+ Access: node.Access,Display: node.Display,Order: node.Order,Content: node.Content,diff --git a/backend/services/node.service.go b/backend/services/node.service.goindex ad82b6a7..3413b055 100644--- a/backend/services/node.service.go+++ b/backend/services/node.service.go@@ -28,7 +28,7 @@ func (s *Service) GetAllNodes(userId types.Snowflake) ([]*models.Node, error) {rows, err := s.db.Query(`WITH RECURSIVE user_nodes AS (-- 1. Every node owned by the userSELECT n.id, n.user_id, n.parent_id, n.name, n.description, n.tags, n.role, n.color, n.icon, n.theme,- n.accessibility, n.display, n.order, n.size, n.metadata, n.created_timestamp, n.updated_timestamp+ n.accessibility, n.access, n.display, n.order, n.size, n.metadata, n.created_timestamp, n.updated_timestampFROM nodes nWHERE n.user_id = ?@@ -36,7 +36,7 @@ func (s *Service) GetAllNodes(userId types.Snowflake) ([]*models.Node, error) {-- 2. Child nodes of owned nodes (even if not owned by the user)SELECT c.id, c.user_id, c.parent_id, c.name, c.description, c.tags, c.role, c.color, c.icon, c.theme,- c.accessibility, c.display, c.order, c.size, c.metadata, c.created_timestamp, c.updated_timestamp+ c.accessibility, c.access, c.display, c.order, c.size, c.metadata, c.created_timestamp, c.updated_timestampFROM nodes cJOIN user_nodes un ON un.id = c.parent_id)@@ -60,6 +60,7 @@ SELECT * FROM user_nodes ORDER BY role, 'order' DESC, name;`, userId)&node.Icon,&node.Theme,&node.Accessibility,+ &node.Access,&node.Display,&node.Order,&node.Size,@@ -81,7 +82,7 @@ func (s *Service) GetSharedNodes(userId types.Snowflake) ([]*models.Node, error)rows, err := s.db.Query(`WITH RECURSIVE accessible_nodes AS (SELECT n.id, n.user_id, n.parent_id, n.name, n.description, n.tags, n.role, n.color, n.icon, n.theme,- n.accessibility, n.display, n.order, n.size, n.metadata, n.created_timestamp, n.updated_timestamp+ n.accessibility, n.access, n.display, n.order, n.size, n.metadata, n.created_timestamp, n.updated_timestampFROM nodes nJOIN permissions p ON p.node_id = n.idWHERE p.user_id = ?@@ -89,7 +90,7 @@ func (s *Service) GetSharedNodes(userId types.Snowflake) ([]*models.Node, error)UNIONSELECT c.id, c.user_id, c.parent_id, c.name, c.description, c.tags, c.role, c.color, c.icon, c.theme,- c.accessibility, c.display, c.order, c.size, c.metadata, c.created_timestamp, c.updated_timestamp+ c.accessibility, c.access, c.display, c.order, c.size, c.metadata, c.created_timestamp, c.updated_timestampFROM nodes cJOIN accessible_nodes an ON an.id = c.parent_id)@@ -115,6 +116,7 @@ func (s *Service) GetSharedNodes(userId types.Snowflake) ([]*models.Node, error)&node.Icon,&node.Theme,&node.Accessibility,+ &node.Access,&node.Display,&node.Order,&node.Size,@@ -167,7 +169,7 @@ func (s *Service) GetSharedNodes(userId types.Snowflake) ([]*models.Node, error)func (s *Service) GetAllNodeBackup(user_id types.Snowflake) ([]*models.Node, error) {var nodes = make([]*models.Node, 0)- rows, err := s.db.Query("SELECT `id`, `user_id`, `parent_id`, `name`, `description`, `tags`, `role`, `color`, `icon`, `thumbnail`, `theme`, `accessibility`, `display`, `order`, `content`, `content_compiled`, `size`, `metadata`, `created_timestamp`, `updated_timestamp` FROM nodes WHERE user_id = ?", user_id)+ rows, err := s.db.Query("SELECT `id`, `user_id`, `parent_id`, `name`, `description`, `tags`, `role`, `color`, `icon`, `thumbnail`, `theme`, `accessibility`, `access`, `display`, `order`, `content`, `content_compiled`, `size`, `metadata`, `created_timestamp`, `updated_timestamp` FROM nodes WHERE user_id = ?", user_id)if err != nil {return nil, err}@@ -186,6 +188,7 @@ func (s *Service) GetAllNodeBackup(user_id types.Snowflake) ([]*models.Node, err&node.Thumbnail,&node.Theme,&node.Accessibility,+ &node.Access,&node.Display,&node.Order,&node.Content,@@ -215,7 +218,7 @@ func (s *Service) GetUserUploadsSize(userId types.Snowflake) (int64, error) {func (s *Service) GetPublicNode(nodeId types.Snowflake) (*models.Node, error) {var node models.Node- err := s.db.QueryRow("SELECT `id`, `user_id`, `parent_id`, `name`, `description`, `tags`, `role`, `color`, `icon`, `thumbnail`, `theme`, `accessibility`, `display`, `order`, `content`, `content_compiled`, `size`, `metadata`, `created_timestamp`, `updated_timestamp` FROM nodes WHERE id = ? AND accessibility = 3", nodeId).Scan(+ err := s.db.QueryRow("SELECT `id`, `user_id`, `parent_id`, `name`, `description`, `tags`, `role`, `color`, `icon`, `thumbnail`, `theme`, `accessibility`, `access`, `display`, `order`, `content`, `content_compiled`, `size`, `metadata`, `created_timestamp`, `updated_timestamp` FROM nodes WHERE id = ? AND accessibility = 3", nodeId).Scan(&node.Id,&node.UserId,&node.ParentId,@@ -228,6 +231,7 @@ func (s *Service) GetPublicNode(nodeId types.Snowflake) (*models.Node, error) {&node.Thumbnail,&node.Theme,&node.Accessibility,+ &node.Access,&node.Display,&node.Order,&node.Content,@@ -244,7 +248,7 @@ func (s *Service) GetPublicNode(nodeId types.Snowflake) (*models.Node, error) {func (s *Service) GetNode(nodeId types.Snowflake) (*models.Node, error) {var node models.Node- err := s.db.QueryRow("SELECT `id`, `user_id`, `parent_id`, `name`, `description`, `tags`, `role`, `color`, `icon`, `thumbnail`, `theme`, `accessibility`, `display`, `order`, `content`, `content_compiled`, `size`, `metadata`, `created_timestamp`, `updated_timestamp` FROM nodes WHERE id = ?", nodeId).Scan(+ err := s.db.QueryRow("SELECT `id`, `user_id`, `parent_id`, `name`, `description`, `tags`, `role`, `color`, `icon`, `thumbnail`, `theme`, `accessibility`, `access`, `display`, `order`, `content`, `content_compiled`, `size`, `metadata`, `created_timestamp`, `updated_timestamp` FROM nodes WHERE id = ?", nodeId).Scan(&node.Id,&node.UserId,&node.ParentId,@@ -257,6 +261,7 @@ func (s *Service) GetNode(nodeId types.Snowflake) (*models.Node, error) {&node.Thumbnail,&node.Theme,&node.Accessibility,+ &node.Access,&node.Display,&node.Order,&node.Content,@@ -272,7 +277,7 @@ func (s *Service) GetNode(nodeId types.Snowflake) (*models.Node, error) {}func (s *Service) CreateNode(node *models.Node) error {- _, err := s.db.Exec("INSERT INTO nodes (`id`, `user_id`, `parent_id`, `name`, `description`, `tags`, `role`, `color`, `icon`, `thumbnail`, `theme`, `accessibility`, `display`, `order`, `content`, `content_compiled`, `size`, `metadata`, `created_timestamp`, `updated_timestamp`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",+ _, err := s.db.Exec("INSERT INTO nodes (`id`, `user_id`, `parent_id`, `name`, `description`, `tags`, `role`, `color`, `icon`, `thumbnail`, `theme`, `accessibility`, `access`, `display`, `order`, `content`, `content_compiled`, `size`, `metadata`, `created_timestamp`, `updated_timestamp`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",node.Id,node.UserId,node.ParentId,@@ -285,6 +290,7 @@ func (s *Service) CreateNode(node *models.Node) error {node.Thumbnail,node.Theme,node.Accessibility,+ node.Access,node.Display,node.Order,node.Content,@@ -297,7 +303,7 @@ func (s *Service) CreateNode(node *models.Node) error {}func (s *Service) UpdateNode(node *models.Node) error {- _, err := s.db.Exec("UPDATE nodes SET `parent_id` = ?, `user_id` = ?, `name` = ?, `description` = ?, `tags` = ?, `role` = ?, `color` = ?, `icon` = ?, `thumbnail` = ?, `theme` = ?, `accessibility` = ?, `display` = ?, `order` = ?, `content` = ?, `content_compiled` = ?, `metadata` = ?, `updated_timestamp` = ? WHERE id = ?",+ _, err := s.db.Exec("UPDATE nodes SET `parent_id` = ?, `user_id` = ?, `name` = ?, `description` = ?, `tags` = ?, `role` = ?, `color` = ?, `icon` = ?, `thumbnail` = ?, `theme` = ?, `accessibility` = ?, `access` = ?, `display` = ?, `order` = ?, `content` = ?, `content_compiled` = ?, `metadata` = ?, `updated_timestamp` = ? WHERE id = ?",node.ParentId,node.UserId,node.Name,@@ -309,6 +315,7 @@ func (s *Service) UpdateNode(node *models.Node) error {node.Thumbnail,node.Theme,node.Accessibility,+ node.Access,node.Display,node.Order,node.Content,diff --git a/frontend/app/components/Node/NodePermissions.vue b/frontend/app/components/Node/NodePermissions.vueindex bddd7bda..10d85e73 100644--- a/frontend/app/components/Node/NodePermissions.vue+++ b/frontend/app/components/Node/NodePermissions.vue@@ -14,6 +14,10 @@><Icon name="new_tab" :small="true" fill="var(--font-color-light)" /><span>{{ link }}</span></a></p>+ <div class="access">+ <label for="access">Default permission for new users</label>+ <AppSelect v-model="node.access" :items="DOCUMENT_GENERAL_ACCESS" :searchable="false" size="150px" placeholder="Default" />+ </div></div><!-- Search + add --><form @submit.prevent>@@ -175,6 +179,7 @@ form {.info-secondary {color: var(--font-color-light);font-size: 14px;+ margin: 0;text-align: center;}@@ -199,6 +204,13 @@ form {}}+.access {+ display: flex;+ align-items: center;+ justify-content: space-between;+ margin-top: 10px;+}+button {padding: 4px 8px;border: none;diff --git a/frontend/app/composables/constants.ts b/frontend/app/composables/constants.tsindex 1b871bf4..7b58ca8d 100644--- a/frontend/app/composables/constants.ts+++ b/frontend/app/composables/constants.ts@@ -8,6 +8,10 @@ export const DOCUMENT_ACCESSIBILITIES: ANode[] = [{ id: 1, label: 'Private' },{ id: 3, label: 'Published' },];+export const DOCUMENT_GENERAL_ACCESS: ANode[] = [+ { id: 0, label: 'Viewer' },+ { id: 2, label: 'Editor' },+];export const DOCUMENT_SIZES = [{ label: 'Small', id: 0 },diff --git a/frontend/app/pages/(public)/doc/[id]/edit.vue b/frontend/app/pages/(public)/doc/[id]/edit.vuenew file mode 100644index 00000000..ac4faf12--- /dev/null+++ b/frontend/app/pages/(public)/doc/[id]/edit.vue@@ -0,0 +1,49 @@+<template>+ <MarkdownEditor v-if="document && !error" ref="editor" :doc="document" @save="data => save(data)" @auto-save="data => autoSave(data)" @exit="exit" />+</template>+<script lang="ts" setup>+import type { Node } from '~/stores';+import MarkdownEditor from '~/components/MarkdownEditor/LazyMarkdownEditor.vue';+const store = useNodesStore();+const route = useRoute();++const editor = ref();+const doc_id = route.params.id as string;+const document = ref<Node | undefined>(undefined);+const notifications = useNotifications();+const error: Ref<string> = ref('');++watchEffect(async () => {+ const docFromStore = store.getById(doc_id);+ if (!docFromStore) {+ try {+ document.value = await store.fetchPublic(doc_id);+ console.log(document.value);+ } catch {+ error.value = 'Document not found';+ }+ } else if (docFromStore?.partial) {+ try {+ document.value = await store.fetch({ id: doc_id });+ console.log(document.value);+ } catch {+ error.value = 'Document not found';+ }+ } else document.value = docFromStore;+});++definePageMeta({ breadcrumb: 'Edit' });++function save(doc: Node) {+ store+ .update(doc)+ .then(() => notifications.add({ type: 'success', title: 'Document successfully updated' }))+ .catch(e => notifications.add({ type: 'error', title: 'Error', message: e }));+}++function autoSave(doc: Node) {+ store.update(doc);+}++const exit = () => useRouter().push(`/doc/${doc_id}`);+</script>diff --git a/frontend/app/pages/(public)/doc/[id].vue b/frontend/app/pages/(public)/doc/[id]/index.vuesimilarity index 73%rename from frontend/app/pages/(public)/doc/[id].vuerename to frontend/app/pages/(public)/doc/[id]/index.vueindex 1fe49efa..11a405e3 100644--- a/frontend/app/pages/(public)/doc/[id].vue+++ b/frontend/app/pages/(public)/doc/[id]/index.vue@@ -33,9 +33,9 @@</template><script setup lang="ts">-import TableOfContent from '../../dashboard/docs/_components/table-of-content/TableOfContents.vue';-import DocumentSkeleton from '../../dashboard/docs/_components/DocumentSkeleton.vue';-import DocumentCardHeader from '../../dashboard/docs/_components/DocumentCardHeader.vue';+import TableOfContent from '@/pages/dashboard/docs/_components/table-of-content/TableOfContents.vue';+import DocumentSkeleton from '@/pages/dashboard/docs/_components/DocumentSkeleton.vue';+import DocumentCardHeader from '@/pages/dashboard/docs/_components/DocumentCardHeader.vue';import type { Node } from '@/stores';const route = useRoute();@@ -57,7 +57,6 @@ watchEffect(async () => {</script><style scoped lang="scss">-/* Grille : [1fr] [contenu 800px centré] [1fr pour loger la TOC] */.reader {display: grid;align-items: start;@@ -66,28 +65,26 @@ watchEffect(async () => {}.doc-container {- margin: 0; /* plus besoin d'auto */- grid-column: 2; /* colonne centrale */+ margin: 0;+ grid-column: 2;}@media screen and (width >= 810px) {.doc-container {- max-width: 800px; /* cohérent avec la colonne centrale */+ max-width: 800px;padding: 0 2rem;}}-/* La TOC vit dans la colonne de droite, sans décaler le centre */.toc {- position: sticky; /* optionnel : TOC sticky */+ position: sticky;top: 1rem;width: 100%;max-width: 320px;- grid-column: 3; /* colonne droite */- justify-self: start; /* colle à gauche de la colonne */+ grid-column: 3;+ justify-self: start;}-/* Cache la TOC quand la colonne droite devient trop étroite */@media screen and (width <= 1280px) {.toc {display: none;diff --git a/frontend/app/pages/dashboard/docs/_components/DocumentCardHeader.vue b/frontend/app/pages/dashboard/docs/_components/DocumentCardHeader.vueindex cfdf6167..a9089bf7 100644--- a/frontend/app/pages/dashboard/docs/_components/DocumentCardHeader.vue+++ b/frontend/app/pages/dashboard/docs/_components/DocumentCardHeader.vue@@ -5,17 +5,17 @@<DocumentCardHeaderSkeleton v-if="!doc" /><!-- Real content --><template v-else>- <p v-if="!public" class="top-row">+ <p class="top-row"><span style="display: flex; align-items: center; gap: 12px"><img v-if="user" :src="useAvatar(user)" class="avatar" /><span style="color: var(--font-color-light); font-size: 18px">{{ user?.username }}</span></span>- <DocumentCardHeaderActionRow :doc="doc" class="no-print" />+ <DocumentCardHeaderActionRow v-if="!public" :doc="doc" class="no-print" /></p><NuxtLink class="category" :to="`/dashboard/categories/${category?.id}`">{{ category?.name || 'Uncategorized' }}</NuxtLink><h1 class="title" :class="{ public: public }">{{ doc?.name }}</h1><p class="description">{{ doc?.description }}</p>- <div v-if="doc.tags" class="document-tags">+ <div v-if="doc.tags" class="tags"><tag v-for="tag in doc.tags.split(',')" :key="tag" class="primary">{{ tag.trim() }}</tag></div></template>@@ -68,6 +68,7 @@ p {font-family: Inter;}.top-row {+ margin-top: 6px;display: flex;align-items: center;justify-content: space-between;@@ -86,15 +87,16 @@ p {}.category {+ display: block;+ padding-top: 8px;font-size: 20px;font-weight: 500;color: var(--font-color-light);}}-.document-tags {+.tags {display: flex;flex-wrap: wrap;- margin-bottom: 10px;padding-top: 5px;}@@ -119,7 +121,7 @@ p {.icon,.description,- .document-tags,+ .tags,.top-row,.user {display: none;diff --git a/frontend/app/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue b/frontend/app/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vueindex 08a69cdd..ee5c8d60 100644--- a/frontend/app/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue+++ b/frontend/app/pages/dashboard/docs/_components/DocumentCardHeaderActionRow.vue@@ -66,7 +66,7 @@ function exportMarkdown() {<style lang="scss" scoped>.row {display: flex;- margin: 0.75rem 0.5rem;+ margin: 0 0.5rem 6px 0;}.row svg {cursor: pointer;diff --git a/frontend/app/stores/db_strustures.d.ts b/frontend/app/stores/db_strustures.d.tsindex bcae3fb8..36d7afbc 100644--- a/frontend/app/stores/db_strustures.d.ts+++ b/frontend/app/stores/db_strustures.d.ts@@ -35,6 +35,7 @@ export interface DB_Node {thumbnail?: string;theme?: string;accessibility?: number; // 1 Visible; 2 Draft; 3 Archived;+ access?: number; // 1 Viewer; 2 Editor;display?: number; // 1 List; 2 Grid;order?: number; // -1 for pinned and -2 for bookmarkcontent?: string;