π 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
Add new document properties (color, thumbnail, theme, icon)
Smaug673990cb3f32c53e
diff --git a/backend/controllers/documents.controller.go b/backend/controllers/documents.controller.goindex 48edb862..07f6f0f2 100644--- a/backend/controllers/documents.controller.go+++ b/backend/controllers/documents.controller.go@@ -93,6 +93,10 @@ func (ctr *Controller) CreateDocument(c *gin.Context) (int, any) {Description: document.Description,Tags: document.Tags,Pinned: document.Pinned,+ Thumbnail: document.Thumbnail,+ Theme: document.Theme,+ Icon: document.Icon,+ Color: document.Color,Category: document.Category,ParentId: document.ParentId,Accessibility: document.Accessibility,@@ -142,6 +146,10 @@ func (ctr *Controller) UpdateDocument(c *gin.Context) (int, any) {Description: document.Description,Tags: document.Tags,Pinned: document.Pinned,+ Thumbnail: document.Thumbnail,+ Theme: document.Theme,+ Icon: document.Icon,+ Color: document.Color,Category: document.Category,ParentId: document.ParentId,Accessibility: document.Accessibility,diff --git a/backend/migrations/000009_doc_meta.down.sql b/backend/migrations/000009_doc_meta.down.sqlnew file mode 100644index 00000000..e69de29bdiff --git a/backend/migrations/000009_doc_meta.up.sql b/backend/migrations/000009_doc_meta.up.sqlnew file mode 100644index 00000000..ba3bcf4c--- /dev/null+++ b/backend/migrations/000009_doc_meta.up.sql@@ -0,0 +1,12 @@+alter table documents+ add thumbnail TEXT null after pinned;++alter table documents+ add theme varchar(30) null after thumbnail;++alter table documents+ add icon TEXT null after thumbnail;++alter table documents+ add color int null after theme;+diff --git a/backend/models/document.model.go b/backend/models/document.model.goindex a70ae08e..c63128d2 100644--- a/backend/models/document.model.go+++ b/backend/models/document.model.go@@ -8,6 +8,10 @@ type Document struct {Description *string `json:"description" form:"description" binding:"omitempty,max=250"`Tags *string `json:"tags" form:"tags" binding:"omitempty,max=250"`Pinned int `json:"pinned" form:"pinned" binding:"omitempty"` // 0: Not pinned; 1: Pinned; 2: Pinned to top+ Thumbnail *string `json:"thumbnail" form:"thumbnail" binding:"omitempty"`+ Theme *string `json:"theme" form:"theme" binding:"omitempty"`+ Icon *string `json:"icon" form:"icon" binding:"omitempty"`+ Color *int `json:"color" form:"color" binding:"omitempty"`Category *types.Snowflake `json:"category" form:"category" binding:"omitempty"`ParentId *types.Snowflake `json:"parent_id" form:"parent_id" binding:"omitempty"`Accessibility int `json:"accessibility" form:"accessibility" binding:"required"` // 0: Public; 1: Private; 2: Unlisted;diff --git a/backend/services/document.service.go b/backend/services/document.service.goindex e8aa1f70..a4e6ff7f 100644--- a/backend/services/document.service.go+++ b/backend/services/document.service.go@@ -21,7 +21,7 @@ func NewDocumentService(db *sql.DB) DocumentService {func (s *Service) GetAllDocuments(userId types.Snowflake) ([]*models.Document, error) {var documents = make([]*models.Document, 0)- rows, err := s.db.Query("SELECT id, name, description, tags, pinned, category, parent_id, accessibility, author_id, created_timestamp, updated_timestamp FROM documents WHERE author_id = ? ORDER BY pinned DESC, name", userId)+ rows, err := s.db.Query("SELECT id, name, description, tags, pinned, thumbnail, theme, icon, color, category, parent_id, accessibility, author_id, created_timestamp, updated_timestamp FROM documents WHERE author_id = ? ORDER BY pinned DESC, name", userId)if err != nil {return nil, err}@@ -35,6 +35,10 @@ func (s *Service) GetAllDocuments(userId types.Snowflake) ([]*models.Document, e&document.Description,&document.Tags,&document.Pinned,+ &document.Thumbnail,+ &document.Theme,+ &document.Icon,+ &document.Color,&document.Category,&document.ParentId,&document.Accessibility,@@ -50,7 +54,7 @@ func (s *Service) GetAllDocuments(userId types.Snowflake) ([]*models.Document, efunc (s *Service) GetAllDocumentBackup(author_id types.Snowflake) ([]*models.Document, error) {var documents = make([]*models.Document, 0)- rows, err := s.db.Query("SELECT id, name, description, tags, pinned, category, parent_id, accessibility, content_markdown, content_html, author_id, created_timestamp, updated_timestamp FROM documents WHERE author_id = ?", author_id)+ rows, err := s.db.Query("SELECT id, name, description, tags, pinned, thumbnail, theme, icon, color, category, parent_id, accessibility, content_markdown, content_html, author_id, created_timestamp, updated_timestamp FROM documents WHERE author_id = ?", author_id)if err != nil {return nil, err}@@ -62,6 +66,10 @@ func (s *Service) GetAllDocumentBackup(author_id types.Snowflake) ([]*models.Doc&document.Description,&document.Tags,&document.Pinned,+ &document.Thumbnail,+ &document.Theme,+ &document.Icon,+ &document.Color,&document.Category,&document.ParentId,&document.Accessibility,@@ -79,12 +87,16 @@ func (s *Service) GetAllDocumentBackup(author_id types.Snowflake) ([]*models.Docfunc (s *Service) GetDocument(documentId types.Snowflake) (*models.Document, error) {var document models.Document- err := s.db.QueryRow("SELECT id, name, description, tags, pinned, category, parent_id, accessibility, content_markdown, content_html, author_id, created_timestamp, updated_timestamp FROM documents WHERE id = ?", documentId).Scan(+ err := s.db.QueryRow("SELECT id, name, description, tags, pinned, thumbnail, theme, icon, color, category, parent_id, accessibility, content_markdown, content_html, author_id, created_timestamp, updated_timestamp FROM documents WHERE id = ?", documentId).Scan(&document.Id,&document.Name,&document.Description,&document.Tags,&document.Pinned,+ &document.Thumbnail,+ &document.Theme,+ &document.Icon,+ &document.Color,&document.Category,&document.ParentId,&document.Accessibility,@@ -100,12 +112,16 @@ func (s *Service) GetDocument(documentId types.Snowflake) (*models.Document, err}func (s *Service) CreateDocument(document *models.Document) error {- _, err := s.db.Exec("INSERT INTO documents (id, name, description, tags, pinned, category, parent_id, accessibility, content_markdown, content_html, author_id, created_timestamp, updated_timestamp) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",+ _, err := s.db.Exec("INSERT INTO documents (id, name, description, tags, pinned, thumbnail, theme, icon, color, category, parent_id, accessibility, content_markdown, content_html, author_id, created_timestamp, updated_timestamp) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",document.Id,document.Name,document.Description,document.Tags,document.Pinned,+ document.Thumbnail,+ document.Theme,+ document.Icon,+ document.Color,document.Category,document.ParentId,document.Accessibility,@@ -118,11 +134,15 @@ func (s *Service) CreateDocument(document *models.Document) error {}func (s *Service) UpdateDocument(document *models.Document) error {- _, err := s.db.Exec("UPDATE documents SET name = ?, description = ?, tags = ?, pinned = ?, category = ?, parent_id = ?, accessibility = ?, content_markdown = ?, content_html = ? WHERE id = ?",+ _, err := s.db.Exec("UPDATE documents SET name = ?, description = ?, tags = ?, pinned = ?, thumbnail = ?, theme = ?, icon = ?, color = ?, category = ?, parent_id = ?, accessibility = ?, content_markdown = ?, content_html = ? WHERE id = ?",document.Name,document.Description,document.Tags,document.Pinned,+ document.Thumbnail,+ document.Theme,+ document.Icon,+ document.Color,document.Category,document.ParentId,document.Accessibility,